Beispiel #1
0
/**
 * @brief Return the hash of an attachment's folder.
 *
 * @param int $channel_id
 *  The id of the channel
 * @param string $attachHash
 *  The hash of the attachment
 * @return string
 */
function find_folder_hash_by_attach_hash($channel_id, $attachHash, $recurse = false)
{
    logger('attach_hash: ' . $attachHash);
    $r = q("SELECT folder FROM attach WHERE uid = %d AND hash = '%s' LIMIT 1", intval($channel_id), dbesc($attachHash));
    $hash = '';
    if ($r && $r[0]['folder']) {
        if ($recurse) {
            $hash = find_folder_hash_by_attach_hash($channel_id, $r[0]['folder'], true) . '/' . $r[0]['folder'];
        } else {
            $hash = $r[0]['folder'];
        }
    }
    return $hash;
}
Beispiel #2
0
/**
 * @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;
}