diff options
author | tuscanhobbit <tuscanhobbit@users.noreply.github.com> | 2014-06-24 12:05:11 +0200 |
---|---|---|
committer | tuscanhobbit <tuscanhobbit@users.noreply.github.com> | 2014-06-24 12:05:11 +0200 |
commit | cc4001fce7934b49e6e7888a602b9bb9c33cf37f (patch) | |
tree | 91f7e332149b40fd872ce66c742ca158190e80ba /include/attach.php | |
parent | b2b47dcd7ca823bacd5d223666c8603d099116ec (diff) | |
download | volse-hubzilla-cc4001fce7934b49e6e7888a602b9bb9c33cf37f.tar.gz volse-hubzilla-cc4001fce7934b49e6e7888a602b9bb9c33cf37f.tar.bz2 volse-hubzilla-cc4001fce7934b49e6e7888a602b9bb9c33cf37f.zip |
Fixes to links and forward URLs in filestorage
Diffstat (limited to 'include/attach.php')
-rw-r--r-- | include/attach.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/include/attach.php b/include/attach.php index a3ee3f0ef..bf58566fe 100644 --- a/include/attach.php +++ b/include/attach.php @@ -834,6 +834,45 @@ function get_cloudpath($arr) { return $path; } +function get_parent_cloudpath($channel_id, $channel_name, $attachHash) { + //Build directory tree and redirect + $parentHash = $attachHash; + do { + $parentHash = findFolderHashByAttachHash($channel_id, $parentHash); + if ($parentHash) { + $parentName = findFilenameByHash($channel_id, $parentHash); + $parentFullPath = $parentName."/".$parentFullPath; + } + } while ($parentHash); + $parentFullPath = z_root() . "/cloud/" . $channel_name . "/" . $parentFullPath; + goaway($parentFullPath); +} +function findFolderHashByAttachHash($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 findFilenameByHash($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 |