From cb77a299bbc0918b84778bc70322b80c1d505111 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 1 Aug 2018 09:58:48 +0200 Subject: [PATCH 01/23] add templates console visual --- pandora_console/extras/mr/19.sql | 55 ++++++++++++++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 55 +++++++++++++- .../godmode/reporting/map_builder.php | 31 +++++++- .../reporting/visual_console_favorite.php | 26 ++++++- .../reporting/visual_console_template.php | 73 +++++++++++++++++++ .../visual_console_template_wizard.php | 71 ++++++++++++++++++ pandora_console/pandoradb.sql | 50 +++++++++++++ pandora_console/pandoradb_data.sql | 4 +- 8 files changed, 355 insertions(+), 10 deletions(-) create mode 100644 pandora_console/extras/mr/19.sql create mode 100644 pandora_console/godmode/reporting/visual_console_template.php create mode 100644 pandora_console/godmode/reporting/visual_console_template_wizard.php diff --git a/pandora_console/extras/mr/19.sql b/pandora_console/extras/mr/19.sql new file mode 100644 index 0000000000..1678c6ec6d --- /dev/null +++ b/pandora_console/extras/mr/19.sql @@ -0,0 +1,55 @@ +START TRANSACTION; + +-- --------------------------------------------------------------------- +-- Table `tlayout` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlayout_template` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `id_group` INTEGER UNSIGNED NOT NULL, + `background` varchar(200) NOT NULL, + `height` INTEGER UNSIGNED NOT NULL default 0, + `width` INTEGER UNSIGNED NOT NULL default 0, + `background_color` varchar(50) NOT NULL default '#FFF', + `is_favourite` INTEGER UNSIGNED NOT NULL default 0, + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tlayout_data` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id_layout_template` INTEGER UNSIGNED NOT NULL default 0, + `pos_x` INTEGER UNSIGNED NOT NULL default 0, + `pos_y` INTEGER UNSIGNED NOT NULL default 0, + `height` INTEGER UNSIGNED NOT NULL default 0, + `width` INTEGER UNSIGNED NOT NULL default 0, + `label` TEXT, + `image` varchar(200) DEFAULT "", + `type` tinyint(1) UNSIGNED NOT NULL default 0, + `period` INTEGER UNSIGNED NOT NULL default 3600, + `module_name` mediumint(8) unsigned NOT NULL default '0', + `agent_name` int(10) unsigned NOT NULL default 0, + `id_layout_linked` INTEGER unsigned NOT NULL default '0', + `parent_item` INTEGER UNSIGNED NOT NULL default 0, + `enable_link` tinyint(1) UNSIGNED NOT NULL default 1, + `id_metaconsole` int(10) NOT NULL default 0, + `id_group` INTEGER UNSIGNED NOT NULL default 0, + `id_custom_graph` INTEGER UNSIGNED NOT NULL default 0, + `border_width` INTEGER UNSIGNED NOT NULL default 0, + `type_graph` varchar(50) NOT NULL default 'area', + `label_position` varchar(50) NOT NULL default 'down', + `border_color` varchar(200) DEFAULT "", + `fill_color` varchar(200) DEFAULT "", + `show_statistics` tinyint(2) NOT NULL default '0', + `id_layout_linked_weight` int(10) NOT NULL default '0', + `element_group` int(10) NOT NULL default '0', + `show_on_top` tinyint(1) NOT NULL default '0', + `clock_animation` varchar(60) NOT NULL default "analogic_1", + `time_format` varchar(60) NOT NULL default "time", + `timezone` varchar(60) NOT NULL default "Europe/Madrid", + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 4516010753..8bbde497b6 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1175,13 +1175,13 @@ ALTER TABLE titem MODIFY `source_data` int(10) unsigned; INSERT INTO `tconfig` (`token`, `value`) VALUES ('big_operation_step_datos_purge', '100'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('small_operation_step_datos_purge', '1000'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('days_autodisable_deletion', '30'); -INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 18); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('MR', 19); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_docs_logo', 'default_docs.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_support_logo', 'default_support.png'); INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_logo_white_bg_preview', 'pandora_logo_head_white_bg.png'); UPDATE tconfig SET value = 'https://licensing.artica.es/pandoraupdate7/server.php' WHERE token='url_update_manager'; DELETE FROM `tconfig` WHERE `token` = 'current_package_enterprise'; -INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '724'); +INSERT INTO `tconfig` (`token`, `value`) VALUES ('current_package_enterprise', '726'); -- --------------------------------------------------------------------- -- Table `tconfig_os` @@ -1712,4 +1712,55 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- --------------------------------------------------------------------- +-- Table `tlayout` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlayout_template` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `id_group` INTEGER UNSIGNED NOT NULL, + `background` varchar(200) NOT NULL, + `height` INTEGER UNSIGNED NOT NULL default 0, + `width` INTEGER UNSIGNED NOT NULL default 0, + `background_color` varchar(50) NOT NULL default '#FFF', + `is_favourite` INTEGER UNSIGNED NOT NULL default 0, + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tlayout_data` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id_layout_template` INTEGER UNSIGNED NOT NULL default 0, + `pos_x` INTEGER UNSIGNED NOT NULL default 0, + `pos_y` INTEGER UNSIGNED NOT NULL default 0, + `height` INTEGER UNSIGNED NOT NULL default 0, + `width` INTEGER UNSIGNED NOT NULL default 0, + `label` TEXT, + `image` varchar(200) DEFAULT "", + `type` tinyint(1) UNSIGNED NOT NULL default 0, + `period` INTEGER UNSIGNED NOT NULL default 3600, + `module_name` mediumint(8) unsigned NOT NULL default '0', + `agent_name` int(10) unsigned NOT NULL default 0, + `id_layout_linked` INTEGER unsigned NOT NULL default '0', + `parent_item` INTEGER UNSIGNED NOT NULL default 0, + `enable_link` tinyint(1) UNSIGNED NOT NULL default 1, + `id_metaconsole` int(10) NOT NULL default 0, + `id_group` INTEGER UNSIGNED NOT NULL default 0, + `id_custom_graph` INTEGER UNSIGNED NOT NULL default 0, + `border_width` INTEGER UNSIGNED NOT NULL default 0, + `type_graph` varchar(50) NOT NULL default 'area', + `label_position` varchar(50) NOT NULL default 'down', + `border_color` varchar(200) DEFAULT "", + `fill_color` varchar(200) DEFAULT "", + `show_statistics` tinyint(2) NOT NULL default '0', + `id_layout_linked_weight` int(10) NOT NULL default '0', + `element_group` int(10) NOT NULL default '0', + `show_on_top` tinyint(1) NOT NULL default '0', + `clock_animation` varchar(60) NOT NULL default "analogic_1", + `time_format` varchar(60) NOT NULL default "time", + `timezone` varchar(60) NOT NULL default "Europe/Madrid", + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index b21ec23f3d..9574354e2d 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -34,14 +34,39 @@ $hack_metaconsole = ''; if (defined('METACONSOLE')) $hack_metaconsole = '../../'; -$buttons['visual_console_favorite'] = array('active' => false, +$buttons['visual_console'] = array( + 'active' => true, + 'text' => '' . + html_print_image ("images/visual_console.png", true, array ("title" => __('Visual Console List'))) .'' +); + +$buttons['visual_console_favorite'] = array( + 'active' => false, 'text' => '' . - html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .''); + html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .'' +); + +$buttons['visual_console_template'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' +); + +$buttons['visual_console_template_wizard'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' +); if (!defined('METACONSOLE')) { ui_print_page_header( __('Reporting') .' » ' . __('Visual Console'), - "images/op_reporting.png", false, "map_builder", false, $buttons); + "images/op_reporting.png", + false, + "map_builder", + false, + $buttons + ); } $id_layout = (int) get_parameter ('id_layout'); diff --git a/pandora_console/godmode/reporting/visual_console_favorite.php b/pandora_console/godmode/reporting/visual_console_favorite.php index d8f58da452..b753125375 100644 --- a/pandora_console/godmode/reporting/visual_console_favorite.php +++ b/pandora_console/godmode/reporting/visual_console_favorite.php @@ -28,9 +28,29 @@ if (!$vconsoles_read && !$vconsoles_write && !$vconsoles_manage) { exit; } -$buttons['map_builder'] = array('active' => false, - 'text' => '' . - html_print_image ("images/visual_console.png", true, array ("title" => __('Visual Console'))) .''); +$buttons['visual_console'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/visual_console.png", true, array ("title" => __('Visual Console List'))) .'' +); + +$buttons['visual_console_favorite'] = array( + 'active' => true, + 'text' => '' . + html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .'' +); + +$buttons['visual_console_template'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' +); + +$buttons['visual_console_template_wizard'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' +); if (!defined('METACONSOLE')) { ui_print_page_header( diff --git a/pandora_console/godmode/reporting/visual_console_template.php b/pandora_console/godmode/reporting/visual_console_template.php new file mode 100644 index 0000000000..2a0c5952c7 --- /dev/null +++ b/pandora_console/godmode/reporting/visual_console_template.php @@ -0,0 +1,73 @@ + false, + 'text' => '' . + html_print_image ("images/visual_console.png", true, array ("title" => __('Visual Console List'))) .'' +); + +$buttons['visual_console_favorite'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .'' +); + +$buttons['visual_console_template'] = array( + 'active' => true, + 'text' => '' . + html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' +); + +$buttons['visual_console_template_wizard'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' +); + +if (!defined('METACONSOLE')) { + ui_print_page_header( + __('Reporting') .' » ' . __('Visual Console'), + "images/op_reporting.png", + false, + "map_builder", + false, + $buttons + ); +} + + +?> \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_template_wizard.php b/pandora_console/godmode/reporting/visual_console_template_wizard.php new file mode 100644 index 0000000000..bcedbabd0b --- /dev/null +++ b/pandora_console/godmode/reporting/visual_console_template_wizard.php @@ -0,0 +1,71 @@ + false, + 'text' => '' . + html_print_image ("images/visual_console.png", true, array ("title" => __('Visual Console List'))) .'' +); + +$buttons['visual_console_favorite'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .'' +); + +$buttons['visual_console_template'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' +); + +$buttons['visual_console_template_wizard'] = array( + 'active' => true, + 'text' => '' . + html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' +); + +if (!defined('METACONSOLE')) { + ui_print_page_header( + __('Reporting') .' » ' . __('Visual Console'), + "images/op_reporting.png", + false, + "map_builder", + false, + $buttons + ); +} +?> \ No newline at end of file diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 7817f642fb..eceafc2f2b 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3246,4 +3246,54 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( CONSTRAINT `tautoconfig_action_ibfk_1` FOREIGN KEY (`id_autoconfig`) REFERENCES `tautoconfig` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- --------------------------------------------------------------------- +-- Table `tlayout` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlayout_template` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `id_group` INTEGER UNSIGNED NOT NULL, + `background` varchar(200) NOT NULL, + `height` INTEGER UNSIGNED NOT NULL default 0, + `width` INTEGER UNSIGNED NOT NULL default 0, + `background_color` varchar(50) NOT NULL default '#FFF', + `is_favourite` INTEGER UNSIGNED NOT NULL default 0, + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; +-- --------------------------------------------------------------------- +-- Table `tlayout_data` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id_layout_template` INTEGER UNSIGNED NOT NULL default 0, + `pos_x` INTEGER UNSIGNED NOT NULL default 0, + `pos_y` INTEGER UNSIGNED NOT NULL default 0, + `height` INTEGER UNSIGNED NOT NULL default 0, + `width` INTEGER UNSIGNED NOT NULL default 0, + `label` TEXT, + `image` varchar(200) DEFAULT "", + `type` tinyint(1) UNSIGNED NOT NULL default 0, + `period` INTEGER UNSIGNED NOT NULL default 3600, + `module_name` mediumint(8) unsigned NOT NULL default '0', + `agent_name` int(10) unsigned NOT NULL default 0, + `id_layout_linked` INTEGER unsigned NOT NULL default '0', + `parent_item` INTEGER UNSIGNED NOT NULL default 0, + `enable_link` tinyint(1) UNSIGNED NOT NULL default 1, + `id_metaconsole` int(10) NOT NULL default 0, + `id_group` INTEGER UNSIGNED NOT NULL default 0, + `id_custom_graph` INTEGER UNSIGNED NOT NULL default 0, + `border_width` INTEGER UNSIGNED NOT NULL default 0, + `type_graph` varchar(50) NOT NULL default 'area', + `label_position` varchar(50) NOT NULL default 'down', + `border_color` varchar(200) DEFAULT "", + `fill_color` varchar(200) DEFAULT "", + `show_statistics` tinyint(2) NOT NULL default '0', + `id_layout_linked_weight` int(10) NOT NULL default '0', + `element_group` int(10) NOT NULL default '0', + `show_on_top` tinyint(1) NOT NULL default '0', + `clock_animation` varchar(60) NOT NULL default "analogic_1", + `time_format` varchar(60) NOT NULL default "time", + `timezone` varchar(60) NOT NULL default "Europe/Madrid", + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 63052f7458..58f35ab553 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -109,10 +109,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('custom_report_front_logo', 'images/pandora_logo_white.jpg'), ('custom_report_front_header', ''), ('custom_report_front_footer', ''), -('MR', 18), +('MR', 19), ('identification_reminder', 1), ('identification_reminder_timestamp', 0), -('current_package_enterprise', '725'), +('current_package_enterprise', '726'), ('post_process_custom_values', '{"0.00000038580247":"Seconds to months","0.00000165343915":"Seconds to weeks","0.00001157407407":"Seconds to days","0.01666666666667":"Seconds to minutes","0.00000000093132":"Bytes to Gigabytes","0.00000095367432":"Bytes to Megabytes","0.0009765625":"Bytes to Kilobytes","0.00000001653439":"Timeticks to weeks","0.00000011574074":"Timeticks to days"}'), ('custom_docs_logo', 'default_docs.png'), ('custom_support_logo', 'default_support.png'), From 333e5c874c4411ce80cbc1fb709715796f670efa Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 1 Aug 2018 11:52:20 +0200 Subject: [PATCH 02/23] create template visual console --- .../reporting/visual_console_template.php | 64 ++++++++- .../visual_console_template_wizard.php | 134 ++++++++++++++++++ 2 files changed, 196 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_template.php b/pandora_console/godmode/reporting/visual_console_template.php index 2a0c5952c7..074a8648b7 100644 --- a/pandora_console/godmode/reporting/visual_console_template.php +++ b/pandora_console/godmode/reporting/visual_console_template.php @@ -18,8 +18,8 @@ global $config; require_once ($config['homedir'] . '/include/functions_visual_map.php'); // ACL for the general permission -$vconsoles_read = check_acl ($config['id_user'], 0, "VR"); -$vconsoles_write = check_acl ($config['id_user'], 0, "VW"); +$vconsoles_read = check_acl ($config['id_user'], 0, "VR"); +$vconsoles_write = check_acl ($config['id_user'], 0, "VW"); $vconsoles_manage = check_acl ($config['id_user'], 0, "VM"); if (!$vconsoles_read && !$vconsoles_write && !$vconsoles_manage) { @@ -69,5 +69,65 @@ if (!defined('METACONSOLE')) { ); } +$id_layout = (int) get_parameter ('id_layout', 0); +$name_template = (string) get_parameter ('name_template', ''); +$group = (int) get_parameter ('group'); +$action = (string) get_parameter ('action', ''); + +if($action == "create_template"){ + +} + +if($action == "delete_template"){ + +} + +$visual_console_array = visual_map_get_user_layouts($config['id_user'], true); + +if (!check_acl ($config['id_user'], 0, "VR")){ + $return_all_group = false; +} +else{ + $return_all_group = true; +} + +$table = '
'; +$table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; +$table .= "
"; + $table .= "" . __("Create From") . ":"; + $table .= ""; + $table .= html_print_select($visual_console_array, 'id_layout', $id_layout, '', __('none'), 0, true); + $table .= "
"; + $table .= "" . __("Name") . ":"; + $table .= ""; + $table .= html_print_input_text ('name_template', $name_template, '', 50, 255, true); + $table .= "
"; + $table .= '' . __("Group") . ':'; + $table .= ""; + $table .= html_print_select_groups(false, "AR", $return_all_group, "group", $group, 'this.form.submit();', '', 0, true, false, true, '', false); + $table .= "
"; + +if (check_acl ($config['id_user'], 0, "RW")) { + $table .= '
'; + $table .= html_print_input_hidden('action', 'create_template'); + $table .= html_print_submit_button (__('Create template'), 'apply', false, 'class="sub next"', true); + $table .= '
'; +} +$table .= '
'; + +echo ui_toggle($table, __('Create New Template'), '', false, true); + ?> \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_template_wizard.php b/pandora_console/godmode/reporting/visual_console_template_wizard.php index bcedbabd0b..76ac71b03d 100644 --- a/pandora_console/godmode/reporting/visual_console_template_wizard.php +++ b/pandora_console/godmode/reporting/visual_console_template_wizard.php @@ -68,4 +68,138 @@ if (!defined('METACONSOLE')) { $buttons ); } + + +$templates = reporting_enterprise_get_template_reports(array ('order' => 'id_group, name'), array('id_report', 'name'), true); + +$template_select = array(); +if ($templates === false) + $template_select = array(); +else { + $groups = array(__('All') => 0); + foreach ($templates as $template) { + $id_group = $template['id_group']; + $group_name = ''; + + if (!isset($groups[$id_group])) + $groups[$id_group] = groups_get_name($id_group, true); + + if (!empty($groups[$id_group])) + $group_name = $groups[$id_group]; + + $template_select[$template['id_report']] = array('optgroup' => $group_name, 'name' => $template['name']); + } +} + +if (is_metaconsole()) { + $keys_field = 'nombre'; +} +else { + $keys_field = 'id_grupo'; +} + +$attr_available = array('id' => 'image-select_all_available', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); +$attr_apply = array('id' => 'image-select_all_apply', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); + +$table = '
'; +$table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; +$table .= "
"; + $table .= "" . __('Templates') . ":"; + $table .= ""; + $table .= html_print_select($template_select, 'templates', $template_selected, '', __('None'), '0', true, false, true, '', false, 'width:180px;'); + $table .= ""; + $table .= "" . __('Report name') . " " . + ui_print_help_tip(__('Left in blank if you want to use default name: Template name - agents (num agents) - Date'), true) . ":"; + $table .= ""; + $table .= html_print_input_text ('template_report_name', '', '', 80, 150, true); + $table .= "
"; + $table .= '' . __('Filter group') . ':'; + $table .= ""; + $table .= html_print_select_groups( + false, "RR", users_can_manage_group_all("RR"), + 'group', '', '', '', 0, true, false, false, + '', false, false, false, false, $keys_field + ); + $table .= ""; + $table .= "" . __('Target group') . ":"; + $table .= ""; + $table .= html_print_select_groups( + false, "RR", users_can_manage_group_all("RR"), + 'template_report_group', '', '', '', 0, true, + false, false, '', false, false, false, false, + $keys_field + ); + $table .= "
"; + $table .= '' . __('Filter agent') . ':'; + $table .= ""; + $table .= html_print_input_text ('agent_filter', $agent_filter, '', 20, 150, true); + $table .= ""; + $table .= ''; + $table .= ""; + $table .= ''; + $table .= "
"; + $table .= "" . __('Agents available')."  " . + html_print_image ('images/tick.png', true, $attr_available, false, true); + $table .= ""; + $table .= "" . __('Agents to apply')."  " . + html_print_image ('images/tick.png', true, $attr_apply, false, true); + $table .= "
"; + $option_style = array(); + $template_agents_in = array(); + $template_agents_all = array(); + $template_agents_out = array(); + $template_agents_out = array_diff_key($template_agents_all, $template_agents_in); + $template_agents_in_keys = array_keys($template_agents_in); + $template_agents_out_keys = array_keys($template_agents_out); + + $table .= html_print_select ($template_agents_out, 'id_agents[]', 0, false, '', '', true, true, true, '', false, 'width: 100%;', $option_style); + $table .= ""; + $table .= html_print_image ('images/darrowright.png', true, array ('id' => 'right', 'title' => __('Add agents to template'))); + $table .= html_print_image ('images/darrowleft.png', true, array ('id' => 'left', 'title' => __('Undo agents to template'))); + $table .= ""; + $table .= $option_style = array(); + //Agents applied to the template + $table .= html_print_select ($template_agents_in, 'id_agents2[]', 0, false, '', '', true, true, true, '', false, 'width: 100%;', $option_style); + $table .= "
"; + +if (check_acl ($config['id_user'], 0, "RW")) { + $table .= '
'; + $table .= html_print_input_hidden('action', 'create_template'); + $table .= html_print_submit_button (__('Apply template'), 'apply', false, 'class="sub next"', true); + $table .= '
'; +} +$table .= '
'; + +echo $table; + ?> \ No newline at end of file From f10058428f9b4274a54846dc94139d55db5096ec Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 1 Aug 2018 12:22:13 +0200 Subject: [PATCH 03/23] Added backend functions to create vconsole template --- pandora_console/extras/mr/19.sql | 13 +-- .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 14 +-- .../include/functions_visual_map.php | 88 +++++++++++++++++++ pandora_console/pandoradb.sql | 13 +-- 4 files changed, 109 insertions(+), 19 deletions(-) diff --git a/pandora_console/extras/mr/19.sql b/pandora_console/extras/mr/19.sql index 1678c6ec6d..97275c0961 100644 --- a/pandora_console/extras/mr/19.sql +++ b/pandora_console/extras/mr/19.sql @@ -1,7 +1,7 @@ START TRANSACTION; -- --------------------------------------------------------------------- --- Table `tlayout` +-- Table `tlayout_template` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout_template` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, @@ -16,11 +16,11 @@ CREATE TABLE IF NOT EXISTS `tlayout_template` ( ) ENGINE = InnoDB DEFAULT CHARSET=utf8; -- --------------------------------------------------------------------- --- Table `tlayout_data` +-- Table `tlayout_template_data` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_layout_template` INTEGER UNSIGNED NOT NULL default 0, + `id_layout_template` INTEGER UNSIGNED NOT NULL, `pos_x` INTEGER UNSIGNED NOT NULL default 0, `pos_y` INTEGER UNSIGNED NOT NULL default 0, `height` INTEGER UNSIGNED NOT NULL default 0, @@ -29,8 +29,8 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( `image` varchar(200) DEFAULT "", `type` tinyint(1) UNSIGNED NOT NULL default 0, `period` INTEGER UNSIGNED NOT NULL default 3600, - `module_name` mediumint(8) unsigned NOT NULL default '0', - `agent_name` int(10) unsigned NOT NULL default 0, + `module_name` text NOT NULL, + `agent_name` varchar(600) BINARY NOT NULL default '', `id_layout_linked` INTEGER unsigned NOT NULL default '0', `parent_item` INTEGER UNSIGNED NOT NULL default 0, `enable_link` tinyint(1) UNSIGNED NOT NULL default 1, @@ -49,7 +49,8 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( `clock_animation` varchar(60) NOT NULL default "analogic_1", `time_format` varchar(60) NOT NULL default "time", `timezone` varchar(60) NOT NULL default "Europe/Madrid", - PRIMARY KEY(`id`) + PRIMARY KEY(`id`), + FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 8bbde497b6..ecb53717a3 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -1713,7 +1713,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- --------------------------------------------------------------------- --- Table `tlayout` +-- Table `tlayout_template` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout_template` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, @@ -1728,11 +1728,11 @@ CREATE TABLE IF NOT EXISTS `tlayout_template` ( ) ENGINE = InnoDB DEFAULT CHARSET=utf8; -- --------------------------------------------------------------------- --- Table `tlayout_data` +-- Table `tlayout_template_data` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_layout_template` INTEGER UNSIGNED NOT NULL default 0, + `id_layout_template` INTEGER UNSIGNED NOT NULL, `pos_x` INTEGER UNSIGNED NOT NULL default 0, `pos_y` INTEGER UNSIGNED NOT NULL default 0, `height` INTEGER UNSIGNED NOT NULL default 0, @@ -1741,8 +1741,8 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( `image` varchar(200) DEFAULT "", `type` tinyint(1) UNSIGNED NOT NULL default 0, `period` INTEGER UNSIGNED NOT NULL default 3600, - `module_name` mediumint(8) unsigned NOT NULL default '0', - `agent_name` int(10) unsigned NOT NULL default 0, + `module_name` text NOT NULL, + `agent_name` varchar(600) BINARY NOT NULL default '', `id_layout_linked` INTEGER unsigned NOT NULL default '0', `parent_item` INTEGER UNSIGNED NOT NULL default 0, `enable_link` tinyint(1) UNSIGNED NOT NULL default 1, @@ -1761,6 +1761,6 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( `clock_animation` varchar(60) NOT NULL default "analogic_1", `time_format` varchar(60) NOT NULL default "time", `timezone` varchar(60) NOT NULL default "Europe/Madrid", - PRIMARY KEY(`id`) + PRIMARY KEY(`id`), + FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; - diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 9773bd831d..92bb93a735 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4064,6 +4064,94 @@ function visual_map_macro($label,$module){ $label = str_replace('_address_',agents_get_address(modules_get_agentmodule_agent($module)),$label); $label = str_replace('_moduledescription_',modules_get_agentmodule_descripcion($module),$label); return $label; +} + +/** + * Visual console templates + */ + +function visual_map_template_get_template_definition($id_layout_template) { + global $config; + + return db_get_row ('tlayout_template', 'id_layout_template', $id_layout_template); +} + + +function visual_map_template_get_template_elements($id_layout_template) { + global $config; + + return db_get_all_rows_filter('tlayout_template_data', array('id_layout_template' => $id_layout_template)); +} + +function visual_map_get_definition($id_layout) { + global $config; + + return db_get_row ('tlayout', 'id', $id_layout); +} + + +function visual_map_get_elements($id_layout) { + global $config; + + return db_get_all_rows_filter('tlayout_data', array('id_layout' => $id_layout)); +} + +/** + * Creates a new template from existing visual console + * @param int $id_layout existing visual console + * @return true OK, false not OK + */ +function visual_map_create_template($id_layout, $name) { + global $config; + + $layout = visual_map_get_definition($id_layout); + $layout_data = visual_map_get_elements($id_layout); + + // Create new template based on received information + $template_skel = $layout; + + // rm id + unset($template_skel["id"]); + + $template_id = db_process_sql_insert('tlayout_template', $template_skel); + + foreach ($layout_data as $item) { + $data_template_skel = $item; + + // remove unwanted fields + unset($data_template_skel["id"]); + unset($data_template_skel["id_layout"]); + + // Update fields + $data_template_skel["id_layout_template"] = $template_id; + $data_template_skel["module_name"] = modules_get_agentmodule_name($item["id_agente_modulo"]); + $data_template_skel["agent_name"] = agents_get_name($item["id_agent"]); + + // remove unwanted fields + unset($data_template_skel["id_agente_modulo"]); + unset($data_template_skel["id_agent"]); + + $data_template_id = db_process_sql_insert('tlayout_template_data', $data_template_skel); + + } + + + return $template_id; +} + + +/** + * Creates a new visual console based on target id_layout_template + * @param int $id_layout_template target template + * @param string $name name for new visual console + * @param int $id_agent target id_agent to customize template + * @return id_layout OK, null not OK + */ +function visual_map_instanciate_template($id_layout_template, $name, $id_agent) { + + + + } ?> \ No newline at end of file diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index eceafc2f2b..be2783255c 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -3247,7 +3247,7 @@ CREATE TABLE IF NOT EXISTS `tautoconfig_actions` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- --------------------------------------------------------------------- --- Table `tlayout` +-- Table `tlayout_template` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout_template` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, @@ -3262,11 +3262,11 @@ CREATE TABLE IF NOT EXISTS `tlayout_template` ( ) ENGINE = InnoDB DEFAULT CHARSET=utf8; -- --------------------------------------------------------------------- --- Table `tlayout_data` +-- Table `tlayout_template_data` -- --------------------------------------------------------------------- CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - `id_layout_template` INTEGER UNSIGNED NOT NULL default 0, + `id_layout_template` INTEGER UNSIGNED NOT NULL, `pos_x` INTEGER UNSIGNED NOT NULL default 0, `pos_y` INTEGER UNSIGNED NOT NULL default 0, `height` INTEGER UNSIGNED NOT NULL default 0, @@ -3275,8 +3275,8 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( `image` varchar(200) DEFAULT "", `type` tinyint(1) UNSIGNED NOT NULL default 0, `period` INTEGER UNSIGNED NOT NULL default 3600, - `module_name` mediumint(8) unsigned NOT NULL default '0', - `agent_name` int(10) unsigned NOT NULL default 0, + `module_name` text NOT NULL, + `agent_name` varchar(600) BINARY NOT NULL default '', `id_layout_linked` INTEGER unsigned NOT NULL default '0', `parent_item` INTEGER UNSIGNED NOT NULL default 0, `enable_link` tinyint(1) UNSIGNED NOT NULL default 1, @@ -3295,5 +3295,6 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` ( `clock_animation` varchar(60) NOT NULL default "analogic_1", `time_format` varchar(60) NOT NULL default "time", `timezone` varchar(60) NOT NULL default "Europe/Madrid", - PRIMARY KEY(`id`) + PRIMARY KEY(`id`), + FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; From 92911e8fb8473119729842e04f2d61ca46889b7e Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 1 Aug 2018 12:24:27 +0200 Subject: [PATCH 04/23] fixed js wizard template visual console --- .../visual_console_template_wizard.php | 447 +++++++++++++++++- 1 file changed, 446 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/reporting/visual_console_template_wizard.php b/pandora_console/godmode/reporting/visual_console_template_wizard.php index 76ac71b03d..2144ac6406 100644 --- a/pandora_console/godmode/reporting/visual_console_template_wizard.php +++ b/pandora_console/godmode/reporting/visual_console_template_wizard.php @@ -192,6 +192,12 @@ $table .= " \ No newline at end of file +?> + \ No newline at end of file From dd0d9e4fa50acb7d2aa88364c21f89134f2c29ef Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 1 Aug 2018 12:28:17 +0200 Subject: [PATCH 05/23] Fixed vconsole template name & group_id --- pandora_console/include/functions_visual_map.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 92bb93a735..8e692e1574 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4101,7 +4101,7 @@ function visual_map_get_elements($id_layout) { * @param int $id_layout existing visual console * @return true OK, false not OK */ -function visual_map_create_template($id_layout, $name) { +function visual_map_create_template($id_layout, $name, $id_group) { global $config; $layout = visual_map_get_definition($id_layout); @@ -4113,6 +4113,13 @@ function visual_map_create_template($id_layout, $name) { // rm id unset($template_skel["id"]); + // Update fields + if (!empty($name)) { + $template_skel["name"] = $name; + } + + $template_skel["id_group"] = $id_group; + $template_id = db_process_sql_insert('tlayout_template', $template_skel); foreach ($layout_data as $item) { From e2e07f2724723c608382ba6f5bb5cb455399aa6a Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 1 Aug 2018 12:54:08 +0200 Subject: [PATCH 06/23] Added visual_map_get_user_layout_templates --- .../include/functions_visual_map.php | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 8e692e1574..acb1fae4a0 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4161,4 +4161,104 @@ function visual_map_instanciate_template($id_layout_template, $name, $id_agent) } + +/** + * Get a list of layout templates for given user. + * + * @param int User id. + * @param bool Wheter to return all the fields or only the name (to use in + * html_print_select() directly) + * @param array Additional filters to filter the layouts. + * @param bool Whether to return All group or not. + * + * @return array A list of layouts the user can see. + */ +function visual_map_get_user_layout_templates ($id_user = 0, $only_names = false, $filter = false, + $returnAllGroup = true, $favourite = false) { + + if (! is_array ($filter)){ + $filter = array (); + } else { + if(!empty($filter['name'])){ + $where .= "name LIKE '%".io_safe_output($filter['name'])."%'"; + unset($filter['name']); + } + } + + if($favourite){ + if (empty($where)){ + $where = ""; + } + + if ($where != '') { + $where .= ' AND '; + } + + $where .= "is_favourite = 1"; + } + + if ($returnAllGroup) { + $groups = users_get_groups ($id_user, 'VR', true, true); + } else { + + if(!empty($filter['group'])) { + $permissions_group = users_get_groups ($id_user, 'VR', false, true); + if(empty($permissions_group)){ + $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', true, true); + if(empty($groups)) { + $groups = users_get_groups ($id_user, 'VM', true, true); + } + } + + + unset($filter['group']); + } + + if (!empty($groups)) { + if (empty($where)) + $where = ""; + + if ($where != '') { + $where .= ' AND '; + } + $where .= sprintf ('id_group IN (%s)', implode (",", array_keys ($groups))); + } + + $where .= db_format_array_where_clause_sql ($filter); + + if ($where == '') { + $where = array(); + } + + $layouts = db_get_all_rows_filter ('tlayout_template', $where); + if ($layouts == false) + return array (); + + $retval = array (); + foreach ($layouts as $layout) { + if ($only_names) + $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; +} + + ?> \ No newline at end of file From 8e52d9e18411ddc8bc0f9f1c375304027d200aa1 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 1 Aug 2018 13:05:27 +0200 Subject: [PATCH 07/23] added visual_map_instanciate_template --- .../include/functions_visual_map.php | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index acb1fae4a0..d1050fb16c 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4146,7 +4146,6 @@ function visual_map_create_template($id_layout, $name, $id_group) { return $template_id; } - /** * Creates a new visual console based on target id_layout_template * @param int $id_layout_template target template @@ -4155,13 +4154,48 @@ function visual_map_create_template($id_layout, $name, $id_group) { * @return id_layout OK, null not OK */ function visual_map_instanciate_template($id_layout_template, $name, $id_agent) { + global $config; + + $layout_id = false; + if ($id_agent) { + // retrieve template data + $template = visual_map_template_get_template_definition($id_layout_template); + $template_data = visual_map_template_get_template_elements($id_layout_template); + if ($template === false) { + return false; + } + + $template["name"] = $name; + + unset($template["id"]); + + // insert template schema + $layout_id = db_process_sql_insert('tlayout', $template); + + foreach ($template_data as $item) { + + // update fields + $item["id_agente_modulo"] = modules_get_agentmodule_id($agent_id, $item["module_name"]); + $item["id_agent"] = $agent_id; + $item["id_layout"] = $layout_id; + + // remove useless fields + unset($item["id"]); + unset($item["id_layout_template"]); + unset($item["agent_name"]); + unset($item["module_name"]); + + $data_template_id = db_process_sql_insert('tlayout_data', $item); + } + } + + return $id_layout; } - /** * Get a list of layout templates for given user. * From 49aeb349eb31618a65f9128d2fef41a90ae2bc0b Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 1 Aug 2018 13:10:10 +0200 Subject: [PATCH 08/23] create form templates visual console --- .../reporting/visual_console_template.php | 54 +++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_template.php b/pandora_console/godmode/reporting/visual_console_template.php index 074a8648b7..38e18f7d42 100644 --- a/pandora_console/godmode/reporting/visual_console_template.php +++ b/pandora_console/godmode/reporting/visual_console_template.php @@ -71,15 +71,28 @@ if (!defined('METACONSOLE')) { $id_layout = (int) get_parameter ('id_layout', 0); $name_template = (string) get_parameter ('name_template', ''); -$group = (int) get_parameter ('group'); +$group = (int) get_parameter ('group', 0); $action = (string) get_parameter ('action', ''); if($action == "create_template"){ + if(!$id_layout){ + ui_print_error_message(__('visual console has not been selected')); + } + $result = visual_map_create_template($id_layout, $name_template, $group); + + if(!$result){ + ui_print_error_message(__('Error. Error created template')); + } + else{ + ui_print_success_message(__('Successfully created template')); + } } if($action == "delete_template"){ - + if(!$id_layout){ + ui_print_error_message(__('visual console has not been selected')); + } } $visual_console_array = visual_map_get_user_layouts($config['id_user'], true); @@ -121,7 +134,7 @@ $table .= "
"; if (check_acl ($config['id_user'], 0, "RW")) { $table .= '
'; - $table .= html_print_input_hidden('action', 'create_template'); + $table .= html_print_input_hidden('action', 'create_template', true); $table .= html_print_submit_button (__('Create template'), 'apply', false, 'class="sub next"', true); $table .= '
'; } @@ -129,5 +142,40 @@ $table .= ''; echo ui_toggle($table, __('Create New Template'), '', false, true); +$array_template_visual_console = visual_map_get_user_layout_templates($config['id_user']); + +if($array_template_visual_console && is_array($array_template_visual_console)){ + $table = new stdClass(); + $table->width = '100%'; + $table->class = 'databox data'; + $table->data = array (); + $table->head = array (); + $table->head[0] = __('Name'); + $table->head[1] = __('Group'); + $table->head[2] = __('Fovourite'); + $table->head[3] = __('Delete'); + $table->size[3] = "6%"; + + $table->align = array (); + $table->align[0] = 'left'; + $table->align[1] = 'left'; + $table->align[2] = 'left'; + $table->align[3] = 'left'; + + foreach ($array_template_visual_console as $key => $value) { + $data = array (); + $data[0] = $value['name']; + $data[1] = $value['id_group']; + $data[2] = $value['is_favourite']; + $data[3] = ''.html_print_image ("images/cross.png", true).''; + array_push ($table->data, $data); + } + + html_print_table ($table); +} +else{ + ui_print_info_message(__('No data to show')); +} + ?> \ No newline at end of file From 11372e5b946b4c490cf889202b51f966c9c8e4da Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 1 Aug 2018 13:12:10 +0200 Subject: [PATCH 09/23] Delete vconsole template method --- .../include/functions_visual_map.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index d1050fb16c..d319891cba 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4196,6 +4196,23 @@ function visual_map_instanciate_template($id_layout_template, $name, $id_agent) } +/** + * Erases given id_layout_template + * @param int $id_layout_template target template to be deleted + * @return true OK, false ERR + */ +function visual_map_delete_template($id_layout_template) { + global $config; + + if (!$id_layout_template) { + return false; + } + + // tlayout_template_data is erased using foreign key + return db_process_sql_delete('tlayout_template', array('id' => $id_layout_template)); + +} + /** * Get a list of layout templates for given user. * From dc56e0712c5e6e9a463129841c77ba533064cc7b Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 1 Aug 2018 13:20:20 +0200 Subject: [PATCH 10/23] delete template visual console --- .../godmode/reporting/visual_console_template.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_template.php b/pandora_console/godmode/reporting/visual_console_template.php index 38e18f7d42..5a88c43c00 100644 --- a/pandora_console/godmode/reporting/visual_console_template.php +++ b/pandora_console/godmode/reporting/visual_console_template.php @@ -60,7 +60,7 @@ $buttons['visual_console_template_wizard'] = array( if (!defined('METACONSOLE')) { ui_print_page_header( - __('Reporting') .' » ' . __('Visual Console'), + __('Visual Console') .' » ' . __('Template'), "images/op_reporting.png", false, "map_builder", @@ -93,6 +93,15 @@ if($action == "delete_template"){ if(!$id_layout){ ui_print_error_message(__('visual console has not been selected')); } + + $result = visual_map_delete_template($id_layout); + + if(!$result){ + ui_print_error_message(__('Error. Error delete template')); + } + else{ + ui_print_success_message(__('Successfully delete template')); + } } $visual_console_array = visual_map_get_user_layouts($config['id_user'], true); @@ -104,7 +113,7 @@ else{ $return_all_group = true; } -$table = '
'; +$table = ''; $table .= ""; $table .= ""; $table .= "
"; From 62d2b509adac2a873ffb5880281c3b5402dab9da Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 1 Aug 2018 13:21:04 +0200 Subject: [PATCH 11/23] fixed minor error --- .../godmode/reporting/visual_console_template_wizard.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_template_wizard.php b/pandora_console/godmode/reporting/visual_console_template_wizard.php index 2144ac6406..7683c6a447 100644 --- a/pandora_console/godmode/reporting/visual_console_template_wizard.php +++ b/pandora_console/godmode/reporting/visual_console_template_wizard.php @@ -60,7 +60,7 @@ $buttons['visual_console_template_wizard'] = array( if (!defined('METACONSOLE')) { ui_print_page_header( - __('Reporting') .' » ' . __('Visual Console'), + __('Visual Console') .' » ' . __('Wizard'), "images/op_reporting.png", false, "map_builder", @@ -69,7 +69,6 @@ if (!defined('METACONSOLE')) { ); } - $templates = reporting_enterprise_get_template_reports(array ('order' => 'id_group, name'), array('id_report', 'name'), true); $template_select = array(); From 2a7e710b9eab585698e2d20f24398100a94d335c Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 1 Aug 2018 13:51:45 +0200 Subject: [PATCH 12/23] fixed errors in template wizar visual console --- .../visual_console_template_wizard.php | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_template_wizard.php b/pandora_console/godmode/reporting/visual_console_template_wizard.php index 7683c6a447..8de897c6e6 100644 --- a/pandora_console/godmode/reporting/visual_console_template_wizard.php +++ b/pandora_console/godmode/reporting/visual_console_template_wizard.php @@ -69,27 +69,38 @@ if (!defined('METACONSOLE')) { ); } -$templates = reporting_enterprise_get_template_reports(array ('order' => 'id_group, name'), array('id_report', 'name'), true); +$action = get_parameter ('action', ''); -$template_select = array(); -if ($templates === false) - $template_select = array(); -else { - $groups = array(__('All') => 0); - foreach ($templates as $template) { - $id_group = $template['id_group']; - $group_name = ''; +if ($action == 'apply') { + $agents_selected = (array) get_parameter('id_agents2'); + $id_layout_template = get_parameter('templates'); + $name = get_parameter('template_report_name', ''); + $group = get_parameter('template_report_group'); - if (!isset($groups[$id_group])) - $groups[$id_group] = groups_get_name($id_group, true); + if (empty($agents_selected) || empty($id_layout_template)) + $result = false; + else { + if($agents_selected && is_array($agents_selected)){ + foreach ($agents_selected as $key => $value) { + $result = visual_map_instanciate_template( + $id_layout_template, + $name, + $value + ); + } + } + } - if (!empty($groups[$id_group])) - $group_name = $groups[$id_group]; - - $template_select[$template['id_report']] = array('optgroup' => $group_name, 'name' => $template['name']); + if ($result){ + ui_print_success_message(__('Sucessfully applied')); + } + else{ + ui_print_error_message(__('Could not be applied')); } } +$templates = visual_map_get_user_layout_templates($config['id_user'], true); + if (is_metaconsole()) { $keys_field = 'nombre'; } @@ -107,7 +118,7 @@ $table .= ""; $table .= ""; $table .= ""; $table .= "
"; - $table .= html_print_select($template_select, 'templates', $template_selected, '', __('None'), '0', true, false, true, '', false, 'width:180px;'); + $table .= html_print_select($templates, 'templates', $id_layout_template, '', __('None'), '0', true, false, true, '', false, 'width:180px;'); $table .= ""; $table .= "" . __('Report name') . " " . @@ -199,7 +210,7 @@ html_print_input_hidden('agents_out_keys', implode($separator, $template_agents_ if (check_acl ($config['id_user'], 0, "RW")) { $table .= '
'; - $table .= html_print_input_hidden('action', 'create_template'); + $table .= html_print_input_hidden('action', 'apply', true); $table .= html_print_submit_button (__('Apply template'), 'apply', false, 'class="sub next"', true); $table .= '
'; } From 1369333ab86ad5fe47749ba515f740b92d816507 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 1 Aug 2018 13:52:34 +0200 Subject: [PATCH 13/23] Minor fix vconsole template --- pandora_console/include/functions_visual_map.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index d319891cba..b62d3b4dba 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4073,7 +4073,7 @@ function visual_map_macro($label,$module){ function visual_map_template_get_template_definition($id_layout_template) { global $config; - return db_get_row ('tlayout_template', 'id_layout_template', $id_layout_template); + return db_get_row ('tlayout_template', 'id', $id_layout_template); } From e4e97fc8afc4648dc56190e0d05909e22393627f Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 1 Aug 2018 14:52:56 +0200 Subject: [PATCH 14/23] Minor fix vconsole templates --- pandora_console/include/functions_visual_map.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index b62d3b4dba..d5aef69f7e 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4168,7 +4168,11 @@ function visual_map_instanciate_template($id_layout_template, $name, $id_agent) return false; } - $template["name"] = $name; + if (!empty($name)) { + $template["name"] = $name; + } else { + $template["name"] .= io_safe_input(' ') . agents_get_alias($id_agent); + } unset($template["id"]); @@ -4178,8 +4182,8 @@ function visual_map_instanciate_template($id_layout_template, $name, $id_agent) foreach ($template_data as $item) { // update fields - $item["id_agente_modulo"] = modules_get_agentmodule_id($agent_id, $item["module_name"]); - $item["id_agent"] = $agent_id; + $item["id_agente_modulo"] = modules_get_agentmodule_id($item["module_name"], $id_agent); + $item["id_agent"] = $id_agent; $item["id_layout"] = $layout_id; // remove useless fields From a709d0af9fd40b997c7ced99c2429cee3d481bd3 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 1 Aug 2018 14:52:56 +0200 Subject: [PATCH 15/23] Minor fix vconsole templates --- pandora_console/include/functions_visual_map.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index b62d3b4dba..4779f4e477 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4168,7 +4168,11 @@ function visual_map_instanciate_template($id_layout_template, $name, $id_agent) return false; } - $template["name"] = $name; + if (!empty($name)) { + $template["name"] = $name; + } else { + $template["name"] .= io_safe_input(' ') . agents_get_alias($id_agent); + } unset($template["id"]); @@ -4178,8 +4182,8 @@ function visual_map_instanciate_template($id_layout_template, $name, $id_agent) foreach ($template_data as $item) { // update fields - $item["id_agente_modulo"] = modules_get_agentmodule_id($agent_id, $item["module_name"]); - $item["id_agent"] = $agent_id; + $item["id_agente_modulo"] = modules_get_agentmodule_id($item["module_name"], $id_agent); + $item["id_agent"] = $id_agent; $item["id_layout"] = $layout_id; // remove useless fields @@ -4192,7 +4196,7 @@ function visual_map_instanciate_template($id_layout_template, $name, $id_agent) } } - return $id_layout; + return $layout_id; } From 9924c7877a7139524b4a53f5a40dde740128e854 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 1 Aug 2018 15:17:58 +0200 Subject: [PATCH 16/23] Weird fix agentmodule retrieval proc. --- pandora_console/include/functions_visual_map.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 4779f4e477..733c428bb9 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4182,10 +4182,14 @@ function visual_map_instanciate_template($id_layout_template, $name, $id_agent) foreach ($template_data as $item) { // update fields - $item["id_agente_modulo"] = modules_get_agentmodule_id($item["module_name"], $id_agent); + $item["id_agente_modulo"] = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('nombre' => $item["module_name"], 'id_agente' => $id_agent, 'delete_pending' => 0)); $item["id_agent"] = $id_agent; $item["id_layout"] = $layout_id; + // replace macro names + $item["label"] = str_replace('_agentalias_', agents_get_alias($id_agent), $item["label"]); + $item["label"] = str_replace('_agent_', agents_get_name($id_agent), $item["label"]); + // remove useless fields unset($item["id"]); unset($item["id_layout_template"]); From a51851cc79419d52880545880354c4de4e081f64 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 2 Aug 2018 09:35:16 +0200 Subject: [PATCH 17/23] Moved vconsole templates to enterprise --- .../include/functions_visual_map.php | 253 ------------------ 1 file changed, 253 deletions(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 733c428bb9..0ab352842e 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -4066,258 +4066,5 @@ function visual_map_macro($label,$module){ return $label; } -/** - * Visual console templates - */ - -function visual_map_template_get_template_definition($id_layout_template) { - global $config; - - return db_get_row ('tlayout_template', 'id', $id_layout_template); -} - - -function visual_map_template_get_template_elements($id_layout_template) { - global $config; - - return db_get_all_rows_filter('tlayout_template_data', array('id_layout_template' => $id_layout_template)); -} - -function visual_map_get_definition($id_layout) { - global $config; - - return db_get_row ('tlayout', 'id', $id_layout); -} - - -function visual_map_get_elements($id_layout) { - global $config; - - return db_get_all_rows_filter('tlayout_data', array('id_layout' => $id_layout)); -} - -/** - * Creates a new template from existing visual console - * @param int $id_layout existing visual console - * @return true OK, false not OK - */ -function visual_map_create_template($id_layout, $name, $id_group) { - global $config; - - $layout = visual_map_get_definition($id_layout); - $layout_data = visual_map_get_elements($id_layout); - - // Create new template based on received information - $template_skel = $layout; - - // rm id - unset($template_skel["id"]); - - // Update fields - if (!empty($name)) { - $template_skel["name"] = $name; - } - - $template_skel["id_group"] = $id_group; - - $template_id = db_process_sql_insert('tlayout_template', $template_skel); - - foreach ($layout_data as $item) { - $data_template_skel = $item; - - // remove unwanted fields - unset($data_template_skel["id"]); - unset($data_template_skel["id_layout"]); - - // Update fields - $data_template_skel["id_layout_template"] = $template_id; - $data_template_skel["module_name"] = modules_get_agentmodule_name($item["id_agente_modulo"]); - $data_template_skel["agent_name"] = agents_get_name($item["id_agent"]); - - // remove unwanted fields - unset($data_template_skel["id_agente_modulo"]); - unset($data_template_skel["id_agent"]); - - $data_template_id = db_process_sql_insert('tlayout_template_data', $data_template_skel); - - } - - - return $template_id; -} - -/** - * Creates a new visual console based on target id_layout_template - * @param int $id_layout_template target template - * @param string $name name for new visual console - * @param int $id_agent target id_agent to customize template - * @return id_layout OK, null not OK - */ -function visual_map_instanciate_template($id_layout_template, $name, $id_agent) { - global $config; - - $layout_id = false; - - - if ($id_agent) { - // retrieve template data - $template = visual_map_template_get_template_definition($id_layout_template); - $template_data = visual_map_template_get_template_elements($id_layout_template); - - if ($template === false) { - return false; - } - - if (!empty($name)) { - $template["name"] = $name; - } else { - $template["name"] .= io_safe_input(' ') . agents_get_alias($id_agent); - } - - unset($template["id"]); - - // insert template schema - $layout_id = db_process_sql_insert('tlayout', $template); - - foreach ($template_data as $item) { - - // update fields - $item["id_agente_modulo"] = db_get_value_filter('id_agente_modulo', 'tagente_modulo', array('nombre' => $item["module_name"], 'id_agente' => $id_agent, 'delete_pending' => 0)); - $item["id_agent"] = $id_agent; - $item["id_layout"] = $layout_id; - - // replace macro names - $item["label"] = str_replace('_agentalias_', agents_get_alias($id_agent), $item["label"]); - $item["label"] = str_replace('_agent_', agents_get_name($id_agent), $item["label"]); - - // remove useless fields - unset($item["id"]); - unset($item["id_layout_template"]); - unset($item["agent_name"]); - unset($item["module_name"]); - - $data_template_id = db_process_sql_insert('tlayout_data', $item); - } - } - - return $layout_id; - -} - -/** - * Erases given id_layout_template - * @param int $id_layout_template target template to be deleted - * @return true OK, false ERR - */ -function visual_map_delete_template($id_layout_template) { - global $config; - - if (!$id_layout_template) { - return false; - } - - // tlayout_template_data is erased using foreign key - return db_process_sql_delete('tlayout_template', array('id' => $id_layout_template)); - -} - -/** - * Get a list of layout templates for given user. - * - * @param int User id. - * @param bool Wheter to return all the fields or only the name (to use in - * html_print_select() directly) - * @param array Additional filters to filter the layouts. - * @param bool Whether to return All group or not. - * - * @return array A list of layouts the user can see. - */ -function visual_map_get_user_layout_templates ($id_user = 0, $only_names = false, $filter = false, - $returnAllGroup = true, $favourite = false) { - - if (! is_array ($filter)){ - $filter = array (); - } else { - if(!empty($filter['name'])){ - $where .= "name LIKE '%".io_safe_output($filter['name'])."%'"; - unset($filter['name']); - } - } - - if($favourite){ - if (empty($where)){ - $where = ""; - } - - if ($where != '') { - $where .= ' AND '; - } - - $where .= "is_favourite = 1"; - } - - if ($returnAllGroup) { - $groups = users_get_groups ($id_user, 'VR', true, true); - } else { - - if(!empty($filter['group'])) { - $permissions_group = users_get_groups ($id_user, 'VR', false, true); - if(empty($permissions_group)){ - $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', true, true); - if(empty($groups)) { - $groups = users_get_groups ($id_user, 'VM', true, true); - } - } - - - unset($filter['group']); - } - - if (!empty($groups)) { - if (empty($where)) - $where = ""; - - if ($where != '') { - $where .= ' AND '; - } - $where .= sprintf ('id_group IN (%s)', implode (",", array_keys ($groups))); - } - - $where .= db_format_array_where_clause_sql ($filter); - - if ($where == '') { - $where = array(); - } - - $layouts = db_get_all_rows_filter ('tlayout_template', $where); - if ($layouts == false) - return array (); - - $retval = array (); - foreach ($layouts as $layout) { - if ($only_names) - $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; -} - ?> \ No newline at end of file From 4968ff38781d20a485e8f2b0c3db7032eec83dca Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Thu, 2 Aug 2018 10:07:47 +0200 Subject: [PATCH 18/23] Included library from enterprise --- pandora_console/godmode/reporting/visual_console_template.php | 2 ++ .../godmode/reporting/visual_console_template_wizard.php | 1 + 2 files changed, 3 insertions(+) diff --git a/pandora_console/godmode/reporting/visual_console_template.php b/pandora_console/godmode/reporting/visual_console_template.php index 5a88c43c00..58ae80ccce 100644 --- a/pandora_console/godmode/reporting/visual_console_template.php +++ b/pandora_console/godmode/reporting/visual_console_template.php @@ -17,6 +17,8 @@ global $config; require_once ($config['homedir'] . '/include/functions_visual_map.php'); +enterprise_include_once('/include/functions_visual_map.php'); + // ACL for the general permission $vconsoles_read = check_acl ($config['id_user'], 0, "VR"); $vconsoles_write = check_acl ($config['id_user'], 0, "VW"); diff --git a/pandora_console/godmode/reporting/visual_console_template_wizard.php b/pandora_console/godmode/reporting/visual_console_template_wizard.php index 8de897c6e6..d29fa19aa7 100644 --- a/pandora_console/godmode/reporting/visual_console_template_wizard.php +++ b/pandora_console/godmode/reporting/visual_console_template_wizard.php @@ -16,6 +16,7 @@ global $config; require_once ($config['homedir'] . '/include/functions_visual_map.php'); +enterprise_include_once('/include/functions_visual_map.php'); // ACL for the general permission $vconsoles_read = check_acl ($config['id_user'], 0, "VR"); From d5f042939091825cfdcdeb02e7ed7d33809b039b Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 2 Aug 2018 10:57:00 +0200 Subject: [PATCH 19/23] mv enterprise templates visual console --- .../godmode/reporting/map_builder.php | 26 +++++++++-------- .../reporting/visual_console_favorite.php | 28 +++++++++++-------- .../reporting/visual_console_template.php | 26 +++++++++-------- .../visual_console_template_wizard.php | 28 +++++++++++-------- 4 files changed, 62 insertions(+), 46 deletions(-) diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 9574354e2d..7942692421 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -22,6 +22,8 @@ $vconsoles_read = check_acl ($config['id_user'], 0, "VR"); $vconsoles_write = check_acl ($config['id_user'], 0, "VW"); $vconsoles_manage = check_acl ($config['id_user'], 0, "VM"); +$is_enterprise = enterprise_include_once('include/functions_policies.php'); + if (!$vconsoles_read && !$vconsoles_write && !$vconsoles_manage) { db_pandora_audit("ACL Violation", "Trying to access map builder"); @@ -46,17 +48,19 @@ $buttons['visual_console_favorite'] = array( html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .'' ); -$buttons['visual_console_template'] = array( - 'active' => false, - 'text' => '' . - html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' -); +if($is_enterprise){ + $buttons['visual_console_template'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' + ); -$buttons['visual_console_template_wizard'] = array( - 'active' => false, - 'text' => '' . - html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' -); + $buttons['visual_console_template_wizard'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' + ); +} if (!defined('METACONSOLE')) { ui_print_page_header( @@ -87,7 +91,7 @@ if ($delete_layout || $copy_layout) { require ("general/noaccess.php"); exit; } - + $group_id = db_get_value("id_group", "tlayout", "id", $id_layout); if ($group_id === false) { db_pandora_audit("ACL Violation", diff --git a/pandora_console/godmode/reporting/visual_console_favorite.php b/pandora_console/godmode/reporting/visual_console_favorite.php index b753125375..b090f9dde5 100644 --- a/pandora_console/godmode/reporting/visual_console_favorite.php +++ b/pandora_console/godmode/reporting/visual_console_favorite.php @@ -17,10 +17,12 @@ global $config; require_once ($config['homedir'] . '/include/functions_visual_map.php'); // ACL for the general permission -$vconsoles_read = check_acl ($config['id_user'], 0, "VR"); -$vconsoles_write = check_acl ($config['id_user'], 0, "VW"); +$vconsoles_read = check_acl ($config['id_user'], 0, "VR"); +$vconsoles_write = check_acl ($config['id_user'], 0, "VW"); $vconsoles_manage = check_acl ($config['id_user'], 0, "VM"); +$is_enterprise = enterprise_include_once('include/functions_policies.php'); + if (!$vconsoles_read && !$vconsoles_write && !$vconsoles_manage) { db_pandora_audit("ACL Violation", "Trying to access map builder"); @@ -40,17 +42,19 @@ $buttons['visual_console_favorite'] = array( html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .'' ); -$buttons['visual_console_template'] = array( - 'active' => false, - 'text' => '' . - html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' -); +if($is_enterprise){ + $buttons['visual_console_template'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' + ); -$buttons['visual_console_template_wizard'] = array( - 'active' => false, - 'text' => '' . - html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' -); + $buttons['visual_console_template_wizard'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' + ); +} if (!defined('METACONSOLE')) { ui_print_page_header( diff --git a/pandora_console/godmode/reporting/visual_console_template.php b/pandora_console/godmode/reporting/visual_console_template.php index 58ae80ccce..77f2693bf4 100644 --- a/pandora_console/godmode/reporting/visual_console_template.php +++ b/pandora_console/godmode/reporting/visual_console_template.php @@ -24,6 +24,8 @@ $vconsoles_read = check_acl ($config['id_user'], 0, "VR"); $vconsoles_write = check_acl ($config['id_user'], 0, "VW"); $vconsoles_manage = check_acl ($config['id_user'], 0, "VM"); +$is_enterprise = enterprise_include_once('include/functions_policies.php'); + if (!$vconsoles_read && !$vconsoles_write && !$vconsoles_manage) { db_pandora_audit("ACL Violation", "Trying to access map builder"); @@ -48,17 +50,19 @@ $buttons['visual_console_favorite'] = array( html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .'' ); -$buttons['visual_console_template'] = array( - 'active' => true, - 'text' => '' . - html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' -); +if($is_enterprise){ + $buttons['visual_console_template'] = array( + 'active' => true, + 'text' => '' . + html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' + ); -$buttons['visual_console_template_wizard'] = array( - 'active' => false, - 'text' => '' . - html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' -); + $buttons['visual_console_template_wizard'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' + ); +} if (!defined('METACONSOLE')) { ui_print_page_header( @@ -178,7 +182,7 @@ if($array_template_visual_console && is_array($array_template_visual_console)){ $data[0] = $value['name']; $data[1] = $value['id_group']; $data[2] = $value['is_favourite']; - $data[3] = ''.html_print_image ("images/cross.png", true).''; + $data[3] = ''.html_print_image ("images/cross.png", true).''; array_push ($table->data, $data); } diff --git a/pandora_console/godmode/reporting/visual_console_template_wizard.php b/pandora_console/godmode/reporting/visual_console_template_wizard.php index d29fa19aa7..6351f4525d 100644 --- a/pandora_console/godmode/reporting/visual_console_template_wizard.php +++ b/pandora_console/godmode/reporting/visual_console_template_wizard.php @@ -19,10 +19,12 @@ require_once ($config['homedir'] . '/include/functions_visual_map.php'); enterprise_include_once('/include/functions_visual_map.php'); // ACL for the general permission -$vconsoles_read = check_acl ($config['id_user'], 0, "VR"); -$vconsoles_write = check_acl ($config['id_user'], 0, "VW"); +$vconsoles_read = check_acl ($config['id_user'], 0, "VR"); +$vconsoles_write = check_acl ($config['id_user'], 0, "VW"); $vconsoles_manage = check_acl ($config['id_user'], 0, "VM"); +$is_enterprise = enterprise_include_once('include/functions_policies.php'); + if (!$vconsoles_read && !$vconsoles_write && !$vconsoles_manage) { db_pandora_audit("ACL Violation", "Trying to access map builder"); @@ -47,17 +49,19 @@ $buttons['visual_console_favorite'] = array( html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .'' ); -$buttons['visual_console_template'] = array( - 'active' => false, - 'text' => '' . - html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' -); +if($is_enterprise){ + $buttons['visual_console_template'] = array( + 'active' => false, + 'text' => '' . + html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' + ); -$buttons['visual_console_template_wizard'] = array( - 'active' => true, - 'text' => '' . - html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' -); + $buttons['visual_console_template_wizard'] = array( + 'active' => true, + 'text' => '' . + html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' + ); +} if (!defined('METACONSOLE')) { ui_print_page_header( From ef2ff495046c135045d9eb0dbe4288ac8435f42f Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 2 Aug 2018 11:03:13 +0200 Subject: [PATCH 20/23] mv enterprise visual console template --- .../reporting/visual_console_template.php | 196 ------ .../visual_console_template_wizard.php | 665 ------------------ 2 files changed, 861 deletions(-) delete mode 100644 pandora_console/godmode/reporting/visual_console_template.php delete mode 100644 pandora_console/godmode/reporting/visual_console_template_wizard.php diff --git a/pandora_console/godmode/reporting/visual_console_template.php b/pandora_console/godmode/reporting/visual_console_template.php deleted file mode 100644 index 77f2693bf4..0000000000 --- a/pandora_console/godmode/reporting/visual_console_template.php +++ /dev/null @@ -1,196 +0,0 @@ - false, - 'text' => '' . - html_print_image ("images/visual_console.png", true, array ("title" => __('Visual Console List'))) .'' -); - -$buttons['visual_console_favorite'] = array( - 'active' => false, - 'text' => '' . - html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .'' -); - -if($is_enterprise){ - $buttons['visual_console_template'] = array( - 'active' => true, - 'text' => '' . - html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' - ); - - $buttons['visual_console_template_wizard'] = array( - 'active' => false, - 'text' => '' . - html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' - ); -} - -if (!defined('METACONSOLE')) { - ui_print_page_header( - __('Visual Console') .' » ' . __('Template'), - "images/op_reporting.png", - false, - "map_builder", - false, - $buttons - ); -} - -$id_layout = (int) get_parameter ('id_layout', 0); -$name_template = (string) get_parameter ('name_template', ''); -$group = (int) get_parameter ('group', 0); -$action = (string) get_parameter ('action', ''); - -if($action == "create_template"){ - if(!$id_layout){ - ui_print_error_message(__('visual console has not been selected')); - } - - $result = visual_map_create_template($id_layout, $name_template, $group); - - if(!$result){ - ui_print_error_message(__('Error. Error created template')); - } - else{ - ui_print_success_message(__('Successfully created template')); - } -} - -if($action == "delete_template"){ - if(!$id_layout){ - ui_print_error_message(__('visual console has not been selected')); - } - - $result = visual_map_delete_template($id_layout); - - if(!$result){ - ui_print_error_message(__('Error. Error delete template')); - } - else{ - ui_print_success_message(__('Successfully delete template')); - } -} - -$visual_console_array = visual_map_get_user_layouts($config['id_user'], true); - -if (!check_acl ($config['id_user'], 0, "VR")){ - $return_all_group = false; -} -else{ - $return_all_group = true; -} - -$table = ''; -$table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; -$table .= "
"; - $table .= "" . __("Create From") . ":"; - $table .= ""; - $table .= html_print_select($visual_console_array, 'id_layout', $id_layout, '', __('none'), 0, true); - $table .= "
"; - $table .= "" . __("Name") . ":"; - $table .= ""; - $table .= html_print_input_text ('name_template', $name_template, '', 50, 255, true); - $table .= "
"; - $table .= '' . __("Group") . ':'; - $table .= ""; - $table .= html_print_select_groups(false, "AR", $return_all_group, "group", $group, 'this.form.submit();', '', 0, true, false, true, '', false); - $table .= "
"; - -if (check_acl ($config['id_user'], 0, "RW")) { - $table .= '
'; - $table .= html_print_input_hidden('action', 'create_template', true); - $table .= html_print_submit_button (__('Create template'), 'apply', false, 'class="sub next"', true); - $table .= '
'; -} -$table .= ''; - -echo ui_toggle($table, __('Create New Template'), '', false, true); - -$array_template_visual_console = visual_map_get_user_layout_templates($config['id_user']); - -if($array_template_visual_console && is_array($array_template_visual_console)){ - $table = new stdClass(); - $table->width = '100%'; - $table->class = 'databox data'; - $table->data = array (); - $table->head = array (); - $table->head[0] = __('Name'); - $table->head[1] = __('Group'); - $table->head[2] = __('Fovourite'); - $table->head[3] = __('Delete'); - $table->size[3] = "6%"; - - $table->align = array (); - $table->align[0] = 'left'; - $table->align[1] = 'left'; - $table->align[2] = 'left'; - $table->align[3] = 'left'; - - foreach ($array_template_visual_console as $key => $value) { - $data = array (); - $data[0] = $value['name']; - $data[1] = $value['id_group']; - $data[2] = $value['is_favourite']; - $data[3] = ''.html_print_image ("images/cross.png", true).''; - array_push ($table->data, $data); - } - - html_print_table ($table); -} -else{ - ui_print_info_message(__('No data to show')); -} - - -?> \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_template_wizard.php b/pandora_console/godmode/reporting/visual_console_template_wizard.php deleted file mode 100644 index 6351f4525d..0000000000 --- a/pandora_console/godmode/reporting/visual_console_template_wizard.php +++ /dev/null @@ -1,665 +0,0 @@ - false, - 'text' => '' . - html_print_image ("images/visual_console.png", true, array ("title" => __('Visual Console List'))) .'' -); - -$buttons['visual_console_favorite'] = array( - 'active' => false, - 'text' => '' . - html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .'' -); - -if($is_enterprise){ - $buttons['visual_console_template'] = array( - 'active' => false, - 'text' => '' . - html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' - ); - - $buttons['visual_console_template_wizard'] = array( - 'active' => true, - 'text' => '' . - html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' - ); -} - -if (!defined('METACONSOLE')) { - ui_print_page_header( - __('Visual Console') .' » ' . __('Wizard'), - "images/op_reporting.png", - false, - "map_builder", - false, - $buttons - ); -} - -$action = get_parameter ('action', ''); - -if ($action == 'apply') { - $agents_selected = (array) get_parameter('id_agents2'); - $id_layout_template = get_parameter('templates'); - $name = get_parameter('template_report_name', ''); - $group = get_parameter('template_report_group'); - - if (empty($agents_selected) || empty($id_layout_template)) - $result = false; - else { - if($agents_selected && is_array($agents_selected)){ - foreach ($agents_selected as $key => $value) { - $result = visual_map_instanciate_template( - $id_layout_template, - $name, - $value - ); - } - } - } - - if ($result){ - ui_print_success_message(__('Sucessfully applied')); - } - else{ - ui_print_error_message(__('Could not be applied')); - } -} - -$templates = visual_map_get_user_layout_templates($config['id_user'], true); - -if (is_metaconsole()) { - $keys_field = 'nombre'; -} -else { - $keys_field = 'id_grupo'; -} - -$attr_available = array('id' => 'image-select_all_available', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); -$attr_apply = array('id' => 'image-select_all_apply', 'title' => __('Select all'), 'style' => 'cursor: pointer;'); - -$table = '
'; -$table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; -$table .= "
"; - $table .= "" . __('Templates') . ":"; - $table .= ""; - $table .= html_print_select($templates, 'templates', $id_layout_template, '', __('None'), '0', true, false, true, '', false, 'width:180px;'); - $table .= ""; - $table .= "" . __('Report name') . " " . - ui_print_help_tip(__('Left in blank if you want to use default name: Template name - agents (num agents) - Date'), true) . ":"; - $table .= ""; - $table .= html_print_input_text ('template_report_name', '', '', 80, 150, true); - $table .= "
"; - $table .= '' . __('Filter group') . ':'; - $table .= ""; - $table .= html_print_select_groups( - false, "RR", users_can_manage_group_all("RR"), - 'group', '', '', '', 0, true, false, false, - '', false, false, false, false, $keys_field - ); - $table .= ""; - $table .= "" . __('Target group') . ":"; - $table .= ""; - $table .= html_print_select_groups( - false, "RR", users_can_manage_group_all("RR"), - 'template_report_group', '', '', '', 0, true, - false, false, '', false, false, false, false, - $keys_field - ); - $table .= "
"; - $table .= '' . __('Filter agent') . ':'; - $table .= ""; - $table .= html_print_input_text ('agent_filter', $agent_filter, '', 20, 150, true); - $table .= ""; - $table .= ''; - $table .= ""; - $table .= ''; - $table .= "
"; - $table .= "" . __('Agents available')."  " . - html_print_image ('images/tick.png', true, $attr_available, false, true); - $table .= ""; - $table .= "" . __('Agents to apply')."  " . - html_print_image ('images/tick.png', true, $attr_apply, false, true); - $table .= "
"; - $option_style = array(); - $template_agents_in = array(); - $template_agents_all = array(); - $template_agents_out = array(); - $template_agents_out = array_diff_key($template_agents_all, $template_agents_in); - $template_agents_in_keys = array_keys($template_agents_in); - $template_agents_out_keys = array_keys($template_agents_out); - - $table .= html_print_select ($template_agents_out, 'id_agents[]', 0, false, '', '', true, true, true, '', false, 'width: 100%;', $option_style); - $table .= ""; - $table .= html_print_image ('images/darrowright.png', true, array ('id' => 'right', 'title' => __('Add agents to template'))); - $table .= html_print_image ('images/darrowleft.png', true, array ('id' => 'left', 'title' => __('Undo agents to template'))); - $table .= ""; - $table .= $option_style = array(); - //Agents applied to the template - $table .= html_print_select ($template_agents_in, 'id_agents2[]', 0, false, '', '', true, true, true, '', false, 'width: 100%;', $option_style); - $table .= "
"; - -html_print_input_hidden('separator', $separator); -html_print_input_hidden('agents_in', implode($separator, $template_agents_in)); -html_print_input_hidden('agents_in_keys', implode($separator, $template_agents_in_keys)); -html_print_input_hidden('agents_out', implode($separator, $template_agents_out)); -html_print_input_hidden('agents_out_keys', implode($separator, $template_agents_out_keys)); - -if (check_acl ($config['id_user'], 0, "RW")) { - $table .= '
'; - $table .= html_print_input_hidden('action', 'apply', true); - $table .= html_print_submit_button (__('Apply template'), 'apply', false, 'class="sub next"', true); - $table .= '
'; -} -$table .= '
'; - -echo $table; - -?> - \ No newline at end of file From 9d5004efbf402b3489463a3440de103170d31c13 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 2 Aug 2018 11:07:22 +0200 Subject: [PATCH 21/23] fixed minor error --- pandora_console/godmode/reporting/map_builder.php | 4 ++-- pandora_console/godmode/reporting/visual_console_favorite.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 7942692421..5e9a64f75e 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -51,13 +51,13 @@ $buttons['visual_console_favorite'] = array( if($is_enterprise){ $buttons['visual_console_template'] = array( 'active' => false, - 'text' => '' . + 'text' => '' . html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' ); $buttons['visual_console_template_wizard'] = array( 'active' => false, - 'text' => '' . + 'text' => '' . html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' ); } diff --git a/pandora_console/godmode/reporting/visual_console_favorite.php b/pandora_console/godmode/reporting/visual_console_favorite.php index b090f9dde5..f447f76585 100644 --- a/pandora_console/godmode/reporting/visual_console_favorite.php +++ b/pandora_console/godmode/reporting/visual_console_favorite.php @@ -45,13 +45,13 @@ $buttons['visual_console_favorite'] = array( if($is_enterprise){ $buttons['visual_console_template'] = array( 'active' => false, - 'text' => '' . + 'text' => '' . html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' ); $buttons['visual_console_template_wizard'] = array( 'active' => false, - 'text' => '' . + 'text' => '' . html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' ); } From c3413bbf62279590b8f0fc54432c42c761bd0415 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 2 Aug 2018 13:06:43 +0200 Subject: [PATCH 22/23] fixed minor error --- .../reporting/visual_console_favorite.php | 52 ++++++++++++++----- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/pandora_console/godmode/reporting/visual_console_favorite.php b/pandora_console/godmode/reporting/visual_console_favorite.php index f447f76585..b04d06b028 100644 --- a/pandora_console/godmode/reporting/visual_console_favorite.php +++ b/pandora_console/godmode/reporting/visual_console_favorite.php @@ -22,6 +22,7 @@ $vconsoles_write = check_acl ($config['id_user'], 0, "VW"); $vconsoles_manage = check_acl ($config['id_user'], 0, "VM"); $is_enterprise = enterprise_include_once('include/functions_policies.php'); +$is_metaconsole = is_metaconsole(); if (!$vconsoles_read && !$vconsoles_write && !$vconsoles_manage) { db_pandora_audit("ACL Violation", @@ -30,37 +31,55 @@ if (!$vconsoles_read && !$vconsoles_write && !$vconsoles_manage) { exit; } +if(!$is_metaconsole){ + $url_visual_console = 'index.php?sec=network&sec2=godmode/reporting/map_builder'; + $url_visual_console_favorite = 'index.php?sec=network&sec2=godmode/reporting/visual_console_favorite'; + $url_visual_console_template = 'index.php?sec=network&sec2=enterprise/godmode/reporting/visual_console_template'; + $url_visual_console_template_wizard = 'index.php?sec=network&sec2=enterprise/godmode/reporting/visual_console_template_wizard'; +} +else{ + $url_visual_console = 'index.php?sec=screen&sec2=screens/screens&action=visualmap'; + $url_visual_console_favorite = 'index.php?sec=screen&sec2=screens/screens&action=visualmap_favorite'; + $url_visual_console_template = 'index.php?sec=screen&sec2=screens/screens&action=visualmap_template'; + $url_visual_console_template_wizard = 'index.php?sec=screen&sec2=screens/screens&action=visualmap_wizard'; +} + $buttons['visual_console'] = array( 'active' => false, - 'text' => '' . + 'text' => '' . html_print_image ("images/visual_console.png", true, array ("title" => __('Visual Console List'))) .'' ); $buttons['visual_console_favorite'] = array( 'active' => true, - 'text' => '' . + 'text' => '' . html_print_image ("images/list.png", true, array ("title" => __('Visual Favourite Console'))) .'' ); if($is_enterprise){ $buttons['visual_console_template'] = array( 'active' => false, - 'text' => '' . + 'text' => '' . html_print_image ("images/templates.png", true, array ("title" => __('Visual Console Template'))) .'' ); $buttons['visual_console_template_wizard'] = array( 'active' => false, - 'text' => '' . + 'text' => '' . html_print_image ("images/wand.png", true, array ("title" => __('Visual Console Template Wizard'))) .'' ); } -if (!defined('METACONSOLE')) { +if (!$is_metaconsole) { ui_print_page_header( __('Reporting') .' » ' . __('Visual Favourite Console'), "images/op_reporting.png", false, "map_builder", false, $buttons); } +else{ + ui_meta_print_header( + __('Visual console') . " » " . $visualConsoleName, "", + $buttons); +} $search = (string) get_parameter("search",""); $ag_group = (int) get_parameter("ag_group",0); @@ -72,7 +91,7 @@ if(!is_metaconsole()){ action='index.php?sec=network&sec2=godmode/reporting/visual_console_favorite'>"; } else { echo "
"; + action='index.php?sec=screen&sec2=screens/screens&action=visualmap_favorite'>"; } echo "
  • "; echo "
    • "; @@ -85,14 +104,14 @@ if(!is_metaconsole()){ $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, + 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 "
"; echo "
"; @@ -127,12 +146,17 @@ echo "
"; } else{ echo "