ViewPhoto: simplify filter verification
This commit is contained in:
parent
52472d8b58
commit
ec2d702a0d
@ -50,13 +50,12 @@ class ViewPhoto extends HTMLController
|
|||||||
if (isset($_GET['by']))
|
if (isset($_GET['by']))
|
||||||
{
|
{
|
||||||
// Let's first verify that the filter is valid
|
// Let's first verify that the filter is valid
|
||||||
$contributors = array_filter($tag->getContributorList(), fn($el) => $el['slug'] === $_GET['by']);
|
$user = Member::fromSlug($_GET['by']);
|
||||||
if (count($contributors) !== 1)
|
if (!$user)
|
||||||
throw new UnexpectedValueException('Invalid filter for this album or tag.');
|
throw new UnexpectedValueException('Invalid filter for this album or tag.');
|
||||||
|
|
||||||
// Alright, let's run with it then
|
// Alright, let's run with it then
|
||||||
$filter = reset($contributors);
|
$page->setActiveFilter($user->getSlug());
|
||||||
$page->setActiveFilter($filter['slug']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->page->adopt($page);
|
$this->page->adopt($page);
|
||||||
|
@ -723,9 +723,8 @@ class Asset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Take active filter into account as well
|
// 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}';
|
$where[] = 'id_user_uploaded = {int:id_user_uploaded}';
|
||||||
$params['id_user_uploaded'] = $user->getUserId();
|
$params['id_user_uploaded'] = $user->getUserId();
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,11 @@ abstract class User
|
|||||||
return $this->ip_address;
|
return $this->ip_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSlug()
|
||||||
|
{
|
||||||
|
return $this->slug;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether user is logged in.
|
* Returns whether user is logged in.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user