aboutsummaryrefslogtreecommitdiffstats
path: root/include/attach.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-19 21:39:28 -0700
committerzotlabs <mike@macgirvin.com>2017-03-19 21:39:28 -0700
commit78aeb50ce59b9d83d88b5e1bc9f82195635b0996 (patch)
tree5b4ca54e20c7c66a8a17012d902f9ef17d3f8062 /include/attach.php
parenta12a614e7e6c7d7b5e789d9c69396be55925c951 (diff)
downloadvolse-hubzilla-78aeb50ce59b9d83d88b5e1bc9f82195635b0996.tar.gz
volse-hubzilla-78aeb50ce59b9d83d88b5e1bc9f82195635b0996.tar.bz2
volse-hubzilla-78aeb50ce59b9d83d88b5e1bc9f82195635b0996.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/attach.php')
-rw-r--r--include/attach.php44
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 ];
+
+
+}
+
+