2019-08-08 13:36:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2010 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
|
|
|
|
// as published by the Free Software Foundation for version 2.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
// Load global vars
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
check_login();
|
|
|
|
|
|
|
|
if (! check_acl($config['id_user'], 0, 'IR') && ! check_acl($config['id_user'], 0, 'IW') && ! check_acl($config['id_user'], 0, 'IM')) {
|
2019-09-02 17:01:41 +02:00
|
|
|
// Doesn't have access to this page.
|
2019-08-08 13:36:12 +02:00
|
|
|
db_pandora_audit('ACL Violation', 'Trying to access IntegriaIMS ticket creation');
|
|
|
|
include 'general/noaccess.php';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui_print_page_header(__('Create Integria IMS Incident'), '', false, '', false, '');
|
|
|
|
|
2019-09-02 17:01:41 +02:00
|
|
|
// Check if Integria integration enabled.
|
2019-08-08 13:36:12 +02:00
|
|
|
if ($config['integria_enabled'] == 0) {
|
|
|
|
ui_print_error_message(__('Integria integration must be enabled in Pandora setup'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-02 17:01:41 +02:00
|
|
|
// Check connection to Integria IMS API.
|
|
|
|
$has_connection = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_login', []);
|
2019-08-08 13:36:12 +02:00
|
|
|
|
2019-09-02 17:01:41 +02:00
|
|
|
if ($has_connection === false) {
|
|
|
|
ui_print_error_message(__('Integria IMS API is not reachable'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If everything OK, get parameters from Integria IMS API.
|
|
|
|
$group_values = [];
|
|
|
|
$integria_criticity_values = [];
|
|
|
|
$integria_users_values = [];
|
|
|
|
$integria_types_values = [];
|
|
|
|
|
|
|
|
$integria_groups_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_groups', []);
|
|
|
|
|
|
|
|
get_array_from_csv_data($integria_groups_csv, $group_values);
|
|
|
|
|
|
|
|
$integria_criticity_levels_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_incident_priorities', []);
|
|
|
|
|
|
|
|
get_array_from_csv_data($integria_criticity_levels_csv, $integria_criticity_values);
|
|
|
|
|
|
|
|
$integria_users_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_users', []);
|
|
|
|
|
|
|
|
$csv_array = explode("\n", $integria_users_csv);
|
|
|
|
|
|
|
|
foreach ($csv_array as $csv_line) {
|
|
|
|
if (!empty($csv_line)) {
|
|
|
|
$integria_users_values[$csv_line] = $csv_line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$integria_types_csv = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'get_types', []);
|
|
|
|
|
|
|
|
get_array_from_csv_data($integria_types_csv, $integria_types_values);
|
|
|
|
|
|
|
|
$event_id = (int) get_parameter('from_event');
|
2019-08-08 13:36:12 +02:00
|
|
|
$create_incident = (int) get_parameter('create_incident', 0);
|
2019-09-02 17:01:41 +02:00
|
|
|
$incident_group_id = (int) get_parameter('default_group');
|
2019-08-08 13:36:12 +02:00
|
|
|
$incident_default_criticity_id = (int) get_parameter('default_criticity');
|
|
|
|
$incident_default_owner = (int) get_parameter('default_owner');
|
|
|
|
$incident_type = (int) get_parameter('incident_type');
|
2019-09-02 17:01:41 +02:00
|
|
|
$incident_title = events_get_field_value_by_event_id($event_id, get_parameter('incident_title'));
|
|
|
|
$incident_content = events_get_field_value_by_event_id($event_id, get_parameter('incident_content'));
|
|
|
|
|
|
|
|
if ($create_incident === 1) {
|
|
|
|
// Call Integria IMS API method to create an incident.
|
|
|
|
$result_api_call = integria_api_call($config['integria_hostname'], $config['integria_user'], $config['integria_pass'], $config['integria_api_pass'], 'create_incident', [$incident_title, $incident_group_id, $incident_default_criticity_id, $incident_content, '', '0', '', 'admin', '0', '1']);
|
2019-08-08 13:36:12 +02:00
|
|
|
|
2019-09-02 17:01:41 +02:00
|
|
|
$incident_created_ok = ($result_api_call != false) ? true : false;
|
2019-08-08 13:36:12 +02:00
|
|
|
|
2019-09-02 17:01:41 +02:00
|
|
|
ui_print_result_message(
|
|
|
|
$incident_created_ok,
|
|
|
|
__('Successfully created'),
|
|
|
|
__('Could not be created')
|
|
|
|
);
|
|
|
|
}
|
2019-08-08 13:36:12 +02:00
|
|
|
|
|
|
|
$table = new stdClass();
|
|
|
|
$table->width = '100%';
|
|
|
|
$table->id = 'add_alert_table';
|
|
|
|
$table->class = 'databox filters';
|
|
|
|
$table->head = [];
|
|
|
|
|
|
|
|
$table->data = [];
|
|
|
|
$table->size = [];
|
|
|
|
$table->size = [];
|
|
|
|
$table->size[0] = '15%';
|
|
|
|
$table->size[1] = '90%';
|
|
|
|
|
|
|
|
$table->data[0][0] = __('Group');
|
|
|
|
$table->data[0][1] = html_print_select(
|
2019-09-02 17:01:41 +02:00
|
|
|
$group_values,
|
|
|
|
'default_group',
|
|
|
|
$config['default_group'],
|
2019-08-08 13:36:12 +02:00
|
|
|
'',
|
|
|
|
__('Select'),
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
|
|
|
$table->data[1][0] = __('Default Criticity');
|
|
|
|
$table->data[1][1] = html_print_select(
|
2019-09-02 17:01:41 +02:00
|
|
|
$integria_criticity_values,
|
2019-08-08 13:36:12 +02:00
|
|
|
'default_criticity',
|
2019-09-02 17:01:41 +02:00
|
|
|
$config['default_criticity'],
|
2019-08-08 13:36:12 +02:00
|
|
|
'',
|
|
|
|
__('Select'),
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
|
|
|
$table->data[2][0] = __('Default Owner');
|
|
|
|
$table->data[2][1] = html_print_select(
|
2019-09-02 17:01:41 +02:00
|
|
|
$integria_users_values,
|
2019-08-08 13:36:12 +02:00
|
|
|
'default_owner',
|
2019-09-02 17:01:41 +02:00
|
|
|
$config['default_owner'],
|
2019-08-08 13:36:12 +02:00
|
|
|
'',
|
|
|
|
__('Select'),
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
|
|
|
$table->data[0][2] = __('Incident Type');
|
|
|
|
$table->data[0][3] = html_print_select(
|
2019-09-02 17:01:41 +02:00
|
|
|
$integria_types_values,
|
2019-08-08 13:36:12 +02:00
|
|
|
'incident_type',
|
2019-09-02 17:01:41 +02:00
|
|
|
$config['incident_type'],
|
2019-08-08 13:36:12 +02:00
|
|
|
'',
|
|
|
|
__('Select'),
|
|
|
|
0,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true,
|
|
|
|
'',
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
2019-09-02 17:01:41 +02:00
|
|
|
$table->data[1][2] = __('Incident title').ui_print_help_icon('response_macros', true);
|
2019-08-08 13:36:12 +02:00
|
|
|
$table->data[1][3] = html_print_input_text(
|
|
|
|
'incident_title',
|
2019-09-02 17:01:41 +02:00
|
|
|
$config['incident_title'],
|
2019-08-08 13:36:12 +02:00
|
|
|
__('Name'),
|
|
|
|
50,
|
|
|
|
100,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
2019-09-02 17:01:41 +02:00
|
|
|
$table->data[2][2] = __('Incident content').ui_print_help_icon('response_macros', true);
|
2019-08-08 13:36:12 +02:00
|
|
|
$table->data[2][3] = html_print_input_text(
|
|
|
|
'incident_content',
|
2019-09-02 17:01:41 +02:00
|
|
|
$config['incident_content'],
|
2019-08-08 13:36:12 +02:00
|
|
|
'',
|
|
|
|
50,
|
|
|
|
100,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
echo '<form name="create_integria_incident_form" method="POST">';
|
|
|
|
html_print_table($table);
|
2019-09-02 17:01:41 +02:00
|
|
|
html_print_input_hidden('create_incident', 1);
|
|
|
|
echo '<div style="width: 100%; text-align:right;">';
|
2019-08-08 13:36:12 +02:00
|
|
|
html_print_submit_button(__('Create'), 'accion', false, 'class="sub wand"');
|
2019-09-02 17:01:41 +02:00
|
|
|
echo '</div>';
|
2019-08-08 13:36:12 +02:00
|
|
|
echo '</form>';
|