diff options
author | Thomas Willingham <founder@kakste.com> | 2013-06-07 03:46:43 +0100 |
---|---|---|
committer | Thomas Willingham <founder@kakste.com> | 2013-06-07 03:46:43 +0100 |
commit | 466a6d5227fbaf0a36cd76b5603cb42bb1b7462b (patch) | |
tree | 395936a63e27fa105e0dc69d13c1b951dc9e9439 /include/items.php | |
parent | dc6472e046ee6ac0afc934e8ad1edc1e281a3cb0 (diff) | |
parent | c21f8c68e39e22a0348e5717109f0005d4d35809 (diff) | |
download | volse-hubzilla-466a6d5227fbaf0a36cd76b5603cb42bb1b7462b.tar.gz volse-hubzilla-466a6d5227fbaf0a36cd76b5603cb42bb1b7462b.tar.bz2 volse-hubzilla-466a6d5227fbaf0a36cd76b5603cb42bb1b7462b.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include/items.php')
-rwxr-xr-x | include/items.php | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/include/items.php b/include/items.php index 4704ca344..9041e3da7 100755 --- a/include/items.php +++ b/include/items.php @@ -98,17 +98,25 @@ function post_activity_item($arr) { $ret = array('success' => false); + $is_comment = false; + if((($arr['parent']) && $arr['parent'] != $arr['id']) || (($arr['parent_mid']) && $arr['parent_mid'] != $arr['mid'])) + $is_comment = true; + if(! x($arr,'item_flags')) { - $arr['item_flags'] = ITEM_ORIGIN | ITEM_WALL | ITEM_THREAD_TOP; + if($is_comment) + $arr['item_flags'] = ITEM_ORIGIN; + else + $arr['item_flags'] = ITEM_ORIGIN | ITEM_WALL | ITEM_THREAD_TOP; } + $channel = get_app()->get_channel(); $observer = get_app()->get_observer(); $arr['aid'] = ((x($arr,'aid')) ? $arr['aid'] : $channel['channel_account_id']); $arr['uid'] = ((x($arr,'uid')) ? $arr['uid'] : $channel['channel_id']); - if(! perm_is_allowed($arr['uid'],$observer['xchan_hash'],(($arr['parent']) ? 'post_comment' : 'post_wall'))) { + if(! perm_is_allowed($arr['uid'],$observer['xchan_hash'],(($is_comment) ? 'post_comments' : 'post_wall'))) { $ret['message'] = t('Permission denied'); return $ret; } @@ -1907,7 +1915,9 @@ function get_item_contact($item,$contacts) { function tag_deliver($uid,$item_id) { - // look for mention tags and setup a second delivery chain for forum/community posts if appropriate + // Called when we deliver things that might be tagged in ways that require delivery processing. + // Handles community tagging of posts and also look for mention tags + // and sets up a second delivery chain if appropriate $a = get_app(); @@ -1923,13 +1933,41 @@ function tag_deliver($uid,$item_id) { intval($item_id), intval($uid) ); - if(! count($i)) + if(! $i) return; $i = fetch_post_tags($i); $item = $i[0]; + + if($item['obj_type'] === ACTIVITY_OBJ_TAGTERM) { + + // We received a community tag activity for a post. + // See if we are the owner of the parent item and have given permission to tag our posts. + // If so tag the parent post. + + // FIXME --- If the item is deleted, remove the tag from the parent. + // (First ensure that deleted items use this function, or else do that part separately.) + + if(($item['owner_xchan'] === $u[0]['channel_hash']) && (! get_pconfig($u[0]['channel_id'],'system','blocktags'))) { + $j_tgt = json_decode($item['target'],true); + if($j_tgt && $j_tgt['mid']) { + $p = q("select * from item where mid = '%s' and uid = %d limit 1", + dbesc($j_tgt['mid']), + intval($u[0]['channel_id']) + ); + if($p) { + $j_obj = json_decode($item['object'],true); + if($j_obj && $j_obj['id'] && $j_obj['title']) { + store_item_tag($u[0]['channel_id'],$p[0]['id'],TERM_OBJ_POST,TERM_HASHTAG,$j_obj['title'],$j['obj']['id']); + proc_run('php','include/notifier.php','edit_post',$p[0]['id']); + } + } + } + } + } + $terms = get_terms_oftype($item['term'],TERM_MENTION); logger('tag_deliver: post mentions: ' . print_r($terms,true), LOGGER_DATA); |