ViewPhoto: simplify filter verification

This commit is contained in:
2024-01-15 11:33:43 +01:00
parent 52472d8b58
commit ec2d702a0d
3 changed files with 9 additions and 6 deletions

View File

@@ -50,13 +50,12 @@ class ViewPhoto extends HTMLController
if (isset($_GET['by']))
{
// Let's first verify that the filter is valid
$contributors = array_filter($tag->getContributorList(), fn($el) => $el['slug'] === $_GET['by']);
if (count($contributors) !== 1)
$user = Member::fromSlug($_GET['by']);
if (!$user)
throw new UnexpectedValueException('Invalid filter for this album or tag.');
// Alright, let's run with it then
$filter = reset($contributors);
$page->setActiveFilter($filter['slug']);
$page->setActiveFilter($user->getSlug());
}
$this->page->adopt($page);