From 92301209b708c83508668d339344bfcdc393748d Mon Sep 17 00:00:00 2001 From: darode Date: Mon, 19 Nov 2012 18:10:48 +0000 Subject: [PATCH] 2012-11-19 Dario Rodriguez * operation/integria_incidents/incident.list.php, operation/integria_incidents/incident.incident.php, operation/integria_incidents/incident.php, operation/integria_incidents/incident.files.php, operation/integria_incidents/incident.workunits.php: Fixed several errors in behavior, added messages about operation result and added style to buttons. MERGED FROM 4.0.2 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7160 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 11 +++ .../integria_incidents/incident.files.php | 2 +- .../integria_incidents/incident.incident.php | 6 +- .../integria_incidents/incident.list.php | 2 +- .../operation/integria_incidents/incident.php | 78 ++++++++++++++++--- .../integria_incidents/incident.workunits.php | 2 +- 6 files changed, 85 insertions(+), 16 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9313ea0c00..be8578e7f3 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2012-11-19 Dario Rodriguez + + * operation/integria_incidents/incident.list.php, + operation/integria_incidents/incident.incident.php, + operation/integria_incidents/incident.php, + operation/integria_incidents/incident.files.php, + operation/integria_incidents/incident.workunits.php: Fixed several errors + in behavior, added messages about operation result and added style to buttons. + + MERGED FROM 4.0.2 + 2012-11-19 Junichi Satoh * godmode/agentes/planned_downtime.editor.php: Allowed to change diff --git a/pandora_console/operation/integria_incidents/incident.files.php b/pandora_console/operation/integria_incidents/incident.files.php index a2c455b672..9990dd4944 100644 --- a/pandora_console/operation/integria_incidents/incident.files.php +++ b/pandora_console/operation/integria_incidents/incident.files.php @@ -26,7 +26,7 @@ $table->data[1][0] = "".__('Description')."
".html_print_textarea('de $form = "
"; $form .= html_print_table($table, true); -$form .= html_print_submit_button(__('Add'), 'submit_button', false, '', true); +$form .= html_print_submit_button(__('Add'), 'submit_button', false, 'class="sub next"', true); $form .= html_print_input_hidden('tab', 'files', true); $form .= html_print_input_hidden('attach_file', '1', true); $form .= html_print_input_hidden('id_incident', $id_incident, true); diff --git a/pandora_console/operation/integria_incidents/incident.incident.php b/pandora_console/operation/integria_incidents/incident.incident.php index 021d1ed4af..dd9c01d9c2 100644 --- a/pandora_console/operation/integria_incidents/incident.incident.php +++ b/pandora_console/operation/integria_incidents/incident.incident.php @@ -121,7 +121,7 @@ $table->data[4][0] = "".__('Resolution epilog')."
".html_print_textar if(isset($result['id_incidencia'])) { echo ""; html_print_table($table); - html_print_submit_button(__('Update'), 'submit_button'); + html_print_submit_button(__('Update'), 'submit_button', false, "class='sub upd'"); html_print_input_hidden('tab', 'incident'); html_print_input_hidden('update_incident', '1'); html_print_input_hidden('id_incident', $result['id_incidencia']); @@ -130,8 +130,8 @@ if(isset($result['id_incidencia'])) { else { echo ""; html_print_table($table); - html_print_submit_button(__('Create'), 'submit_button'); - html_print_input_hidden('tab', 'incident'); + html_print_submit_button(__('Create'), 'submit_button', false, "class='sub next'"); + html_print_input_hidden('tab', 'list'); html_print_input_hidden('create_incident', '1'); echo "
"; } diff --git a/pandora_console/operation/integria_incidents/incident.list.php b/pandora_console/operation/integria_incidents/incident.list.php index 54608ad0f7..f32d812c9e 100644 --- a/pandora_console/operation/integria_incidents/incident.list.php +++ b/pandora_console/operation/integria_incidents/incident.list.php @@ -73,7 +73,7 @@ html_print_select ($groups, 'search_group', $search_group, '', '', 0, false, fal } echo ''; echo ''; -html_print_submit_button (__('Search')); +html_print_submit_button (__('Search'), '', false, "class='sub search'"); echo ''; echo ''; diff --git a/pandora_console/operation/integria_incidents/incident.php b/pandora_console/operation/integria_incidents/incident.php index 8c71319c64..4c53abb852 100755 --- a/pandora_console/operation/integria_incidents/incident.php +++ b/pandora_console/operation/integria_incidents/incident.php @@ -49,13 +49,23 @@ if($update_incident == 1) { $params = implode($token, $values); $url = $integria_api."&op=update_incident&token=".$token."¶ms=".$params; + // Call the integria API $result = incidents_call_api($url); + + $result_array = incidents_xml_to_array($result); + + if ($result_array['data']) { + ui_print_success_message (__("Incident updated")); + } else { + ui_print_error_message (__("There was a problem updating the incident, please check if any field was modified and the values are correct.")); + } } $create_incident = get_parameter('create_incident', 0); if($create_incident == 1) { + $values[0] = str_replace(" ", "%20", io_safe_output(get_parameter('title'))); $values[1] = get_parameter('group'); $values[2] = get_parameter('priority'); @@ -67,9 +77,15 @@ if($create_incident == 1) { $url = $integria_api."&op=create_incident&token=".$token."¶ms=".$params; // Call the integria API - $result = incidents_xml_to_array(incidents_call_api($url)); + $result = incidents_call_api($url); - $id_incident = $result['data']; + $result_array = incidents_xml_to_array($result); + + if ($result_array['data']) { + ui_print_success_message (__("Incident created")); + } else { + ui_print_error_message (__("There was a problem creating incident")); + } } // Header @@ -121,7 +137,7 @@ if($attach_file == 1) { $values[0] = $id_incident; $values[1] = $_FILES['new_file']['name']; $values[2] = $_FILES['new_file']['size']; - $values[3] = str_replace(" ", "%20", io_safe_output(get_parameter('description'), __('No description available'))); + $values[3] = io_safe_output(get_parameter('description'), __('No description available')); $values[4] = base64_encode($file_content); @@ -131,31 +147,49 @@ if($attach_file == 1) { // Call the integria API $result = incidents_call_api($url, array('params' => $params)); + + $result_array = incidents_xml_to_array($result); + + if ($result_array['data'] == 0) { + ui_print_success_message (__("File uploaded")); + } else { + ui_print_error_message (__("There was a problem uploading file")); + } } else { switch ($_FILES['new_file']['error']) { case 1: - echo '

