aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/RedDAV/RedBrowser.php5
-rw-r--r--include/RedDAV/RedFile.php2
-rw-r--r--include/attach.php109
-rw-r--r--include/conversation.php2
-rw-r--r--include/text.php29
5 files changed, 127 insertions, 20 deletions
diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php
index 9ea2b9808..93a546086 100644
--- a/include/RedDAV/RedBrowser.php
+++ b/include/RedDAV/RedBrowser.php
@@ -249,7 +249,10 @@ class RedBrowser extends DAV\Browser\Plugin {
'$header' => t('Files') . ": " . $this->escapeHTML($path) . "/",
'$quota' => $quota,
'$total' => t('Total'),
- '$actionspanel' => $output
+ '$actionspanel' => $output,
+ '$shared' => t('Shared'),
+ '$create' => t('Create'),
+ 'upload' => t('Upload')
));
$html .= replace_macros(get_markup_template('cloud_directory.tpl'), array(
diff --git a/include/RedDAV/RedFile.php b/include/RedDAV/RedFile.php
index 3a5230dc1..f2ee071b8 100644
--- a/include/RedDAV/RedFile.php
+++ b/include/RedDAV/RedFile.php
@@ -276,4 +276,4 @@ class RedFile extends DAV\Node implements DAV\IFile {
attach_delete($this->auth->owner_id, $this->data['hash']);
}
-} \ No newline at end of file
+}
diff --git a/include/attach.php b/include/attach.php
index a76dd4b28..ec175fcb3 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -753,14 +753,17 @@ function attach_delete($channel_id, $resource) {
$channel_address = (($c) ? $c[0]['channel_address'] : 'notfound');
- $r = q("SELECT hash, flags, folder FROM attach WHERE hash = '%s' AND uid = %d limit 1",
+ $r = q("SELECT hash, filename, flags, folder FROM attach WHERE hash = '%s' AND uid = %d limit 1",
dbesc($resource),
intval($channel_id)
);
+
if(! $r)
return;
+ $url = get_parent_cloudpath($channel_id, $channel_address, $resource) . $r[0]['filename'];
+
// If resource is a directory delete everything in the directory recursive
if($r[0]['flags'] & ATTACH_FLAG_DIR) {
$x = q("SELECT hash, flags FROM attach WHERE folder = '%s' AND uid = %d",
@@ -802,6 +805,8 @@ function attach_delete($channel_id, $resource) {
dbesc($r[0]['folder']),
intval($channel_id)
);
+
+ file_activity($channel_id, $resource, $allow_cid='', $allow_gid='', $deny_cid='', $deny_gid='', $url, 'drop', $no_activity=false);
}
/**
@@ -934,3 +939,105 @@ function pipe_streams($in, $out) {
$size += fwrite($out, fread($in, 8192));
return $size;
}
+
+function file_activity($channel_id, $hash, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $url, $action, $no_activity) {
+
+ require_once('include/items.php');
+
+ $url = rawurlencode($url);
+
+ $poster = get_app()->get_observer();
+
+ $verb = ACTIVITY_FILE . '/' . $action . '/' . $hash;
+
+ $mid = item_message_id();
+
+ $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_UNSEEN;
+
+ if($action == 'post') {
+ //check if activity item exists
+ //if yes send drop activity and create a new one
+
+ $r = q("SELECT * FROM item WHERE verb = '%s'",
+ dbesc($verb)
+ );
+
+ if($r) {
+
+ $dmid = item_message_id();
+ $updateverb = ACTIVITY_FILE . '/drop/' . $hash . '#' . $mid;
+
+ $arr = array();
+
+ $arr['aid'] = get_account_id();
+ $arr['uid'] = $channel_id;
+ $arr['mid'] = $dmid;
+ $arr['parent_mid'] = $dmid;
+ $arr['item_flags'] = $item_flags;
+ $arr['author_xchan'] = $poster['xchan_hash'];
+ $arr['owner_xchan'] = $poster['xchan_hash'];
+ $arr['title'] = '';
+ $arr['allow_cid'] = $allow_cid;
+ $arr['allow_gid'] = $allow_gid;
+ $arr['deny_cid'] = $deny_cid;
+ $arr['deny_gid'] = $deny_gid;
+ $arr['item_restrict'] = ITEM_HIDDEN;
+ $arr['item_private'] = 0;
+ $arr['verb'] = $updateverb;
+ $arr['body'] = $url;
+
+ $post = item_store($arr);
+ $item_id = $post['item_id'];
+
+ if($item_id) {
+ proc_run('php',"include/notifier.php","activity",$item_id);
+ }
+
+ //call_hooks('post_local_end', $arr);
+
+ //notice( t('File activity updated') . EOL);
+
+ if($no_activity) {
+ return;
+ }
+
+ }
+ }
+
+ if($no_activity) {
+ return;
+ }
+
+ $arr = array();
+
+ $arr['aid'] = get_account_id();
+ $arr['uid'] = $channel_id;
+ $arr['mid'] = $mid;
+ $arr['parent_mid'] = $mid;
+ $arr['item_flags'] = $item_flags;
+ $arr['author_xchan'] = $poster['xchan_hash'];
+ $arr['owner_xchan'] = $poster['xchan_hash'];
+ $arr['title'] = '';
+ $arr['allow_cid'] = $allow_cid;
+ $arr['allow_gid'] = $allow_gid;
+ $arr['deny_cid'] = $deny_cid;
+ $arr['deny_gid'] = $deny_gid;
+ $arr['item_restrict'] = ITEM_HIDDEN;
+ $arr['item_private'] = 0;
+ $arr['verb'] = $verb;
+ $arr['body'] = $url;
+
+ $post = item_store($arr);
+ $item_id = $post['item_id'];
+
+ if($item_id) {
+ proc_run('php',"include/notifier.php","activity",$item_id);
+ }
+
+ //call_hooks('post_local_end', $arr);
+
+ //(($action === 'post') ? notice( t('File activity posted') . EOL) : notice( t('File activity dropped') . EOL));
+
+ return;
+
+}
diff --git a/include/conversation.php b/include/conversation.php
index 0d59ff92e..25c844fef 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1572,7 +1572,7 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
$tabs[] = array(
'label' => t('Files'),
'url' => $a->get_baseurl() . '/cloud/' . $nickname . ((get_observer_hash()) ? '' : '?f=&davguest=1'),
- 'sel' => ((argv(0) == 'cloud') ? 'active' : ''),
+ 'sel' => ((argv(0) == 'cloud' || argv(0) == 'sharedwithme') ? 'active' : ''),
'title' => t('Files and Storage'),
'id' => 'files-tab',
);
diff --git a/include/text.php b/include/text.php
index c130a9b8a..b6e4abf24 100644
--- a/include/text.php
+++ b/include/text.php
@@ -606,9 +606,11 @@ function get_tags($s) {
$s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s);
// ignore anything in [style= ]
-
$s = preg_replace('/\[style=(.*?)\]/sm','',$s);
+ // ignore anything in [color= ], because it may contain color codes which are mistaken for tags
+ $s = preg_replace('/\[color=(.*?)\]/sm','',$s);
+
// match any double quoted tags
if(preg_match_all('/([@#]\&quot\;.*?\&quot\;)/',$s,$match)) {
@@ -620,12 +622,11 @@ function get_tags($s) {
// Match full names against @tags including the space between first and last
// We will look these up afterward to see if they are full names or not recognisable.
- if(preg_match_all('/(@[^ \x0D\x0A,:?\[]+ [^ \x0D\x0A@,:?\[]+)([ \x0D\x0A@,:?\[]|$)/',$s,$match)) {
+ // The lookbehind is used to prevent a match in the middle of a word
+ // '=' needs to be avoided because when the replacement is made (in handle_tag()) it has to be ignored there
+ // Feel free to allow '=' if the issue with '=' is solved in handle_tag()
+ if(preg_match_all('/(?<![a-zA-Z0-9=])(@[^ \x0D\x0A,:?\[]+ [^ \x0D\x0A@,:?\[]+)/',$s,$match)) {
foreach($match[1] as $mtch) {
- if(strstr($mtch,"]")) {
- // we might be inside a bbcode color tag - leave it alone
- continue;
- }
if(substr($mtch,-1,1) === '.')
$ret[] = substr($mtch,0,-1);
else
@@ -636,20 +637,13 @@ function get_tags($s) {
// Otherwise pull out single word tags. These can be @nickname, @first_last
// and #hash tags.
- if(preg_match_all('/([@#][^ \x0D\x0A,;:?\[]+)([ \x0D\x0A,;:?\[]|$)/',$s,$match)) {
+ if(preg_match_all('/(?<![a-zA-Z0-9=])([@#][^ \x0D\x0A,;:?\[]+)/',$s,$match)) {
foreach($match[1] as $mtch) {
- if(strstr($mtch,"]")) {
- // we might be inside a bbcode color tag - leave it alone
- continue;
- }
if(substr($mtch,-1,1) === '.')
$mtch = substr($mtch,0,-1);
// ignore strictly numeric tags like #1 or #^ bookmarks or ## double hash
if((strpos($mtch,'#') === 0) && ( ctype_digit(substr($mtch,1)) || substr($mtch,1,1) === '^') || substr($mtch,1,1) === '#')
continue;
- // try not to catch url fragments
- if(strpos($s,$mtch) && preg_match('/[a-zA-z0-9\/]/',substr($s,strpos($s,$mtch)-1,1)))
- continue;
// or quote remnants from the quoted strings we already picked out earlier
if(strpos($mtch,'&quot'))
continue;
@@ -2155,8 +2149,11 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
//create text for link
$url = $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag);
$newtag = '#[zrl=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/zrl]';
- //replace tag by the link
- $body = str_replace($tag, $newtag, $body);
+ //replace tag by the link. Make sure to not replace something in the middle of a word
+ // The '=' is needed to not replace color codes if the code is also used as a tag
+ // Much better would be to somehow completely avoiding things in e.g. [color]-tags.
+ // This would allow writing things like "my favourite tag=#foobar".
+ $body = preg_replace('/(?<![a-zA-Z0-9=])'.preg_quote($tag).'/', $newtag, $body);
$replaced = true;
}
//is the link already in str_tags?