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

Update to add support for user-view-[role] permissions for cases where people may be implementing a user.php (or related) template file @adrianbj

This commit is contained in:
Ryan Cramer
2021-05-06 10:07:47 -04:00
parent 4ce75aed1a
commit 3485aa8763
2 changed files with 70 additions and 27 deletions

View File

@@ -167,14 +167,18 @@ class Permissions extends PagesType {
'page-edit-images' => $this->_('Use the image editor to manipulate (crop, resize, etc.) images'),
'page-rename' => $this->_('Change the name of published pages they are allowed to edit'),
'user-admin-all' => $this->_('Administer users in any role (except superuser)'),
'user-view-all' => $this->_('User can view users in any role (including superuser)'),
'user-view-self' => $this->_('User can view themself (when not already by other permission)')
);
foreach($this->wire('roles') as $role) {
if($role->name == 'guest' || $role->name == 'superuser') continue;
foreach($this->wire()->roles as $role) {
if($role->name === 'guest') continue;
$a["user-view-$role->name"] = sprintf($this->_('View users in role: %s'), $role->name);
if($role->name === 'superuser') continue;
$a["user-admin-$role->name"] = sprintf($this->_('Administer users in role: %s'), $role->name);
}
$languages = $this->wire('languages');
$languages = $this->wire()->languages;
if($languages) {
$label = $this->_('Edit fields on a page in language: %s');
$alsoLabel = $this->_('(also required to create or delete pages)');