Commit fbe8a885 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

feat(management) Give access to the entry in Action::hasPermission

issue #5980
parent 9dd73d8b
...@@ -176,7 +176,7 @@ class Action ...@@ -176,7 +176,7 @@ class Action
return; return;
} }
if (!$this->hasPermission($this->parent->listing->getBase())) { if (!$this->hasPermission()) {
return; return;
} }
...@@ -204,7 +204,7 @@ class Action ...@@ -204,7 +204,7 @@ class Action
} }
// Skip the entry completely if there's no permission to execute it // Skip the entry completely if there's no permission to execute it
if (!$this->hasPermission($entry->dn, $entry->getTemplatedType(), $entry->isTemplate())) { if (!$this->hasPermission($entry)) {
return '<img src="images/empty.png" alt=" " class="optional"/>'; return '<img src="images/empty.png" alt=" " class="optional"/>';
} }
...@@ -226,14 +226,18 @@ class Action ...@@ -226,14 +226,18 @@ class Action
return TRUE; return TRUE;
} }
function hasPermission (string $dn, string $type = NULL, bool $template = FALSE): bool function hasPermission (ListingEntry $entry = NULL): bool
{ {
global $ui; global $ui;
if ($type === NULL) { if ($entry === NULL) {
$dn = $this->parent->listing->getBase();
$types = $this->parent->objectTypes; $types = $this->parent->objectTypes;
$template = FALSE;
} else { } else {
$types = [$type]; $dn = $entry->dn;
$types = [$entry->getTemplatedType()];
$template = $entry->isTemplate();
} }
/* /*
* if category is missing it’s deducted from type (all types are tested for menu actions) * if category is missing it’s deducted from type (all types are tested for menu actions)
......
...@@ -49,7 +49,7 @@ class LockAction extends Action ...@@ -49,7 +49,7 @@ class LockAction extends Action
return; return;
} }
if (!$this->hasPermission($this->parent->listing->getBase())) { if (!$this->hasPermission()) {
return; return;
} }
...@@ -84,7 +84,7 @@ class LockAction extends Action ...@@ -84,7 +84,7 @@ class LockAction extends Action
} }
// Skip the entry completely if there's no permission to execute it // Skip the entry completely if there's no permission to execute it
if (!$this->hasPermission($entry->dn, $entry->getTemplatedType(), $entry->isTemplate())) { if (!$this->hasPermission($entry)) {
return '<img src="images/empty.png" alt=" " class="center optional"/>'; return '<img src="images/empty.png" alt=" " class="center optional"/>';
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment