Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-29311: Implement permissions for Change main Location in Locations tab #519

Merged
merged 1 commit into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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