aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Lib/NativeWiki.php2
-rw-r--r--Zotlabs/Module/Channel_calendar.php5
-rw-r--r--include/attach.php7
-rwxr-xr-xinclude/items.php115
4 files changed, 54 insertions, 75 deletions
diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php
index e2bd07c0d..662fddad0 100644
--- a/Zotlabs/Lib/NativeWiki.php
+++ b/Zotlabs/Lib/NativeWiki.php
@@ -191,7 +191,7 @@ class NativeWiki {
return array('item' => null, 'success' => false);
}
else {
- $drop = drop_item($item['id'], false, DROPITEM_NORMAL, true);
+ $drop = drop_item($item['id'], false, DROPITEM_NORMAL);
}
info( t('Wiki files deleted successfully'));
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index fcb3ca58b..ac08dfa96 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -455,11 +455,6 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if($can_delete || $local_delete) {
- q("update item set resource_type = '', resource_id = '' where resource_type = 'event' and resource_id = '%s' and uid = %d",
- dbesc($event_id),
- intval(local_channel())
- );
-
// if this is a different page type or it's just a local delete
// but not by the item author or owner, do a simple deletion
diff --git a/include/attach.php b/include/attach.php
index f169e0669..80efe0838 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -1514,12 +1514,15 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
function attach_drop_photo($channel_id,$resource) {
- $x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d",
+ $x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d and item_deleted = 0",
dbesc($resource),
intval($channel_id)
);
+
if($x) {
- drop_item($x[0]['id'],false,(($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1),true);
+ $stage = (($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1);
+ $interactive = (($x[0]['item_hidden']) ? false : true);
+ drop_item($x[0]['id'], $interactive, $stage);
}
$r = q("SELECT content FROM photo WHERE resource_id = '%s' AND uid = %d AND os_storage = 1",
diff --git a/include/items.php b/include/items.php
index b6d8eb652..35a5a6124 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3663,7 +3663,7 @@ function retain_item($id) {
);
}
-function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force = false) {
+function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL) {
$uid = 0;
if(! local_channel() && ! remote_channel())
@@ -3671,7 +3671,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force
if(count($items)) {
foreach($items as $item) {
- $owner = drop_item($item,$interactive,$stage,$force);
+ $owner = drop_item($item,$interactive,$stage);
if($owner && ! $uid)
$uid = $owner;
}
@@ -3694,12 +3694,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force
// $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,$force = false) {
-
- // These resource types have linked items that should only be removed at the same time
- // as the linked resource; if we encounter one set it to item_hidden rather than item_deleted.
-
- $linked_resource_types = [ 'photo' ];
+function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) {
// locate item to be deleted
@@ -3711,13 +3706,11 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
if(! $interactive)
return 0;
notice( t('Item not found.') . EOL);
- goaway(z_root() . '/' . $_SESSION['return_url']);
+ //goaway(z_root() . '/' . $_SESSION['return_url']);
}
$item = $r[0];
- $linked_item = (($item['resource_id'] && $item['resource_type'] && in_array($item['resource_type'], $linked_resource_types)) ? true : false);
-
$ok_to_delete = false;
// system deletion
@@ -3740,26 +3733,12 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
if($ok_to_delete) {
- if ($item['resource_type'] === 'event') {
- $x = q("delete from event where event_hash = '%s' and uid = %d",
- dbesc($item['resource_id']),
- intval($item['uid'])
- );
- }
-
// set the deleted flag immediately on this item just in case the
// hook calls a remote process which loops. We'll delete it properly in a second.
- if(($linked_item) && (! $force)) {
- $r = q("UPDATE item SET item_hidden = 1 WHERE id = %d",
- intval($item['id'])
- );
- }
- else {
- $r = q("UPDATE item SET item_deleted = 1 WHERE id = %d",
- intval($item['id'])
- );
- }
+ $r = q("UPDATE item SET item_deleted = 1 WHERE id = %d",
+ intval($item['id'])
+ );
$arr = [
'item' => $item,
@@ -3799,14 +3778,13 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1)) {
Master::Summon([ 'Notifier','drop',$notify_id ]);
}
-
- goaway(z_root() . '/' . $_SESSION['return_url']);
+ //goaway(z_root() . '/' . $_SESSION['return_url']);
}
else {
if(! $interactive)
return 0;
notice( t('Permission denied.') . EOL);
- goaway(z_root() . '/' . $_SESSION['return_url']);
+ //goaway(z_root() . '/' . $_SESSION['return_url']);
}
}
@@ -3821,14 +3799,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
* @param boolean $force
* @return boolean
*/
-function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
-
- //$linked_item = (($item['resource_id']) ? true : false);
-
- $linked_resource_types = [ 'photo' ];
- $linked_item = (($item['resource_id'] && $item['resource_type'] && in_array($item['resource_type'], $linked_resource_types)) ? true : false);
+function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL) {
- logger('item: ' . $item['id'] . ' stage: ' . $stage . ' force: ' . $force, LOGGER_DATA);
+ logger('item: ' . $item['id'] . ' stage: ' . $stage, LOGGER_DATA);
switch($stage) {
case DROPITEM_PHASE2:
@@ -3841,42 +3814,50 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
break;
case DROPITEM_PHASE1:
- if($linked_item && ! $force) {
- $r = q("UPDATE item SET item_hidden = 1,
- changed = '%s', edited = '%s' WHERE id = %d",
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($item['id'])
- );
- }
- else {
- $r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where id = %d",
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($item['id'])
- );
- }
-
+ $r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where id = %d",
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ intval($item['id'])
+ );
break;
case DROPITEM_NORMAL:
default:
- if($linked_item && ! $force) {
- $r = q("UPDATE item SET item_hidden = 1,
- changed = '%s', edited = '%s' WHERE id = %d",
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($item['id'])
- );
- }
- else {
- $r = q("DELETE FROM item WHERE id = %d",
- intval($item['id'])
- );
- }
+ $r = q("DELETE FROM item WHERE id = %d",
+ intval($item['id'])
+ );
break;
}
+ // immediately remove local linked resources
+
+ if($item['resource_type'] === 'event') {
+ $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
+ dbesc($item['resource_id']),
+ intval($item['uid'])
+ );
+
+ $sync_data = $r[0];
+
+ $x = q("delete from event where event_hash = '%s' and uid = %d",
+ dbesc($item['resource_id']),
+ intval($item['uid'])
+ );
+
+ if($x) {
+ $sync_data['event_deleted'] = 1;
+ build_sync_packet($item['uid'], ['event' => [$syncsync_data]]);
+ }
+ }
+
+ if($item['resource_type'] === 'photo') {
+ attach_delete($item['uid'], $item['resource_id'], true );
+ $channel = channelx_by_n($item['uid']);
+ $sync_data = attach_export_data($channel, $item['resource_id'], true);
+ if($sync_data)
+ build_sync_packet($item['uid'], ['file' => [$sync_data]]);
+ }
+
// immediately remove any undesired profile likes.
q("delete from likes where iid = %d and channel_id = %d",