'.__('File is too big').'

'; + ui_print_error_message (__('File is too big')); break; case 3: - echo '

'.__('File was partially uploaded. Please try again').'

'; + ui_print_error_message (__('File was partially uploaded. Please try again')); break; case 4: - echo '

'.__('No file was uploaded').'

'; + ui_print_error_message (__('No file was uploaded')); break; default: - echo '

'.__('Generic upload error').'(Code: '.$_FILES['new_file']['error'].')

'; + ui_print_error_message (__('Generic upload error').'(Code: '.$_FILES['new_file']['error'].')'); } } } $delete_file = get_parameter('delete_file', 0); -if($delete_file != 0) { +if($delete_file != 0 && !$attach_file) { $url = $integria_api."&op=delete_file¶ms=".$delete_file; // Call the integria API $result = incidents_call_api($url); + + $result = incidents_call_api($url, array('params' => $params)); + + $result_array = incidents_xml_to_array($result); + + if ($result_array['data'] == 0 || $result_array['data'] == -2) { + ui_print_success_message (__("File deleted")); + } else if ($result_array['data'] == -1) { + ui_print_error_message (__("You user doesn't have enough rights to delete this file")); + } } $delete_incident = get_parameter('delete_incident', 0); @@ -165,6 +199,14 @@ if($delete_incident != 0) { // Call the integria API $result = incidents_call_api($url); + + $result_array = incidents_xml_to_array($result); + + if ($result_array['data']) { + ui_print_success_message (__("Incident deleted")); + } else { + ui_print_error_message (__("There was a problem deteling incident")); + } } $create_workunit = get_parameter('create_workunit', 0); @@ -183,11 +225,22 @@ if($create_workunit == 1) { // Call the integria API $result = incidents_call_api($url); + + $result_array = incidents_xml_to_array($result); + + if ($result_array['data']) { + ui_print_success_message (__("Workunit added")); + } else { + ui_print_error_message (__("There was a problem adding workunit")); + } } +$params = array(); + // Set the url with parameters to call the api switch($tab) { case 'list': + $search_string = get_parameter('search_string', ""); $params[0] = $search_string; @@ -196,7 +249,7 @@ switch($tab) { $search_group = get_parameter('search_group', 1); $params[2] = $search_group; - + $params = implode($token,$params); $url = $integria_api."&op=get_incidents&token=".$token."¶ms=".$params; @@ -205,8 +258,13 @@ switch($tab) { $url_groups = $integria_api."&op=get_groups¶ms=1"; break; case 'incident': - $url = $integria_api."&op=get_incident_details¶ms=".$id_incident; case 'editor': + //Request incident information if any + if ($id_incident) { + $url = $integria_api."&op=get_incident_details¶ms=".$id_incident; + } else { + $url = $integria_api."&op=get_incident_details"; + } $url_resolutions = $integria_api."&op=get_incidents_resolutions"; $url_status = $integria_api."&op=get_incidents_status"; $url_sources = $integria_api."&op=get_incidents_sources"; diff --git a/pandora_console/operation/integria_incidents/incident.workunits.php b/pandora_console/operation/integria_incidents/incident.workunits.php index 7350810434..f320ea2b8a 100644 --- a/pandora_console/operation/integria_incidents/incident.workunits.php +++ b/pandora_console/operation/integria_incidents/incident.workunits.php @@ -32,7 +32,7 @@ $table->data[1][0] = "".__('Description')."
".html_print_textarea('de $form = "
"; $form .= html_print_table($table, true); -$form .= html_print_submit_button(__('Add'), 'submit_button', false, '', true); +$form .= html_print_submit_button(__('Add'), 'submit_button', false, 'class="sub next"', true); $form .= html_print_input_hidden('tab', 'workunits', true); $form .= html_print_input_hidden('create_workunit', '1', true); $form .= html_print_input_hidden('id_incident', $id_incident, true);