diff --git a/pandora_console/godmode/setup/setup_integria.php b/pandora_console/godmode/setup/setup_integria.php index 7c6c3c6f47..4139487077 100644 --- a/pandora_console/godmode/setup/setup_integria.php +++ b/pandora_console/godmode/setup/setup_integria.php @@ -49,7 +49,7 @@ if (is_ajax()) { $has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []); -if ($has_connection === false) { +if ($has_connection === false && $config['integria_enabled']) { ui_print_error_message(__('Integria IMS API is not reachable')); } @@ -86,12 +86,10 @@ if (get_parameter('update_config', 0) == 1) { 'talert_commands', [ 'name' => io_safe_input('Integria IMS Ticket'), - 'command' => io_safe_input('perl /usr/share/pandora_server/util/integria_rticket.pl -p '.$config['integria_hostname'].'/integria/include/api.php -u '.$config['integria_api_pass'].','.$config['integria_user'].','.$config['integria_pass'].' -create_ticket -name "_field1_" -desc "_field2_" -group _field3_ -priority _field4_ -owner _field5_ -type _field6_'), + 'command' => io_safe_input('Internal type'), 'internal' => 1, 'description' => io_safe_input('Create an incident in Integria IMS'), - 'fields_descriptions' => '["'.io_safe_input('Ticket title').'","'.io_safe_input('Ticket description').'","'.io_safe_input('Ticket group ID').'","'.io_safe_input('Ticket priority').'","'.io_safe_input('Ticket owner').'","'.io_safe_input('Ticket type').'"]', - 'fields_values' => '["'.io_safe_input($config['incident_title']).'", "'.io_safe_input($config['incident_content']).'", "'.io_safe_input($config['default_group']).'", "'.io_safe_input($config['default_criticity']).'", "'.io_safe_input($config['default_owner']).'", "'.io_safe_input($config['incident_type']).'"]', - 'fields_hidden' => '["","","","","","","","","",""]', + 'fields_descriptions' => '["'.io_safe_input('Ticket title').'","'.io_safe_input('Ticket group ID').'","'.io_safe_input('Ticket priority').'","'.io_safe_input('Ticket owner').'","'.io_safe_input('Ticket type').'","'.io_safe_input('Ticket status').'","'.io_safe_input('Ticket description').'"]', ] ); @@ -99,44 +97,42 @@ if (get_parameter('update_config', 0) == 1) { $action_values = [ 'field1' => io_safe_input($config['incident_title']), 'field1_recovery' => io_safe_input($config['incident_title']), - 'field2' => io_safe_input($config['incident_content']), - 'field2_recovery' => io_safe_input($config['incident_content']), - 'field3' => io_safe_input($config['default_group']), - 'field3_recovery' => io_safe_input($config['default_group']), - 'field4' => io_safe_input($config['default_criticity']), - 'field4_recovery' => io_safe_input($config['default_criticity']), - 'field5' => io_safe_input($config['default_owner']), - 'field5_recovery' => io_safe_input($config['default_owner']), + 'field2' => io_safe_input($config['default_group']), + 'field2_recovery' => io_safe_input($config['default_group']), + 'field3' => io_safe_input($config['default_criticity']), + 'field3_recovery' => io_safe_input($config['default_criticity']), + 'field4' => io_safe_input($config['default_owner']), + 'field4_recovery' => io_safe_input($config['default_owner']), + 'field5' => io_safe_input($config['incident_type']), + 'field5_recovery' => io_safe_input($config['incident_type']), + 'field6' => io_safe_input($config['incident_status']), + 'field6_recovery' => io_safe_input($config['incident_status']), + 'field7' => io_safe_input($config['incident_content']), + 'field7_recovery' => io_safe_input($config['incident_content']), 'id_group' => 0, 'action_threshold' => 0, ]; alerts_create_alert_action(io_safe_input('Create Integria IMS ticket'), $id_command_inserted, $action_values); } else { - // Update 'Integria IMS Ticket' command setup when setup data is updated, user enables IntegriaIMS integration and it does exist in database. - db_process_sql_update( - 'talert_commands', - [ - 'command' => io_safe_input('perl /usr/share/pandora_server/util/integria_rticket.pl -p '.$config['integria_hostname'].'/integria/include/api.php -u '.$config['integria_api_pass'].','.$config['integria_user'].','.$config['integria_pass'].' -create_ticket -name "_field1_" -desc "_field2_" -group _field3_ -priority _field4_ -owner _field5_ -type _field6_'), - 'fields_values' => '["'.io_safe_input($config['incident_title']).'", "'.io_safe_input($config['incident_content']).'", "'.io_safe_input($config['default_group']).'", "'.io_safe_input($config['default_criticity']).'", "'.io_safe_input($config['default_owner']).'", "'.io_safe_input($config['incident_type']).'"]', - ], - ['name' => io_safe_input('Integria IMS Ticket')] - ); - // Update 'Create Integria IMS Ticket' action when setup data is updated, user enables IntegriaIMS integration and command does exist in database. db_process_sql_update( 'talert_actions', [ 'field1' => io_safe_input($config['incident_title']), 'field1_recovery' => io_safe_input($config['incident_title']), - 'field2' => io_safe_input($config['incident_content']), - 'field2_recovery' => io_safe_input($config['incident_content']), - 'field3' => io_safe_input($config['default_group']), - 'field3_recovery' => io_safe_input($config['default_group']), - 'field4' => io_safe_input($config['default_criticity']), - 'field4_recovery' => io_safe_input($config['default_criticity']), - 'field5' => io_safe_input($config['default_owner']), - 'field5_recovery' => io_safe_input($config['default_owner']), + 'field2' => io_safe_input($config['default_group']), + 'field2_recovery' => io_safe_input($config['default_group']), + 'field3' => io_safe_input($config['default_criticity']), + 'field3_recovery' => io_safe_input($config['default_criticity']), + 'field4' => io_safe_input($config['default_owner']), + 'field4_recovery' => io_safe_input($config['default_owner']), + 'field5' => io_safe_input($config['incident_type']), + 'field5_recovery' => io_safe_input($config['incident_type']), + 'field6' => io_safe_input($config['incident_status']), + 'field6_recovery' => io_safe_input($config['incident_status']), + 'field7' => io_safe_input($config['incident_content']), + 'field7_recovery' => io_safe_input($config['incident_content']), ], ['name' => io_safe_input('Create Integria IMS ticket')] ); @@ -324,17 +320,6 @@ $row['control'] = html_print_select( ); $table_cr_settings->data['custom_response_def_criticity'] = $row; -// Custom response default creator. -$row = []; -$row['name'] = __('Creator'); -$row['control'] = html_print_autocomplete_users_from_integria( - 'default_creator', - $config['default_creator'], - true -); - -$table_cr_settings->data['custom_response_def_creator'] = $row; - // Custom response default owner. $row = []; $row['name'] = __('Owner'); diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 598c341fca..ab3aad9c7a 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -3426,11 +3426,7 @@ function html_print_autocomplete_users_from_integria( ); html_print_input_hidden($name.'_hidden', $id_agent_module); - if ($disable === true) { - ui_print_help_tip(__('This value cannot be updated.'), false); - } else { - ui_print_help_tip(__('Type at least two characters to search the user.'), false); - } + ui_print_help_tip(__('Type at least two characters to search the user.'), false); $javascript_ajax_page = ui_get_full_url('ajax.php', false, false, false, false); ?> diff --git a/pandora_console/operation/incidents/configure_integriaims_incident.php b/pandora_console/operation/incidents/configure_integriaims_incident.php index 457a280a08..e837b9753f 100644 --- a/pandora_console/operation/incidents/configure_integriaims_incident.php +++ b/pandora_console/operation/incidents/configure_integriaims_incident.php @@ -102,22 +102,6 @@ $incident_content = events_get_field_value_by_event_id($event_id, get_parameter( $incident_title = str_replace(',', ':::', $incident_title); $incident_content = str_replace(',', ':::', $incident_content); -// If incident id is specified, retrieve incident values from api to populate combos with such values. -if ($update) { - // Call Integria IMS API method to get details of an incident given its id. - $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_details', [$incident_id_edit]); - - // API call does not return indexes, therefore future modifications of API function in Integria IMS may lead to inconsistencies when accessing resulting array in this file. - $incident_details_separator = explode(',', $result_api_call); - - $incident_details = array_map( - function ($item) { - return str_replace(':::', ',', $item); - }, - $incident_details_separator - ); -} - // Perform action. if ($create_incident === true) { // Call Integria IMS API method to create an incident. @@ -145,6 +129,22 @@ if ($create_incident === true) { ); } +// If incident id is specified, retrieve incident values from api to populate combos with such values. +if ($update) { + // Call Integria IMS API method to get details of an incident given its id. + $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_details', [$incident_id_edit]); + + // API call does not return indexes, therefore future modifications of API function in Integria IMS may lead to inconsistencies when accessing resulting array in this file. + $incident_details_separator = explode(',', $result_api_call); + + $incident_details = array_map( + function ($item) { + return str_replace(':::', ',', $item); + }, + $incident_details_separator + ); +} + // Main table. $table = new stdClass(); $table->width = '100%'; @@ -228,14 +228,18 @@ $table->data[1][1] .= '
'.html_print_select( ).'
'; $table->data[2][1] = '

'.__('Creator').':

'; -$table->data[2][1] .= '
'.html_print_autocomplete_users_from_integria( +$table->data[2][1] .= '
'.html_print_input_text( 'creator', - $update ? $incident_details[10] : $config['default_creator'], - true, + $config['integria_user'], + '', '30', - $update, - true -).'
'; + 100, + false, + true, + false, + '', + 'w100p' +).ui_print_help_tip(__('This field corresponds to the Integria IMS user specified in Integria IMS setup'), true).'
'; $table->data[1][2] = '

'.__('Criticity').':

'; $table->data[1][2] .= '
'.html_print_select( diff --git a/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php b/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php index b2dff81224..8d9b908c3a 100644 --- a/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php +++ b/pandora_console/operation/incidents/dashboard_detail_integriaims_incident.php @@ -167,6 +167,8 @@ if (check_acl($config['id_user'], 0, 'IW')) { __('File successfully added'), __('File could not be added') ); + } else { + ui_print_error_message(__('File has an invalid extension')); } } @@ -258,8 +260,13 @@ if (check_acl($config['id_user'], 0, 'IW')) { $table_files_section->data[2][0] .= '
'.html_print_submit_button(__('Upload'), 'accion', false, 'class="sub wand"', true).'
'; - $upload_file_form = '
'.'

'.__('Add attachment').'

'.html_print_table($table_files_section, true).html_print_input_hidden('upload_file', 1, true).'

'.__('Attached files').'

'.html_print_table($table_files, true).'
'; + $upload_file_form = '
'; + if (check_acl($config['id_user'], 0, 'IW')) { + $upload_file_form .= '
'.'

'.__('Add attachment').'

'.html_print_table($table_files_section, true).html_print_input_hidden('upload_file', 1, true); + } + + $upload_file_form .= '

'.__('Attached files').'

'.html_print_table($table_files, true).'
'; // Incident comments management. $upload_comment = get_parameter('upload_comment'); @@ -290,21 +297,27 @@ if (check_acl($config['id_user'], 0, 'IW')) { $table_comments->data = []; + $comment_disabled = ($array_get_incidents[6] == 7); + + if ($comment_disabled === true) { + $attribute = 'disabled=disabled'; + } + $table_comments_section->data[0][0] = '

'.__('Description').':

'; $table_comments_section->data[0][0] .= html_print_textarea( 'comment_description', 3, 20, '', - '', + $attribute, true ); - $table_comments_section->data[1][1] .= '
'.html_print_submit_button(__('Add'), 'accion', false, 'class="sub wand"', true).'
'; + $table_comments_section->data[1][1] .= '
'.html_print_submit_button(__('Add'), 'accion', $comment_disabled, 'class="sub wand"', true).'
'; - // Upload comment. - if ($upload_comment) { - $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'create_workunit', [$incident_id, $comment_description, '0.00', 'no', 'no', '0']); + // Upload comment. If ticket is closed, this action cannot be performed. + if ($upload_comment && $array_get_incidents[6] != 7) { + $result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'create_workunit', [$incident_id, $comment_description, '0.00', 0, 1, '0']); // API method returns id of new comment if success. $comment_added = ($result_api_call >= '0') ? true : false; @@ -330,18 +343,24 @@ if (check_acl($config['id_user'], 0, 'IW')) { } } - $upload_comment_form = ''; + $comment_table = ''; if (!empty($comments)) { foreach ($comments as $key => $value) { - $upload_comment_form .= '
'.$value[3].' said '.$value[1].''.$value[2].' Hours
'; - $upload_comment_form .= '
'.$value[4].'
'; + $comment_table .= '
'.$value[3].' said '.$value[1].''.$value[2].' Hours
'; + $comment_table .= '
'.$value[4].'
'; } } else { - $upload_comment_form = __('No comments found'); + $comment_table = __('No comments found'); } - $upload_comment_form = '

'.__('Add comment').'

'.html_print_table($table_comments_section, true).html_print_input_hidden('upload_comment', 1, true).'
'.'

'.__('Comments').'

'.$upload_comment_form.'
'; + $upload_comment_form = '
'; + + if (check_acl($config['id_user'], 0, 'IW')) { + $upload_comment_form .= '

'.__('Add comment').'

'.html_print_table($table_comments_section, true).html_print_input_hidden('upload_comment', 1, true).'
'; + } + + $upload_comment_form .= '

'.__('Comments').'

'.$comment_table.'
'; } @@ -420,33 +439,31 @@ $description_box = '
'.html_print_texta ).'
'; ui_toggle($description_box, __('Description'), '', '', false); -if (check_acl($config['id_user'], 0, 'IW')) { - echo '
'; - ui_toggle( - $upload_file_form, - __('Attached files'), - '', - '', - true, - false, - 'white_box white_box_opened', - 'no-border flex' - ); - echo '
'; +echo '
'; +ui_toggle( + $upload_file_form, + __('Attached files'), + '', + '', + true, + false, + 'white_box white_box_opened', + 'no-border flex' +); +echo '
'; - echo '
'; - ui_toggle( - $upload_comment_form, - __('Comments'), - '', - '', - true, - false, - 'white_box white_box_opened', - 'no-border flex' - ); - echo '
'; -} +echo '
'; +ui_toggle( + $upload_comment_form, + __('Comments'), + '', + '', + true, + false, + 'white_box white_box_opened', + 'no-border flex' +); +echo '
'; ?>