aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/items.php')
-rwxr-xr-xinclude/items.php107
1 files changed, 66 insertions, 41 deletions
diff --git a/include/items.php b/include/items.php
index fb2f2586a..756625d85 100755
--- a/include/items.php
+++ b/include/items.php
@@ -2186,6 +2186,20 @@ function item_store($arr,$allow_exec = false) {
unset($arr['term']);
}
+ if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid) || strlen($public_policy))
+ $private = 1;
+ else
+ $private = $arr['item_private'];
+
+ $arr['parent'] = $parent_id;
+ $arr['allow_cid'] = $allow_cid;
+ $arr['allow_gid'] = $allow_gid;
+ $arr['deny_cid'] = $deny_cid;
+ $arr['deny_gid'] = $deny_gid;
+ $arr['public_policy'] = $public_policy;
+ $arr['item_private'] = $private;
+ $arr['comments_closed'] = $comments_closed;
+
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
dbesc_array($arr);
@@ -2203,7 +2217,6 @@ function item_store($arr,$allow_exec = false) {
intval($arr['uid'])
);
-
if($r && count($r)) {
$current_post = $r[0]['id'];
$arr = $r[0]; // This will gives us a fresh copy of what's now in the DB and undo the db escaping, which really messes up the notifications
@@ -2223,40 +2236,14 @@ function item_store($arr,$allow_exec = false) {
);
}
- if((! $parent_id) || ($arr['parent_mid'] === $arr['mid']))
- $parent_id = $current_post;
+ $arr['id'] = $current_post;
- if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid) || strlen($public_policy))
- $private = 1;
- else
- $private = $arr['item_private'];
-
- // Set parent id - and also make sure to inherit the parent's ACL's.
-
- $r = q("UPDATE item SET parent = %d, allow_cid = '%s', allow_gid = '%s',
- deny_cid = '%s', deny_gid = '%s', public_policy = '%s', item_private = %d, comments_closed = '%s'
- WHERE id = %d",
- intval($parent_id),
- dbesc($allow_cid),
- dbesc($allow_gid),
- dbesc($deny_cid),
- dbesc($deny_gid),
- dbesc($public_policy),
- intval($private),
- dbesc($comments_closed),
- intval($current_post)
- );
+ if(! intval($r[0]['parent'])) {
+ $x = q("update item set parent = id where id = %d",
+ intval($r[0]['id'])
+ );
+ }
- // These are probably redundant now that we've queried the just stored post
- $arr['id'] = $current_post;
- $arr['parent'] = $parent_id;
- $arr['allow_cid'] = $allow_cid;
- $arr['allow_gid'] = $allow_gid;
- $arr['deny_cid'] = $deny_cid;
- $arr['deny_gid'] = $deny_gid;
- $arr['public_policy'] = $public_policy;
- $arr['item_private'] = $private;
- $arr['comments_closed'] = $comments_closed;
// Store taxonomy
@@ -2865,12 +2852,27 @@ function tag_deliver($uid,$item_id) {
if(preg_match($pattern,$body,$matches))
$tagged = true;
- $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/';
- if(preg_match($pattern,$body,$matches))
- $plustagged = true;
+ $pattern = '/@\!?\[zrl\=(.*?)\](.*?)\+\[\/zrl\]/';
+
+ if(preg_match_all($pattern,$body,$matches,PREG_SET_ORDER)) {
+ $max_forums = get_config('system','max_tagged_forums');
+ if(! $max_forums)
+ $max_forums = 2;
+ $matched_forums = 0;
+ foreach($matches as $match) {
+ $matched_forums ++;
+ if($term['url'] === $match[1] && $term['term'] === $match[2]) {
+ if($matched_forums <= $max_forums) {
+ $plustagged = true;
+ break;
+ }
+ logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring');
+ }
+ }
+ }
if(! ($tagged || $plustagged)) {
- logger('tag_deliver: mention was in a reshare - ignoring');
+ logger('tag_deliver: mention was in a reshare or exceeded max_tagged_forums - ignoring');
return;
}
@@ -2987,6 +2989,7 @@ function tgroup_check($uid,$item) {
}
}
+
if($mention) {
logger('tgroup_check: mention found for ' . $u[0]['channel_name']);
}
@@ -2995,6 +2998,7 @@ function tgroup_check($uid,$item) {
// At this point we've determined that the person receiving this post was mentioned in it.
// Now let's check if this mention was inside a reshare so we don't spam a forum
+ // note: $term has been set to the matching term
$body = $item['body'];
@@ -3006,14 +3010,35 @@ function tgroup_check($uid,$item) {
$body = preg_replace('/\[share(.*?)\[\/share\]/','',$body);
- $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/';
+
+// $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/';
+
+ $pattern = '/@\!?\[zrl\=(.*?)\](.*?)\+\[\/zrl\]/';
+
+ $found = false;
+
+ if(preg_match_all($pattern,$body,$matches,PREG_SET_ORDER)) {
+ $max_forums = get_config('system','max_tagged_forums');
+ if(! $max_forums)
+ $max_forums = 2;
+ $matched_forums = 0;
+ foreach($matches as $match) {
+ $matched_forums ++;
+ if($term['url'] === $match[1] && $term['term'] === $match[2]) {
+ if($matched_forums <= $max_forums) {
+ $found = true;
+ break;
+ }
+ logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring');
+ }
+ }
+ }
- if(! preg_match($pattern,$body,$matches)) {
- logger('tgroup_check: mention was in a reshare - ignoring');
+ if(! $found) {
+ logger('tgroup_check: mention was in a reshare or exceeded max_tagged_forums - ignoring');
return false;
}
-
return true;
}