mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-27 02:59:15 +00:00
Auto reload user permissions (#7694)
Reload the current loaded permissions for the logged in user when using the Upgrade web interface
This commit is contained in:
@@ -43,6 +43,37 @@
|
||||
$permission = new permission;
|
||||
$permission->restore();
|
||||
|
||||
//reload the permissions for current user
|
||||
if (!empty($_SESSION["groups"]) && is_array($_SESSION["groups"])) {
|
||||
//clear current permissions
|
||||
unset($_SESSION['permissions'], $_SESSION['user']['permissions']);
|
||||
|
||||
//get the permissions assigned to the groups that the current user is a member of, set the permissions in session variables
|
||||
$x = 0;
|
||||
$sql = "select distinct(permission_name) from v_group_permissions ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and permission_assigned = 'true' ";
|
||||
foreach ($_SESSION["groups"] as $field) {
|
||||
if (!empty($field['group_name'])) {
|
||||
$sql_where_or[] = "group_name = :group_name_".$x;
|
||||
$parameters['group_name_'.$x] = $field['group_name'];
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
if (is_array($sql_where_or) && @sizeof($sql_where_or) != 0) {
|
||||
$sql .= "and (".implode(' or ', $sql_where_or).") ";
|
||||
}
|
||||
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach ($result as $row) {
|
||||
$_SESSION['permissions'][$row["permission_name"]] = true;
|
||||
$_SESSION["user"]["permissions"][$row["permission_name"]] = true;
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $result, $row);
|
||||
}
|
||||
|
||||
//redirect the users
|
||||
if (empty($included) || !$included) {
|
||||
//show a message to the user
|
||||
|
||||
Reference in New Issue
Block a user