1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 08:17:12 +02:00

Update Role and User classes to use new $permissions->getDelegatedMethod() where appropriate

This commit is contained in:
Ryan Cramer
2023-07-19 14:29:36 -04:00
parent bf144afd65
commit 05cdf08949
2 changed files with 11 additions and 1 deletions

View File

@@ -108,6 +108,13 @@ class Role extends Page {
if(!ctype_alnum(str_replace('-', '', $name))) {
$name = $this->wire()->sanitizer->pageName($name);
}
if($context) {
$method = $permissions->getDelegatedMethod($name, $context);
if($method) {
// non-installed permission delegates to a method call such as $page->editable()
return $context->$method();
}
}
$delegated = $permissions->getDelegatedPermissions();
if(isset($delegated[$name])) $name = $delegated[$name];
}
@@ -243,4 +250,3 @@ class Role extends Page {
}
}

View File

@@ -261,6 +261,10 @@ class User extends Page {
// code later on will make sure they exist in the template's addRoles/createRoles
$p = 'page-edit';
} else if(!$permissions->has($name)) {
if($page) {
$method = $permissions->getDelegatedMethod($name, $page);
if($method) return $page->$method(); // i.e. $page->editable()
}
$delegated = $permissions->getDelegatedPermissions();
$p = isset($delegated[$name]) ? $delegated[$name] : $name;
} else {