From a6c62373816a03ac6ee6a6e94a313346649e9152 Mon Sep 17 00:00:00 2001 From: vgilc Date: Fri, 24 Feb 2012 13:29:22 +0000 Subject: [PATCH] 2012-02-24 Vanessa Gil * include/functions_reporting.php godmode/reporting/graphs.php: Added template graph tabs to graph builder view. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5644 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 + .../reporting/graph_template_editor.php | 225 --------- .../reporting/graph_template_item_editor.php | 236 ---------- .../godmode/reporting/graph_template_list.php | 166 ------- .../reporting/graph_template_wizard.php | 431 ------------------ pandora_console/godmode/reporting/graphs.php | 34 +- .../include/functions_reporting.php | 80 +--- 7 files changed, 34 insertions(+), 1144 deletions(-) delete mode 100644 pandora_console/godmode/reporting/graph_template_editor.php delete mode 100644 pandora_console/godmode/reporting/graph_template_item_editor.php delete mode 100644 pandora_console/godmode/reporting/graph_template_list.php delete mode 100644 pandora_console/godmode/reporting/graph_template_wizard.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index bdd64dda64..d350084f2c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2012-02-24 Vanessa Gil + + * include/functions_reporting.php + godmode/reporting/graphs.php: Added template graph tabs to graph + builder view. + 2012-02-24 Junichi Satoh include/help/ja/help_ff_threshold.php: Small warning about do not diff --git a/pandora_console/godmode/reporting/graph_template_editor.php b/pandora_console/godmode/reporting/graph_template_editor.php deleted file mode 100644 index c1380de357..0000000000 --- a/pandora_console/godmode/reporting/graph_template_editor.php +++ /dev/null @@ -1,225 +0,0 @@ - $name, - 'id_user' => $config['id_user'], - 'period' => $period, - 'width' => $width, - 'height' => $height, - 'id_group' => $id_group, - 'stacked' => $stacked, - 'private' => 0, - 'events' => $events, - 'description' => $description - ); - $id_template = db_process_sql_insert('tgraph_template', $values); -} - -$buttons['graph_list'] = array('active' => false, - 'text' => '' . - html_print_image("images/god6.png", true, array ("title" => __('Graph list'))) .''); - -$buttons['wizard'] = array('active' => false, - 'text' => '' . - html_print_image("images/wand.png", true, array ("title" => __('Wizard'))) .''); - -$buttons['template'] = array('active' => false, - 'text' => '' . - html_print_image("images/paste_plain.png", true, array ("title" => __('Templates'))) .''); - -$buttons['template_editor'] = array('active' => true, - 'text' => '' . - html_print_image("images/config.png", true, array ("title" => __('Item editor'))) .''); - -// Header -ui_print_page_header (__('Graph template editor'), "", false, "", true, $buttons); - -if ($create) { - if ($id_template === false) { - ui_print_error_message ('Error creating template'); - } else { - ui_print_success_message ('Template created successfully'); - } -} - -if ($id_template) { - $template_data = db_get_row_sql("SELECT * FROM tgraph_template WHERE id_graph_template = " . $id_template); - $stacked = $template_data['stacked']; - $events = $template_data['events']; - $period = $template_data['period']; - $name = $template_data['name']; - $description = $template_data['description']; - $id_group = $template_data['id_group']; - $width = $template_data['width']; - $height = $template_data['height']; -} else { - $id_agent = 0; - $id_module = 0; - $id_group = 0; - $name = ""; - $description = ""; - $width = 550; - $height = 210; - $period = 86400; - $events = 0; - $factor = 1; - $stacked = 0; -} - -if ($update) { - $stacked = get_parameter('stacked'); - $events = get_parameter('events'); - $period = get_parameter('period'); - $name = get_parameter('name'); - $description = get_parameter('description'); - $id_group = get_parameter('id_group'); - $width = get_parameter('width'); - $height = get_parameter('height'); - - if ($name == '') { - ui_print_error_message (__('Not updated. Blank name')); - } else { - $result = db_process_sql_update ('tgraph_template', - array ( - 'name' => $name, - 'period' => $period, - 'width' => $width, - 'height' => $height, - 'id_group' => $id_group, - 'stacked' => $stacked, - 'events' => $events, - 'description' => $description - ), - array ('id_graph_template' => $id_template)); - ui_print_result_message ($result, __('Template updated successfully'), __('Error updating template')); - } -} - -// ----------------------- -// CREATE/EDIT GRAPH TEMPLATE FORM -// ----------------------- - -echo ""; - -if ($id_template) - echo ""; -else - echo ""; - -echo ""; -echo ""; -echo ""; -echo ""; - -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; -echo ""; - -$periods = array(3600 => "1 ".__('hour'), 7200 => "2 ".__('hours'), 10800 => "3 ".__('hours'), - 21600 => "6 ".__('hours'), 43200 => "12 ".__('hours'), 86400 => "1 ".__('day'), - 172800 => "2 ".__('days'), 345600 => "4 ".__('days'), 604800 => __('Last week'), - 1296000 => "15 ".__('days'), 2592000 => __('Last month'), 5184000 => "2 ".__('months'), - 15552000 => "6 ".__('months'), 31104000 => __('1 year'), 31104000 => __('1 year')); - -echo ""; -echo ""; -echo ""; -echo ""; - -echo ""; -echo ""; -echo ""; - -echo ""; - -echo ""; -echo "
".__('Name').""; - -$own_info = get_user_info ($config['id_user']); -if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) - $return_all_groups = true; -else - $return_all_groups = false; - -echo "".__('Group')."" . - html_print_select_groups($config['id_user'], "AR", $return_all_groups, 'graph_id_group', $id_group, '', '', '', true) . - "
".__('Description').""; -echo "
"; -echo "".__('Width').""; -echo ""; -echo "".__('Height').""; -echo "
"; -echo "".__('Period').""; -html_print_select ($periods, 'period', $period); -echo ""; -echo "".__('Stacked').""; - -include_once($config["homedir"] . "/include/functions_graph.php"); - -$stackeds = array( - GRAPH_AREA => __('Area'), - GRAPH_STACKED_AREA => __('Stacked area'), - GRAPH_LINE => __('Line'), - GRAPH_STACKED_LINE => __('Stacked line')); -html_print_select ($stackeds, 'stacked', $stacked); -echo "
"; -echo "".__('View events').""; -html_print_checkbox('events', 1, $events); -echo "
"; -if ($id_template) { - echo ""; -} -else { - echo ""; -} -echo "
"; -echo ""; diff --git a/pandora_console/godmode/reporting/graph_template_item_editor.php b/pandora_console/godmode/reporting/graph_template_item_editor.php deleted file mode 100644 index e0434d9077..0000000000 --- a/pandora_console/godmode/reporting/graph_template_item_editor.php +++ /dev/null @@ -1,236 +0,0 @@ - false, - 'text' => '' . - html_print_image("images/god6.png", true, array ("title" => __('Graph list'))) .''); - -$buttons['wizard'] = array('active' => false, - 'text' => '' . - html_print_image("images/wand.png", true, array ("title" => __('Wizard'))) .''); - -$buttons['template'] = array('active' => false, - 'text' => '' . - html_print_image("images/paste_plain.png", true, array ("title" => __('Templates'))) .''); - -$buttons['template_editor'] = array('active' => true, - 'text' => '' . - html_print_image("images/config.png", true, array ("title" => __('Template editor'))) .''); - -// Header -ui_print_page_header (__('Graph template editor'), "", false, "", true, $buttons); - -if ($create) { - if (!$id_template) { - ui_print_error_message ('Not created. Blank template.'); - } else { - $agent = get_parameter('agent', ''); - $module = get_parameter('module', ''); - $match = get_parameter('match', 0); - $weight = get_parameter('weight', 1); - - if ($module != '') { - $values = array ( - 'id_template' => $id_template, - 'agent' => $agent, - 'module' => $module, - 'exact_match' => $match, - 'weight' => $weight - ); - $id_gs_template = db_process_sql_insert('tgraph_source_template', $values); - if ($id_gs_template === false) { - ui_print_error_message ('Error creating template'); - } else { - ui_print_success_message ('Template created successfully'); - } - } else { - ui_print_error_message ('Not created. Blank module'); - } - } -} - -if ($delete) { - $id_gs_template = get_parameter('id_gs_template'); - $id_template = get_parameter('id_template'); - - $result = db_process_sql_delete ('tgraph_source_template', - array ('id_gs_template' => $id_gs_template)); - - if ($result !== false) { - $result = true; - } else { - $result = false; - } - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Not deleted. Error deleting data')); -} - -if ($multiple_delete) { - $ids = (array)get_parameter('delete_multiple', array()); - - db_process_sql_begin(); - - foreach ($ids as $id) { - $result = db_process_sql_delete ('tgraph_source_template', - array ('id_gs_template' => $id)); - - if ($result === false) { - db_process_sql_rollback(); - break; - } - } - - if ($result !== false) { - db_process_sql_commit(); - } - - if ($result !== false) $result = true; - else $result = false; - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Not deleted. Error deleting data')); -} - -if ($change_weight) { - $new_weight = get_parameter('new_weight'); - $id_gs_template = get_parameter ('id_gs_template'); - $value = array ( - 'weight' => $new_weight - ); - $result = db_process_sql_update('tgraph_source_template', $value, array('id_gs_template'=>$id_gs_template)); -} - -if ($id_template) { - $sql = "SELECT * FROM tgraph_source_template where id_template=$id_template"; - $templates = db_get_all_rows_sql($sql); - if ($templates != false) { - $table_aux->width = '98%'; - - $table_aux->size = array(); - //$table_aux->size[0] = '40%'; - $table_aux->size[1] = '40%'; - $table_aux->size[2] = '30%'; - $table_aux->size[3] = '20%'; - $table_aux->size[4] = '60px'; - - //$table_aux->head[0] = __('Agent'); - //$table_aux->align[0] = 'center'; - $table_aux->head[1] = __('Module'); - $table_aux->align[1] = 'center'; - $table_aux->head[2] = __('Weight'); - $table_aux->align[2] = 'center'; - $table_aux->head[3] = __('Exact match'); - $table_aux->align[3] = 'center'; - $table_aux->head[4] = __('Action') . html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); - $table_aux->align[4] = 'center'; - - $table_aux->data = array(); - - foreach ($templates as $template) { - $data = array(); - - //$data[0] = $template['agent']; - $data[1] = $template['module']; - - $dec_weight = $template['weight']-0.125; - $inc_weight = $template['weight']+0.125; - $data[2] = "". - html_print_image('images/down.png', true, array ('title' => __('Decrease Weight')))."". - $template['weight']. - "". - html_print_image('images/up.png', true, array ('title' => __('Increase Weight'))).""; - - if ($template['exact_match']) - $data[3] = __('Yes'); - else - $data[3] = __('No'); - - $data[4] = "" . - html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "" . - html_print_checkbox_extended ('delete_multiple[]', $template['id_gs_template'], false, false, '', 'class="check_delete"', true); - - array_push ($table_aux->data, $data); - } - - if(isset($data)) { - echo "
"; - html_print_input_hidden('multiple_delete', 1); - html_print_table ($table_aux); - echo "
"; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); - echo "
"; - echo "
"; - } - - } -} - -//Configuration form -$table->width = '98%'; - -$table->data = array(); - -//$table->data[0][0] = ''.__('Agent').''; -//$table->data[1][0] = html_print_input_text('agent', '', '', 30, 255, true); -$table->data[0][0] = ''.__('Module').''."     "; -$table->data[0][0] .= "    ".html_print_input_text('module', '', '', 30, 255, true); -$table->data[1][0] = ''.__('Weight').''."     "; -$table->data[1][0] .= '    '.html_print_input_text('weight', 2, '', 3, 5, true); -$table->data[2][0] = __('Exact match')."     "; -$table->data[2][0] .= html_print_checkbox('match', 1, 0, true); - -echo '
'; -html_print_table($table); -echo '
'; - -html_print_submit_button (__('Add'), 'crt', false, 'class="sub add"'); - -echo '
'; -echo '
'; -?> - - diff --git a/pandora_console/godmode/reporting/graph_template_list.php b/pandora_console/godmode/reporting/graph_template_list.php deleted file mode 100644 index 0c178597e0..0000000000 --- a/pandora_console/godmode/reporting/graph_template_list.php +++ /dev/null @@ -1,166 +0,0 @@ - false, - 'text' => '' . - html_print_image("images/god6.png", true, array ("title" => __('Graph list'))) .''); - -$buttons['wizard'] = array('active' => false, - 'text' => '' . - html_print_image("images/wand.png", true, array ("title" => __('Wizard'))) .''); - -$buttons['template'] = array('active' => true, - 'text' => '' . - html_print_image("images/paste_plain.png", true, array ("title" => __('Templates'))) .''); - -// Header -ui_print_page_header (__('Graph template management'), "", false, "", true, $buttons); - -$delete = get_parameter ('delete_template', 0); -$id_template = get_parameter('id', 0); -$multiple_delete = (bool)get_parameter('multiple_delete', 0); - -if ($delete) { - $result = db_process_sql_delete ('tgraph_template', - array ('id_graph_template' => $id_template)); - - if ($result !== false) - $result = true; - else - $result = false; - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Not deleted. Error deleting data')); -} - -if ($multiple_delete) { - $ids = (array)get_parameter('delete_multiple', array()); - - db_process_sql_begin(); - - foreach ($ids as $id) { - $result = db_process_sql_delete ('tgraph_template', - array ('id_graph_template' => $id)); - - if ($result === false) { - db_process_sql_rollback(); - break; - } - } - - if ($result !== false) { - db_process_sql_commit(); - } - - if ($result !== false) $result = true; - else $result = false; - - ui_print_result_message ($result, - __('Successfully deleted'), - __('Not deleted. Error deleting data')); -} - - -$own_info = get_user_info ($config['id_user']); -if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) - $return_all_group = true; -else - $return_all_group = false; - -$templates = reporting_template_graphs_get_user ($config['id_user'], false, $return_all_group, "IW"); - -if (! empty ($templates)) { - $table->width = '98%'; - $tale->class = 'databox_frame'; - $table->align = array (); - $table->align[3] = 'center'; - $table->head = array (); - $table->head[0] = __('Template name'); - $table->head[1] = __('Description'); - $table->head[3] = __('Group'); - $table->size[3] = '50px'; - if (check_acl ($config['id_user'], 0, "AW")) { - $table->align[4] = 'center'; - $table->head[4] = __('Action'). html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); - $table->size[4] = '60px'; - } - $table->data = array (); - - foreach ($templates as $template) { - $data = array (); - - $data[0] = ''.$template['name'].''; - $data[1] = $template["description"]; - - $data[3] = ui_print_group_icon($template['id_group'],true); - - if (check_acl ($config['id_user'], 0, "AW")) { - $data[4] = '' . html_print_image("images/cross.png", true) . ''. - html_print_checkbox_extended ('delete_multiple[]', $template['id_graph_template'], false, false, '', 'class="check_delete"', true); - } - - array_push ($table->data, $data); - } - - echo "
"; - html_print_input_hidden('multiple_delete', 1); - html_print_table ($table); - echo "
"; - html_print_submit_button(__('Delete'), 'delete_btn', false, 'class="sub delete"'); - echo "
"; - echo "
"; -} -else { - echo "
".__('There are no defined graph templates')."
"; -} - -echo '
'; -echo '
'; -html_print_submit_button (__('Create template'), 'create', false, 'class="sub next"'); -echo "
"; -echo "
"; - -?> - - diff --git a/pandora_console/godmode/reporting/graph_template_wizard.php b/pandora_console/godmode/reporting/graph_template_wizard.php deleted file mode 100644 index ff6f92710d..0000000000 --- a/pandora_console/godmode/reporting/graph_template_wizard.php +++ /dev/null @@ -1,431 +0,0 @@ - $id_template_cleanup)); - - if($result) { - foreach ($id_graphs as $id_graph) { - $result_aux = db_process_sql_delete('tgraph_source', array('id_graph' => $id_graph)); - } - echo 1; - } else { - echo 0; - } - } - - return; -} - -// Result for cleanup functionality -echo ''; -echo ''; - -$buttons['graph_list'] = array('active' => false, - 'text' => '' . - html_print_image("images/god6.png", true, array ("title" => __('Graph list'))) .''); - -$buttons['wizard'] = array('active' => true, - 'text' => '' . - html_print_image("images/wand.png", true, array ("title" => __('Wizard'))) .''); - -$buttons['template'] = array('active' => false, - 'text' => '' . - html_print_image("images/paste_plain.png", true, array ("title" => __('Templates'))) .''); - -// Header -ui_print_page_header (__('Wizard template'), "", false, "", true, $buttons); - -// Apply templates action -if ($action_wizard == 'apply') { - $agents_selected = (array) get_parameter ('id_agents2'); - $template_selected = get_parameter('templates'); - - if (empty($agents_selected) || empty($template_selected)) - $result = false; - else { - $result = reporting_apply_report_template_graph($agents_selected, $template_selected); - } -} - -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- '; - - // List all available templates - $own_info = get_user_info ($config['id_user']); - if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) - $return_all_group = true; - else - $return_all_group = false; - - $templates = reporting_template_graphs_get_user ($config['id_user'], false, true, 'IW'); - - if ($templates === false) - $template_select = array(); - else{ - foreach ($templates as $template){ - $template_select[$template['id_graph_template']] = $template['name']; - } - } - - echo __('Templates') . "    "; - html_print_select($template_select, 'templates', $template_selected, '', __('None'), '0', false, false, true, '', false, 'width:180px;'); - echo "  "; - echo ''; - - html_print_image ('images/clean.png', false, array ('title' => __('Clean up template'))); - echo ''; - ?> -
- "; - ?> -
- "; - ?> -
- " . __('Agents available')."  " . html_print_submit_button (__('Select all'), 'select_all', false, 'class="sub upd"', true); - ?> - - " . __('Agents to apply')."  " . html_print_submit_button (__('Select all'), 'select_all2', false, 'class="sub upd"', true); - ?> -
- - -
- 'right', 'title' => __('Add agents to template'))); - ?> -



