From b330972eab9e88c9eecbd9f1ae17e060324228ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Adamczyk?= Date: Tue, 19 Jun 2018 12:26:39 +0200 Subject: [PATCH] EZP-29311: Implement permissions for Change main Location in Locations tab --- .../views/content/tab/locations/tab.html.twig | 1 + src/lib/UI/Value/Content/Location.php | 17 +++++++++++++++++ src/lib/UI/Value/ValueFactory.php | 3 +++ 3 files changed, 21 insertions(+) diff --git a/src/bundle/Resources/views/content/tab/locations/tab.html.twig b/src/bundle/Resources/views/content/tab/locations/tab.html.twig index e16535ff11..1df6eaa86c 100644 --- a/src/bundle/Resources/views/content/tab/locations/tab.html.twig +++ b/src/bundle/Resources/views/content/tab/locations/tab.html.twig @@ -59,6 +59,7 @@ diff --git a/src/lib/UI/Value/Content/Location.php b/src/lib/UI/Value/Content/Location.php index 904fbf5edd..56568c152e 100644 --- a/src/lib/UI/Value/Content/Location.php +++ b/src/lib/UI/Value/Content/Location.php @@ -52,6 +52,13 @@ class Location extends CoreLocation */ protected $userCanRemove; + /** + * User can edit. + * + * @var bool + */ + protected $userCanEdit; + /** * @param APILocation $location * @param array $properties @@ -70,4 +77,14 @@ public function canDelete(): bool { return !$this->main && $this->userCanManage && $this->userCanRemove; } + + /** + * Can edit location. + * + * @return bool + */ + public function canEdit(): bool + { + return $this->userCanEdit; + } } diff --git a/src/lib/UI/Value/ValueFactory.php b/src/lib/UI/Value/ValueFactory.php index f479f3fb0d..cfeb89c57b 100644 --- a/src/lib/UI/Value/ValueFactory.php +++ b/src/lib/UI/Value/ValueFactory.php @@ -175,6 +175,9 @@ public function createLocation(Location $location): UIValue\Content\Location 'userCanRemove' => $this->permissionResolver->canUser( 'content', 'remove', $location->getContentInfo(), [$location] ), + 'userCanEdit' => $this->permissionResolver->canUser( + 'content', 'edit', $location->getContentInfo(), [$location] + ), 'main' => $location->getContentInfo()->mainLocationId === $location->id, ]); }