Allow users to filter albums by contributors #48

Merged
Roflin merged 18 commits from refactor/viewalbum into master 2024-01-20 20:11:18 +01:00
Showing only changes of commit 25b9528628 - Show all commits

View File

@ -32,6 +32,7 @@ class ViewPhotoAlbum extends HTMLController
else
{
$id_tag = 1;
$tag = Tag::fromId($id_tag);
$title = 'Albums';
}
@ -44,7 +45,7 @@ class ViewPhotoAlbum extends HTMLController
// Can we do fancy things here?
// !!! TODO: permission system?
$buttons = $this->getAlbumButtons($id_tag, $tag ?? null);
$buttons = $this->getAlbumButtons($tag);
if (!empty($buttons))
$this->page->adopt(new AlbumButtonBox($buttons));
@ -129,7 +130,7 @@ class ViewPhotoAlbum extends HTMLController
return $albums;
}
private function getAlbumButtons($id_tag, $tag)
private function getAlbumButtons(Tag $tag)
{
$buttons = [];
$user = Registry::get('user');
@ -137,17 +138,17 @@ class ViewPhotoAlbum extends HTMLController
if ($user->isLoggedIn())
{
$buttons[] = [
'url' => BASEURL . '/download/?tag=' . $id_tag,
'url' => BASEURL . '/download/?tag=' . $tag->id_tag,
'caption' => 'Download album',
];
}
if (isset($tag))
if ($tag->id_parent != 0)
{
if ($tag->kind === 'Album')
{
$buttons[] = [
'url' => BASEURL . '/uploadmedia/?tag=' . $id_tag,
'url' => BASEURL . '/uploadmedia/?tag=' . $tag->id_tag,
'caption' => 'Upload photos here',
];
}
@ -157,14 +158,14 @@ class ViewPhotoAlbum extends HTMLController
if ($tag->kind === 'Album')
{
$buttons[] = [
'url' => BASEURL . '/editalbum/?id=' . $id_tag,
'url' => BASEURL . '/editalbum/?id=' . $tag->id_tag,
'caption' => 'Edit album',
];
}
elseif ($tag->kind === 'Person')
{
$buttons[] = [
'url' => BASEURL . '/edittag/?id=' . $id_tag,
'url' => BASEURL . '/edittag/?id=' . $tag->id_tag,
'caption' => 'Edit tag',
];
}
@ -174,7 +175,7 @@ class ViewPhotoAlbum extends HTMLController
if ($user->isAdmin() && (!isset($tag) || $tag->kind === 'Album'))
{
$buttons[] = [
'url' => BASEURL . '/addalbum/?tag=' . $id_tag,
'url' => BASEURL . '/addalbum/?tag=' . $tag->id_tag,
'caption' => 'Create subalbum',
];
}