diff --git a/controllers/ViewPhoto.php b/controllers/ViewPhoto.php index fb151a0..0b8a6b8 100644 --- a/controllers/ViewPhoto.php +++ b/controllers/ViewPhoto.php @@ -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); diff --git a/models/Asset.php b/models/Asset.php index 9510735..c2973c7 100644 --- a/models/Asset.php +++ b/models/Asset.php @@ -723,9 +723,8 @@ class Asset } // Take active filter into account as well - if (!empty($activeFilter)) + if (!empty($activeFilter) && ($user = Member::fromSlug($activeFilter)) !== false) { - $user = Member::fromSlug($activeFilter); $where[] = 'id_user_uploaded = {int:id_user_uploaded}'; $params['id_user_uploaded'] = $user->getUserId(); } diff --git a/models/User.php b/models/User.php index f690f27..b69790d 100644 --- a/models/User.php +++ b/models/User.php @@ -75,6 +75,11 @@ abstract class User return $this->ip_address; } + public function getSlug() + { + return $this->slug; + } + /** * Returns whether user is logged in. */