Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Added permissions rule precedence for exact rules, removed action from permission rules to make it simpler and shorter, increased role list dropdown length

givanz5a39ca87fdf0
diff --git a/admin/controller/admin/user.php b/admin/controller/admin/user.php
index cbd42c2..36ef078 100755
--- a/admin/controller/admin/user.php
+++ b/admin/controller/admin/user.php
@@ -35,6 +35,7 @@ class User extends UserBase {
$options = [
'type' => 'admin', //$this->type,
+ 'limit'=> 100,
] + $this->global;
$roles = $roles->getAll($options);
diff --git a/system/user/role.php b/system/user/role.php
index bffdd47..5654af6 100755
--- a/system/user/role.php
+++ b/system/user/role.php
@@ -84,7 +84,19 @@ class Role {
$denyList = array_map(function ($value) {return false; }, array_flip($matches[0]));
}
- $result = $denyList + $allowList;
+ //rules that match exactly the permission takes precedence (does not have *)
+ $exactAllow = array_intersect($allowRules, $permissions);
+ $exactDeny = array_intersect($denyRules, $permissions);
+
+ if ($exactAllow) {
+ $exactAllow = array_map(function ($value) { return true; }, array_flip($exactAllow));
+ }
+
+ if ($exactDeny) {
+ $exactDeny = array_map(function ($value) { return false; }, array_flip($exactDeny));
+ }
+
+ $result = $exactDeny + $exactAllow + $denyList + $allowList;
if (is_array($permission)) {
return $result;
@@ -142,7 +154,11 @@ class Role {
foreach ($methods as $method) {
//ignore constructor
if ($method[0] != '_') {
- $data[$method] = $permission . "/$method";
+ if ($method == 'index') {
+ $data[$method] = $permission;
+ } else {
+ $data[$method] = "$permission/$method";
+ }
}
}
}
@@ -198,7 +214,11 @@ class Role {
foreach ($methods as $method) {
//ignore constructor
if ($method[0] != '_') {
- $data['permissions'][] = $permission . "/$method";
+ if ($method == 'index') {
+ $data['permissions'][] = $permission;
+ } else {
+ $data['permissions'][] = "$permission/$method";
+ }
}
}
}