diff options
author | Simon Rettberg | 2018-02-12 14:17:07 +0100 |
---|---|---|
committer | Simon Rettberg | 2018-02-12 14:17:07 +0100 |
commit | a8b0095b335780ae0bb950bc44021215d43a6b2d (patch) | |
tree | 08b61723fe4facaa6956730f02fa5ede250d9cc6 /modules-available/permissionmanager/inc/permissionutil.inc.php | |
parent | [backup] Use permission helpers (diff) | |
download | slx-admin-a8b0095b335780ae0bb950bc44021215d43a6b2d.tar.gz slx-admin-a8b0095b335780ae0bb950bc44021215d43a6b2d.tar.xz slx-admin-a8b0095b335780ae0bb950bc44021215d43a6b2d.zip |
[permissionmanager] Introduce "location-aware" flag for permissions
This flag tells wether the permission can be restricted to certain
locations in a meaningful way. This flag has to be set in the
permissions.json of the according module.
For example, the permission to reboot the server cannot be limited
to certain locations in a meaningful way, while the view of the
client log can be filtered to only show log entries for clients
in specific locations.
Diffstat (limited to 'modules-available/permissionmanager/inc/permissionutil.inc.php')
-rw-r--r-- | modules-available/permissionmanager/inc/permissionutil.inc.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/modules-available/permissionmanager/inc/permissionutil.inc.php b/modules-available/permissionmanager/inc/permissionutil.inc.php index 5ff41046..3daf422e 100644 --- a/modules-available/permissionmanager/inc/permissionutil.inc.php +++ b/modules-available/permissionmanager/inc/permissionutil.inc.php @@ -100,9 +100,9 @@ class PermissionUtil if (!is_array($data)) continue; preg_match('#^modules/([^/]+)/#', $file, $out); - foreach( $data as $p ) { + foreach( $data as $p => $data) { $description = Dictionary::translateFileModule($out[1], "permissions", $p); - self::putInPermissionTree($out[1].".".$p, $description, $permissions); + self::putInPermissionTree($out[1].".".$p, $data['location-aware'], $description, $permissions); } } ksort($permissions); @@ -120,10 +120,11 @@ class PermissionUtil * Place a permission into the given permission tree. * * @param string $permission the permission to place in the tree + * @param bool $locationAware whether this permissions can be restricted to specific locations only * @param string $description the description of the permission * @param array $tree the permission tree to modify */ - private static function putInPermissionTree($permission, $description, &$tree) + private static function putInPermissionTree($permission, $locationAware, $description, &$tree) { $subPermissions = explode('.', $permission); foreach ($subPermissions as $subPermission) { @@ -134,6 +135,6 @@ class PermissionUtil $tree =& $tree[$subPermission]; } } - $tree = $description; + $tree = array('description' => $description, 'location-aware' => $locationAware, 'isLeaf' => true); } }
\ No newline at end of file |