aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/attach.php5
-rw-r--r--mod/photos.php7
2 files changed, 10 insertions, 2 deletions
diff --git a/include/attach.php b/include/attach.php
index cf463785e..6cd3249cf 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -818,15 +818,16 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi
* The hash to delete
* @return void
*/
-function attach_delete($channel_id, $resource) {
+function attach_delete($channel_id, $resource, $is_photo = 0) {
$c = q("SELECT channel_address FROM channel WHERE channel_id = %d LIMIT 1",
intval($channel_id)
);
$channel_address = (($c) ? $c[0]['channel_address'] : 'notfound');
+ $photo_sql = (($is_photo) ? " and is_photo = 1 " : '');
- $r = q("SELECT hash, flags, folder FROM attach WHERE hash = '%s' AND uid = %d limit 1",
+ $r = q("SELECT hash, flags, folder FROM attach WHERE hash = '%s' AND uid = %d $photo_sql limit 1",
dbesc($resource),
intval($channel_id)
);
diff --git a/mod/photos.php b/mod/photos.php
index 68077a5b1..2bd809b19 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -6,6 +6,7 @@ require_once('include/acl_selectors.php');
require_once('include/bbcode.php');
require_once('include/security.php');
require_once('include/Contact.php');
+require_once('include/attach.php');
function photos_init(&$a) {
@@ -140,6 +141,7 @@ function photos_post(&$a) {
);
if($r) {
foreach($r as $i) {
+ attach_delete($page_owner_uid, $i['resource_id'], 1 );
drop_item($i['id'],false,DROPITEM_PHASE1,true /* force removal of linked items */);
proc_run('php','include/notifier.php','drop',$i['id']);
}
@@ -150,6 +152,9 @@ function photos_post(&$a) {
q("delete from photo where resource_id in ( $str ) and uid = %d",
intval($page_owner_uid)
);
+
+ // @FIXME do the same for the linked attach
+
}
goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address']);
@@ -174,6 +179,8 @@ function photos_post(&$a) {
intval($page_owner_uid),
dbesc($r[0]['resource_id'])
);
+ attach_delete($page_owner_uid, $r[0]['resource_id'], 1 );
+
$i = q("SELECT * FROM `item` WHERE `resource_id` = '%s' AND resource_type = 'photo' and `uid` = %d LIMIT 1",
dbesc($r[0]['resource_id']),
intval($page_owner_uid)