Skip to content

Commit

Permalink
Merge pull request #519 from mikadamczyk/EZP-29311
Browse files Browse the repository at this point in the history
EZP-29311: Implement permissions for Change main Location in Locations tab
  • Loading branch information
Łukasz Serwatka authored Jun 20, 2018
2 parents ff393bd + b330972 commit 4139a67
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<input
type="radio"
{{ location.main ? 'checked' }}
{{ not location.canEdit ? 'disabled' }}
name="updateMainLocation"
value="{{ location.id }}">
</td>
Expand Down
17 changes: 17 additions & 0 deletions src/lib/UI/Value/Content/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ class Location extends CoreLocation
*/
protected $userCanRemove;

/**
* User can edit.
*
* @var bool
*/
protected $userCanEdit;

/**
* @param APILocation $location
* @param array $properties
Expand All @@ -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;
}
}
3 changes: 3 additions & 0 deletions src/lib/UI/Value/ValueFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
Expand Down

0 comments on commit 4139a67

Please sign in to comment.