From feb89b87f0aa9b324a18b0baababad708284f49b Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 29 Jan 2013 12:31:32 +0000 Subject: [PATCH] 2013-01-29 Miguel de Dios * general/shortcut_bar.php, godmode/alerts/alert_actions.php, godmode/category/edit_category.php, include/functions_reports.php, include/db/postgresql.php, include/functions_gis.php, include/functions_treeview.php, include/functions_network_components.php: improved the code style. * include/javascript/pandora.js: in function "agent_changed_by_multiple_agents" added hook for to call any function when loaded the module list. (now used in the wizzard of reports in enterprise). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7540 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 13 ++++++++++++ pandora_console/general/shortcut_bar.php | 8 +++---- .../godmode/alerts/alert_actions.php | 21 ++++++++++--------- .../godmode/category/edit_category.php | 6 +++--- pandora_console/include/db/postgresql.php | 12 +++++------ pandora_console/include/functions_gis.php | 4 ++-- .../include/functions_network_components.php | 14 +++++++++++-- pandora_console/include/functions_reports.php | 2 +- .../include/functions_treeview.php | 11 +++++----- pandora_console/include/javascript/pandora.js | 5 +++++ 10 files changed, 63 insertions(+), 33 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 26c125dabf..97c51eb75d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,16 @@ +2013-01-29 Miguel de Dios + + * general/shortcut_bar.php, godmode/alerts/alert_actions.php, + godmode/category/edit_category.php, include/functions_reports.php, + include/db/postgresql.php, include/functions_gis.php, + include/functions_treeview.php, + include/functions_network_components.php: improved the code style. + + * include/javascript/pandora.js: in function + "agent_changed_by_multiple_agents" added hook for to call any + function when loaded the module list. (now used in the wizzard + of reports in enterprise). + 2013-01-29 Sergio Martin * include/functions_treeview.php diff --git a/pandora_console/general/shortcut_bar.php b/pandora_console/general/shortcut_bar.php index ea81fed40e..6cff9d69a7 100644 --- a/pandora_console/general/shortcut_bar.php +++ b/pandora_console/general/shortcut_bar.php @@ -82,7 +82,7 @@ if (is_ajax()){ } // Select only opened incidents - if ($get_opened_incidents) { + if ($get_opened_incidents) { $own_info = get_user_info ($config['id_user']); if ($own_info['is_admin'] || check_acl ($config['id_user'], 0, "PM")) @@ -95,20 +95,20 @@ if (is_ajax()){ ORDER BY actualizacion"; - if (!empty($own_groups)) { + if (!empty($own_groups)) { $result_incidents_update = db_get_all_rows_sql ($sql); } else { $result_incidents_update = false; } - + if ($result_incidents_update === false) $shortcut_incidents = 0; else $shortcut_incidents = $result_incidents_update[0]['total_incidents']; echo $shortcut_incidents; - } + } return; } diff --git a/pandora_console/godmode/alerts/alert_actions.php b/pandora_console/godmode/alerts/alert_actions.php index 26239a2f3a..ad759d340e 100644 --- a/pandora_console/godmode/alerts/alert_actions.php +++ b/pandora_console/godmode/alerts/alert_actions.php @@ -193,21 +193,22 @@ if ($update_action) { exit; } else { - // Header + // Header if (defined('METACONSOLE')) { alerts_meta_print_header (); } - else { + else { ui_print_page_header (__('Alerts').' » '.__('Alert actions'), "images/god2.png", false, "alert_action", true); - } + } } } - } else { - // Header + } + else { + // Header if (defined('METACONSOLE')) { alerts_meta_print_header (); } - else { + else { ui_print_page_header (__('Alerts').' » '.__('Alert actions'), "images/god2.png", false, "alert_action", true); } } @@ -220,7 +221,7 @@ if ($update_action) { $info_fields = ''; $values = array(); - + for($i=1;$i<=10;$i++) { $values['field'.$i] = (string) get_parameter ('field'.$i.'_value'); $info_fields .= ' Field1: ' . $values['field'.$i]; @@ -230,7 +231,7 @@ if ($update_action) { $values['id_alert_command'] = $id_alert_command; $values['id_group'] = $group; $values['action_threshold'] = $action_threshold; - + if (!$name) { $result = ''; } @@ -270,11 +271,11 @@ if ($delete_action) { exit; } else { - // Header + // Header if (defined('METACONSOLE')) { alerts_meta_print_header (); } - else { + else { ui_print_page_header (__('Alerts').' » '.__('Alert actions'), "images/god2.png", false, "alert_action", true); } } diff --git a/pandora_console/godmode/category/edit_category.php b/pandora_console/godmode/category/edit_category.php index 7945cd2e16..0918f32813 100755 --- a/pandora_console/godmode/category/edit_category.php +++ b/pandora_console/godmode/category/edit_category.php @@ -42,7 +42,7 @@ $buttons = array( $buttons[$tab]['active'] = false; // Header -if(defined('METACONSOLE')) { +if (defined('METACONSOLE')) { ui_meta_print_header(__('Categories configuration'), __('Editor'), $buttons); } else { @@ -52,7 +52,7 @@ else { // Two actions can performed in this page: update and create categories // Update category: update an existing category -if ($update_category && $id_category != 0) { +if ($update_category && $id_category != 0) { $values = array(); $values['name'] = $name_category; @@ -113,7 +113,7 @@ echo '
'; echo ""; - echo ""; + echo ""; echo ""; diff --git a/pandora_console/include/db/postgresql.php b/pandora_console/include/db/postgresql.php index 12cf250f49..a8d57c475b 100644 --- a/pandora_console/include/db/postgresql.php +++ b/pandora_console/include/db/postgresql.php @@ -285,7 +285,7 @@ function postgresql_db_get_all_rows_in_table($table, $order_field = "", $order = if ($order_field != "") { return db_get_all_rows_sql ('SELECT * FROM "'.$table.'" ORDER BY '.$order_field . ' ' . $order); } - else { + else { return db_get_all_rows_sql ('SELECT * FROM "'.$table.'"'); } } @@ -609,13 +609,13 @@ function postgresql_db_format_array_where_clause_sql ($values, $join = 'AND', $p * @return the first value of the first row of a table result from query. * */ -function postgresql_db_get_value_sql($sql, $dbconnection = false) { +function postgresql_db_get_value_sql($sql, $dbconnection = false) { $sql .= " LIMIT 1"; $result = postgresql_db_get_all_rows_sql ($sql, false, true, $dbconnection); - + if($result === false) return false; - + foreach ($result[0] as $f) return $f; } @@ -630,10 +630,10 @@ function postgresql_db_get_value_sql($sql, $dbconnection = false) { function postgresql_db_get_row_sql ($sql, $search_history_db = false) { $sql .= " LIMIT 1"; $result = postgresql_db_get_all_rows_sql($sql, $search_history_db); - + if($result === false) return false; - + return $result[0]; } diff --git a/pandora_console/include/functions_gis.php b/pandora_console/include/functions_gis.php index 3de865e656..589cac4e0d 100644 --- a/pandora_console/include/functions_gis.php +++ b/pandora_console/include/functions_gis.php @@ -194,14 +194,14 @@ function gis_make_layer($name, $visible = true, $dot = null, $idLayer = null) { function () { popup.destroy(); }); feature.popup = popup; map.addPopup(popup); - + jQuery.ajax ({ data: "page=operation/gis_maps/ajax&opt="+featureData.type+"&id=" + featureData.id, type: "GET", dataType: 'json', url: "ajax.php", timeout: 10000, - success: function (data) { + success: function (data) { if (data.correct) { $('.cloudContent' + featureData.id).css('text-align', 'left'); $('.cloudContent' + featureData.id).html(data.content); diff --git a/pandora_console/include/functions_network_components.php b/pandora_console/include/functions_network_components.php index 9b9c51e6a1..7996f3083d 100644 --- a/pandora_console/include/functions_network_components.php +++ b/pandora_console/include/functions_network_components.php @@ -108,6 +108,7 @@ function network_components_get_group_name ($id_network_component_group) { function network_components_get_group ($id_network_component_group, $filter = false, $fields = false) { if (empty ($id_network_component_group)) return false; + if (! is_array ($filter)) $filter = array (); $filter['id_sg'] = (int) $id_network_component_group; @@ -218,6 +219,7 @@ function network_components_get_groups ($id_module_components = 0, $localCompone function network_components_get_network_component ($id_network_component, $filter = false, $fields = false) { if (empty ($id_network_component)) return false; + if (! is_array ($filter)) $filter = array (); $filter['id_nc'] = (int) $id_network_component; @@ -227,7 +229,7 @@ function network_components_get_network_component ($id_network_component, $filte if(!empty($network_component) && $network_component['id_category'] != 0) { $network_component['category_name'] = (string) db_get_value('name','tcategory','id',$network_component['id_category']); } - + return $network_component; } @@ -254,10 +256,13 @@ function network_components_create_network_component ($name, $type, $id_group, $ if (empty ($name)) return false; + if (empty ($type)) return false; + if (! is_array ($values)) $values = array (); + $values['name'] = $name; $values['type'] = (int) $type; $values['id_group'] = (int) $id_group; @@ -277,9 +282,11 @@ function network_components_create_network_component ($name, $type, $id_group, $ function network_components_update_network_component ($id_network_component, $values = false) { if (empty ($id_network_component)) return false; + $component = network_components_get_network_component ($id_network_component); if (empty ($component)) return false; + if (! is_array ($values)) return false; @@ -299,6 +306,7 @@ function network_components_update_network_component ($id_network_component, $va function network_components_delete_network_component ($id_network_component) { if (empty ($id_network_component)) return false; + $filter = array (); $filter['id_nc'] = $id_network_component; @@ -319,6 +327,7 @@ function network_components_delete_network_component ($id_network_component) { function network_components_create_module_from_network_component ($id_network_component, $id_agent) { if (! users_access_to_agent ($id_agent, 'AW')) return false; + $component = network_components_get_network_component ($id_network_component, false, array ('name', @@ -375,6 +384,7 @@ function network_components_create_module_from_network_component ($id_network_co function network_components_get_name ($id_network_component) { if (empty ($id_network_component)) return false; + return @db_get_value ('name', 'tnetwork_component', 'id', $id_network_component); } @@ -382,7 +392,7 @@ function network_components_get_name ($id_network_component) { * Duplicate local compoment. * @param integer id_local_component Id of localc component for duplicate. */ -function network_components_duplicate_network_component ($id_local_component) { +function network_components_duplicate_network_component ($id_local_component) { $network = network_components_get_network_component ($id_local_component); if ($network === false) diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index e90b833c31..e6f7c1438e 100644 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -604,7 +604,7 @@ function reports_get_report_types ($template = false, $not_editor = false) { } } - if (!$template) { + if (!$template) { $types['agent_configuration'] = array('optgroup' => __('Configuration'), 'name' => __('Agent configuration')); $types['group_configuration'] = array('optgroup' => __('Configuration'), diff --git a/pandora_console/include/functions_treeview.php b/pandora_console/include/functions_treeview.php index 68b2ae7395..7421855d09 100755 --- a/pandora_console/include/functions_treeview.php +++ b/pandora_console/include/functions_treeview.php @@ -178,7 +178,7 @@ function treeview_printAlertsTable($id_module, $server_data = array()) { function treeview_printTable($id_agente, $server_data = array()) { global $config; - + if(empty($server_data)) { $server_name = ''; $server_id = ''; @@ -404,7 +404,7 @@ function treeview_printTree($type) { metaconsole_restore_db(); } - + if ($list === false) { echo '

'.__('There aren\'t agents in this agrupation').'

'; echo ''; @@ -414,7 +414,7 @@ function treeview_printTree($type) { echo "
"; html_print_label (__("Name"),'name'); echo "