mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Use isset in permission exists for improved efficiency(#7126)
Using isset on the key name of the array allows it to use a hash table lookup to improve the lookup times for a permission. The permission name is not set if it does not exist for the current user.
This commit is contained in:
@@ -127,21 +127,12 @@ if (!class_exists('permissions')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//set default to false
|
||||
$result = false;
|
||||
|
||||
//search for the permission
|
||||
if (!empty($this->permissions) && !empty($permission_name)) {
|
||||
foreach($this->permissions as $key => $value) {
|
||||
if ($key == $permission_name) {
|
||||
$result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($permission_name)) {
|
||||
return isset($this->permissions[$permission_name]);
|
||||
}
|
||||
|
||||
//return the result
|
||||
return $result;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user