diff options
author | Einer von Vielen <tomwie@users.sourceforge.net> | 2015-01-14 22:49:16 +0100 |
---|---|---|
committer | Einer von Vielen <tomwie@users.sourceforge.net> | 2015-01-14 22:49:16 +0100 |
commit | dfab2416926631b7b08c6c89b62528ca2520f130 (patch) | |
tree | 6c76af9d656eec6e74ed6c3c05d7ccc2b6ef5e48 /include/items.php | |
parent | 09129cbe5f7e8cb331b68469b74438464960af0b (diff) | |
parent | 7090b58f68251b8c4b39332f2ea051e95ead3df3 (diff) | |
download | volse-hubzilla-dfab2416926631b7b08c6c89b62528ca2520f130.tar.gz volse-hubzilla-dfab2416926631b7b08c6c89b62528ca2520f130.tar.bz2 volse-hubzilla-dfab2416926631b7b08c6c89b62528ca2520f130.zip |
Merge remote-tracking branch 'upstream/master' into toc
Diffstat (limited to 'include/items.php')
-rwxr-xr-x | include/items.php | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/include/items.php b/include/items.php index 4c533aedc..5812efa90 100755 --- a/include/items.php +++ b/include/items.php @@ -2673,7 +2673,7 @@ function tag_deliver($uid,$item_id) { * Fetch stuff we need - a channel and an item */ - $u = q("select * from channel where channel_id = %d limit 1", + $u = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($uid) ); if(! $u) @@ -2811,7 +2811,7 @@ function tag_deliver($uid,$item_id) { if($terms) logger('tag_deliver: post mentions: ' . print_r($terms,true), LOGGER_DATA); - $link = normalise_link($a->get_baseurl() . '/channel/' . $u[0]['channel_address']); + $link = normalise_link($u[0]['xchan_url']); if($terms) { foreach($terms as $term) { @@ -2952,7 +2952,7 @@ function tgroup_check($uid,$item) { if(! perm_is_allowed($uid,$item['author_xchan'],'tag_deliver')) return false; - $u = q("select * from channel where channel_id = %d limit 1", + $u = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($uid) ); @@ -2964,7 +2964,7 @@ function tgroup_check($uid,$item) { if($terms) logger('tgroup_check: post mentions: ' . print_r($terms,true), LOGGER_DATA); - $link = normalise_link($a->get_baseurl() . '/channel/' . $u[0]['channel_address']); + $link = normalise_link($u[0]['xchan_url']); if($terms) { foreach($terms as $term) { @@ -3939,7 +3939,7 @@ function drop_items($items) { // $stage = 1 => set deleted flag on the item and perform intial notifications // $stage = 2 => perform low level delete at a later stage -function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { +function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = false) { $a = get_app(); @@ -3959,6 +3959,8 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { $item = $r[0]; + $linked_item = (($item['resource_id']) ? true : false); + $ok_to_delete = false; // system deletion @@ -3980,10 +3982,11 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { // hook calls a remote process which loops. We'll delete it properly in a second. $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ) WHERE id = %d", - intval(ITEM_DELETED), + intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED), intval($item['id']) ); + $arr = array('item' => $item, 'interactive' => $interactive, 'stage' => $stage); call_hooks('drop_item', $arr ); @@ -3995,10 +3998,10 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { ); if($items) { foreach($items as $i) - delete_item_lowlevel($i,$stage); + delete_item_lowlevel($i,$stage,$force); } else - delete_item_lowlevel($item,$stage); + delete_item_lowlevel($item,$stage,$force); if(! $interactive) return 1; @@ -4030,8 +4033,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { // It merely destroys all resources associated with an item. // Please do not use without a suitable wrapper. -function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { +function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL,$force = false) { + $linked_item = (($item['resource_id']) ? true : false); switch($stage) { case DROPITEM_PHASE2: @@ -4047,7 +4051,7 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { case DROPITEM_PHASE1: $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), changed = '%s', edited = '%s' WHERE id = %d", - intval(ITEM_DELETED), + intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($item['id']) @@ -4056,13 +4060,24 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { case DROPITEM_NORMAL: default: - $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '', - changed = '%s', edited = '%s' WHERE id = %d", - intval(ITEM_DELETED), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - intval($item['id']) - ); + if($linked_item && ! $force) { + $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), + changed = '%s', edited = '%s' WHERE id = %d", + intval(ITEM_HIDDEN), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + } + else { + $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '', + changed = '%s', edited = '%s' WHERE id = %d", + intval(ITEM_DELETED), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + } break; } @@ -4074,25 +4089,6 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { intval($item['uid']) ); - // If item is a link to a photo/event resource, nuke all the associated photos/events - // This only applies to photos uploaded from the photos page. Photos inserted into a post do not - // generate a resource_id and therefore aren't intimately linked to the item. - - if(strlen($item['resource_id'])) { - if($item['resource_type'] === 'event') { - q("delete from event where event_hash = '%s' and uid = %d", - dbesc($item['resource_id']), - intval($item['uid']) - ); - } - elseif($item['resource_type'] === 'photo') { - q("DELETE FROM `photo` WHERE `resource_id` = '%s' AND `uid` = %d ", - dbesc($item['resource_id']), - intval($item['uid']) - ); - } - } - // network deletion request. Keep the message structure so that we can deliver delete notifications. // Come back after several days (or perhaps a month) to do the lowlevel delete (DROPITEM_PHASE2). @@ -4115,8 +4111,7 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL) { intval(TERM_OBJ_POST) ); -// FIXME remove notifications for this item - + // FIXME remove notifications for this item return true; } |