From 1a77bdd1d0d4a7f989d1c117c30cd6327779cd71 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 19 Feb 2019 13:14:19 -0800 Subject: fix ability for file storage creators (visitors) to be able to delete their own content --- Zotlabs/Storage/Browser.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Storage/Browser.php') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index c2d70b854..cb8b9afeb 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -205,17 +205,21 @@ class Browser extends DAV\Browser\Plugin { // upload access. system.thumbnail_security should be set to 1 if you want to include these // types + $is_creator = false; $photo_icon = ''; $preview_style = intval(get_config('system','thumbnail_security',0)); - $r = q("select content from attach where hash = '%s' and uid = %d limit 1", + $r = q("select content, creator from attach where hash = '%s' and uid = %d limit 1", dbesc($attachHash), intval($owner) ); - if($r && file_exists(dbunescbin($r[0]['content']) . '.thumb')) { - $photo_icon = 'data:image/jpeg;base64,' . base64_encode(file_get_contents(dbunescbin($r[0]['content']) . '.thumb')); -// logger('found thumb: ' . $photo_icon); + if($r) { + $is_creator = (($r[0]['creator'] === get_observer_hash()) ? true : false); + if(file_exists(dbunescbin($r[0]['content']) . '.thumb')) { + $photo_icon = 'data:image/jpeg;base64,' . base64_encode(file_get_contents(dbunescbin($r[0]['content']) . '.thumb')); +// logger('found thumb: ' . $photo_icon); + } } if(strpos($type,'image/') === 0 && $attachHash) { @@ -247,6 +251,7 @@ class Browser extends DAV\Browser\Plugin { $ft['attachIcon'] = (($size) ? $attachIcon : ''); // @todo Should this be an item value, not a global one? $ft['is_owner'] = $is_owner; + $ft['is_creator'] = $is_creator; $ft['fullPath'] = $fullPath; $ft['displayName'] = $displayName; $ft['type'] = $type; @@ -256,6 +261,8 @@ class Browser extends DAV\Browser\Plugin { $ft['iconFromType'] = getIconFromType($type); $f[] = $ft; +logger('f:' . print_r($ft,true)); + } -- cgit v1.2.3