From 955a840ad65aac27d2e2e2e3dde367337cceb446 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 20 Apr 2024 20:54:06 -0600 Subject: [PATCH] Update permissions.php If the $_SESSION['permissions'] isset then use it to prevent round trips to the database. --- resources/classes/permissions.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/resources/classes/permissions.php b/resources/classes/permissions.php index 8c5752242a..67401cfb7b 100644 --- a/resources/classes/permissions.php +++ b/resources/classes/permissions.php @@ -64,13 +64,18 @@ if (!class_exists('permissions')) { $this->user_uuid = $_SESSION['user_uuid']; } - //create the groups object - $group = new groups($this->database, $this->domain_uuid, $this->user_uuid); - $this->groups = $group->assigned(); - - //get the list of groups assigned to the user - $this->permissions = $this->assigned(); + //get the permissions + if (isset($_SESSION['permissions'])) { + $this->permissions = $_SESSION['permissions']; + } + else { + //create the groups object + $group = new groups($this->database, $this->domain_uuid, $this->user_uuid); + $this->groups = $group->assigned(); + //get the list of groups assigned to the user + $this->permissions = $this->assigned(); + } } /** @@ -121,15 +126,12 @@ if (!class_exists('permissions')) { return true; } - //set permisisons array - $permissions = $_SESSION["permissions"]; - //set default to false $result = false; //search for the permission - if (!empty($permissions) && !empty($permission_name)) { - foreach($permissions as $key => $value) { + if (!empty($this->permissions) && !empty($permission_name)) { + foreach($this->permissions as $key => $value) { if ($key == $permission_name) { $result = true; break;