aboutsummaryrefslogtreecommitdiffstats
path: root/include/attach.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/attach.php')
-rw-r--r--include/attach.php29
1 files changed, 25 insertions, 4 deletions
diff --git a/include/attach.php b/include/attach.php
index 86c792ed9..3a802bd11 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -276,6 +276,8 @@ function attach_by_hash($hash, $observer_hash, $rev = 0) {
return $ret;
}
+ $r[0]['content'] = dbunescbin($r[0]['content']);
+
if($r[0]['folder']) {
$x = attach_can_view_folder($r[0]['uid'],$observer_hash,$r[0]['folder']);
if(! $x) {
@@ -2037,6 +2039,7 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
if($hash_ptr === $resource_id) {
$attach_ptr = $r[0];
}
+ $r[0]['content'] = dbunescbin($r[0]['content']);
$hash_ptr = $r[0]['folder'];
$paths[] = $r[0];
@@ -2222,7 +2225,6 @@ function copy_folder_to_cloudfiles($channel, $observer_hash, $srcpath, $cloudpat
* the attach.hash of the new parent folder, which must already exist. If $new_folder_hash is blank or empty,
* the file is relocated to the root of the channel's storage area.
*
- * @fixme: this operation is currently not synced to clones !!
*
* @param int $channel_id
* @param int $resource_id
@@ -2232,7 +2234,7 @@ function copy_folder_to_cloudfiles($channel, $observer_hash, $srcpath, $cloudpat
function attach_move($channel_id, $resource_id, $new_folder_hash) {
$c = channelx_by_n($channel_id);
- if(! $c)
+ if(! ($c && $resource_id))
return false;
$r = q("select * from attach where hash = '%s' and uid = %d limit 1",
@@ -2244,13 +2246,32 @@ function attach_move($channel_id, $resource_id, $new_folder_hash) {
$oldstorepath = dbunescbin($r[0]['content']);
+ if($r[0]['is_dir']) {
+ $move_success = true;
+ $x = q("select hash from attach where folder = '%s' and uid = %d",
+ dbesc($r[0]['hash']),
+ intval($channel_id)
+ );
+ if($x) {
+ foreach($x as $xv) {
+ $rs = attach_move($channel_id,$xv['hash'],$r[0]['hash']);
+ if(! $rs) {
+ $move_success = false;
+ break;
+ }
+ }
+ }
+ return $move_success;
+ }
+
+
if($new_folder_hash) {
- $n = q("select * from attach where hash = '%s' and uid = %d limit 1",
+ $n = q("select * from attach where hash = '%s' and uid = %d and is_dir = 1 limit 1",
dbesc($new_folder_hash),
intval($channel_id)
);
if(! $n)
- return;
+ return false;
$newdirname = $n[0]['filename'];
$newstorepath = dbunescbin($n[0]['content']) . '/' . $resource_id;