aboutsummaryrefslogtreecommitdiffstats
path: root/include/attach.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-12-06 16:07:40 -0800
committerzotlabs <mike@macgirvin.com>2017-12-06 16:07:40 -0800
commitd326e7a75c58e49d84d286f89a97573dbc3e870b (patch)
tree30a6ea15488250066af84754b1ee4e88325a6b45 /include/attach.php
parent4c08d7c4808a811ad8c942df9fa3983d261826ff (diff)
downloadvolse-hubzilla-d326e7a75c58e49d84d286f89a97573dbc3e870b.tar.gz
volse-hubzilla-d326e7a75c58e49d84d286f89a97573dbc3e870b.tar.bz2
volse-hubzilla-d326e7a75c58e49d84d286f89a97573dbc3e870b.zip
hubzilla issue #680, implement IMoveTarget and recursive file/directory move/rename
Diffstat (limited to 'include/attach.php')
-rw-r--r--include/attach.php23
1 files changed, 21 insertions, 2 deletions
diff --git a/include/attach.php b/include/attach.php
index b1199507d..3a802bd11 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -2234,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",
@@ -2246,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 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;