testing attach_list()

This commit is contained in:
Mike Macgirvin 2023-03-19 15:55:24 +11:00
parent 97464120bd
commit 6c8e8dcc99

View file

@ -1205,14 +1205,14 @@ function attach_list($channel, $observer, $sort_key = 'display_path', $direction
// add a 'root directory' to the results
array_unshift($r, [ 'display_path' => '/', 'hash' => '' ]);
array_unshift($r, [ 'display_path' => '', 'hash' => '' ]);
$str = ids_to_querystr($r, 'hash', true);
$folders = [];
if ($str) {
$x = q(
"select count( distinct hash ) as total, folder from attach where is_photo = 1 and uid = %d and folder in ( $str ) $sql_extra group by folder ",
"select count( distinct hash ) as total, folder from attach where uid = %d and folder in ( $str ) $sql_extra group by folder ",
intval($channel_id)
);
if ($x) {
@ -1220,7 +1220,9 @@ function attach_list($channel, $observer, $sort_key = 'display_path', $direction
foreach ($x as $xv) {
if ($xv['folder'] === $rv['hash']) {
if ($xv['total'] != 0 && attach_can_view_folder($channel_id, $observer_xchan, $xv['folder'])) {
$folders[] = [ 'path' => $rv['display_path'], 'folder' => $xv['folder'], 'total' => $xv['total'] ];
$folders[] = [ 'path' => $rv['display_path'], 'folder' => $xv['folder'],
'location' => 'cloud/' . $channel['channel_address'] . '/' . $rv['display_path'],
'total' => $xv['total'] ];
}
}
}
@ -1241,7 +1243,7 @@ function attach_list($channel, $observer, $sort_key = 'display_path', $direction
'shorttext' => (($folder['path']) ? ellipsify($folder['path'], 28) : '/'),
'jstext' => (($folder['path']) ? addslashes($folder['path']) : '/'),
'total' => $folder['total'],
'url' => z_root() . '/' . $folder['path'],
'url' => z_root() . '/' . $folder['location'],
'urlencode' => urlencode($folder['path']),
'bin2hex' => $folder['folder']
];