diff options
author | Mario <mario@mariovavti.com> | 2020-12-16 16:57:56 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2020-12-16 16:57:56 +0000 |
commit | b4b566318a0e52b6396445ddc21c20c0abcc8ce4 (patch) | |
tree | e65c0225d0c85a72db1e709e3a32484584b049c0 /include/attach.php | |
parent | 27df896a9cb1f713c49e290f2a4e7d9860aff1d5 (diff) | |
download | volse-hubzilla-b4b566318a0e52b6396445ddc21c20c0abcc8ce4.tar.gz volse-hubzilla-b4b566318a0e52b6396445ddc21c20c0abcc8ce4.tar.bz2 volse-hubzilla-b4b566318a0e52b6396445ddc21c20c0abcc8ce4.zip |
files_ng: fix regression in finding the right path in certain situations and add a info panel with attach and zrl bbcode
Diffstat (limited to 'include/attach.php')
-rw-r--r-- | include/attach.php | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/include/attach.php b/include/attach.php index 7ef5c4d0e..8ebe2d243 100644 --- a/include/attach.php +++ b/include/attach.php @@ -647,17 +647,15 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $pathname = filepath_macro($newalbum); } elseif(array_key_exists('folder',$arr)) { - $x = q("select display_path from attach where hash = '%s' and uid = %d limit 1", - dbesc($arr['folder']), - intval($channel['channel_id']) - ); - if($x) - $pathname = $x[0]['display_path']; + $pathname = find_path_by_hash($channel['channel_id'], $arr['folder']); } else { $pathname = filepath_macro($album); } } + elseif(array_key_exists('folder',$arr)) { + $pathname = find_path_by_hash($channel['channel_id'], $arr['folder']); + } if(! $pathname) { $pathname = filepath_macro($upload_path); } @@ -807,6 +805,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $os_relpath = ltrim($os_relpath,'/'); $os_path = $os_relpath; + $display_path = ltrim($pathname . '/' . $filename,'/'); if($src) { @@ -890,7 +889,6 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { ); } else { - $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, folder, filesize, revision, os_storage, is_photo, content, created, edited, os_path, display_path, allow_cid, allow_gid,deny_cid, deny_gid ) VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", intval($channel['channel_account_id']), @@ -1747,6 +1745,29 @@ function find_filename_by_hash($channel_id, $attachHash) { } /** + * @brief Returns the display_path of an attachment in a given channel. + * + * @param int $channel_id + * The id of the channel + * @param string $attachHash + * The hash of the attachment + * @return string + * The filename of the attachment + */ +function find_path_by_hash($channel_id, $attachHash) { + $r = q("SELECT display_path FROM attach WHERE uid = %d AND hash = '%s' LIMIT 1", + intval($channel_id), + dbesc($attachHash) + ); + $display_path = ''; + if ($r) { + $display_path = $r[0]['display_path']; + } + + return $display_path; +} + +/** * @brief Pipes $in to $out in 16KB chunks. * * @param resource $in File pointer of input |