Allow users to filter albums by contributors #48
@ -21,22 +21,30 @@ class Download
|
||||
$tag = (int)$_GET['tag'];
|
||||
$album = Tag::fromId($tag);
|
||||
|
||||
if (isset($_GET['by']) && ($user = Member::fromSlug($_GET['by'])) !== false)
|
||||
$id_user_uploaded = $user->getUserId();
|
||||
else
|
||||
$id_user_uploaded = null;
|
||||
|
||||
if (isset($_SESSION['current_export']))
|
||||
throw new UserFacingException('You can only export one album at the same time. Please wait until the other download finishes, or try again later.');
|
||||
|
||||
// So far so good?
|
||||
$this->exportAlbum($album);
|
||||
$this->exportAlbum($album, $id_user_uploaded);
|
||||
exit;
|
||||
}
|
||||
|
||||
private function exportAlbum(Tag $album)
|
||||
private function exportAlbum(Tag $album, $id_user_uploaded)
|
||||
{
|
||||
$files = [];
|
||||
|
||||
$album_ids = array_merge([$album->id_tag], $this->getChildAlbumIds($album->id_tag));
|
||||
foreach ($album_ids as $album_id)
|
||||
{
|
||||
$iterator = AssetIterator::getByOptions(['id_tag' => $album_id]);
|
||||
$iterator = AssetIterator::getByOptions([
|
||||
'id_tag' => $album_id,
|
||||
'id_user_uploaded' => $id_user_uploaded,
|
||||
]);
|
||||
while ($asset = $iterator->next())
|
||||
$files[] = join(DIRECTORY_SEPARATOR, [$asset->getSubdir(), $asset->getFilename()]);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class ViewPhotoAlbum extends HTMLController
|
||||
}
|
||||
|
||||
// Add an interface to query and modify the album/tag
|
||||
$buttons = $this->getAlbumButtons($tag);
|
||||
$buttons = $this->getAlbumButtons($tag, $active_filter);
|
||||
$button_strip = new AlbumButtonBox($buttons, $filters, $active_filter);
|
||||
$this->page->adopt($button_strip);
|
||||
|
||||
@ -174,15 +174,16 @@ class ViewPhotoAlbum extends HTMLController
|
||||
return $albums;
|
||||
}
|
||||
|
||||
private function getAlbumButtons(Tag $tag)
|
||||
private function getAlbumButtons(Tag $tag, $active_filter)
|
||||
{
|
||||
$buttons = [];
|
||||
$user = Registry::get('user');
|
||||
|
||||
if ($user->isLoggedIn())
|
||||
{
|
||||
$suffix = !empty($active_filter) ? '&by=' . $active_filter : '';
|
||||
$buttons[] = [
|
||||
'url' => BASEURL . '/download/?tag=' . $tag->id_tag,
|
||||
'url' => BASEURL . '/download/?tag=' . $tag->id_tag . $suffix,
|
||||
'caption' => 'Download album',
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user