From 6998bb1f23b63c3439f34d9b3f53c42a6922a58e Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 24 Jul 2016 07:41:53 -0400 Subject: Multiple file upload by drag and drop with progress indicators and auto page reload --- Zotlabs/Storage/Browser.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Storage') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 713d75108..e719530b5 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -306,7 +306,8 @@ class Browser extends DAV\Browser\Plugin { '$folder_submit' => t('Create'), '$upload_header' => t('Upload file'), '$upload_submit' => t('Upload'), - '$quota' => $quota + '$quota' => $quota, + '$dragdroptext' => t('Drop files here to immediately upload') )); } -- cgit v1.2.3 From 271f85be3b36a4d4aac55a51cb7ff2580a95ce3e Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 24 Jul 2016 20:27:59 -0700 Subject: add acl selection to files upload via /cloud (still missing from directory creation) --- Zotlabs/Storage/Browser.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Storage') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index e719530b5..93c55bd4c 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -274,6 +274,22 @@ class Browser extends DAV\Browser\Plugin { // SimpleCollection, we won't need to show the panel either. if (get_class($node) === 'Sabre\\DAV\\SimpleCollection') return; + require_once('include/acl_selectors.php'); + + $aclselect = null; + $lockstate = ''; + + if($this->auth-owner_id) { + $channel = channelx_by_n($this->auth->owner_id); + if($channel) { + $acl = new \Zotlabs\Access\AccessList($channel); + $channel_acl = $acl->get(); + $lockstate = (($acl->is_private()) ? 'lock' : 'unlock'); + + $aclselect = ((local_channel() == $this->auth->owner_id) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : ''); + + } + } // Storage and quota for the account (all channels of the owner of this directory)! $limit = engr_units_to_bytes(service_class_fetch($owner, 'attach_upload_limit')); @@ -293,7 +309,6 @@ class Browser extends DAV\Browser\Plugin { userReadableSize($limit), round($used / $limit, 1) * 100); } - // prepare quota for template $quota = array(); $quota['used'] = $used; @@ -307,6 +322,10 @@ class Browser extends DAV\Browser\Plugin { '$upload_header' => t('Upload file'), '$upload_submit' => t('Upload'), '$quota' => $quota, + '$channick' => $this->auth->owner_nick, + '$aclselect' => $aclselect, + '$lockstate' => $lockstate, + '$return_url' => \App::$cmd, '$dragdroptext' => t('Drop files here to immediately upload') )); } -- cgit v1.2.3 From 6900dd34a47786521bcfcd7bd128be797e5f8477 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 26 Jul 2016 09:04:52 +0200 Subject: URLUtil path has changed since sabredav 1.8 - fixes renaming issue in dav clients --- Zotlabs/Storage/Directory.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Storage') diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index 6242d5274..0860f99a1 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -3,6 +3,7 @@ namespace Zotlabs\Storage; use Sabre\DAV; +use Sabre\HTTP; /** * @brief RedDirectory class. @@ -159,7 +160,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { throw new DAV\Exception\Forbidden('Permission denied.'); } - list($parent_path, ) = DAV\URLUtil::splitPath($this->red_path); + list($parent_path, ) = HTTP\URLUtil::splitPath($this->red_path); $new_path = $parent_path . '/' . $name; $r = q("UPDATE attach SET filename = '%s' WHERE hash = '%s' AND uid = %d", -- cgit v1.2.3 From 560af7a5b8e30001ea6bf9a6d2ea36e94ae904d0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 26 Jul 2016 13:17:46 +0200 Subject: allow multiple-file cloud upload --- Zotlabs/Storage/Browser.php | 75 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'Zotlabs/Storage') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 93c55bd4c..0d1d4e791 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -69,6 +69,81 @@ class Browser extends DAV\Browser\Plugin { } } + /** + * Extend from parent to add our own listeners + */ + function initialize(DAV\Server $server) { + parent::initialize($server); + if ($this->enablePost) { + $this->server->on('onBrowserPostAction', [$this, 'cloudPostAction']); + } + } + + /** + * Handles POST requests for tree operations. + * + * @param string $uri + * @param string $action + * @param array $postVars + * @return boolean false will stop other events in the beforeMethod chain to execute + */ + function cloudPostAction($uri, $action, $postVars) { + switch ($postVars['sabreAction']) { + case 'mkcol' : + if (isset($postVars['name']) && trim($postVars['name'])) { + // Using basename() because we won't allow slashes + list(, $folderName) = \Sabre\HTTP\URLUtil::splitPath(trim($postVars['name'])); + + if (isset($postVars['resourceType'])) { + $resourceType = explode(',', $postVars['resourceType']); + } else { + $resourceType = ['{DAV:}collection']; + } + + $properties = []; + foreach ($postVars as $varName => $varValue) { + // Any _POST variable in clark notation is treated + // like a property. + if ($varName[0] === '{') { + // PHP will convert any dots to underscores. + // This leaves us with no way to differentiate + // the two. + // Therefore we replace the string *DOT* with a + // real dot. * is not allowed in uris so we + // should be good. + $varName = str_replace('*DOT*', '.', $varName); + $properties[$varName] = $varValue; + } + } + + $mkCol = new DAV\MkCol( + $resourceType, + $properties + ); + $this->server->createCollection($uri . '/' . $folderName, $mkCol); + } + break; + + case 'put' : + + if ($_FILES) + $file = current($_FILES); + else + break; + + for ($i = 0; $i < count($file['name']); $i++) { + list(, $newName) = \Sabre\HTTP\URLUtil::splitPath(trim($file['name'][$i])); + + if (is_uploaded_file($file['tmp_name'][$i])) { + $this->server->createFile($uri . '/' . $newName, fopen($file['tmp_name'][$i], 'r')); + } + } + break; + + } + return false; + } + /** * @brief Creates the directory listing for the given path. * -- cgit v1.2.3 From f808f1601b548ee4830f7a16b479eadce3b66094 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 27 Jul 2016 16:49:55 +0200 Subject: rework drag and drop to drag directly into files area, implement the default upload button to work with the same mechanism as drag and drop, revert 560af7a5b8e30001ea6bf9a6d2ea36e94ae904d0 since it did not work so well with the new cloud upload mechanism --- Zotlabs/Storage/Browser.php | 75 --------------------------------------------- 1 file changed, 75 deletions(-) (limited to 'Zotlabs/Storage') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 0d1d4e791..93c55bd4c 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -69,81 +69,6 @@ class Browser extends DAV\Browser\Plugin { } } - /** - * Extend from parent to add our own listeners - */ - function initialize(DAV\Server $server) { - parent::initialize($server); - if ($this->enablePost) { - $this->server->on('onBrowserPostAction', [$this, 'cloudPostAction']); - } - } - - /** - * Handles POST requests for tree operations. - * - * @param string $uri - * @param string $action - * @param array $postVars - * @return boolean false will stop other events in the beforeMethod chain to execute - */ - function cloudPostAction($uri, $action, $postVars) { - switch ($postVars['sabreAction']) { - case 'mkcol' : - if (isset($postVars['name']) && trim($postVars['name'])) { - // Using basename() because we won't allow slashes - list(, $folderName) = \Sabre\HTTP\URLUtil::splitPath(trim($postVars['name'])); - - if (isset($postVars['resourceType'])) { - $resourceType = explode(',', $postVars['resourceType']); - } else { - $resourceType = ['{DAV:}collection']; - } - - $properties = []; - foreach ($postVars as $varName => $varValue) { - // Any _POST variable in clark notation is treated - // like a property. - if ($varName[0] === '{') { - // PHP will convert any dots to underscores. - // This leaves us with no way to differentiate - // the two. - // Therefore we replace the string *DOT* with a - // real dot. * is not allowed in uris so we - // should be good. - $varName = str_replace('*DOT*', '.', $varName); - $properties[$varName] = $varValue; - } - } - - $mkCol = new DAV\MkCol( - $resourceType, - $properties - ); - $this->server->createCollection($uri . '/' . $folderName, $mkCol); - } - break; - - case 'put' : - - if ($_FILES) - $file = current($_FILES); - else - break; - - for ($i = 0; $i < count($file['name']); $i++) { - list(, $newName) = \Sabre\HTTP\URLUtil::splitPath(trim($file['name'][$i])); - - if (is_uploaded_file($file['tmp_name'][$i])) { - $this->server->createFile($uri . '/' . $newName, fopen($file['tmp_name'][$i], 'r')); - } - } - break; - - } - return false; - } - /** * @brief Creates the directory listing for the given path. * -- cgit v1.2.3