aboutsummaryrefslogtreecommitdiffstats
path: root/include/attach.php
diff options
context:
space:
mode:
authorKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2014-06-29 17:49:46 +0200
committerKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2014-06-29 17:49:46 +0200
commit322091cd12ba972d1f3fee0df47ffb4e49a452ce (patch)
tree364190b66e0c3774495841e80e1b005a695bdb71 /include/attach.php
parent5be3ba8436cbe998bdadc2404ebc7aafa05f94df (diff)
downloadvolse-hubzilla-322091cd12ba972d1f3fee0df47ffb4e49a452ce.tar.gz
volse-hubzilla-322091cd12ba972d1f3fee0df47ffb4e49a452ce.tar.bz2
volse-hubzilla-322091cd12ba972d1f3fee0df47ffb4e49a452ce.zip
Fixed some more timestamp bugs in RedDAV.
Fixed an SQL-query in RedFile::put(), where parameters where in wrong order.
Diffstat (limited to 'include/attach.php')
-rw-r--r--include/attach.php43
1 files changed, 30 insertions, 13 deletions
diff --git a/include/attach.php b/include/attach.php
index fdb9c0d56..a7b094500 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -665,17 +665,25 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
);
if($r) {
- if(mkdir($path,STORAGE_DEFAULT_PERMISSIONS, true)) {
+ if(mkdir($path, STORAGE_DEFAULT_PERMISSIONS, true)) {
$ret['success'] = true;
$ret['data'] = $arr;
+
+ // update the parent folder's lastmodified timestamp
+ $e = q("UPDATE attach SET edited = '%s' WHERE hash = '%s' AND uid = %d LIMIT 1",
+ dbesc($created),
+ dbesc($arr['folder']),
+ intval($channel_id)
+ );
}
else {
logger('attach_mkdir: ' . mkdir . ' ' . $path . 'failed.');
$ret['message'] = t('mkdir failed.');
}
}
- else
+ else {
$ret['message'] = t('database storage failed.');
+ }
return $ret;
@@ -727,31 +735,30 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi
return;
}
-
+
/**
- * @brief Delete a file.
+ * @brief Delete a file/directory.
*
- * @param $channel_id
- * @param $resource
+ * @param int $channel_id
+ * @param string $resource a hash to delete
*/
function attach_delete($channel_id, $resource) {
-
- $c = q("select channel_address from channel where channel_id = %d limit 1",
+ $c = q("SELECT channel_address FROM channel WHERE channel_id = %d LIMIT 1",
intval($channel_id)
);
$channel_address = (($c) ? $c[0]['channel_address'] : 'notfound');
- $r = q("select hash, flags from attach where hash = '%s' and uid = %d limit 1",
+ $r = q("SELECT hash, flags, folder FROM attach WHERE hash = '%s' AND uid = %d limit 1",
dbesc($resource),
intval($channel_id)
);
-
if(! $r)
return;
+ // If resource is a directory delete everything in the directory recursive
if($r[0]['flags'] & ATTACH_FLAG_DIR) {
$x = q("select hash, flags from attach where folder = '%s' and uid = %d",
dbesc($resource),
@@ -763,8 +770,10 @@ function attach_delete($channel_id, $resource) {
}
}
}
+
+ // delete a file from filesystem
if($r[0]['flags'] & ATTACH_FLAG_OS) {
- $y = q("select data from attach where hash = '%s' and uid = %d limit 1",
+ $y = q("SELECT data FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1",
dbesc($resource),
intval($channel_id)
);
@@ -778,14 +787,22 @@ function attach_delete($channel_id, $resource) {
}
}
- $z = q("delete from attach where hash = '%s' and uid = %d limit 1",
+ // delete from database
+ $z = q("DELETE FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1",
dbesc($resource),
intval($channel_id)
);
+ // update the parent folder's lastmodified timestamp
+ $e = q("UPDATE attach SET edited = '%s' WHERE hash = '%s' AND uid = %d LIMIT 1",
+ dbesc(datetime_convert()),
+ dbesc($r[0]['folder']),
+ intval($channel_id)
+ );
+
return;
}
-
+
/**
* @brief Returns path to file in cloud/.
*