diff options
author | Mario Vavti <mario@mariovavti.com> | 2016-09-08 09:52:35 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2016-09-08 09:52:35 +0200 |
commit | 35f1055739f133cdeda290aa3a45992f97bb32fa (patch) | |
tree | 188798d75af9eedaa7884cb4522ada748eb3f4a7 /include/attach.php | |
parent | 98d5ae91f5a716d415fa3dd639e9819ae7003202 (diff) | |
parent | 83b89b9576655c11a9beaaf2261b3a9013a52da5 (diff) | |
download | volse-hubzilla-35f1055739f133cdeda290aa3a45992f97bb32fa.tar.gz volse-hubzilla-35f1055739f133cdeda290aa3a45992f97bb32fa.tar.bz2 volse-hubzilla-35f1055739f133cdeda290aa3a45992f97bb32fa.zip |
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev
Diffstat (limited to 'include/attach.php')
-rw-r--r-- | include/attach.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/attach.php b/include/attach.php index 137d2b11c..237b06217 100644 --- a/include/attach.php +++ b/include/attach.php @@ -2165,3 +2165,51 @@ function attach_move($channel_id,$resource_id,$new_folder_hash) { } +function attach_folder_select_list($channel_id) { + + $r = q("select * from attach where is_dir = 1 and uid = %d", + intval($channel_id) + ); + + $out = []; + $out[''] = '/'; + + if($r) { + foreach($r as $rv) { + $x = attach_folder_rpaths($r,$rv); + if($x) + $out[$x[0]] = $x[1]; + } + } + return $out; +} + +function attach_folder_rpaths($all_folders,$that_folder) { + + $path = '/' . $that_folder['filename']; + $current_hash = $that_folder['hash']; + $parent_hash = $that_folder['folder']; + $error = false; + $found = false; + + if($parent_hash) { + do { + foreach($all_folders as $selected) { + if(! $selected['is_dir']) + continue; + if($selected['hash'] == $parent_hash) { + $path = '/' . $selected['filename'] . $path; + $current_hash = $selected['hash']; + $parent_hash = $selected['folder']; + $found = true; + break; + } + } + if(! $found) + $error = true; + } + while((! $found) && (! $error) && ($parent_hash != '')); + } + return (($error) ? false : [ $current_hash , $path ]); + +}
\ No newline at end of file |