From 32466c69060b37b9d827a4df4643192f0190405c Mon Sep 17 00:00:00 2001 From: "jose.gonzalez@pandorafms.com" Date: Thu, 3 Nov 2022 10:18:17 +0100 Subject: [PATCH] Changes --- pandora_console/godmode/category/category.php | 19 +++- .../godmode/category/edit_category.php | 87 +++++++++++-------- .../godmode/groups/modu_group_list.php | 34 ++++---- pandora_console/include/class/HTML.class.php | 2 +- .../include/class/ModuleTemplates.class.php | 77 +++++----------- 5 files changed, 105 insertions(+), 114 deletions(-) diff --git a/pandora_console/godmode/category/category.php b/pandora_console/godmode/category/category.php index a25bd4a263..4ac78b7414 100755 --- a/pandora_console/godmode/category/category.php +++ b/pandora_console/godmode/category/category.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas * Please see http://pandorafms.org for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -228,7 +228,6 @@ if (empty($result) === false) { if ($is_management_allowed === true) { // Form to add new categories or search categories. - echo "
"; if (is_metaconsole() === true) { echo '
'; } else { @@ -236,9 +235,21 @@ if ($is_management_allowed === true) { } html_print_input_hidden('create_category', '1', true); - html_print_submit_button(__('Create category'), 'create_button', false, 'class="sub next"'); + + html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Create category'), + 'create_button', + false, + [ 'icon' => 'next' ], + true + ), + ] + ); + echo '
'; - echo '
'; enterprise_hook('close_meta_frame'); } diff --git a/pandora_console/godmode/category/edit_category.php b/pandora_console/godmode/category/edit_category.php index 3cd20c0325..64b4a193c2 100755 --- a/pandora_console/godmode/category/edit_category.php +++ b/pandora_console/godmode/category/edit_category.php @@ -1,21 +1,36 @@ [ 'active' => false, @@ -68,8 +83,8 @@ if (defined('METACONSOLE')) { $buttons[$tab]['active'] = false; -// Header -if (defined('METACONSOLE')) { +// Header. +if (is_metaconsole() === true) { ui_meta_print_header(__('Categories configuration'), __('Editor'), $buttons); } else { ui_print_page_header(__('Categories configuration'), 'images/gm_modules.png', false, '', true, $buttons); @@ -186,32 +201,30 @@ if (defined('METACONSOLE')) { echo ''; -echo ""; -echo ''; -echo ''; -echo ''; -echo '
'; -if ($action == 'update') { +if ($action === 'update') { html_print_input_hidden('update_category', 1); - html_print_submit_button( - __('Update'), - 'update_button', - false, - 'class="sub next"' - ); -} - -if ($action == 'new') { + $buttonCaption = __('Update'); + $buttonName = 'update_button'; + $buttonIcon = 'update'; +} else if ($action === 'new') { html_print_input_hidden('create_category', 1); - html_print_submit_button( - __('Create'), - 'create_button', - false, - 'class="sub next"' - ); + $buttonCaption = __('Create'); + $buttonName = 'create_button'; + $buttonIcon = 'next'; } -echo '
'; +html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + $buttonCaption, + $buttonName, + false, + [ 'icon' => $buttonIcon ], + true + ), + ] +); echo ''; echo ''; diff --git a/pandora_console/godmode/groups/modu_group_list.php b/pandora_console/godmode/groups/modu_group_list.php index 84dc35ada8..5fa233ce86 100644 --- a/pandora_console/godmode/groups/modu_group_list.php +++ b/pandora_console/godmode/groups/modu_group_list.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2022 Artica Soluciones Tecnologicas * Please see http://pandorafms.org for full contribution list * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -43,7 +43,7 @@ if (is_ajax() === true) { $get_group_json = (bool) get_parameter('get_group_json'); $get_group_agents = (bool) get_parameter('get_group_agents'); - if ($get_group_json) { + if ($get_group_json === true) { $id_group = (int) get_parameter('id_group'); if (! check_acl($config['id_user'], $id_group, 'AR')) { @@ -174,7 +174,7 @@ if ($is_management_allowed === true && $delete_group === true) { $result = db_process_sql_delete('tmodule_group', ['id_mg' => $id_group]); - if ($result) { + if ((bool) $result === true) { $result = db_process_sql_update( 'tagente_modulo', ['id_module_group' => 0], @@ -223,11 +223,11 @@ if ($is_management_allowed === true && $delete_group === true) { } } - if (! $result) { - ui_print_error_message(__('There was a problem deleting group')); - } else { - ui_print_success_message(__('Group successfully deleted')); - } + ui_print_result_message( + $result, + __('Group successfully deleted'), + __('There was a problem deleting group') + ); } // Prepare pagination. @@ -298,13 +298,17 @@ if (empty($groups) === false) { if ($is_management_allowed === true) { echo '
'; - echo '
'; - html_print_submit_button( - __('Create module group'), - 'crt', - false, - 'class="sub next"' + html_print_div( + [ + 'class' => 'action-buttons', + 'content' => html_print_submit_button( + __('Create module group'), + 'crt', + false, + [ 'icon' => 'next' ], + true + ), + ] ); - echo '
'; echo '
'; } diff --git a/pandora_console/include/class/HTML.class.php b/pandora_console/include/class/HTML.class.php index c8c42f31e4..1e4729d55e 100644 --- a/pandora_console/include/class/HTML.class.php +++ b/pandora_console/include/class/HTML.class.php @@ -418,7 +418,7 @@ class HTML 'name' => 'submit', 'label' => __('Go back'), 'type' => 'submit', - 'attributes' => [ 'icon' => 'back' ], + 'attributes' => [ 'icon' => 'cancel' ], 'return' => true, ], ], diff --git a/pandora_console/include/class/ModuleTemplates.class.php b/pandora_console/include/class/ModuleTemplates.class.php index f478549269..312c69bf86 100644 --- a/pandora_console/include/class/ModuleTemplates.class.php +++ b/pandora_console/include/class/ModuleTemplates.class.php @@ -436,64 +436,27 @@ class ModuleTemplates extends HTML return; } - // It's important to keep the structure and order in the same way for backwards compatibility. - switch ($config['dbtype']) { - case 'mysql': - $sql = sprintf( - ' - SELECT components.name, components.description, components.type, components.max, components.min, components.module_interval, - components.tcp_port, components.tcp_send, components.tcp_rcv, components.snmp_community, components.snmp_oid, - components.id_module_group, components.id_modulo, components.plugin_user, components.plugin_pass, components.plugin_parameter, - components.max_timeout, components.max_retries, components.history_data, components.min_warning, components.max_warning, components.str_warning, components.min_critical, - components.max_critical, components.str_critical, components.min_ff_event, components.dynamic_interval, components.dynamic_max, components.dynamic_min, components.dynamic_two_tailed, comp_group.name AS group_name, components.critical_instructions, components.warning_instructions, components.unknown_instructions - FROM `tnetwork_component` AS components, tnetwork_profile_component AS tpc, tnetwork_component_group AS comp_group - WHERE tpc.id_nc = components.id_nc - AND components.id_group = comp_group.id_sg - AND tpc.id_np = %d', - $this->id_np - ); - break; - - case 'postgresql': - $sql = sprintf( - ' - SELECT components.name, components.description, components.type, components.max, components.min, components.module_interval, - components.tcp_port, components.tcp_send, components.tcp_rcv, components.snmp_community, components.snmp_oid, - components.id_module_group, components.id_modulo, components.plugin_user, components.plugin_pass, components.plugin_parameter, - components.max_timeout, components.max_retries, components.history_data, components.min_warning, components.max_warning, components.str_warning, components.min_critical, - components.max_critical, components.str_critical, components.min_ff_event, comp_group.name AS group_name, components.critical_instructions, components.warning_instructions, components.unknown_instructions - FROM "tnetwork_component" AS components, tnetwork_profile_component AS tpc, tnetwork_component_group AS comp_group - WHERE tpc.id_nc = components.id_nc - AND components.id_group = comp_group.id_sg - AND tpc.id_np = %d', - $this->id_np - ); - break; - - case 'oracle': - $sql = sprintf( - ' - SELECT components.name, components.description, components.type, components.max, components.min, components.module_interval, - components.tcp_port, components.tcp_send, components.tcp_rcv, components.snmp_community, components.snmp_oid, - components.id_module_group, components.id_modulo, components.plugin_user, components.plugin_pass, components.plugin_parameter, - components.max_timeout, components.max_retries, components.history_data, components.min_warning, components.max_warning, components.str_warning, components.min_critical, - components.max_critical, components.str_critical, components.min_ff_event, comp_group.name AS group_name, components.critical_instructions, components.warning_instructions, components.unknown_instructions - FROM tnetwork_component AS components, tnetwork_profile_component AS tpc, tnetwork_component_group AS comp_group - WHERE tpc.id_nc = components.id_nc - AND components.id_group = comp_group.id_sg - AND tpc.id_np = %d', - $this->id_np - ); - break; - } + $sql = sprintf( + ' + SELECT components.name, components.description, components.type, components.max, components.min, components.module_interval, + components.tcp_port, components.tcp_send, components.tcp_rcv, components.snmp_community, components.snmp_oid, + components.id_module_group, components.id_modulo, components.plugin_user, components.plugin_pass, components.plugin_parameter, + components.max_timeout, components.max_retries, components.history_data, components.min_warning, components.max_warning, components.str_warning, components.min_critical, + components.max_critical, components.str_critical, components.min_ff_event, components.dynamic_interval, components.dynamic_max, components.dynamic_min, components.dynamic_two_tailed, comp_group.name AS group_name, components.critical_instructions, components.warning_instructions, components.unknown_instructions + FROM `tnetwork_component` AS components, tnetwork_profile_component AS tpc, tnetwork_component_group AS comp_group + WHERE tpc.id_nc = components.id_nc + AND components.id_group = comp_group.id_sg + AND tpc.id_np = %d', + $this->id_np + ); $components = db_get_all_rows_sql($sql); $row_names = []; $inv_names = []; - // Find the names of the rows that we are getting and throw away the duplicate numeric keys + // Find the names of the rows that we are getting and throw away the duplicate numeric keys. foreach ($components[0] as $row_name => $detail) { - if (is_numeric($row_name)) { + if (is_numeric($row_name) === true) { $inv_names[] = $row_name; } else { $row_names[] = $row_name; @@ -501,17 +464,17 @@ class ModuleTemplates extends HTML } $fileName = io_safe_output($profile_info['name']); - // Send headers to tell the browser we're sending a file + // Send headers to tell the browser we're sending a file. header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename='.preg_replace('/\s/', '_', $fileName).'.csv'); header('Pragma: no-cache'); header('Expires: 0'); - // Clean up output buffering + // Clean up output buffering. while (@ob_end_clean()) { } - // Then print the first line (row names) + // Then print the first line (row names). echo '"'.implode('"'.$config['csv_divider'].'"', $row_names).'"'; echo "\n"; @@ -960,7 +923,7 @@ class ModuleTemplates extends HTML 'label' => __('Create'), 'name' => 'crt', 'type' => 'submit', - 'attributes' => 'class="sub wand"', + 'attributes' => ['icon' => 'wand'], 'return' => true, ], ]; @@ -970,7 +933,7 @@ class ModuleTemplates extends HTML 'label' => __('Delete selected'), 'name' => 'erase', 'type' => 'button', - 'attributes' => 'class="sub cancel"', + 'attributes' => ['icon' => 'cancel'], 'return' => true, ], ];