diff options
author | zotlabs <mike@macgirvin.com> | 2017-01-15 15:24:51 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2017-01-15 15:24:51 -0800 |
commit | b20cce1408445a48e8aec133b6df44bcd71c6321 (patch) | |
tree | ce27352fc7b7c3857843634a05b073245a7c5d6f /include | |
parent | e843d27f8c4cd3ecabc3598a92db0c814f4d0ed7 (diff) | |
download | volse-hubzilla-b20cce1408445a48e8aec133b6df44bcd71c6321.tar.gz volse-hubzilla-b20cce1408445a48e8aec133b6df44bcd71c6321.tar.bz2 volse-hubzilla-b20cce1408445a48e8aec133b6df44bcd71c6321.zip |
attach_delete() - remove photo resources even if the attach table row wasn't found.
Diffstat (limited to 'include')
-rw-r--r-- | include/attach.php | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/include/attach.php b/include/attach.php index ba2f60a90..dc5bfd308 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1279,8 +1279,10 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { intval($channel_id) ); - if(! $r) + if(! $r) { + attach_drop_photo($channel_id,$resource); return; + } $cloudpath = get_parent_cloudpath($channel_id, $channel_address, $resource); $object = get_file_activity_object($channel_id, $resource, $cloudpath); @@ -1326,19 +1328,10 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { ); if($r[0]['is_photo']) { - $x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d", - dbesc($resource), - intval($channel_id) - ); - if($x) { - drop_item($x[0]['id'],false,(($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1),true); - } - q("DELETE FROM photo WHERE uid = %d AND resource_id = '%s'", - intval($channel_id), - dbesc($resource) - ); + attach_drop_photo($channel_id,$resource); } + // update the parent folder's lastmodified timestamp $e = q("UPDATE attach SET edited = '%s' WHERE hash = '%s' AND uid = %d", dbesc(datetime_convert()), @@ -1351,6 +1344,24 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { return; } + +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", + dbesc($resource), + intval($channel_id) + ); + if($x) { + drop_item($x[0]['id'],false,(($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1),true); + } + q("DELETE FROM photo WHERE uid = %d AND resource_id = '%s'", + intval($channel_id), + dbesc($resource) + ); + +} + + /** * @brief Returns path to file in cloud/. * |