aboutsummaryrefslogtreecommitdiffstats
path: root/include/reddav.php
diff options
context:
space:
mode:
authorhabeascodice <habeascodice@federated.social>2014-11-17 08:30:26 -0800
committerhabeascodice <habeascodice@federated.social>2014-11-17 08:30:26 -0800
commit540b7af2c12666047710dd8f5e0c54d23ae8872c (patch)
treeea90f72d9d308f6cb061a528c1f8494106e70087 /include/reddav.php
parent80eb84e843cdca51bbf4ebda180f4de41351b9c4 (diff)
parentee38bebbd6a641eb953eacf493c085053442d972 (diff)
downloadvolse-hubzilla-540b7af2c12666047710dd8f5e0c54d23ae8872c.tar.gz
volse-hubzilla-540b7af2c12666047710dd8f5e0c54d23ae8872c.tar.bz2
volse-hubzilla-540b7af2c12666047710dd8f5e0c54d23ae8872c.zip
Merge branch 'master' of https://github.com/habeascodice/red
Diffstat (limited to 'include/reddav.php')
-rw-r--r--include/reddav.php26
1 files changed, 16 insertions, 10 deletions
diff --git a/include/reddav.php b/include/reddav.php
index 86b3a00e4..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)
);
@@ -50,7 +50,7 @@ function RedChannelList(&$auth) {
if ($r) {
foreach ($r as $rr) {
if (perm_is_allowed($rr['channel_id'], $auth->observer, 'view_storage')) {
- logger('found channel: /cloud/' . $rr['channel_address'], LOGGER_DEBUG);
+ logger('found channel: /cloud/' . $rr['channel_address'], LOGGER_DATA);
// @todo can't we drop '/cloud'? It gets stripped off anyway in RedDirectory
$ret[] = new RedDAV\RedDirectory('/cloud/' . $rr['channel_address'], $auth);
}
@@ -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)
);
@@ -188,7 +194,7 @@ function RedCollectionData($file, &$auth) {
* @throw \Sabre\DAV\Exception\Forbidden
*/
function RedFileData($file, &$auth, $test = false) {
- logger($file . (($test) ? ' (test mode) ' : ''), LOGGER_DEBUG);
+ logger($file . (($test) ? ' (test mode) ' : ''), LOGGER_DATA);
$x = strpos($file, '/cloud');
if ($x === 0) {
@@ -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)