aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-01-25 14:40:04 -0800
committerzotlabs <mike@macgirvin.com>2017-01-25 14:40:04 -0800
commit5bc6941b577f59784dd2eb46c7dae32862b52576 (patch)
tree885e22d1f83cbf98b9866fa8ea4f4c3804ee22cd
parent45dbd31d286838254cd1ae60e4ebb39c112526be (diff)
downloadvolse-hubzilla-5bc6941b577f59784dd2eb46c7dae32862b52576.tar.gz
volse-hubzilla-5bc6941b577f59784dd2eb46c7dae32862b52576.tar.bz2
volse-hubzilla-5bc6941b577f59784dd2eb46c7dae32862b52576.zip
resolve the linked item delete issue by declaring what types of linked items cannot be deleted
-rw-r--r--Zotlabs/Lib/NativeWikiPage.php4
-rwxr-xr-xinclude/items.php7
2 files changed, 8 insertions, 3 deletions
diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php
index 79b7548ce..85a1e8bed 100644
--- a/Zotlabs/Lib/NativeWikiPage.php
+++ b/Zotlabs/Lib/NativeWikiPage.php
@@ -20,7 +20,7 @@ class NativeWikiPage {
$sql_extra = item_permissions_sql($channel_id,$observer_hash);
- $r = q("select * from item where resource_type = 'nwikipage' and resource_id = '%s' and uid = %d and item_hidden = 0
+ $r = q("select * from item where resource_type = 'nwikipage' and resource_id = '%s' and uid = %d and item_deleted = 0 and item_hidden = 0
$sql_extra group by mid",
dbesc($resource_id),
intval($channel_id)
@@ -277,7 +277,7 @@ class NativeWikiPage {
$r = null;
if($ids) {
- $r = q("select * from item where resource_type = 'nwikipage' and resource_id = '%s' and uid = %d and id in ( $ids ) $sql_extra",
+ $r = q("select * from item where resource_type = 'nwikipage' and resource_id = '%s' and uid = %d and id in ( $ids ) and item_deleted = 0 $sql_extra",
dbesc($resource_id),
intval($channel_id)
);
diff --git a/include/items.php b/include/items.php
index 66ec2ffea..8213ab161 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3343,6 +3343,11 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force
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' ];
+
// locate item to be deleted
$r = q("SELECT * FROM item WHERE id = %d LIMIT 1",
@@ -3358,7 +3363,7 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
$item = $r[0];
- $linked_item = (($item['resource_id']) ? true : false);
+ $linked_item = (($item['resource_id'] && $item['resource_type'] && in_array($linked_resource_types,$item['resource_type'])) ? true : false);
$ok_to_delete = false;