Update permissions.php
If the $_SESSION['permissions'] isset then use it to prevent round trips to the database.
This commit is contained in:
@@ -64,13 +64,18 @@ if (!class_exists('permissions')) {
|
|||||||
$this->user_uuid = $_SESSION['user_uuid'];
|
$this->user_uuid = $_SESSION['user_uuid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get the permissions
|
||||||
|
if (isset($_SESSION['permissions'])) {
|
||||||
|
$this->permissions = $_SESSION['permissions'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
//create the groups object
|
//create the groups object
|
||||||
$group = new groups($this->database, $this->domain_uuid, $this->user_uuid);
|
$group = new groups($this->database, $this->domain_uuid, $this->user_uuid);
|
||||||
$this->groups = $group->assigned();
|
$this->groups = $group->assigned();
|
||||||
|
|
||||||
//get the list of groups assigned to the user
|
//get the list of groups assigned to the user
|
||||||
$this->permissions = $this->assigned();
|
$this->permissions = $this->assigned();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,15 +126,12 @@ if (!class_exists('permissions')) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//set permisisons array
|
|
||||||
$permissions = $_SESSION["permissions"];
|
|
||||||
|
|
||||||
//set default to false
|
//set default to false
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|
||||||
//search for the permission
|
//search for the permission
|
||||||
if (!empty($permissions) && !empty($permission_name)) {
|
if (!empty($this->permissions) && !empty($permission_name)) {
|
||||||
foreach($permissions as $key => $value) {
|
foreach($this->permissions as $key => $value) {
|
||||||
if ($key == $permission_name) {
|
if ($key == $permission_name) {
|
||||||
$result = true;
|
$result = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user