Add new class methods and use them

This commit is contained in:
FusionPBX
2023-09-11 01:45:19 -06:00
committed by GitHub
parent 6411f50750
commit 2c5724c6ed
8 changed files with 238 additions and 184 deletions
+3 -36
View File
@@ -274,44 +274,11 @@
}
}
//check if the permission exists
if (!function_exists('permission_exists')) {
function permission_exists($permission, $operator = 'or') {
//set default
$result = false;
//permissions exist
if (!empty($_SESSION["permissions"]) && is_array($_SESSION["permissions"]) && @sizeof($_SESSION['permissions']) != 0) {
//array
if (is_array($permission) && @sizeof($permission) != 0) {
if ($operator == 'and') {
$exists_all = true;
foreach ($permission as $perm) {
if ($_SESSION["permissions"][$permission] != true) {
$exists_all = false;
break;
}
}
$result = $exists_all;
}
else {
$exists_one = false;
foreach ($permission as $perm) {
if (isset($_SESSION["permissions"][$perm]) && $_SESSION["permissions"][$perm] != true) {
$exists_one = true;
break;
}
}
$result = $exists_one;
}
}
//single
else {
if (isset($_SESSION["permissions"][$permission]) && $_SESSION["permissions"][$permission] == true) {
$result = true;
}
}
}
//return the result
return $result;
$permission = new permissions;
return $permission->exists($permission);
}
}