diff options
Diffstat (limited to 'include/RedDAV')
-rw-r--r-- | include/RedDAV/RedBrowser.php | 5 | ||||
-rw-r--r-- | include/RedDAV/RedDirectory.php | 18 | ||||
-rw-r--r-- | include/RedDAV/RedFile.php | 13 |
3 files changed, 22 insertions, 14 deletions
diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php index 9ea2b9808..93a546086 100644 --- a/include/RedDAV/RedBrowser.php +++ b/include/RedDAV/RedBrowser.php @@ -249,7 +249,10 @@ class RedBrowser extends DAV\Browser\Plugin { '$header' => t('Files') . ": " . $this->escapeHTML($path) . "/", '$quota' => $quota, '$total' => t('Total'), - '$actionspanel' => $output + '$actionspanel' => $output, + '$shared' => t('Shared'), + '$create' => t('Create'), + 'upload' => t('Upload') )); $html .= replace_macros(get_markup_template('cloud_directory.tpl'), array( diff --git a/include/RedDAV/RedDirectory.php b/include/RedDAV/RedDirectory.php index 85af0d57f..68186d21b 100644 --- a/include/RedDAV/RedDirectory.php +++ b/include/RedDAV/RedDirectory.php @@ -52,7 +52,8 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota { //logger('directory ' . $ext_path, LOGGER_DATA); $this->ext_path = $ext_path; // remove "/cloud" from the beginning of the path - $this->red_path = ((strpos($ext_path, '/cloud') === 0) ? substr($ext_path, 6) : $ext_path); + $modulename = get_app()->module; + $this->red_path = ((strpos($ext_path, '/' . $modulename) === 0) ? substr($ext_path, strlen($modulename) + 1) : $ext_path); if (! $this->red_path) { $this->red_path = '/'; } @@ -112,8 +113,9 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota { throw new DAV\Exception\Forbidden('Permission denied.'); } - if ($this->red_path === '/' && $name === 'cloud') { - return new RedDirectory('/cloud', $this->auth); + $modulename = get_app()->module; + if ($this->red_path === '/' && $name === $modulename) { + return new RedDirectory('/' . $modulename, $this->auth); } $x = RedFileData($this->ext_path . '/' . $name, $this->auth); @@ -316,8 +318,9 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota { public function childExists($name) { // On /cloud we show a list of available channels. // @todo what happens if no channels are available? - if ($this->red_path === '/' && $name === 'cloud') { - //logger('We are at /cloud show a channel list', LOGGER_DEBUG); + $modulename = get_app()->module; + if ($this->red_path === '/' && $name === $modulename) { + //logger('We are at ' $modulename . ' show a channel list', LOGGER_DEBUG); return true; } @@ -338,14 +341,15 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota { function getDir() { //logger($this->ext_path, LOGGER_DEBUG); $this->auth->log(); + $modulename = get_app()->module; $file = $this->ext_path; - $x = strpos($file, '/cloud'); + $x = strpos($file, '/' . $modulename); if ($x === false) return; if ($x === 0) { - $file = substr($file, 6); + $file = substr($file, strlen($modulename) + 1); } if ((! $file) || ($file === '/')) { diff --git a/include/RedDAV/RedFile.php b/include/RedDAV/RedFile.php index 3a5230dc1..9ce6490a7 100644 --- a/include/RedDAV/RedFile.php +++ b/include/RedDAV/RedFile.php @@ -96,7 +96,7 @@ class RedFile extends DAV\Node implements DAV\IFile { $size = 0; // @todo only 3 values are needed - $c = q("SELECT * FROM channel WHERE channel_id = %d AND NOT (channel_pageflags & %d)>0 LIMIT 1", + $c = q("SELECT * FROM channel WHERE channel_id = %d AND (channel_pageflags & %d) = 0 LIMIT 1", intval($this->auth->owner_id), intval(PAGE_REMOVED) ); @@ -107,14 +107,15 @@ class RedFile extends DAV\Node implements DAV\IFile { ); if ($r) { if ($r[0]['flags'] & ATTACH_FLAG_OS) { - $f = 'store/' . $this->auth->owner_nick . '/' . (($r[0]['data']) ? $r[0]['data'] : ''); + $fname = dbunescbin($r[0]['data']); + $f = 'store/' . $this->auth->owner_nick . '/' . (($fname) ? $fname : ''); // @todo check return value and set $size directly @file_put_contents($f, $data); $size = @filesize($f); logger('filename: ' . $f . ' size: ' . $size, LOGGER_DEBUG); } else { $r = q("UPDATE attach SET data = '%s' WHERE hash = '%s' AND uid = %d", - dbesc(stream_get_contents($data)), + dbescbin(stream_get_contents($data)), dbesc($this->data['hash']), intval($this->data['uid']) ); @@ -191,10 +192,10 @@ class RedFile extends DAV\Node implements DAV\IFile { } if ($r[0]['flags'] & ATTACH_FLAG_OS ) { - $f = 'store/' . $this->auth->owner_nick . '/' . (($this->os_path) ? $this->os_path . '/' : '') . $r[0]['data']; + $f = 'store/' . $this->auth->owner_nick . '/' . (($this->os_path) ? $this->os_path . '/' : '') . dbunescbin($r[0]['data']); return fopen($f, 'rb'); } - return $r[0]['data']; + return dbunescbin($r[0]['data']); } } @@ -276,4 +277,4 @@ class RedFile extends DAV\Node implements DAV\IFile { attach_delete($this->auth->owner_id, $this->data['hash']); } -}
\ No newline at end of file +} |