diff options
author | zotlabs <mike@macgirvin.com> | 2017-03-19 21:39:28 -0700 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2017-03-29 13:57:15 +0200 |
commit | 5915f31950a7b2314a6718854b7808475d394b44 (patch) | |
tree | ec12f0fe54b20483e2871dd1469291df3e766ab0 /include | |
parent | 8caa4d9e37497645e3bd02aff2975f7851ee9837 (diff) | |
download | volse-hubzilla-5915f31950a7b2314a6718854b7808475d394b44.tar.gz volse-hubzilla-5915f31950a7b2314a6718854b7808475d394b44.tar.bz2 volse-hubzilla-5915f31950a7b2314a6718854b7808475d394b44.zip |
add function attach_syspaths to calculate the contents of os_path and display_path; add this to the rename function. We will also need it to populate existing file/photo structures as an upgrade task.
Diffstat (limited to 'include')
-rw-r--r-- | include/attach.php | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/include/attach.php b/include/attach.php index d7c1b9da4..93401226d 100644 --- a/include/attach.php +++ b/include/attach.php @@ -2212,10 +2212,23 @@ function attach_move($channel_id, $resource_id, $new_folder_hash) { intval($r[0]['id']) ); + + $x = attach_syspaths($channel_id,$resource_id); + + $t1 = q("update attach set os_path = '%s', display_path = '%s' where id = %d", + dbesc($x['os_path']), + dbesc($x['path']), + intval($r[0]['id']) + ); + + if($r[0]['is_photo']) { - $t = q("update photo set album = '%s', filename = '%s' where resource_id = '%s' and uid = %d", + $t = q("update photo set album = '%s', filename = '%s', os_path = '%s', display_path = '%s' + where resource_id = '%s' and uid = %d", dbesc($newdirname), dbesc($filename), + dbesc($x['os_path']), + dbesc($x['path']), dbesc($resource_id), intval($channel_id) ); @@ -2248,7 +2261,7 @@ function attach_folder_select_list($channel_id) { } } } -logger('results: ' . print_r($out,true)); + return $out; } @@ -2280,3 +2293,30 @@ function attach_folder_rpaths($all_folders,$that_folder) { return (($error) ? false : [ $current_hash , $path ]); } + + +function attach_syspaths($channel_id,$attach_hash) { + + $os_path = ''; + $path = ''; + do { + + $r = q("select folder, filename, hash from attach where hash = '%s' and uid = %d", + dbesc($attach_hash), + intval($channel_id) + ); + if(! $r) + break; + + $os_path = $r[0]['hash'] . (($os_path) ? '/' . $os_path : ''); + $path = $r[0]['filename'] . (($path) ? '/' . $path : ''); + $attach_hash = $r[0]['folder']; + } + while($attach_hash); + + return [ 'os_path' => $os_path, 'path' => $path ]; + + +} + + |