diff options
author | zotlabs <mike@macgirvin.com> | 2016-10-13 21:06:26 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2016-10-13 21:06:26 -0700 |
commit | 40e03a05be8273a0c5fcebeeab127009976d6086 (patch) | |
tree | 2f987765fa51f208fe69f5de988c98b5c1c10fa4 /Zotlabs/Storage | |
parent | bd70e6ae6d5baa5f75e3c704ae25ff41a6a90047 (diff) | |
parent | b9eb74a705823ddc0fafe81e460442b525d0e7ed (diff) | |
download | volse-hubzilla-40e03a05be8273a0c5fcebeeab127009976d6086.tar.gz volse-hubzilla-40e03a05be8273a0c5fcebeeab127009976d6086.tar.bz2 volse-hubzilla-40e03a05be8273a0c5fcebeeab127009976d6086.zip |
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'Zotlabs/Storage')
-rw-r--r-- | Zotlabs/Storage/BasicAuth.php | 32 | ||||
-rw-r--r-- | Zotlabs/Storage/Browser.php | 29 | ||||
-rw-r--r-- | Zotlabs/Storage/Directory.php | 42 | ||||
-rw-r--r-- | Zotlabs/Storage/File.php | 48 |
4 files changed, 76 insertions, 75 deletions
diff --git a/Zotlabs/Storage/BasicAuth.php b/Zotlabs/Storage/BasicAuth.php index 995976dcd..0ff9fad13 100644 --- a/Zotlabs/Storage/BasicAuth.php +++ b/Zotlabs/Storage/BasicAuth.php @@ -12,7 +12,7 @@ use Sabre\HTTP\ResponseInterface; * This class also contains some data which is not necessary for authentication * like timezone settings. * - * @extends Sabre\DAV\Auth\Backend\AbstractBasic + * @extends \\Sabre\\DAV\\Auth\\Backend\\AbstractBasic * * @link http://github.com/friendica/red * @license http://opensource.org/licenses/mit-license.php The MIT License (MIT) @@ -24,37 +24,37 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { * * It is used for building path in filestorage/. * - * @var string|null + * @var string|null $channel_name */ protected $channel_name = null; /** - * channel_id of the current channel of the logged-in account. + * @brief channel_id of the current channel of the logged-in account. * - * @var int + * @var int $channel_id */ public $channel_id = 0; /** - * channel_hash of the current channel of the logged-in account. + * @brief channel_hash of the current channel of the logged-in account. * - * @var string + * @var string $channel_hash */ public $channel_hash = ''; /** - * Set in mod/cloud.php to observer_hash. + * @brief Set in mod/cloud.php to observer_hash. * - * @var string + * @var string $observer */ public $observer = ''; /** * * @see Browser::set_writeable() - * @var \Sabre\DAV\Browser\Plugin + * @var \\Sabre\\DAV\\Browser\\Plugin $browser */ public $browser; /** - * channel_id of the current visited path. Set in Directory::getDir(). + * @brief channel_id of the current visited path. Set in Directory::getDir(). * - * @var int + * @var int $owner_id */ public $owner_id = 0; /** @@ -62,15 +62,15 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { * * Used for creating the path in cloud/ * - * @var string + * @var string $owner_nick */ public $owner_nick = ''; /** * Timezone from the visiting channel's channel_timezone. * - * Used in @ref RedBrowser + * Used in @ref Browser * - * @var string + * @var string $timezone */ protected $timezone = ''; @@ -82,7 +82,7 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { * @brief Validates a username and password. * * - * @see \Sabre\DAV\Auth\Backend\AbstractBasic::validateUserPass + * @see \\Sabre\\DAV\\Auth\\Backend\\AbstractBasic::validateUserPass * @param string $username * @param string $password * @return bool @@ -211,7 +211,7 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { * * If nobody is currently logged in, this method should return null. * - * @see \Sabre\DAV\Auth\Backend\AbstractBasic::getCurrentUser + * @see \\Sabre\\DAV\\Auth\\Backend\\AbstractBasic::getCurrentUser * @return string|null */ public function getCurrentUser() { diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index 4a7e49e86..a30eedba5 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -7,10 +7,10 @@ use Sabre\DAV; /** * @brief Provides a DAV frontend for the webbrowser. * - * RedBrowser is a SabreDAV server-plugin to provide a view to the DAV storage + * Browser is a SabreDAV server-plugin to provide a view to the DAV storage * for the webbrowser. * - * @extends \Sabre\DAV\Browser\Plugin + * @extends \\Sabre\\DAV\\Browser\\Plugin * * @link http://github.com/friendica/red * @license http://opensource.org/licenses/mit-license.php The MIT License (MIT) @@ -19,13 +19,13 @@ class Browser extends DAV\Browser\Plugin { /** * @see set_writeable() - * @see \Sabre\DAV\Auth\Backend\BackendInterface - * @var RedBasicAuth + * @see \\Sabre\\DAV\\Auth\\Backend\\BackendInterface + * @var BasicAuth $auth */ private $auth; /** - * @brief Constructor for RedBrowser class. + * @brief Constructor for Browser class. * * $enablePost will be activated through set_writeable() in a later stage. * At the moment the write_storage permission is only valid for the whole @@ -36,7 +36,7 @@ class Browser extends DAV\Browser\Plugin { * Disable assets with $enableAssets = false. Should get some thumbnail views * anyway. * - * @param RedBasicAuth &$auth + * @param BasicAuth &$auth */ public function __construct(&$auth) { $this->auth = $auth; @@ -95,7 +95,6 @@ class Browser extends DAV\Browser\Plugin { '{DAV:}getlastmodified', ), 1); - $parent = $this->server->tree->getNodeForPath($path); $parentpath = array(); @@ -263,10 +262,11 @@ class Browser extends DAV\Browser\Plugin { * @brief Creates a form to add new folders and upload files. * * @param \Sabre\DAV\INode $node - * @param string &$output + * @param[in,out] string &$output + * @param string $path */ public function htmlActionsPanel(DAV\INode $node, &$output, $path) { - if (! $node instanceof DAV\ICollection) + if(! $node instanceof DAV\ICollection) return; // We also know fairly certain that if an object is a non-extended @@ -278,9 +278,9 @@ class Browser extends DAV\Browser\Plugin { $aclselect = null; $lockstate = ''; - if ($this->auth->owner_id) { + if($this->auth->owner_id) { $channel = channelx_by_n($this->auth->owner_id); - if ($channel) { + if($channel) { $acl = new \Zotlabs\Access\AccessList($channel); $channel_acl = $acl->get(); $lockstate = (($acl->is_private()) ? 'lock' : 'unlock'); @@ -295,12 +295,12 @@ class Browser extends DAV\Browser\Plugin { intval($this->auth->channel_account_id) ); $used = $r[0]['total']; - if ($used) { + if($used) { $quotaDesc = t('You are using %1$s of your available file storage.'); $quotaDesc = sprintf($quotaDesc, userReadableSize($used)); } - if ($limit && $used) { + if($limit && $used) { $quotaDesc = t('You are using %1$s of %2$s available file storage. (%3$s%)'); $quotaDesc = sprintf($quotaDesc, userReadableSize($used), @@ -355,7 +355,7 @@ class Browser extends DAV\Browser\Plugin { * * @param int $owner * The owner_id - * @param string $hash + * @param string $parentHash * The parent's folder hash * @param string $attachName * The name of the attachment @@ -373,6 +373,7 @@ class Browser extends DAV\Browser\Plugin { $hash = $rr['hash']; } } + return $hash; } diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php index de4d90da4..ad450b2dd 100644 --- a/Zotlabs/Storage/Directory.php +++ b/Zotlabs/Storage/Directory.php @@ -9,9 +9,9 @@ use Sabre\DAV; * * A class that represents a directory. * - * @extends \Sabre\DAV\Node - * @implements \Sabre\DAV\ICollection - * @implements \Sabre\DAV\IQuota + * @extends \\Sabre\\DAV\\Node + * @implements \\Sabre\\DAV\\ICollection + * @implements \\Sabre\\DAV\\IQuota * * @link http://github.com/friendica/red * @license http://opensource.org/licenses/mit-license.php The MIT License (MIT) @@ -21,7 +21,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { /** * @brief The path inside /cloud * - * @var string + * @var string $red_path */ private $red_path; private $folder_hash; @@ -29,7 +29,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { * @brief The full path as seen in the browser. * /cloud + $red_path * @todo I think this is not used anywhere, we always strip '/cloud' and only use it in debug - * @var string + * @var string $ext_path */ private $ext_path; private $root_dir = ''; @@ -38,7 +38,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { * @brief The real path on the filesystem. * The actual path in store/ with the hashed names. * - * @var string + * @var string $os_path */ private $os_path = ''; @@ -46,7 +46,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { * @brief Sets up the directory node, expects a full path. * * @param string $ext_path a full path - * @param RedBasicAuth &$auth_plugin + * @param BasicAuth &$auth_plugin */ public function __construct($ext_path, &$auth_plugin) { // $ext_path = urldecode($ext_path); @@ -55,14 +55,14 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { // remove "/cloud" from the beginning of the path $modulename = \App::$module; $this->red_path = ((strpos($ext_path, '/' . $modulename) === 0) ? substr($ext_path, strlen($modulename) + 1) : $ext_path); - if (! $this->red_path) { + if(! $this->red_path) { $this->red_path = '/'; } $this->auth = $auth_plugin; $this->folder_hash = ''; $this->getDir(); - if ($this->auth->browser) { + if($this->auth->browser) { $this->auth->browser->set_writeable(); } } @@ -76,8 +76,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { /** * @brief Returns an array with all the child nodes. * - * @throw \Sabre\DAV\Exception\Forbidden - * @return array \Sabre\DAV\INode[] + * @throw "\Sabre\DAV\Exception\Forbidden" + * @return array \\Sabre\\DAV\\INode[] */ public function getChildren() { logger('children for ' . $this->ext_path, LOGGER_DATA); @@ -98,8 +98,8 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { /** * @brief Returns a child by name. * - * @throw \Sabre\DAV\Exception\Forbidden - * @throw \Sabre\DAV\Exception\NotFound + * @throw "\Sabre\DAV\Exception\Forbidden" + * @throw "\Sabre\DAV\Exception\NotFound" * @param string $name */ public function getChild($name) { @@ -141,7 +141,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { * * @todo handle duplicate directory name * - * @throw \Sabre\DAV\Exception\Forbidden + * @throw "\Sabre\DAV\Exception\Forbidden" * @param string $name The new name of the directory. * @return void */ @@ -186,7 +186,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { * After successful creation of the file, you may choose to return the ETag * of the new file here. * - * @throw \Sabre\DAV\Exception\Forbidden + * @throw "\Sabre\DAV\Exception\Forbidden" * @param string $name Name of the file * @param resource|string $data Initial payload * @return null|string ETag @@ -431,7 +431,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { /** * @todo add description of what this function does. * - * @throw \Sabre\DAV\Exception\NotFound + * @throw "\Sabre\DAV\Exception\NotFound" * @return void */ function getDir() { @@ -557,13 +557,13 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { /** - * @brief Array with all Directory and File DAV\Node items for the given path. + * @brief Array with all Directory and File DAV\\Node items for the given path. * * @param string $file path to a directory * @param \Zotlabs\Storage\BasicAuth &$auth - * @returns null|array \Sabre\DAV\INode[] - * @throw \Sabre\DAV\Exception\Forbidden - * @throw \Sabre\DAV\Exception\NotFound + * @returns null|array \\Sabre\\DAV\\INode[] + * @throw "\Sabre\DAV\Exception\Forbidden" + * @throw "\Sabre\DAV\Exception\NotFound" */ function CollectionData($file, &$auth) { $ret = array(); @@ -710,7 +710,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota { * @param BasicAuth &$auth * @param boolean $test (optional) enable test mode * @return File|Directory|boolean|null - * @throw \Sabre\DAV\Exception\Forbidden + * @throw "\Sabre\DAV\Exception\Forbidden" */ function FileData($file, &$auth, $test = false) { logger($file . (($test) ? ' (test mode) ' : ''), LOGGER_DATA); diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php index 5a70a99f1..d2bca3964 100644 --- a/Zotlabs/Storage/File.php +++ b/Zotlabs/Storage/File.php @@ -9,8 +9,8 @@ use Sabre\DAV; * * It provides all functions to work with files in Red's cloud through DAV protocol. * - * @extends \Sabre\DAV\Node - * @implements \Sabre\DAV\IFile + * @extends \\Sabre\\DAV\\Node + * @implements \\Sabre\\DAV\\IFile * * @link http://github.com/friendica/red * @license http://opensource.org/licenses/mit-license.php The MIT License (MIT) @@ -20,20 +20,20 @@ class File extends DAV\Node implements DAV\IFile { /** * The file from attach table. * - * @var array - * data - * flags - * filename (string) - * filetype (string) + * @var array $data + * * data + * * flags + * * filename (string) + * * filetype (string) */ private $data; /** - * @see \Sabre\DAV\Auth\Backend\BackendInterface - * @var \RedMatrix\RedDAV\RedBasicAuth + * @see \\Sabre\\DAV\\Auth\\Backend\\BackendInterface + * @var \\Zotlabs\\Storage\\BasicAuth $auth */ private $auth; /** - * @var string + * @var string $name */ private $name; @@ -65,8 +65,8 @@ class File extends DAV\Node implements DAV\IFile { /** * @brief Renames the file. * - * @throw Sabre\DAV\Exception\Forbidden - * @param string $name The new name of the file. + * @throw "\Sabre\DAV\Exception\Forbidden" + * @param string $newName The new name of the file. * @return void */ public function setName($newName) { @@ -95,7 +95,7 @@ class File extends DAV\Node implements DAV\IFile { $ch = channelx_by_n($this->auth->owner_id); if($ch) { $sync = attach_export_data($ch,$this->data['hash']); - if($sync) + if($sync) build_sync_packet($ch['channel_id'],array('file' => array($sync))); } } @@ -138,7 +138,7 @@ class File extends DAV\Node implements DAV\IFile { $album = $f1[0]['filename']; $direct = $f1[0]; } - } + } $fname = dbunescbin($d[0]['content']); if(strpos($fname,'store') === false) $f = 'store/' . $this->auth->owner_nick . '/' . $fname ; @@ -151,11 +151,11 @@ class File extends DAV\Node implements DAV\IFile { logger('filename: ' . $f . ' size: ' . $size, LOGGER_DEBUG); } $gis = @getimagesize($f); - logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA); + logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA); if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) { $is_photo = 1; } - } + } else { // this shouldn't happen any more $r = q("UPDATE attach SET content = '%s' WHERE hash = '%s' AND uid = %d", @@ -222,7 +222,7 @@ class File extends DAV\Node implements DAV\IFile { $sync = attach_export_data($c[0],$this->data['hash']); - if($sync) + if($sync) build_sync_packet($c[0]['channel_id'],array('file' => array($sync))); } @@ -322,16 +322,16 @@ class File extends DAV\Node implements DAV\IFile { * This method checks the permissions and then calls attach_delete() function * to actually remove the file. * - * @throw \Sabre\DAV\Exception\Forbidden + * @throw "\Sabre\DAV\Exception\Forbidden" */ public function delete() { logger('delete file ' . basename($this->name), LOGGER_DEBUG); - if ((! $this->auth->owner_id) || (! perm_is_allowed($this->auth->owner_id, $this->auth->observer, 'write_storage'))) { + if((! $this->auth->owner_id) || (! perm_is_allowed($this->auth->owner_id, $this->auth->observer, 'write_storage'))) { throw new DAV\Exception\Forbidden('Permission denied.'); } - if ($this->auth->owner_id !== $this->auth->channel_id) { + if($this->auth->owner_id !== $this->auth->channel_id) { if (($this->auth->observer !== $this->data['creator']) || intval($this->data['is_dir'])) { throw new DAV\Exception\Forbidden('Permission denied.'); } @@ -340,14 +340,14 @@ class File extends DAV\Node implements DAV\IFile { if(get_pconfig($this->auth->owner_id,'system','os_delete_prohibit') && \App::$module == 'dav') { throw new DAV\Exception\Forbidden('Permission denied.'); } - + attach_delete($this->auth->owner_id, $this->data['hash']); $ch = channelx_by_n($this->auth->owner_id); if($ch) { - $sync = attach_export_data($ch,$this->data['hash'],true); - if($sync) - build_sync_packet($ch['channel_id'],array('file' => array($sync))); + $sync = attach_export_data($ch, $this->data['hash'], true); + if($sync) + build_sync_packet($ch['channel_id'], array('file' => array($sync))); } } } |