From 1fe2e5057f969c280411ffef1d5487198f72bfcd Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sun, 4 Sep 2016 16:33:18 +0200 Subject: [PATCH] Don't show album creation button for non-admins. --- controllers/ViewPhotoAlbum.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/controllers/ViewPhotoAlbum.php b/controllers/ViewPhotoAlbum.php index 4f26d074..9dae53cf 100644 --- a/controllers/ViewPhotoAlbum.php +++ b/controllers/ViewPhotoAlbum.php @@ -57,16 +57,23 @@ class ViewPhotoAlbum extends HTMLController if (isset($header_box)) $this->page->adopt($header_box); - $this->page->adopt(new AlbumButtonBox([ - [ + // Can we do fancy things here? + // !!! TODO: permission system? + $buttons = []; + if (Registry::get('user')->isLoggedIn()) + $buttons[] = [ 'url' => BASEURL . '/uploadmedia/?tag=' . $id_tag, 'caption' => 'Upload new photos here', - ], - [ + ]; + if (Registry::get('user')->isAdmin()) + $buttons[] = [ 'url' => BASEURL . '/addalbum/?tag=' . $id_tag, 'caption' => 'Create new subalbum here', - ] - ])); + ]; + + // Enough actions for a button box? + if (!empty($buttons)) + $this->page->adopt(new AlbumButtonBox($buttons)); // Fetch subalbums, but only if we're on the first page. if ($page === 1)