diff options
author | Olivier van Helden <olivier@van-helden.net> | 2014-12-03 17:54:07 -0400 |
---|---|---|
committer | Olivier van Helden <olivier@van-helden.net> | 2014-12-03 17:54:07 -0400 |
commit | e523061b7261439a71bdacf8f46d4c614740b356 (patch) | |
tree | 1a0577c64197c4289ed154d2c2d5fdf48a7e5192 /include/reddav.php | |
parent | 13fd91d6f5723774a1b96257f8096acb2873b4ed (diff) | |
parent | b71b45aafc618d32d23c099a4d4db8bad2f09e54 (diff) | |
download | volse-hubzilla-e523061b7261439a71bdacf8f46d4c614740b356.tar.gz volse-hubzilla-e523061b7261439a71bdacf8f46d4c614740b356.tar.bz2 volse-hubzilla-e523061b7261439a71bdacf8f46d4c614740b356.zip |
Merge pull request #1 from friendica/master
Merge master from friendica
Diffstat (limited to 'include/reddav.php')
-rw-r--r-- | include/reddav.php | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/include/reddav.php b/include/reddav.php index c16e08e27..750ca1b24 100644 --- a/include/reddav.php +++ b/include/reddav.php @@ -42,7 +42,7 @@ require_once('include/RedDAV/RedBasicAuth.php'); function RedChannelList(&$auth) { $ret = array(); - $r = q("SELECT channel_id, channel_address FROM channel WHERE NOT (channel_pageflags & %d) AND NOT (channel_pageflags & %d)", + $r = q("SELECT channel_id, channel_address FROM channel WHERE NOT (channel_pageflags & %d)>0 AND NOT (channel_pageflags & %d)>0", intval(PAGE_REMOVED), intval(PAGE_HIDDEN) ); @@ -115,7 +115,7 @@ function RedCollectionData($file, &$auth) { $permission_error = false; for ($x = 1; $x < count($path_arr); $x++) { - $r = q("SELECT id, hash, filename, flags FROM attach WHERE folder = '%s' AND filename = '%s' AND uid = %d AND (flags & %d) $perms LIMIT 1", + $r = q("SELECT id, hash, filename, flags FROM attach WHERE folder = '%s' AND filename = '%s' AND uid = %d AND (flags & %d)>0 $perms LIMIT 1", dbesc($folder), dbesc($path_arr[$x]), intval($channel_id), @@ -124,7 +124,7 @@ function RedCollectionData($file, &$auth) { if (! $r) { // path wasn't found. Try without permissions to see if it was the result of permissions. $errors = true; - $r = q("select id, hash, filename, flags from attach where folder = '%s' and filename = '%s' and uid = %d and (flags & %d) limit 1", + $r = q("select id, hash, filename, flags from attach where folder = '%s' and filename = '%s' and uid = %d and (flags & %d)>0 limit 1", dbesc($folder), basename($path_arr[$x]), intval($channel_id), @@ -155,8 +155,14 @@ function RedCollectionData($file, &$auth) { logger("Path mismatch: $path !== /$file"); return NULL; } - - $r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, created, edited from attach where folder = '%s' and uid = %d $perms group by filename", + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + $prefix = 'DISTINCT ON (filename)'; + $suffix = 'ORDER BY filename'; + } else { + $prefix = ''; + $suffix = 'GROUP BY filename'; + } + $r = q("select $prefix id, uid, hash, filename, filetype, filesize, revision, folder, flags, created, edited from attach where folder = '%s' and uid = %d $perms $suffix", dbesc($folder), intval($channel_id) ); @@ -231,7 +237,7 @@ function RedFileData($file, &$auth, $test = false) { $errors = false; for ($x = 1; $x < count($path_arr); $x++) { - $r = q("select id, hash, filename, flags from attach where folder = '%s' and filename = '%s' and uid = %d and (flags & %d) $perms", + $r = q("select id, hash, filename, flags from attach where folder = '%s' and filename = '%s' and uid = %d and (flags & %d)>0 $perms", dbesc($folder), dbesc($path_arr[$x]), intval($channel_id), @@ -244,7 +250,7 @@ function RedFileData($file, &$auth, $test = false) { } if (! $r) { $r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, created, edited from attach - where folder = '%s' and filename = '%s' and uid = %d $perms group by filename limit 1", + where folder = '%s' and filename = '%s' and uid = %d $perms order by filename limit 1", dbesc($folder), dbesc(basename($file)), intval($channel_id) @@ -253,7 +259,7 @@ function RedFileData($file, &$auth, $test = false) { if (! $r) { $errors = true; $r = q("select id, uid, hash, filename, filetype, filesize, revision, folder, flags, created, edited from attach - where folder = '%s' and filename = '%s' and uid = %d group by filename limit 1", + where folder = '%s' and filename = '%s' and uid = %d order by filename limit 1", dbesc($folder), dbesc(basename($file)), intval($channel_id) |