Merge pull request #540 from dawnbreak/zotdav

[TASK] Replace deprecated Sabre functions.
This commit is contained in:
zotlabs 2016-09-30 09:02:00 +10:00 committed by GitHub
commit c410ffd10b
2 changed files with 48 additions and 71 deletions

View File

@ -101,8 +101,8 @@ class Browser extends DAV\Browser\Plugin {
$parentpath = array();
// only show parent if not leaving /cloud/; TODO how to improve this?
if ($path && $path != "cloud") {
list($parentUri) = \Sabre\HTTP\URLUtil::splitPath($path);
$fullPath = \Sabre\HTTP\URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
list($parentUri) = \Sabre\Uri\split($path);
$fullPath = \Sabre\HTTP\encodePath($this->server->getBaseUri() . $parentUri);
$parentpath['icon'] = $this->enableAssets ? '<a href="' . $fullPath . '"><img src="' . $this->getAssetUrl('icons/parent' . $this->iconExtension) . '" width="24" alt="' . t('parent') . '"></a>' : '';
$parentpath['path'] = $fullPath;
@ -116,7 +116,7 @@ class Browser extends DAV\Browser\Plugin {
// This is the current directory, we can skip it
if (rtrim($file['href'], '/') == $path) continue;
list(, $name) = \Sabre\HTTP\URLUtil::splitPath($file['href']);
list(, $name) = \Sabre\Uri\split($file['href']);
if (isset($file[200]['{DAV:}resourcetype'])) {
$type = $file[200]['{DAV:}resourcetype']->getValue();
@ -166,8 +166,7 @@ class Browser extends DAV\Browser\Plugin {
$size = isset($file[200]['{DAV:}getcontentlength']) ? (int)$file[200]['{DAV:}getcontentlength'] : '';
$lastmodified = ((isset($file[200]['{DAV:}getlastmodified'])) ? $file[200]['{DAV:}getlastmodified']->getTime()->format('Y-m-d H:i:s') : '');
$fullPath = \Sabre\HTTP\URLUtil::encodePath('/' . trim($this->server->getBaseUri() . ($path ? $path . '/' : '') . $name, '/'));
$fullPath = \Sabre\HTTP\encodePath('/' . trim($this->server->getBaseUri() . ($path ? $path . '/' : '') . $name, '/'));
$displayName = isset($file[200]['{DAV:}displayname']) ? $file[200]['{DAV:}displayname'] : $name;
@ -248,7 +247,7 @@ class Browser extends DAV\Browser\Plugin {
$current_theme = \Zotlabs\Render\Theme::current();
$theme_info_file = "view/theme/" . $current_theme[0] . "/php/theme.php";
$theme_info_file = 'view/theme/' . $current_theme[0] . '/php/theme.php';
if (file_exists($theme_info_file)) {
require_once($theme_info_file);
if (function_exists(str_replace('-', '_', $current_theme[0]) . '_init')) {
@ -287,7 +286,6 @@ class Browser extends DAV\Browser\Plugin {
$lockstate = (($acl->is_private()) ? 'lock' : 'unlock');
$aclselect = ((local_channel() == $this->auth->owner_id) ? populate_acl($channel_acl,false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_storage')) : '');
}
}
@ -363,14 +361,13 @@ class Browser extends DAV\Browser\Plugin {
* The name of the attachment
* @return string
*/
protected function findAttachHash($owner, $parentHash, $attachName) {
$r = q("SELECT hash FROM attach WHERE uid = %d AND folder = '%s' AND filename = '%s' ORDER BY edited DESC LIMIT 1",
intval($owner),
dbesc($parentHash),
dbesc($attachName)
);
$hash = "";
$hash = '';
if ($r) {
foreach ($r as $rr) {
$hash = $rr['hash'];

View File

@ -3,7 +3,6 @@
namespace Zotlabs\Storage;
use Sabre\DAV;
use Sabre\HTTP;
/**
* @brief RedDirectory class.
@ -99,7 +98,6 @@ 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
* @param string $name
@ -160,7 +158,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
throw new DAV\Exception\Forbidden('Permission denied.');
}
list($parent_path, ) = HTTP\URLUtil::splitPath($this->red_path);
list($parent_path, ) = \Sabre\Uri\split($this->red_path);
$new_path = $parent_path . '/' . $name;
$r = q("UPDATE attach SET filename = '%s' WHERE hash = '%s' AND uid = %d",
@ -169,7 +167,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
intval($this->auth->owner_id)
);
$ch = channelx_by_n($this->auth->owner_id);
if ($ch) {
$sync = attach_export_data($ch, $this->folder_hash);
@ -207,7 +204,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
throw new DAV\Exception\Forbidden('Permission denied.');
}
$mimetype = z_mime_content_type($name);
$c = q("SELECT * FROM channel WHERE channel_id = %d AND channel_removed = 0 LIMIT 1",
@ -270,8 +266,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
dbesc($deny_gid)
);
// returns the number of bytes that were written to the file, or FALSE on failure
$size = file_put_contents($f, $data);
// delete attach entry if file_put_contents() failed
@ -284,8 +278,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
// returns now
$edited = datetime_convert();
$is_photo = 0;
$x = @getimagesize($f);
logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
@ -293,7 +285,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$is_photo = 1;
}
// updates entry with filesize and timestamp
$d = q("UPDATE attach SET filesize = '%s', is_photo = %d, edited = '%s' WHERE hash = '%s' AND uid = %d",
dbesc($size),
@ -349,8 +340,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
if ($sync)
build_sync_packet($c[0]['channel_id'], array('file' => array($sync)));
}
/**
@ -391,7 +380,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
/**
* @brief delete directory
*/
public function delete() {
logger('delete file ' . basename($this->red_path), LOGGER_DEBUG);
@ -413,8 +401,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
if ($sync)
build_sync_packet($ch['channel_id'], array('file' => array($sync)));
}
}
@ -573,14 +559,12 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
/**
* @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
*/
function CollectionData($file, &$auth) {
$ret = array();
@ -697,7 +681,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @param BasicAuth &$auth
* @return array Directory[]
*/
function ChannelList(&$auth) {
$ret = array();
@ -722,7 +705,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
/**
* @brief
*
*
* @param string $file
* path to file or directory
* @param BasicAuth &$auth
@ -730,7 +712,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
* @return File|Directory|boolean|null
* @throw \Sabre\DAV\Exception\Forbidden
*/
function FileData($file, &$auth, $test = false) {
logger($file . (($test) ? ' (test mode) ' : ''), LOGGER_DATA);
@ -744,7 +725,6 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$file = substr($file, 4);
}
if ((! $file) || ($file === '/')) {
return new Directory('/', $auth);
}