diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index a63f4672be..720d8750ba 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -46,6 +46,9 @@ $delete_layout = (bool) get_parameter ('delete_layout'); $refr = (int) get_parameter('refr', $config['vc_refr']); $offset = (int) get_parameter('offset', 0); $pagination = (int) get_parameter ("pagination", $config["block_size"]); +$search = (string) get_parameter("search",""); +$ag_group = (int)get_parameter("ag_group",0); +$recursion = get_parameter("recursion",0); if ($delete_layout || $copy_layout) { // Visual console required @@ -199,6 +202,50 @@ if ($delete_layout || $copy_layout) { } } +if ($ag_group > 0) { + + $ag_groups = array(); + $ag_groups = (array)$ag_group; + if ($recursion) { + $ag_groups = groups_get_id_recursive($ag_group, true); + } +} + +echo " + "; +if(!is_metaconsole()){ + echo ""; +} else { + echo ""; +} + +echo ""; +echo ""; +echo "
"; +echo __('Search') . ' '; +html_print_input_text ("search", $search, '', 50); + +echo ""; + +echo __('Group') . ' '; +$own_info = get_user_info($config['id_user']); +if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "AW")) + $return_all_group = false; +else + $return_all_group = true; +html_print_select_groups(false, "AR", $return_all_group, "ag_group", $ag_group, 'this.form.submit();', '', 0, false, false, true, '', false); + +echo ""; +echo __('Group Recursion') . ' '; +html_print_checkbox ("recursion", 1, $recursion, false, false, 'this.form.submit()'); + +echo ""; +echo ""; +echo ""; +echo "
"; + $table = new stdClass(); $table->width = '100%'; $table->class = 'databox data'; @@ -228,31 +275,69 @@ $table->align[4] = 'left'; // or has "VR" privileges, otherwise show only maps of user group $filters['offset'] = $offset; $filters['limit'] = $pagination; +if(!empty($search)){ + $filters['name'] = io_safe_input($search); +} + +if($ag_group){ + $filters['group'] = array_flip($ag_groups); +} + $own_info = get_user_info ($config['id_user']); if (!defined('METACONSOLE')) { - $url = 'index.php?sec=network&sec2=godmode/reporting/map_builder&pagination='.$pagination; + $url = 'index.php?sec=network&sec2=godmode/reporting/map_builder&recursion='.$recursion.'&ag_group='.$ag_group.'&search='.$search.'&pagination='.$pagination; } else { - $url = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&pagination='.$pagination; + $url = 'index.php?sec=screen&sec2=screens/screens&action=visualmap&recursion='.$recursion.'&ag_group='.$ag_group.'&search='.$search.'&pagination='.$pagination; } if ($own_info['is_admin'] || $vconsoles_read) { - $maps = visual_map_get_user_layouts (0,false,$filters); - $total_maps = count(visual_map_get_user_layouts()); + if($ag_group){ + $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)); + }else{ + $maps = visual_map_get_user_layouts (0,false,$filters); + unset($filters['offset']); + unset($filters['limit']); + $total_maps = count(visual_map_get_user_layouts(0,false,$filters)); + } } else { $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, - false, false)); + $filters, false)); } if (!$maps && !is_metaconsole()) { - require_once ($config['homedir'] . "/general/firts_task/map_builder.php"); + $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 { + ui_print_info_message( + array( + 'no_close'=>false, + 'message'=> __('No available data to show'))); + } } elseif (!$maps && is_metaconsole()) { - ui_print_info_message( - array( - 'no_close'=>true, - 'message'=> __('There are no visual console defined yet.'))); + $total = count(visual_map_get_user_layouts ($config['id_user'], false, + false, false)); + if(!$total){ + ui_print_info_message( + array( + 'no_close'=>true, + 'message'=> __('There are no visual console defined yet.'))); + }else{ + ui_print_info_message( + array( + 'no_close'=>false, + 'message'=> __('No available data to show'))); + } + } else { ui_pagination ($total_maps, $url, $offset, $pagination); diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index b06a0c6d5c..1dc9c6c06a 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -2775,14 +2775,29 @@ 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) { - if (! is_array ($filter)) + if (! is_array ($filter)){ $filter = array (); - - if ($returnAllGroup) + } else { + if(!empty($filter['name'])){ + $where .= "name LIKE '%".io_safe_output($filter['name'])."%'"; + unset($filter['name']); + } + } + + if ($returnAllGroup){ $groups = users_get_groups ($id_user, 'VR'); - else - $groups = users_get_groups ($id_user, 'VR', false); - + } else { + if(!empty($filter['group'])){ + $groups = $filter['group']; + unset($filter['group']); + } else { + $groups = users_get_groups ($id_user, 'VR', false); + if(empty($groups)){ + $groups = users_get_groups ($id_user, 'VM', false); + } + } + } + if (!empty($groups)) { if (empty($where)) $where = "";