width = '100%'; $table_filter->class = 'databox filters'; $table_filter->style = []; $table_filter->style[0] = 'font-weight: bold'; $table_filter->style[2] = 'font-weight: bold'; $table_filter->style[4] = 'font-weight: bold'; $table_filter->data = []; $table_filter->data[0][0] = __('Search'); $table_filter->data[0][1] = html_print_input_text( 'search_string', $search_string, '', 25, 255, true ); $return_all_group = false; if (users_can_manage_group_all('LM') === true) { $return_all_group = true; } $table_filter->data[0][2] = __('Group'); $table_filter->data[0][3] = html_print_select_groups( $config['id_user'], 'LM', $return_all_group, 'group_search', $group_search, '', '', 0, true ); $table_filter->data[0][4] = __('Command'); $commands_sql = db_get_all_rows_filter( 'talert_commands', ['id_group' => array_keys(users_get_groups(false, 'LW'))], [ 'id', 'name', ], 'AND', false, true ); $commands = db_get_all_rows_sql($commands_sql); $table_filter->data[0][5] = html_print_select( index_array($commands, 'id', 'name'), 'id_command_search', $id_command_search, '', __('None'), 0, true, false, true, '', false, 'width:150px' ); $table_filter->data[0][6] = '
'; $show_table_filter = ''; if (is_metaconsole()) { ui_toggle($show_table_filter, __('Show Options')); } else { echo $show_table_filter; } $table = new stdClass(); $table->width = '100%'; $table->class = 'info_table'; $table->data = []; $table->head = []; $table->head[0] = __('Name'); $table->head[1] = __('Command'); $table->head[2] = __('Group'); if (is_central_policies_on_node() === false) { $table->head[3] = __('Copy'); $table->head[4] = __('Delete'); } $table->style = []; $table->style[0] = 'font-weight: bold'; $table->size = []; $table->size[3] = '40px'; $table->size[4] = '40px'; $table->align = []; $table->align[1] = 'left'; $table->align[2] = 'left'; $table->align[3] = 'left'; $table->align[4] = 'left'; $filter = []; if (!is_user_admin($config['id_user']) && $group === 0) { $filter['talert_actions.id_group'] = array_keys( users_get_groups(false, 'LM') ); } if ($group_search !== 0) { $filter['talert_actions.id_group'] = $group_search; } if ($search_string !== '') { $filter['talert_actions.name'] = '%'.$search_string.'%'; } if ($id_command_search !== 0) { $filter['talert_commands.id'] = $id_command_search; } $actions = db_get_all_rows_filter( 'talert_actions INNER JOIN talert_commands ON talert_actions.id_alert_command = talert_commands.id', $filter, 'talert_actions.* , talert_commands.id_group AS command_group, talert_commands.name AS command_name' ); if ($actions === false) { $actions = []; } // Pagination. $total_actions = count($actions); $offset = (int) get_parameter('offset'); $limit = (int) $config['block_size']; $actions = array_slice($actions, $offset, $limit); $rowPair = true; $iterator = 0; foreach ($actions as $action) { if ($rowPair) { $table->rowclass[$iterator] = 'rowPair'; } else { $table->rowclass[$iterator] = 'rowOdd'; } $rowPair = !$rowPair; $iterator++; $data = []; if (check_acl_restricted_all($config['id_user'], $action['id_group'], 'LM')) { $data[0] = ''.$action['name'].''; } else { $data[0] = $action['name']; } $data[1] = $action['command_name']; $data[2] = ui_print_group_icon($action['id_group'], true).' '; if (!alerts_validate_command_to_action($action['id_group'], $action['command_group'])) { $data[2] .= html_print_image( 'images/error.png', true, // FIXME: Translation. [ 'title' => __('The action and the command associated with it do not have the same group. Please contact an administrator to fix it.'), ] ); } $data[3] = ''; $data[4] = ''; if (is_central_policies_on_node() === false && check_acl_restricted_all($config['id_user'], $action['id_group'], 'LM') ) { $table->cellclass[] = [ 3 => 'action_buttons', 4 => 'action_buttons', ]; $id_action = $action['id']; $text_confirm = __('Are you sure?'); $data[3] = ''.html_print_image('images/copy.png', true).''; $data[4] = ''.html_print_image('images/cross.png', true).''; } array_push($table->data, $data); } ui_pagination($total_actions, $url); if (isset($data)) { html_print_table($table); ui_pagination($total_actions, $url, 0, 0, false, 'offset', true, 'pagination-bottom'); } else { ui_print_info_message(['no_close' => true, 'message' => __('No alert actions configured') ]); } if (is_central_policies_on_node() === false) { echo ' '; } enterprise_hook('close_meta_frame'); ?>