From 83697cf3e561ceaf0365cd2b4e56fb4bcd00d1fa Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Sat, 23 May 2015 22:35:02 +0200 Subject: [PATCH] Delete attachments on item deletion Delete video from videos page --- include/items.php | 13 +++++ mod/videos.php | 96 ++++++++++++++++++++++++++++++------ view/templates/video_top.tpl | 6 +++ 3 files changed, 101 insertions(+), 14 deletions(-) diff --git a/include/items.php b/include/items.php index 5a0aa9ed51..c5de29a6de 100644 --- a/include/items.php +++ b/include/items.php @@ -4745,6 +4745,18 @@ function drop_item($id,$interactive = true) { // ignore the result } + // If item has attachments, drop them + + foreach(explode(",",$item['attach']) as $attach){ + preg_match("|attach/(\d+)|", $attach, $matches); + q("DELETE FROM `attach` WHERE `id` = %d AND `uid` = %d", + intval($matches[1]), + local_user() + ); + // ignore the result + } + + // clean up item_id and sign meta-data tables /* @@ -4821,6 +4833,7 @@ function drop_item($id,$interactive = true) { // Add a relayable_retraction signature for Diaspora. store_diaspora_retract_sig($item, $a->user, $a->get_baseurl()); } + $drop_id = intval($item['id']); // send the notification upstream/downstream as the case may be diff --git a/mod/videos.php b/mod/videos.php index 0f29e631bd..607c900eb5 100644 --- a/mod/videos.php +++ b/mod/videos.php @@ -43,12 +43,12 @@ function videos_init(&$a) { if(count($albums)) { $a->data['albums'] = $albums; - $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); + $albums_visible = ((intval($a->data['user']['hidewall']) && (! local_user()) && (! remote_user())) ? false : true); if($albums_visible) { $o .= '