diff options
Diffstat (limited to 'include/items.php')
-rw-r--r-- | include/items.php | 119 |
1 files changed, 75 insertions, 44 deletions
diff --git a/include/items.php b/include/items.php index 0a8bc12c0..b1dc1708f 100644 --- a/include/items.php +++ b/include/items.php @@ -952,7 +952,7 @@ function tag_deliver($uid,$item_id) { $mention = false; - $u = q("select uid, nickname, language, username, email, `page-flags`, `notify-flags` from user where uid = %d limit 1", + $u = q("select * from user where uid = %d limit 1", intval($uid) ); if(! count($u)) @@ -1027,10 +1027,20 @@ function tag_deliver($uid,$item_id) { if(! count($c)) return; - q("update item set wall = 1, origin = 1, forum_mode = 1, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s' where id = %d limit 1", + // also reset all the privacy bits to the forum default permissions + + $private = ($u[0]['allow_cid'] || $u[0]['allow_gid'] || $u[0]['deny_cid'] || $u[0]['deny_gid']) ? 1 : 0; + + q("update item set wall = 1, origin = 1, forum_mode = 1, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s', + `private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d limit 1", dbesc($c[0]['name']), dbesc($c[0]['url']), dbesc($c[0]['thumb']), + intval($private), + dbesc($u[0]['allow_cid']), + dbesc($u[0]['allow_gid']), + dbesc($u[0]['deny_cid']), + dbesc($u[0]['deny_gid']), intval($item_id) ); @@ -2227,10 +2237,10 @@ function local_delivery($importer,$data) { logger('local_delivery: received remote comment'); $is_like = false; // remote reply to our post. Import and then notify everybody else. - $datarray = get_atom_elements($feed,$item); + $datarray = get_atom_elements($feed,$item); - $r = q("SELECT `id`, `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `id`, `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['importer_uid']) ); @@ -2266,14 +2276,22 @@ function local_delivery($importer,$data) { // return 0; // } + // our user with $importer['importer_uid'] is the owner + + $own = q("select name,url,thumb from contact where uid = %d and self = 1 limit 1", + intval($importer['importer_uid']) + ); + + $datarray['type'] = 'remote-comment'; $datarray['wall'] = 1; $datarray['parent-uri'] = $parent_uri; $datarray['uid'] = $importer['importer_uid']; - $datarray['owner-name'] = $r[0]['name']; - $datarray['owner-link'] = $r[0]['url']; - $datarray['owner-avatar'] = $r[0]['thumb']; + $datarray['owner-name'] = $own[0]['name']; + $datarray['owner-link'] = $own[0]['url']; + $datarray['owner-avatar'] = $own[0]['thumb']; $datarray['contact-id'] = $importer['id']; + if(($datarray['verb'] === ACTIVITY_LIKE) || ($datarray['verb'] === ACTIVITY_DISLIKE)) { $is_like = true; $datarray['type'] = 'activity'; @@ -2290,26 +2308,34 @@ function local_delivery($importer,$data) { } if(($datarray['verb'] === ACTIVITY_TAG) && ($datarray['object-type'] === ACTIVITY_OBJ_TAGTERM)) { - - + $xo = parse_xml_string($datarray['object'],false); $xt = parse_xml_string($datarray['target'],false); - if(($xt->type == ACTIVITY_OBJ_NOTE) && ($xt->id == $r[0]['uri'])) { + if(($xt->type == ACTIVITY_OBJ_NOTE) && ($xt->id)) { + + // fetch the parent item + + $tagp = q("select * from item where uri = '%s' and uid = %d limit 1", + dbesc($xt->id), + intval($importer['importer_uid']) + ); + if(! count($tagp)) + continue; // extract tag, if not duplicate, and this user allows tags, add to parent item if($xo->id && $xo->content) { $newtag = '#[url=' . $xo->id . ']'. $xo->content . '[/url]'; - - if(! (stristr($r[0]['tag'],$newtag))) { + if(! (stristr($tagp[0]['tag'],$newtag))) { $i = q("SELECT `blocktags` FROM `user` where `uid` = %d LIMIT 1", intval($importer['importer_uid']) ); - if(count($i) && ! ($i[0]['blocktags'])) { - q("UPDATE item SET tag = '%s' WHERE id = %d LIMIT 1", - dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . $newtag), - intval($r[0]['id']) + if(count($i) && ! intval($i[0]['blocktags'])) { + q("UPDATE item SET tag = '%s', `edited` = '%s' WHERE id = %d LIMIT 1", + dbesc($tagp[0]['tag'] . (strlen($tagp[0]['tag']) ? ',' : '') . $newtag), + intval($tagp[0]['id']), + dbesc(datetime_convert()) ); } } @@ -2479,7 +2505,7 @@ function local_delivery($importer,$data) { if(!x($datarray['type']) || $datarray['type'] != 'activity') { - $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 ", + $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0", dbesc($parent_uri), intval($importer['importer_uid']) ); @@ -3013,32 +3039,7 @@ function item_expire($uid,$days) { if($expire_items==0 && $item['type']!='note') continue; - - $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1", - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($item['id']) - ); - - $r = q("DELETE FROM item_id where iid in (select id from item where parent = %d) and uid = %d", - intval($item['id']), - intval($uid) - ); - - $r = q("DELETE FROM sign where iid in (select id from item where parent = %d) and uid = %d", - intval($item['id']), - intval($uid) - ); - - // kill the kids - - $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc($item['parent-uri']), - intval($item['uid']) - ); - + drop_item($item['id'],false); } proc_run('php',"include/notifier.php","expire","$uid"); @@ -3100,6 +3101,25 @@ function drop_item($id,$interactive = true) { intval($item['id']) ); + // clean up categories and tags so they don't end up as orphans + + $matches = false; + $cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + file_tag_unsave_file($item['uid'],$item['id'],$mtch[1],true); + } + } + + $matches = false; + + $cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + file_tag_unsave_file($item['uid'],$item['id'],$mtch[1],false); + } + } + // If item is a link to a photo resource, nuke all the associated photos // (visitors will not have photo resources) // This only applies to photos uploaded from the photos page. Photos inserted into a post do not @@ -3123,6 +3143,17 @@ function drop_item($id,$interactive = true) { // ignore the result } + // clean up item_id and sign meta-data tables + + $r = q("DELETE FROM item_id where iid in (select id from item where parent = %d and uid = %d)", + intval($item['id']), + intval($item['uid']) + ); + + $r = q("DELETE FROM sign where iid in (select id from item where parent = %d and uid = %d)", + intval($item['id']), + intval($item['uid']) + ); // If it's the parent of a comment thread, kill all the kids @@ -3155,7 +3186,7 @@ function drop_item($id,$interactive = true) { } } $drop_id = intval($item['id']); - + // send the notification upstream/downstream as the case may be if(! $interactive) |