performance improvements in visual console list is called indiscriminately to the function get_acl
This commit is contained in:
parent
57990d80a8
commit
638d7ced30
|
@ -258,15 +258,11 @@ $table->head = array ();
|
|||
$table->head[0] = __('Map name');
|
||||
$table->head[1] = __('Group');
|
||||
$table->head[2] = __('Items');
|
||||
$table->head[3] = __('Copy');
|
||||
$table->head[4] = __('Delete');
|
||||
$table->size[3] = "6%";
|
||||
$table->size[4] = "6%";
|
||||
|
||||
// Fix: IW was the old ACL for report editing, now is RW
|
||||
//Only for RW flag
|
||||
if ($vconsoles_write || $vconsoles_manage) {
|
||||
$table->head[3] = __('Copy');
|
||||
$table->head[4] = __('Delete');
|
||||
$table->size[3] = "6%";
|
||||
$table->size[4] = "6%";
|
||||
}
|
||||
|
||||
$table->align = array ();
|
||||
$table->align[0] = 'left';
|
||||
|
@ -299,25 +295,22 @@ if ($own_info['is_admin'] || $vconsoles_read) {
|
|||
$maps = visual_map_get_user_layouts (0,false,$filters,false);
|
||||
unset($filters['offset']);
|
||||
unset($filters['limit']);
|
||||
$total_maps = count(visual_map_get_user_layouts(0,false,$filters,false));
|
||||
$total_maps = count($maps);
|
||||
}else{
|
||||
$maps = visual_map_get_user_layouts (0,false,$filters);
|
||||
$maps = visual_map_get_user_layouts (0,false,$filters, false);
|
||||
unset($filters['offset']);
|
||||
unset($filters['limit']);
|
||||
$total_maps = count(visual_map_get_user_layouts(0,false,$filters));
|
||||
$total_maps = count($maps);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$maps = visual_map_get_user_layouts ($config['id_user'], false,
|
||||
$filters, false);
|
||||
$maps = visual_map_get_user_layouts ($config['id_user'], false, $filters, false);
|
||||
unset($filters['offset']);
|
||||
unset($filters['limit']);
|
||||
$total_maps = count(visual_map_get_user_layouts ($config['id_user'], false,
|
||||
$filters, false));
|
||||
$total_maps = count($maps);
|
||||
}
|
||||
if (!$maps && !is_metaconsole()) {
|
||||
$total = count(visual_map_get_user_layouts ($config['id_user'], false,
|
||||
false, false));
|
||||
$total = count(visual_map_get_user_layouts ($config['id_user'], false, false, false));
|
||||
if(!$total){
|
||||
require_once ($config['homedir'] . "/general/firts_task/map_builder.php");
|
||||
} else {
|
||||
|
@ -328,8 +321,7 @@ if (!$maps && !is_metaconsole()) {
|
|||
}
|
||||
}
|
||||
elseif (!$maps && is_metaconsole()) {
|
||||
$total = count(visual_map_get_user_layouts ($config['id_user'], false,
|
||||
false, false));
|
||||
$total = count(visual_map_get_user_layouts ($config['id_user'], false, false, false));
|
||||
if(!$total){
|
||||
ui_print_info_message(
|
||||
array(
|
||||
|
@ -345,13 +337,17 @@ elseif (!$maps && is_metaconsole()) {
|
|||
}
|
||||
else {
|
||||
ui_pagination ($total_maps, $url, $offset, $pagination);
|
||||
|
||||
foreach ($maps as $map) {
|
||||
// ACL for the visual console permission
|
||||
$vconsole_write = check_acl ($config['id_user'],
|
||||
$map['id_group'], "VW");
|
||||
$vconsole_manage = check_acl ($config['id_user'],
|
||||
$map['id_group'], "VM");
|
||||
$vconsole_write = false;
|
||||
$vconsole_manage = false;
|
||||
if(isset($map['vw'])){
|
||||
$vconsole_write = true;
|
||||
}
|
||||
|
||||
if(isset($map['vm'])){
|
||||
$vconsole_manage = true;
|
||||
}
|
||||
|
||||
$data = array ();
|
||||
|
||||
|
@ -369,7 +365,6 @@ else {
|
|||
|
||||
// Fix: IW was the old ACL for report editing, now is RW
|
||||
if ($vconsole_write || $vconsole_manage) {
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
$data[3] = '<a class="copy_visualmap" href="index.php?sec=network&sec2=godmode/reporting/map_builder&id_layout='.$map['id'].'&copy_layout=1">'.html_print_image ("images/copy.png", true).'</a>';
|
||||
$data[4] = '<a class="delete_visualmap" href="index.php?sec=network&sec2=godmode/reporting/map_builder&id_layout='.$map['id'].'&delete_layout=1">'.html_print_image ("images/cross.png", true).'</a>';
|
||||
|
@ -379,6 +374,11 @@ else {
|
|||
$data[4] = '<a class="delete_visualmap" href="index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=' . $pure . '&id_layout='.$map['id'].'&delete_layout=1">'.html_print_image ("images/cross.png", true).'</a>';
|
||||
}
|
||||
}
|
||||
else{
|
||||
$data[3] = '';
|
||||
$data[4] = '';
|
||||
}
|
||||
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
html_print_table ($table);
|
||||
|
|
|
@ -3364,7 +3364,8 @@ function visual_map_print_visual_map ($id_layout, $show_links = true,
|
|||
*
|
||||
* @return array A list of layouts the user can see.
|
||||
*/
|
||||
function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter = false, $returnAllGroup = true, $favourite = false) {
|
||||
function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter = false,
|
||||
$returnAllGroup = true, $favourite = false) {
|
||||
if (! is_array ($filter)){
|
||||
$filter = array ();
|
||||
} else {
|
||||
|
@ -3386,20 +3387,19 @@ function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter
|
|||
$where .= "is_favourite = 1";
|
||||
}
|
||||
|
||||
|
||||
if ($returnAllGroup) {
|
||||
$groups = users_get_groups ($id_user, 'VR');
|
||||
$groups = users_get_groups ($id_user, 'VR', true, true);
|
||||
} else {
|
||||
if(!empty($filter['group'])) {
|
||||
$permissions_group = users_get_groups ($id_user, 'VR', false);
|
||||
$permissions_group = users_get_groups ($id_user, 'VR', false, true);
|
||||
if(empty($permissions_group)){
|
||||
$permissions_group = users_get_groups ($id_user, 'VM', false);
|
||||
$permissions_group = users_get_groups ($id_user, 'VM', false, true);
|
||||
}
|
||||
$groups = array_intersect_key($filter['group'], $permissions_group);
|
||||
} else {
|
||||
$groups = users_get_groups ($id_user, 'VR', false);
|
||||
$groups = users_get_groups ($id_user, 'VR', false, true);
|
||||
if(empty($groups)) {
|
||||
$groups = users_get_groups ($id_user, 'VM', false);
|
||||
$groups = users_get_groups ($id_user, 'VM', false, true);
|
||||
}
|
||||
}
|
||||
unset($filter['group']);
|
||||
|
@ -3432,6 +3432,17 @@ function visual_map_get_user_layouts ($id_user = 0, $only_names = false, $filter
|
|||
$retval[$layout['id']] = $layout['name'];
|
||||
else
|
||||
$retval[$layout['id']] = $layout;
|
||||
|
||||
//add_perms
|
||||
if ($groups[$layout['id_group']]['vconsole_view']){
|
||||
$retval[$layout['id']]['vr'] = $groups[$layout['id_group']]['vconsole_view'];
|
||||
}
|
||||
if ($groups[$layout['id_group']]['vconsole_edit']){
|
||||
$retval[$layout['id']]['vw'] = $groups[$layout['id_group']]['vconsole_edit'];
|
||||
}
|
||||
if ($groups[$layout['id_group']]['vconsole_management']){
|
||||
$retval[$layout['id']]['vm'] = $groups[$layout['id_group']]['vconsole_management'];
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
|
|
Loading…
Reference in New Issue