diff options
author | Simon Rettberg | 2018-02-12 18:16:24 +0100 |
---|---|---|
committer | Simon Rettberg | 2018-02-12 18:16:24 +0100 |
commit | ace4ece3cc294fbe5b2cdfa53557d312d0057d76 (patch) | |
tree | 884f7be76db771c91f3827560158698bd92586a3 /modules-available/permissionmanager/inc/permissionutil.inc.php | |
parent | [exams] Simplify permissions, add some error messages (diff) | |
download | slx-admin-ace4ece3cc294fbe5b2cdfa53557d312d0057d76.tar.gz slx-admin-ace4ece3cc294fbe5b2cdfa53557d312d0057d76.tar.xz slx-admin-ace4ece3cc294fbe5b2cdfa53557d312d0057d76.zip |
[permissionmanager] getPermissions(): Only consider permissions for active modules
Diffstat (limited to 'modules-available/permissionmanager/inc/permissionutil.inc.php')
-rw-r--r-- | modules-available/permissionmanager/inc/permissionutil.inc.php | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/modules-available/permissionmanager/inc/permissionutil.inc.php b/modules-available/permissionmanager/inc/permissionutil.inc.php index 3daf422e..51aaa6fb 100644 --- a/modules-available/permissionmanager/inc/permissionutil.inc.php +++ b/modules-available/permissionmanager/inc/permissionutil.inc.php @@ -100,17 +100,26 @@ class PermissionUtil if (!is_array($data)) continue; preg_match('#^modules/([^/]+)/#', $file, $out); - foreach( $data as $p => $data) { - $description = Dictionary::translateFileModule($out[1], "permissions", $p); - self::putInPermissionTree($out[1].".".$p, $data['location-aware'], $description, $permissions); + $moduleId = $out[1]; + if (Module::get($moduleId) === false) + continue; + foreach($data as $perm => $permissionFlags) { + $description = Dictionary::translateFileModule($moduleId, "permissions", $perm); + self::putInPermissionTree($moduleId . "." . $perm, $permissionFlags['location-aware'], $description, $permissions); } } ksort($permissions); global $MENU_CAT_OVERRIDE; $sortingOrder = $MENU_CAT_OVERRIDE; - foreach ($permissions as $module => $v) $sortingOrder[Module::get($module)->getCategory()][] = $module; + foreach ($permissions as $module => $v) { + $sortingOrder[Module::get($module)->getCategory()][] = $module; + } $permissions = array_replace(array_flip(call_user_func_array('array_merge', $sortingOrder)), $permissions); - foreach ($permissions as $module => $v) if (is_int($v)) unset($permissions[$module]); + foreach ($permissions as $module => $v) { + if (is_int($v)) { + unset($permissions[$module]); + } + } return $permissions; |