From 344db6e4c56babbb141be55c32a4922bb283a5b0 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Mon, 2 Jul 2018 18:32:59 +0000 Subject: [PATCH] Adds a Delete button to the ViewPhotoPage. The Delete button is non functional yet and is only available for admins and the photo owner. --- controllers/ViewPhoto.php | 5 +++++ public/css/default.css | 10 ++++++++++ templates/PhotoPage.php | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/controllers/ViewPhoto.php b/controllers/ViewPhoto.php index 61518e8e..528c2d86 100644 --- a/controllers/ViewPhoto.php +++ b/controllers/ViewPhoto.php @@ -43,6 +43,11 @@ class ViewPhoto extends HTMLController if ($next_url) $page->setNextPhotoUrl($next_url); + $user = Registry::get('user'); + $author = $photo->getAuthor(); + if ($user->isAdmin() || $user->getUserId() === $author->getUserId()) + $page->setIsAssetOwner(true); + $this->page->adopt($page); $this->page->setCanonicalUrl($photo->getPageUrl()); diff --git a/public/css/default.css b/public/css/default.css index f677f5fc..736b9747 100644 --- a/public/css/default.css +++ b/public/css/default.css @@ -619,6 +619,16 @@ a#previous_photo:hover, a#next_photo:hover { margin: 0; } +#user_actions_box { + background: #fff; + box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); + margin: 25px 0 25px 0; + overflow: auto; + padding: 2%; + float: right; + width: 20%; +} + /* Responsive: smartphone in portrait ---------------------------------------*/ diff --git a/templates/PhotoPage.php b/templates/PhotoPage.php index 7820d545..ea3917cf 100644 --- a/templates/PhotoPage.php +++ b/templates/PhotoPage.php @@ -12,6 +12,7 @@ class PhotoPage extends SubTemplate private $exif; private $previous_photo_url = ''; private $next_photo_url = ''; + private $is_asset_owner = false; public function __construct(Image $photo) { @@ -28,6 +29,10 @@ class PhotoPage extends SubTemplate $this->next_photo_url = $url; } + public function setIsAssetOwner($flag) { + $this->is_asset_owner = $flag; + } + protected function html_content() { $this->photoNav(); @@ -45,6 +50,10 @@ class PhotoPage extends SubTemplate $this->photoMeta(); + if($this->is_asset_owner) { + $this->addUserActions(); + } + echo ' '; } @@ -183,4 +192,13 @@ class PhotoPage extends SubTemplate { $this->exif = $exif; } + + public function addUserActions() + { + echo ' +
+

Actions

+ Delete asset +
'; + } }