Use session and not exec sql if already exists acl perms in session - #1017

This commit is contained in:
enriquecd 2017-06-28 11:31:45 +02:00
parent 1b5d36d89f
commit 78bb583824
1 changed files with 25 additions and 0 deletions

View File

@ -1796,6 +1796,26 @@ function check_acl($id_user, $id_group, $access, $onlyOneGroup = false) {
$id_group = (int) $id_group;
}
if($_SESSION['check_acl'] != null){
if (empty ($_SESSION['check_acl']))
return 0;
$result = 0;
$acl_column = get_acl_column($access);
foreach ($_SESSION['check_acl'] as $row) {
// For each profile for this pair of group and user do...
if (isset($row[$acl_column])) {
$result += $row[$acl_column];
}
}
if ($result >= 1) {
return 1;
}
return 0;
}
$parents_id = array($id_group);
if ($id_group != 0 && $onlyOneGroup !== true) {
$group = db_get_row_filter('tgrupo', array('id_grupo' => $id_group));
@ -1844,8 +1864,13 @@ function check_acl($id_user, $id_group, $access, $onlyOneGroup = false) {
OR tusuario_perfil.id_grupo = 0)", $id_user, implode(', ', $parents_id));
}
$rowdup = db_get_all_rows_sql ($query);
$_SESSION['check_acl'] = $rowdup;
if (empty ($rowdup))
return 0;