aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-05-02 20:08:59 -0700
committerzotlabs <mike@macgirvin.com>2018-05-02 20:08:59 -0700
commite9f49d9d9c02ef6b2f5259f9a323a8a2a2d75af5 (patch)
tree3ad27aa2fdc900ee9ccca7f96d7701eea8e9d80a /Zotlabs
parent9713436f497a031e4369130dda40b415ff285fd8 (diff)
downloadvolse-hubzilla-e9f49d9d9c02ef6b2f5259f9a323a8a2a2d75af5.tar.gz
volse-hubzilla-e9f49d9d9c02ef6b2f5259f9a323a8a2a2d75af5.tar.bz2
volse-hubzilla-e9f49d9d9c02ef6b2f5259f9a323a8a2a2d75af5.zip
admin delete of files
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Filestorage.php39
-rw-r--r--Zotlabs/Storage/Browser.php4
2 files changed, 34 insertions, 9 deletions
diff --git a/Zotlabs/Module/Filestorage.php b/Zotlabs/Module/Filestorage.php
index 5c8557e5a..cd9ab601d 100644
--- a/Zotlabs/Module/Filestorage.php
+++ b/Zotlabs/Module/Filestorage.php
@@ -66,7 +66,7 @@ class Filestorage extends \Zotlabs\Web\Controller {
$perms = get_all_perms($owner, $ob_hash);
- if(! $perms['view_storage']) {
+ if(! ($perms['view_storage'] || is_site_admin())){
notice( t('Permission denied.') . EOL);
return;
}
@@ -75,15 +75,29 @@ class Filestorage extends \Zotlabs\Web\Controller {
// need to return for anyone other than the owner, despite the perms check for now.
$is_owner = (((local_channel()) && ($owner == local_channel())) ? true : false);
- if(! $is_owner) {
+ if(! ($is_owner || is_site_admin())){
info( t('Permission Denied.') . EOL );
return;
}
if(argc() > 3 && argv(3) === 'delete') {
+
+ if(argc() > 4 && argv(4) === 'json')
+ $json_return = true;
+
+
+ $admin_delete = false;
+
if(! $perms['write_storage']) {
- notice( t('Permission denied.') . EOL);
- return;
+ if(is_site_admin()) {
+ $admin_delete = true;
+ }
+ else {
+ notice( t('Permission denied.') . EOL);
+ if($json_return)
+ json_return_and_die([ 'success' => false ]);
+ return;
+ }
}
$file = intval(argv(2));
@@ -92,22 +106,31 @@ class Filestorage extends \Zotlabs\Web\Controller {
intval($owner)
);
if(! $r) {
+ if($json_return)
+ json_return_and_die([ 'success' => false ]);
+
notice( t('File not found.') . EOL);
goaway(z_root() . '/cloud/' . $which);
}
$f = $r[0];
- $channel = \App::get_channel();
+
+ $channel = channelx_by_n($owner);
$url = get_cloud_url($channel['channel_id'], $channel['channel_address'], $f['hash']);
attach_delete($owner, $f['hash']);
- $sync = attach_export_data($channel, $f['hash'], true);
- if($sync) {
- build_sync_packet($channel['channel_id'], array('file' => array($sync)));
+ if(! $admin_delete) {
+ $sync = attach_export_data($channel, $f['hash'], true);
+ if($sync) {
+ build_sync_packet($channel['channel_id'], array('file' => array($sync)));
+ }
}
+ if(json_return)
+ json_return_and_die([ 'success' => true ]);
+
goaway(dirname($url));
}
diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php
index 508c39d22..f4f906ad1 100644
--- a/Zotlabs/Storage/Browser.php
+++ b/Zotlabs/Storage/Browser.php
@@ -241,7 +241,7 @@ class Browser extends DAV\Browser\Plugin {
// put the array for this file together
$ft['attachId'] = $this->findAttachIdByHash($attachHash);
- $ft['fileStorageUrl'] = substr($fullPath, 0, strpos($fullPath, "cloud/")) . "filestorage/" . $this->auth->getCurrentUser();
+ $ft['fileStorageUrl'] = substr($fullPath, 0, strpos($fullPath, "cloud/")) . "filestorage/" . $this->auth->owner_nick;
$ft['icon'] = $icon;
$ft['photo_icon'] = $photo_icon;
$ft['attachIcon'] = (($size) ? $attachIcon : '');
@@ -276,6 +276,8 @@ class Browser extends DAV\Browser\Plugin {
'$create' => t('Create'),
'$upload' => t('Add Files'),
'$is_owner' => $is_owner,
+ '$is_admin' => is_site_admin(),
+ '$admin_delete' => t('Admin Delete'),
'$parentpath' => $parentpath,
'$cpath' => bin2hex(\App::$query_string),
'$tiles' => intval($_SESSION['cloud_tiles']),