getObjecTypesFields($ticket_type_id); } catch (\Throwable $th) { $error = $th->getMessage(); } echo json_encode($fields); } return; } } if (defined('METACONSOLE')) { $sec = 'advanced'; } else { $sec = 'galertas'; } if ($al_action !== false) { $own_info = get_user_info($config['id_user']); if ($own_info['is_admin'] || check_acl_restricted_all($config['id_user'], 0, 'LM')) { $own_groups = array_keys(users_get_groups($config['id_user'], 'LM')); } else { $own_groups = array_keys(users_get_groups($config['id_user'], 'LM', false)); } $is_in_group = in_array($al_action['id_group'], $own_groups); // Header. if (defined('METACONSOLE')) { alerts_meta_print_header(); } else { ui_print_standard_header( __('Alerts'), 'images/gm_alerts.png', false, '', true, [], [ [ 'link' => '', 'label' => __('Configure alert action'), ], ] ); } } else { // Header. if (defined('METACONSOLE')) { alerts_meta_print_header(); } else { ui_print_standard_header( __('Alerts'), 'images/gm_alerts.png', false, '', true, [], [ [ 'link' => '', 'label' => __('Configure alert action'), ], ] ); } $is_in_group = true; } if (!$is_in_group && $al_action['id_group'] != 0) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access unauthorized alert action configuration' ); include 'general/noaccess.php'; exit; } $is_management_allowed = is_management_allowed(); if ($is_management_allowed === false) { if (is_metaconsole() === false) { $url = ''.__('metaconsole').''; } else { $url = __('any node'); } ui_print_warning_message( __( 'This node is configured with centralized mode. All alert actions information is read only. Go to %s to manage it.', $url ) ); } $disabled = !$is_in_group; $disabled_attr = ''; if ($disabled) { $disabled_attr = 'disabled="disabled"'; } $name = ''; $id_command = ''; $group = 0; $action_threshold = '0'; // All group is 0. if ($id) { $action = alerts_get_alert_action($id); $name = $action['name']; $id_command = $action['id_alert_command']; $command = alerts_get_alert_command($id_command); if (empty($command) === false && $command['name'] === io_safe_input('Pandora ITSM Ticket')) { $action['field1'] = io_safe_output(($action['field1'] ?? $config['incident_title'])); $action['field2'] = io_safe_output(($action['field2'] ?? $config['default_group'])); $action['field3'] = io_safe_output(($action['field3'] ?? $config['default_criticity'])); $action['field4'] = io_safe_output(($action['field4'] ?? $config['default_owner'])); $action['field5'] = io_safe_output(($action['field5'] ?? $config['incident_type'])); $action['field6'] = io_safe_output(($action['field6'] ?? $config['incident_status'])); $action['field7'] = io_safe_output(($action['field7'] ?? $config['incident_content'])); $action['field2_recovery'] = io_safe_output(($action['field2'] ?? $config['default_group'])); $action['field3_recovery'] = io_safe_output(($action['field3'] ?? $config['default_criticity'])); $action['field4_recovery'] = io_safe_output(($action['field4'] ?? $config['default_owner'])); $action['field5_recovery'] = io_safe_output(($action['field5'] ?? $config['incident_type'])); $action['field6_recovery'] = io_safe_output(($action['field6_recovery'] ?? $config['incident_status'])); $action['field7_recovery'] = io_safe_output(($action['field7_recovery'] ?? $config['incident_content'])); } $group = $action['id_group']; $action_threshold = $action['action_threshold']; $create_wu_integria = $action['create_wu_integria']; } if (users_can_manage_group_all('LW') === false && !$id) { $group = users_get_first_group(false, 'LW', false); } // Hidden div with help hint to fill with javascript. html_print_div( [ 'id' => 'help_alert_macros_hint', 'content' => ui_print_help_icon('alert_macros', true), 'hidden' => true, ] ); $table = new stdClass(); $table->id = 'table_macros'; $table->width = '100%'; $table->class = 'databox filters filter-table-adv'; $table->style = []; $table->size = []; $table->size[0] = '50%'; $table->size[1] = '50%'; $table->data = []; $table->data[0][0] = html_print_label_input_block( __('Name'), html_print_input_text( 'name', $name, '', 35, 255, true, false, false, '', '', '', '', false, '', '', '', (!$is_management_allowed | $disabled) ) ); if (io_safe_output($name) == 'Monitoring Event') { $table->data[0][1] .= ' '.ui_print_help_tip( __('This action may stop working, if you change its name.'), true, 'images/header_yellow.png' ); } $own_info = get_user_info($config['id_user']); $return_all_group = false; if (users_can_manage_group_all('LW') === true || $disabled) { $return_all_group = true; } $table->data[0][1] = html_print_label_input_block( __('Group'), html_print_select_groups( false, 'LW', $return_all_group, 'group', $group, '', '', 0, true, false, true, 'w100p', (!$is_management_allowed | $disabled) ) ); $create_ticket_command_id = db_get_value('id', 'talert_commands', 'name', io_safe_input('Pandora ITSM Ticket')); $sql_exclude_command_id = ''; if (!is_metaconsole() && $config['ITSM_enabled'] == 0 && $create_ticket_command_id !== false) { $sql_exclude_command_id = ' AND id <> '.$create_ticket_command_id; } $commands_sql = db_get_all_rows_filter( 'talert_commands', 'id_group IN ('.implode(',', array_keys(users_get_groups(false, 'LW'))).')'.$sql_exclude_command_id, [ 'id', 'name', ], 'AND', false, true ); $create_command = ' '; if ($is_management_allowed === true && check_acl($config['id_user'], 0, 'PM') && !$disabled ) { $create_command .= __('Create Command'); $create_command .= ''; $create_command .= html_print_image('images/add.png', true); $create_command .= ''; } $create_command .= '
'; $table->data[1][0] = html_print_label_input_block( __('Command'), html_print_select_from_sql( $commands_sql, 'id_command', $id_command, '', '', 0, true, false, false, (!$is_management_allowed | $disabled) ).$create_command ); $table->data[1][1] = html_print_label_input_block( __('Threshold').ui_print_help_tip(__('An alert action is executed only once within this time interval, regardless of how many times the alert is triggered.'), true), html_print_extended_select_for_time( 'action_threshold', $action_threshold, '', '', '', false, true, false, true, 'w100p', (!$is_management_allowed | $disabled), false, '', false, true ) ); $table_macros = new stdClass(); $table_macros->id = 'table_macros'; $table_macros->width = '100%'; $table_macros->class = 'databox filters filter-table-adv'; $table_macros->style = []; $table_macros->size = []; $table_macros->size[0] = '20%'; $table_macros->size[1] = '40%'; $table_macros->size[2] = '40%'; $table_macros->data = []; $table_macros->data[0][0] = ''; $table_macros->data[0][1] = html_print_label_input_block( __('Triggering'), '' ); $table_macros->data[0][2] = html_print_label_input_block( __('Recovery'), '' ); $table_macros->data[1][0] = html_print_label_input_block( __('Command preview'), '' ); $table_macros->data[1][1] = html_print_label_input_block( '', html_print_textarea( 'command_preview', 5, 30, '', 'disabled="disabled"', true ) ); $table_macros->data[1][2] = html_print_label_input_block( '', html_print_textarea( 'command_recovery_preview', 5, 30, '', 'disabled="disabled"', true ) ); if (empty($command) === false && $command['name'] === io_safe_input('Pandora ITSM Ticket')) { // Selector will work only with Integria activated. $integriaIdName = 'integria_wu'; $table_macros->colspan[$integriaIdName][0] = 3; $table_macros->data[$integriaIdName][0] = html_print_label_input_block( __('Create workunit on recovery').ui_print_help_tip( __('If closed status is set on recovery, a workunit will be added to the ticket in Pandora ITSM rather that closing the ticket.'), true ), html_print_checkbox_switch_extended( 'create_wu_integria', 1, $create_wu_integria, false, '', $disabled_attr, true ) ); } for ($i = 1; $i <= $config['max_macro_fields']; $i++) { $table_macros->data['field'.$i][0] = html_print_image( 'images/spinner.gif', true ); $table_macros->data['field'.$i][1] = html_print_image( 'images/spinner.gif', true ); $table_macros->data['field'.$i][2] = html_print_image( 'images/spinner.gif', true ); // Store the value in a hidden to keep it on first execution $table_macros->data['field'.$i][1] .= html_print_input_hidden( 'field'.$i.'_value', (!empty($action['field'.$i]) || $action['field'.$i] == 0) ? $action['field'.$i] : '', true, '', $disabled_attr ); $table_macros->data['field'.$i][2] .= html_print_input_hidden( 'field'.$i.'_recovery_value', (!empty($action['field'.$i.'_recovery']) || $action['field'.$i] == 0) ? $action['field'.$i.'_recovery'] : '', true, '', $disabled_attr ); } $offset = (int) get_parameter('offset', 0); echo ''; ui_require_javascript_file('pandora_alerts'); ui_require_javascript_file('tinymce', 'vendor/tinymce/tinymce/'); ui_require_javascript_file('alert'); ?>