- 'left', 'title' => __('Undo agents to template'))); - ?> -


-
- -
- -'; -html_print_input_hidden('action_wizard', 'apply'); -html_print_submit_button (__('Apply template'), 'apply', false, 'class="sub next"'); -echo ''; -echo ''; - -// Choose a weird separator -$separator = ';;..;;..;;'; - -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)); -?> - - diff --git a/pandora_console/godmode/reporting/graphs.php b/pandora_console/godmode/reporting/graphs.php index 09a9fee508..325393748b 100644 --- a/pandora_console/godmode/reporting/graphs.php +++ b/pandora_console/godmode/reporting/graphs.php @@ -27,17 +27,37 @@ if (! check_acl ($config['id_user'], 0, "IW")) { return; } +$activeTab = get_parameter('tab', 'main'); + +$enterpriseEnable = false; +if (enterprise_include_once('include/functions_reporting.php') !== ENTERPRISE_NOT_HOOK) { + $enterpriseEnable = true; +} + $buttons['graph_list'] = array('active' => true, 'text' => '' . html_print_image("images/god6.png", true, array ("title" => __('Graph list'))) .''); + +if ($enterpriseEnable){ + $buttons = reporting_enterprise_add_template_graph_tabs($buttons); +} -$buttons['wizard'] = array('active' => false, - 'text' => '' . - html_print_image("images/wand.png", true, array ("title" => __('Wizard'))) .''); +$subsection = ''; +switch ($activeTab){ -$buttons['template'] = array('active' => false, - 'text' => '' . - html_print_image("images/paste_plain.png", true, array ("title" => __('Templates'))) .''); + case 'main': $buttons['graph_list']['active'] = true; + $subsection = ' » '.__('Graph list'); + break; + default: $subsection = reporting_enterprise_add_graph_template_subsection($activeTab, &$buttons); + break; + } + +switch ($activeTab) { + case 'main': require_once('godmode/reporting/graphs.php'); + break; + default: reporting_enterprise_select_graph_template_tab($activeTab); + break; +} $delete_graph = (bool) get_parameter ('delete_graph'); $view_graph = (bool) get_parameter ('view_graph'); @@ -126,7 +146,7 @@ if (! empty ($graphs)) { if (check_acl ($config['id_user'], 0, "AW")) { $table->align[5] = 'center'; $table->head[5] = __('Delete'). html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); - $table->size[5] = '50px'; + $table->size[5] = '60px'; } $table->data = array (); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 2aff500b62..edc7a4eede 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -4640,7 +4640,7 @@ function reporting_get_agentmodule_ttr ($id_agent_module, $period, $date = 0) { return $critical_period; } -/** +/* * Get all the template graphs a user can see. * * @param $id_user User id to check. @@ -4689,82 +4689,4 @@ function reporting_template_graphs_get_user ($id_user = 0, $only_names = false, return $templates; } - -/** - * Apply a template graph - * - * @param array $agents_selected to apply the template. - * @param $template_selected - * - * @return - */ -function reporting_apply_report_template_graph ($agents_selected, $template_selected) { - - if ($agents_selected[0] == '') { - unset($agents_selected[0]); - } - - if ($agents_selected != null) { - - $template_data = db_get_row('tgraph_template','id_graph_template', $template_selected); - - foreach ($agents_selected as $id_agent) { - $values = array( - 'id_user' => $template_data['id_user'], - 'name' => $template_data['name'], - 'description' => $template_data['description'], - 'period' => $template_data['period'], - 'width' => $template_data['width'], - 'height' => $template_data['height'], - 'private' => $template_data['private'], - 'events' => $template_data['events'], - 'stacked' => $template_data['stacked'], - 'id_group' => $template_data['id_group'], - 'id_graph_template' => $template_selected - ); - - $id_graph = db_process_sql_insert('tgraph', $values); - - $sql = "SELECT * FROM tgraph_source_template WHERE id_template=$template_selected"; - $source_templates = db_get_all_rows_sql($sql); - - foreach ($source_templates as $source) { - $modules = agents_get_modules($id_agent, false, array('disabled' => 0)); - $exact_match = $source['exact_match']; - - foreach ($modules as $key => $module) { - $insert_module = false; - if ($exact_match) { - if ($module == $source['module']) { - $insert_module = true; - } - } else { - $exp = '/'.$source['module'].'/i'; - $result = preg_match($exp, $module); - if ($result) { - $insert_module = true; - } - } - if ($insert_module) { - $values_aux = array( - 'id_graph' => $id_graph, - 'id_agent_module' => $key, - 'weight' => $source['weight'] - ); - $id_gs = db_process_sql_insert('tgraph_source', $values_aux); - } - } - } - } - if ($id_graph) { - ui_print_success_message ('Template applied successfully'); - //return true; - } else { - ui_print_error_message ('An error has ocurred apllying template'); - } - } else { - ui_print_error_message ('Agent must be selected'); - } - return false; -} ?>