'.__('metaconsole').'' ) ); } $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']; $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'; if (defined('METACONSOLE')) { if ($id) { $table->head[0] = __('Update Action'); } else { $table->head[0] = __('Create Action'); } $table->head_colspan[0] = 4; $table->headstyle[0] = 'text-align: center'; } $table->style = []; $table->style[0] = 'font-weight: bold'; $table->size = []; $table->size[0] = '20%'; $table->data = []; $table->data[0][0] = __('Name'); $table->data[0][1] = 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' ); } $table->colspan[0][1] = 2; $table->data[1][0] = __('Group'); $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[1][1] = '
'.html_print_select_groups( false, 'LW', $return_all_group, 'group', $group, '', '', 0, true, false, true, '', (!$is_management_allowed | $disabled) ).'
'; $table->colspan[1][1] = 2; $create_ticket_command_id = db_get_value('id', 'talert_commands', 'name', io_safe_input('Integria IMS Ticket')); $sql_exclude_command_id = ''; if ($config['integria_enabled'] == 0 && $create_ticket_command_id !== false) { $sql_exclude_command_id = ' AND id <> '.$create_ticket_command_id; } $table->data[2][0] = __('Command'); $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 ); $table->data[2][1] = html_print_select_from_sql( $commands_sql, 'id_command', $id_command, '', __('None'), 0, true, false, false, (!$is_management_allowed | $disabled) ); $table->data[2][1] .= ' '; if ($is_management_allowed === true && check_acl($config['id_user'], 0, 'PM') && !$disabled ) { $table->data[2][1] .= __('Create Command'); $table->data[2][1] .= ''; $table->data[2][1] .= html_print_image('images/add.png', true); $table->data[2][1] .= ''; } $table->data[2][1] .= '
'; $table->colspan[2][1] = 2; $table->data[3][0] = __('Threshold'); $table->data[3][1] = html_print_extended_select_for_time( 'action_threshold', $action_threshold, '', '', '', false, true, false, true, '', (!$is_management_allowed | $disabled), false, '', false, true ); $table->colspan[3][1] = 2; $table->data[4][0] = ''; $table->data[4][1] = __('Firing'); $table->data[4][2] = __('Recovery'); $table->cellstyle[4][1] = 'font-weight: bold;'; $table->cellstyle[4][2] = 'font-weight: bold;'; $table->data[5][0] = __('Command preview'); $table->data[5][1] = html_print_textarea( 'command_preview', 5, 30, '', 'disabled="disabled"', true ); $table->data[5][2] = html_print_textarea( 'command_recovery_preview', 5, 30, '', 'disabled="disabled"', true ); // Selector will work only with Integria activated. $integriaIdName = 'integria_wu'; $table->data[$integriaIdName][0] = __('Create workunit on recovery').ui_print_help_tip( __('If closed status is set on recovery, a workunit will be added to the ticket in Integria IMS rather that closing the ticket.'), true ); $table->data[$integriaIdName][1] = 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->data['field'.$i][0] = html_print_image( 'images/spinner.gif', true ); $table->data['field'.$i][1] = html_print_image( 'images/spinner.gif', true ); $table->data['field'.$i][2] = html_print_image( 'images/spinner.gif', true ); // Store the value in a hidden to keep it on first execution $table->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->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 ); } echo '
'; $table_html = html_print_table($table, true); echo $table_html; if ($is_management_allowed === true) { echo '
'; if ($id) { html_print_input_hidden('id', $id); if (!$disabled) { html_print_input_hidden('update_action', 1); html_print_submit_button( __('Update'), 'create', false, 'class="sub upd"' ); } else { echo '
'; echo ''; html_print_submit_button(__('Back'), 'back', false, 'class="sub upd"'); echo ''; echo '
'; } } else { html_print_input_hidden('create_action', 1); html_print_submit_button( __('Create'), 'create', false, 'class="sub wand"' ); } echo '
'; } echo ''; enterprise_hook('close_meta_frame'); ui_require_javascript_file('pandora_alerts'); ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/'); ?>