diff options
author | Udo Walter | 2017-03-28 15:11:57 +0200 |
---|---|---|
committer | Udo Walter | 2017-03-28 15:11:57 +0200 |
commit | cca740195f76ef89563ab5c00a76c492a462d752 (patch) | |
tree | 05329226d22262de98e8a6dd5bbabf41f11ff0f4 /modules-available/permissionmanager/inc/permissionutil.inc.php | |
parent | [permission-manager] role-list order consistency (diff) | |
download | slx-admin-cca740195f76ef89563ab5c00a76c492a462d752.tar.gz slx-admin-cca740195f76ef89563ab5c00a76c492a462d752.tar.xz slx-admin-cca740195f76ef89563ab5c00a76c492a462d752.zip |
[permission-manager] added role editor (new role and edit role)
Diffstat (limited to 'modules-available/permissionmanager/inc/permissionutil.inc.php')
-rw-r--r-- | modules-available/permissionmanager/inc/permissionutil.inc.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/modules-available/permissionmanager/inc/permissionutil.inc.php b/modules-available/permissionmanager/inc/permissionutil.inc.php new file mode 100644 index 00000000..10f2a61a --- /dev/null +++ b/modules-available/permissionmanager/inc/permissionutil.inc.php @@ -0,0 +1,37 @@ +<?php + +class PermissionUtil +{ + public static function getPermissions() + { + $permissions = array(); + foreach (glob("modules/*/permissions/permissions.json", GLOB_NOSORT) as $file) { + $data = json_decode(file_get_contents($file), true); + if (!is_array($data)) + continue; + preg_match('#^modules/([^/]+)/#', $file, $out); + $newData = array(); + foreach( $data as $k => $v ) { + $newData[] = $v; + $permissions = self::putInPermissionTree($out[1].".".$k, $v, $permissions); + } + } + return $permissions; + } + + private function putInPermissionTree($permission, $description, $tree) + { + $subPermissions = explode('.', $permission); + $original =& $tree; + foreach ($subPermissions as $subPermission) { + if ($subPermission) { + if (!array_key_exists($subPermission, $tree)) { + $tree[$subPermission] = array(); + } + $tree =& $tree[$subPermission]; + } + } + $tree = $description; + return $original; + } +}
\ No newline at end of file |