aboutsummaryrefslogtreecommitdiffstats
path: root/include/reddav.php
diff options
context:
space:
mode:
authorThomas Willingham <founder@kakste.com>2014-01-15 23:01:02 +0000
committerThomas Willingham <founder@kakste.com>2014-01-15 23:01:02 +0000
commit9f66e5aef325666a0fa6e3f035eaa2c3b35b5b00 (patch)
treec4b261f1cbbf85d4153ecee64fe285cc5aa38ec9 /include/reddav.php
parent9addc83520adada78ad339edd6abe666f65b7059 (diff)
parent762a5432494711bf481943a0dee72cf65f7a04bb (diff)
downloadvolse-hubzilla-9f66e5aef325666a0fa6e3f035eaa2c3b35b5b00.tar.gz
volse-hubzilla-9f66e5aef325666a0fa6e3f035eaa2c3b35b5b00.tar.bz2
volse-hubzilla-9f66e5aef325666a0fa6e3f035eaa2c3b35b5b00.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include/reddav.php')
-rw-r--r--include/reddav.php66
1 files changed, 49 insertions, 17 deletions
diff --git a/include/reddav.php b/include/reddav.php
index d00980011..c53838297 100644
--- a/include/reddav.php
+++ b/include/reddav.php
@@ -100,11 +100,11 @@ class RedDirectory extends DAV\Node implements DAV\ICollection {
$mimetype = z_mime_content_type($name);
- $c = q("select * from channel where channel_id = %d limit 1",
+ $c = q("select * from channel where channel_id = %d and not (channel_pageflags & %d) limit 1",
+ intval(PAGE_REMOVED),
intval($this->auth->owner_id)
);
-
if(! $c) {
logger('createFile: no channel');
throw new DAV\Exception\Forbidden('Permission denied.');
@@ -143,13 +143,21 @@ class RedDirectory extends DAV\Node implements DAV\ICollection {
file_put_contents($f, $data);
$size = filesize($f);
+ $edited = datetime_convert();
- $r = q("update attach set filesize = '%s' where hash = '%s' and uid = %d limit 1",
+ $d = q("update attach set filesize = '%s', edited = '%s' where hash = '%s' and uid = %d limit 1",
dbesc($size),
+ dbesc($edited),
dbesc($hash),
intval($c[0]['channel_id'])
);
+ $e = q("update attach set edited = '%s' where folder = '%s' and uid = %d limit 1",
+ dbesc($edited),
+ dbesc($this->folder_hash),
+ intval($c[0]['channel_id'])
+ );
+
$maxfilesize = get_config('system','maxfilesize');
if(($maxfilesize) && ($size > $maxfilesize)) {
@@ -180,8 +188,9 @@ class RedDirectory extends DAV\Node implements DAV\ICollection {
return;
}
- $r = q("select * from channel where channel_id = %d limit 1",
- dbesc($this->auth->owner_id)
+ $r = q("select * from channel where channel_id = %d and not (channel_pageflags & %d) limit 1",
+ intval(PAGE_REMOVED),
+ intval($this->auth->owner_id)
);
if($r) {
@@ -233,13 +242,17 @@ class RedDirectory extends DAV\Node implements DAV\ICollection {
$channel_name = $path_arr[0];
- $r = q("select channel_id from channel where channel_address = '%s' limit 1",
- dbesc($channel_name)
+
+ $r = q("select channel_id from channel where channel_address = '%s' and not ( channel_pageflags & %d ) limit 1",
+ dbesc($channel_name),
+ intval(PAGE_REMOVED)
);
- if(! $r)
- return;
+ if(! $r) {
+ throw new DAV\Exception\NotFound('The file with name: ' . $channel_name . ' could not be found');
+ return;
+ }
$channel_id = $r[0]['channel_id'];
$this->auth->owner_id = $channel_id;
$this->auth->owner_nick = $channel_name;
@@ -273,6 +286,15 @@ class RedDirectory extends DAV\Node implements DAV\ICollection {
}
+ function getLastModified() {
+ $r = q("select edited from attach where folder = '%s' and uid = %d order by edited desc limit 1",
+ dbesc($this->folder_hash),
+ intval($this->auth->owner_id)
+ );
+ if($r)
+ return datetime_convert('UTC','UTC', $r[0]['edited'],'U');
+ return '';
+ }
@@ -322,12 +344,12 @@ class RedFile extends DAV\Node implements DAV\IFile {
function put($data) {
logger('RedFile::put: ' . basename($this->name), LOGGER_DEBUG);
-
- $c = q("select * from channel where channel_id = %d limit 1",
+ $c = q("select * from channel where channel_id = %d and not (channel_pageflags & %d) limit 1",
+ intval(PAGE_REMOVED),
intval($this->auth->owner_id)
);
- $r = q("select flags, data from attach where hash = '%s' and uid = %d limit 1",
+ $r = q("select flags, folder, data from attach where hash = '%s' and uid = %d limit 1",
dbesc($this->data['hash']),
intval($c[0]['channel_id'])
);
@@ -351,14 +373,23 @@ class RedFile extends DAV\Node implements DAV\IFile {
if($r)
$size = $r[0]['fsize'];
}
+
}
-
- $r = q("update attach set filesize = '%s' where hash = '%s' and uid = %d limit 1",
+
+ $edited = datetime_convert();
+
+ $d = q("update attach set filesize = '%s', edited = '%s' where hash = '%s' and uid = %d limit 1",
dbesc($size),
+ dbesc($edited),
dbesc($this->data['hash']),
intval($c[0]['channel_id'])
);
+ $e = q("update attach set edited = '%s' where folder = '%s' and uid = %d limit 1",
+ dbesc($edited),
+ dbesc($r[0]['folder']),
+ intval($c[0]['channel_id'])
+ );
$maxfilesize = get_config('system','maxfilesize');
@@ -414,7 +445,7 @@ class RedFile extends DAV\Node implements DAV\IFile {
function getLastModified() {
- return $this->data['edited'];
+ return datetime_convert('UTC','UTC',$this->data['edited'],'U');
}
@@ -440,8 +471,9 @@ function RedChannelList(&$auth) {
$ret = array();
- $r = q("select channel_id, channel_address from channel where not (channel_pageflags & %d)",
- intval(PAGE_REMOVED)
+ $r = q("select channel_id, channel_address from channel where not (channel_pageflags & %d) and not (channel_pageflags & %d) ",
+ intval(PAGE_REMOVED),
+ intval(PAGE_HIDDEN)
);
if($r) {