diff options
author | friendica <info@friendica.com> | 2014-06-24 17:27:35 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-06-24 17:27:35 -0700 |
commit | ecd472b7bb2fb0a809c156cb47f4373ba0b8d286 (patch) | |
tree | 25361a36397d767c6872fab74fa6ff4d27ccecb7 /include/attach.php | |
parent | 6848a5f9a716b790575f3b9269579b621496cbc7 (diff) | |
parent | 44abcd83b34611ca0857cd37c76aa06742e0bd54 (diff) | |
download | volse-hubzilla-ecd472b7bb2fb0a809c156cb47f4373ba0b8d286.tar.gz volse-hubzilla-ecd472b7bb2fb0a809c156cb47f4373ba0b8d286.tar.bz2 volse-hubzilla-ecd472b7bb2fb0a809c156cb47f4373ba0b8d286.zip |
Merge https://github.com/friendica/red into pending_merge
Diffstat (limited to 'include/attach.php')
-rw-r--r-- | include/attach.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/attach.php b/include/attach.php index a3ee3f0ef..f5eaaa448 100644 --- a/include/attach.php +++ b/include/attach.php @@ -835,6 +835,51 @@ function get_cloudpath($arr) { } /** + * @brief Returns path to parent folder in cloud/. + * + * @param $arr + * @return string with the folder path + */ +function get_parent_cloudpath($channel_id, $channel_name, $attachHash) { + //Build directory tree and redirect + $parentHash = $attachHash; + do { + $parentHash = find_folder_hash_by_attach_hash($channel_id, $parentHash); + if ($parentHash) { + $parentName = find_filename_by_hash($channel_id, $parentHash); + $parentFullPath = $parentName."/".$parentFullPath; + } + } while ($parentHash); + $parentFullPath = z_root() . "/cloud/" . $channel_name . "/" . $parentFullPath; + return $parentFullPath; +} +function find_folder_hash_by_attach_hash($channel_id, $attachHash) { + $r = q("select * from attach where uid = %d and hash = '%s' limit 1", + intval($channel_id), dbesc($attachHash) + ); + $hash = ""; + if($r) { + foreach($r as $rr) { + $hash = $rr['folder']; + } + } + return $hash; +} +function find_filename_by_hash($channel_id, $attachHash) { + $r = q("select * from attach where uid = %d and hash = '%s' limit 1", + intval($channel_id), dbesc($attachHash) + ); + $filename = ""; + if($r) { + foreach($r as $rr) { + $filename = $rr['filename']; + } + } + return $filename; +} + + +/** * * @param $in * @param $out |