diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 3b96db6277..338c2e0472 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2012-12-06 Miguel de Dios + + * include/functions_agents.php, + operation/integria_incidents/incident.php, + godmode/massive/massive_delete_modules.php, + godmode/modules/manage_network_templates_form.php, + godmode/modules/manage_network_components_form_plugin.php, + godmode/agentes/fields_manager.php, + godmode/agentes/module_manager.php, godmode/users/profile_list.php, + godmode/events/event_filter.php: cleaned source code style. + + * operation/tree.php: fixed the url to childrem consoles from the + metaconsole tree. + 2012-12-05 Ramon Novoa * pandoradb_data.sql, diff --git a/pandora_console/godmode/agentes/fields_manager.php b/pandora_console/godmode/agentes/fields_manager.php index de0b10e537..4d680d308d 100644 --- a/pandora_console/godmode/agentes/fields_manager.php +++ b/pandora_console/godmode/agentes/fields_manager.php @@ -55,7 +55,7 @@ if ($create_field) { /* Update field */ if ($update_field) { /*Check if name field is empty*/ - if( $name != "") { + if( $name != "") { $values = array('name' => $name, 'display_on_front' => $display_on_front); $result = db_process_sql_update('tagent_custom_fields', $values, array('id_field' => $id_field)); diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 35b52438fa..b72bcb794f 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -136,7 +136,8 @@ if ($multiple_delete) { if (db_process_sql("UPDATE tagente_modulo SET nombre = 'pendingdelete', disabled = 1, delete_pending = 1 WHERE id_agente_modulo = ".$id_agent_module_del, "affected_rows", '', true, $status, false) === false) { $error++; - } else { + } + else { // Update module status count if ($module !== false) { if ($module['utimestamp'] == 0) { @@ -152,7 +153,7 @@ if ($multiple_delete) { } db_process_sql ('UPDATE tagente SET total_count=total_count-1 WHERE id_agente=' . $module['id_agente']); } - } + } switch ($config["dbtype"]) { case "mysql": @@ -184,7 +185,7 @@ if ($multiple_delete) { if ($result === false) $error++; } // Trick to detect if we are deleting components of synthetics modules (avg or arithmetic) - else{ + else { $result_components = enterprise_hook('modules_get_synthetic_components', array($id_agent_module_del)); $count_components = 1; if (!empty($result_components)){ diff --git a/pandora_console/godmode/events/event_filter.php b/pandora_console/godmode/events/event_filter.php index 4bd6e1c516..f78bbac65d 100644 --- a/pandora_console/godmode/events/event_filter.php +++ b/pandora_console/godmode/events/event_filter.php @@ -77,7 +77,7 @@ if ($multiple_delete) { db_process_sql_begin(); - foreach ($ids as $id) { + foreach ($ids as $id) { $result = db_process_sql_delete ('tevent_filter', array ('id_filter' => $id)); @@ -117,7 +117,7 @@ $table->head[2] = __('Event type'); $table->head[3] = __('Event status'); $table->head[4] = __('Severity'); $table->head[5] = __('Action') . - html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); + html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();'); $table->style = array (); $table->style[0] = 'font-weight: bold'; $table->align = array (); @@ -156,7 +156,7 @@ foreach ($filters as $filter) { array_push ($table->data, $data); } -if(isset($data)) { +if (isset($data)) { echo "
"; html_print_input_hidden('multiple_delete', 1); html_print_table ($table); diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index acfddb36dc..7d21f8d49b 100644 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -96,14 +96,14 @@ $selection_mode = get_parameter('selection_mode', 'modules'); $recursion = get_parameter('recursion'); if ($delete) { - if($selection_mode == 'modules') { + if ($selection_mode == 'modules') { $force = get_parameter('force_type', false); - if($agents_select == false) { + if ($agents_select == false) { $agents_select = array(); $agents_ = array(); } - + foreach($agents_select as $agent_name) { $agents_[] = agents_get_agent_id($agent_name); } @@ -111,40 +111,40 @@ if ($delete) { } else if($selection_mode == 'agents') { $force = get_parameter('force_group', false); - + $agents_ = $agents_id; $modules_ = $modules_select; } - + $count = 0; $success = 0; - + // If the option to select all of one group or module type is checked - if($force) { - if($force == 'type') { + if ($force) { + if ($force == 'type') { $condition = ''; - if($module_type != 0) + if ($module_type != 0) $condition = ' AND t2.id_tipo_modulo = '.$module_type; $agents_ = db_get_all_rows_sql('SELECT DISTINCT(t1.id_agente) FROM tagente t1, tagente_modulo t2 WHERE t1.id_agente = t2.id_agente'); - foreach($agents_ as $id_agent) { + foreach ($agents_ as $id_agent) { $module_name = db_get_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent, 'id_tipo_modulo' => $module_type),'nombre'); - - if($module_name == false) { + + if ($module_name == false) { $module_name = array(); } - foreach($module_name as $mod_name) { + foreach ($module_name as $mod_name) { $result = process_manage_delete ($mod_name['nombre'], $id_agent['id_agente']); $count ++; $success += (int)$result; } } } - else if($force == 'group') { + else if ($force == 'group') { $agents_ = array_keys (agents_get_group_agents ($group_select, false, "none")); - foreach($agents_ as $id_agent) { + foreach ($agents_ as $id_agent) { $module_name = db_get_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent),'nombre'); if($module_name == false) { $module_name = array(); @@ -291,7 +291,7 @@ echo ''; ui_require_jquery_file ('form'); ui_require_jquery_file ('pandora.controls'); -if($selection_mode == 'modules'){ +if ($selection_mode == 'modules'){ $modules_row = ''; $agents_row = 'none'; } @@ -378,7 +378,7 @@ $(document).ready (function () { } $('input[type=checkbox]').change ( - function () { + function () { if(this.id == "checkbox-force_type"){ if(this.checked) { $(".select_modules_row_2").css('display', 'none'); diff --git a/pandora_console/godmode/modules/manage_network_components_form_plugin.php b/pandora_console/godmode/modules/manage_network_components_form_plugin.php index 678af36ab4..8491e8cd01 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_plugin.php +++ b/pandora_console/godmode/modules/manage_network_components_form_plugin.php @@ -42,19 +42,19 @@ $table->rowstyle['macro_field'] = 'display:none'; push_table_row ($data, 'macro_field'); // If there are $macros, we create the form fields -if(!empty($macros)) { +if (!empty($macros)) { $macros = json_decode($macros, true); - - foreach($macros as $k => $m) { + + foreach ($macros as $k => $m) { $data = array (); $data[0] = $m['desc']; - if(!empty($m['help'])) { + if (!empty($m['help'])) { $data[0] .= ui_print_help_tip ($m['help'], true); } $data[1] = html_print_input_text($m['macro'], $m['value'], '', 15, 60, true); $table->colspan['macro'.$m['macro']][1] = 3; $table->rowclass['macro'.$m['macro']] = 'macro_field'; - + push_table_row ($data, 'macro'.$m['macro']); } } diff --git a/pandora_console/godmode/modules/manage_network_templates_form.php b/pandora_console/godmode/modules/manage_network_templates_form.php index 0c10a7cd4d..96e5490883 100644 --- a/pandora_console/godmode/modules/manage_network_templates_form.php +++ b/pandora_console/godmode/modules/manage_network_templates_form.php @@ -75,7 +75,7 @@ if (isset ($_GET["create"]) || isset ($_GET["update"])) { //Submitted form $name = get_parameter_post ("name"); $description = get_parameter_post ("description"); - if ($name != "") { + if ($name != "") { if ($id_np > 0) { //Profile exists $values = array( @@ -120,7 +120,7 @@ if (isset ($_GET["create"]) || isset ($_GET["update"])) { elseif ($id_np > 0) { //Profile exists $row = db_get_row ("tnetwork_profile", "id_np", $id_np); - + $description = $row["description"]; $name = $row["name"]; diff --git a/pandora_console/godmode/users/profile_list.php b/pandora_console/godmode/users/profile_list.php index f08675d5cc..d53d60ba2f 100644 --- a/pandora_console/godmode/users/profile_list.php +++ b/pandora_console/godmode/users/profile_list.php @@ -61,7 +61,7 @@ if ($delete_profile) { if ($ret === false) { ui_print_error_message(__('There was a problem deleting the profile')); } - else { + else { db_pandora_audit("Profile management", "Delete profile ". $profile['name']); @@ -117,7 +117,7 @@ if ($update_profile) { } } else { - ui_print_error_message(__('Profile name cannot be empty')); + ui_print_error_message(__('Profile name cannot be empty')); } $id_profile = 0; } @@ -151,7 +151,7 @@ if ($create_profile) { if ($name) { $ret = db_process_sql_insert('tperfil', $values); - + if ($ret !== false) { ui_print_success_message(__('Successfully created')); @@ -169,7 +169,7 @@ if ($create_profile) { } } else { - ui_print_error_message(__('There was a problem creating this profile')); + ui_print_error_message(__('There was a problem creating this profile')); } $id_profile = 0; } @@ -202,7 +202,7 @@ $table->align = array_fill (1, 11, "center"); $table->size = array_fill (1, 10, 40); $profiles = db_get_all_rows_in_table ("tperfil"); -if($profiles === false) { +if ($profiles === false) { $profiles = array(); } @@ -224,19 +224,18 @@ foreach ($profiles as $profile) { $data[11] .= '  '. html_print_image("images/cross.png", true) . ''; array_push ($table->data, $data); } - - echo ''; - if(isset($data)) { - html_print_table ($table); - } - else { - echo "
".__('There are no defined profiles')."
"; - } - echo '
'; - html_print_input_hidden ('new_profile', 1); - html_print_submit_button (__('Create'), "crt", false, 'class="sub next"'); - echo "
"; - echo '
'; - unset ($table); -?> +echo '
'; +if (isset($data)) { + html_print_table ($table); +} +else { + echo "
".__('There are no defined profiles')."
"; +} +echo '
'; +html_print_input_hidden ('new_profile', 1); +html_print_submit_button (__('Create'), "crt", false, 'class="sub next"'); +echo "
"; +echo '
'; +unset ($table); +?> \ No newline at end of file diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 2c36666cae..1f783a57cb 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -359,27 +359,32 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o switch ($filter['status']) { // Normal case 0: - $status_sql = "normal_count=total_count"; + $status_sql = + "normal_count = total_count"; break; // Warning case 2: - $status_sql = "critical_count=0 AND warning_count>0"; + $status_sql = + "critical_count = 0 AND warning_count > 0"; break; // Critical case 1: - $status_sql = "critical_count>0"; + $status_sql = + "critical_count > 0"; break; // Unknown case 3: - $status_sql = "critical_count=0 AND warning_count=0 AND unknown_count>0"; + $status_sql = + "critical_count = 0 AND warning_count = 0 + AND unknown_count > 0"; break; // Not normal case 4: - $status_sql = "normal_count<>total_count"; + $status_sql = "normal_count <> total_count"; break; // Not init case 5: - $status_sql = "notinit_count=total_count"; + $status_sql = "notinit_count = total_count"; break; } unset($filter['status']); @@ -459,10 +464,12 @@ function agents_get_agents ($filter = false, $fields = false, $access = 'AR', $o } if ($extra) { - $where = sprintf('(%s OR (%s)) AND (%s) AND (%s) %s', $sql_extra, $where, $where_nogroup, $status_sql, $search); + $where = sprintf('(%s OR (%s)) AND (%s) AND (%s) %s', + $sql_extra, $where, $where_nogroup, $status_sql, $search); } else { - $where = sprintf('%s AND %s AND (%s) %s', $where, $where_nogroup, $status_sql, $search); + $where = sprintf('%s AND %s AND (%s) %s', + $where, $where_nogroup, $status_sql, $search); } $sql = sprintf('SELECT %s FROM tagente diff --git a/pandora_console/operation/integria_incidents/incident.php b/pandora_console/operation/integria_incidents/incident.php index e63ecd766c..3c530803cf 100755 --- a/pandora_console/operation/integria_incidents/incident.php +++ b/pandora_console/operation/integria_incidents/incident.php @@ -35,46 +35,46 @@ $update_incident = get_parameter('update_incident', 0); $integria_api = $config['integria_url']."/include/api.php?return_type=xml&user=".$config['id_user']."&pass=".$config['integria_api_password']; // Header -if($tab == 'list' || $tab == 'editor') { +if ($tab == 'list' || $tab == 'editor') { $buttons = array( - 'list' => array( - 'active' => false, - 'text' => '' . - html_print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .''), - 'editor' => array( - 'active' => false, - 'text' => '' . - html_print_image ("images/add.png", true, array ("title" => __('New Incident'))) .'')); + 'list' => array( + 'active' => false, + 'text' => '' . + html_print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .''), + 'editor' => array( + 'active' => false, + 'text' => '' . + html_print_image ("images/add.png", true, array ("title" => __('New Incident'))) .'')); } else { $buttons = array( - 'list' => array( - 'active' => false, - 'text' => '' . - html_print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .''), - 'incident' => array( - 'active' => false, - 'text' => '' . - html_print_image ("images/eye.png", true, array ("title" => __('Incident details'))) .''), - 'workunits' => array( - 'active' => false, - 'text' => '' . - html_print_image ("images/computer.png", true, array ("title" => __('Workunits'))) .''), - 'files' => array( - 'active' => false, - 'text' => '' . - html_print_image ("images/file.png", true, array ("title" => __('Files'))) .''), - 'tracking' => array( - 'active' => false, - 'text' => '' . - html_print_image ("images/comments.png", true, array ("title" => __('Tracking'))) .'')); + 'list' => array( + 'active' => false, + 'text' => '' . + html_print_image ("images/page_white_text.png", true, array ("title" => __('Incidents'))) .''), + 'incident' => array( + 'active' => false, + 'text' => '' . + html_print_image ("images/eye.png", true, array ("title" => __('Incident details'))) .''), + 'workunits' => array( + 'active' => false, + 'text' => '' . + html_print_image ("images/computer.png", true, array ("title" => __('Workunits'))) .''), + 'files' => array( + 'active' => false, + 'text' => '' . + html_print_image ("images/file.png", true, array ("title" => __('Files'))) .''), + 'tracking' => array( + 'active' => false, + 'text' => '' . + html_print_image ("images/comments.png", true, array ("title" => __('Tracking'))) .'')); } - + $buttons[$tab]['active'] = true; ui_print_page_header (__('Incident management'), "images/book_edit.png", false, "", false, $buttons); -if($update_incident == 1) { +if ($update_incident == 1) { $values[0] = $id_incident; $values[1] = urlencode(io_safe_output(get_parameter('title'))); $values[2] = urlencode(io_safe_output(get_parameter('description'))); @@ -105,7 +105,7 @@ if($update_incident == 1) { $create_incident = get_parameter('create_incident', 0); -if($create_incident == 1) { +if ($create_incident == 1) { $values[0] = urlencode(io_safe_output(get_parameter('title'))); $values[1] = get_parameter('group'); @@ -132,8 +132,8 @@ if($create_incident == 1) { $attach_file = get_parameter('attach_file', 0); -if($attach_file == 1) { - if($_FILES['new_file']['name'] != "" && $_FILES['new_file']['error'] == 0) { +if ($attach_file == 1) { + if ($_FILES['new_file']['name'] != "" && $_FILES['new_file']['error'] == 0) { $file_content = file_get_contents($_FILES["new_file"]["tmp_name"]); $values[0] = $id_incident; @@ -172,6 +172,7 @@ if($attach_file == 1) { break; default: ui_print_error_message (__('Generic upload error').'(Code: '.$_FILES['new_file']['error'].')'); + break; } } } diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index 66d35a7050..3c4e603026 100644 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -44,6 +44,7 @@ if (is_ajax ()) if (enterprise_include_once('include/functions_policies.php') !== ENTERPRISE_NOT_HOOK) { $enterpriseEnable = true; require_once ('enterprise/include/functions_policies.php'); + require_once ('enterprise/meta/include/functions_ui_meta.php'); } $type = get_parameter('type'); @@ -59,10 +60,11 @@ if (is_ajax ()) $server = metaconsole_get_connection ($server_name); metaconsole_connect($server); $console_url = $server['server_url'] . '/'; - } else { + } + else { $console_url = ''; } - + treeview_printTable($id_agente, $console_url); if (defined ('METACONSOLE')) { @@ -123,7 +125,7 @@ if (is_ajax ()) metaconsole_restore_db(); } $countRows = count ($rows); - + //Empty Branch if ($countRows === 0) { echo "