From b658fddfc2f3147310ee61e3338ad1f4441f7797 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Fri, 7 Feb 2020 13:58:26 +0100 Subject: [PATCH] visual changes in module creation --- .../agentes/module_manager_editor_common.php | 566 +++++++++--------- 1 file changed, 282 insertions(+), 284 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index f9685bcf87..90df118c35 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -182,19 +182,11 @@ $table_simple->cellclass = []; $table_simple->colspan = []; - - -$table_simple->colspan[6][1] = 3; - $table_simple->rowspan = []; -if (strstr($page, 'policy_modules')) { - $table_simple->rowspan[3][2] = 3; - $table_simple->colspan[3][2] = 2; -} else { - $table_simple->rowspan[4][2] = 3; - $table_simple->colspan[4][2] = 2; - $table_simple->colspan[5][1] = 3; -} + +$table_simple->rowspan[2][2] = 3; +$table_simple->colspan[2][2] = 2; +$table_simple->colspan[3][1] = 3; $table_simple->data[0][0] = __('Name'); $table_simple->data[0][1] = html_print_input_text_extended( @@ -264,40 +256,9 @@ if ((isset($id_agent_module) && $id_agent_module) || $id_policy_module != 0) { } $in_policy = strstr($page, 'policy_modules'); -if (!$in_policy) { - // Cannot select the current module to be itself parent. - $module_parent_filter = ($id_agent_module) ? ['tagente_modulo.id_agente_modulo' => "<>$id_agent_module"] : ''; - $table_simple->data[1][0] = __('Module parent'); - $modules_can_be_parent = agents_get_modules( - $id_agente, - false, - $module_parent_filter - ); - // If the user cannot have access to parent module, only print the name. - if ($parent_module_id != 0 - && !in_array($parent_module_id, array_keys($modules_can_be_parent)) - ) { - $table_simple->data[1][1] = db_get_value( - 'nombre', - 'tagente_modulo', - 'id_agente_modulo', - $parent_module_id - ); - } else { - $table_simple->data[1][1] = html_print_select( - $modules_can_be_parent, - 'parent_module_id', - $parent_module_id, - '', - __('Not assigned'), - '0', - true - ); - } -} -$table_simple->data[2][0] = __('Type').' '.ui_print_help_icon($help_type, true, '', 'images/help_green.png', '', 'module_type_help'); -$table_simple->data[2][0] .= html_print_input_hidden('id_module_type_hidden', $id_module_type, true); +$table_simple->data[1][0] = __('Type').' '.ui_print_help_icon($help_type, true, '', 'images/help_green.png', '', 'module_type_help'); +$table_simple->data[1][0] .= html_print_input_hidden('id_module_type_hidden', $id_module_type, true); if (!$edit) { $sql = sprintf( @@ -315,8 +276,8 @@ if (!$edit) { $type_names_hash[$tn['id_tipo']] = $tn['nombre']; } - $table_simple->data[2][1] = ''.modules_get_moduletype_description($id_module_type).' ('.$type_names_hash[$id_module_type].')'; - $table_simple->data[2][1] .= html_print_input_hidden( + $table_simple->data[1][1] = ''.modules_get_moduletype_description($id_module_type).' ('.$type_names_hash[$id_module_type].')'; + $table_simple->data[1][1] .= html_print_input_hidden( 'type_names', base64_encode(io_json_mb_encode($type_names_hash)), true @@ -358,7 +319,7 @@ if (!$edit) { } } - $table_simple->data[2][1] = html_print_select( + $table_simple->data[1][1] = html_print_select( $type_description_hash, 'id_module_type', $idModuleType, @@ -376,7 +337,7 @@ if (!$edit) { ); // Store the relation between id and name of the types on a hidden field. - $table_simple->data[2][1] .= html_print_input_hidden( + $table_simple->data[1][1] .= html_print_input_hidden( 'type_names', base64_encode(io_json_mb_encode($type_names_hash)), true @@ -409,74 +370,22 @@ if ($edit_module) { $help_header = 'webserver_module_tab'; } - $table_simple->data[2][0] = __('Type').' '; - $table_simple->data[2][0] .= ui_print_help_icon($help_header, true); + $table_simple->data[1][0] = __('Type').' '; + $table_simple->data[1][0] .= ui_print_help_icon($help_header, true); } if ($disabledBecauseInPolicy) { - $table_simple->data[2][3] .= html_print_input_hidden( + $table_simple->data[1][3] .= html_print_input_hidden( 'id_module_group', $id_module_group, true ); } -$table_simple->data[3][0] = __('Dynamic Threshold Interval'); -$table_simple->data[3][1] = html_print_extended_select_for_time( - 'dynamic_interval', - $dynamic_interval, - '', - 'None', - '0', - 10, - true, - 'width:150px', - false, - $classdisabledBecauseInPolicy, - $disabledBecauseInPolicy -); -$table_simple->data[3][1] .= ''.html_print_image('images/cog.png', true, ['title' => __('Advanced options Dynamic Threshold')]).''; -if ($in_policy) { - $table_simple->cellclass[2][2] = 'hide_dinamic'; - $table_simple->cellclass[2][3] = 'hide_dinamic'; -} else { - $table_simple->cellclass[3][2] = 'hide_dinamic'; - $table_simple->cellclass[3][3] = 'hide_dinamic'; -} - -$table_simple->data[3][2] = ''.__('Dynamic Threshold Min. ').''; -$table_simple->data[3][2] .= html_print_input_text( - 'dynamic_min', - $dynamic_min, - '', - 10, - 255, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -); -$table_simple->data[3][2] .= '
'.__('Dynamic Threshold Max. ').''; -$table_simple->data[3][2] .= html_print_input_text( - 'dynamic_max', - $dynamic_max, - '', - 10, - 255, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -); -$table_simple->data[3][3] = ''.__('Dynamic Threshold Two Tailed: ').''; -$table_simple->data[3][3] .= html_print_checkbox('dynamic_two_tailed', 1, $dynamic_two_tailed, true, $disabledBecauseInPolicy); - -$table_simple->data[4][0] = __('Warning status'); +$table_simple->data[2][0] = __('Warning status'); if (!modules_is_string_type($id_module_type) || $edit) { - $table_simple->data[4][1] .= ''.__('Min. ').''; - $table_simple->data[4][1] .= html_print_input_text( + $table_simple->data[2][1] .= ''.__('Min. ').''; + $table_simple->data[2][1] .= html_print_input_text( 'min_warning', $min_warning, '', @@ -488,8 +397,8 @@ if (!modules_is_string_type($id_module_type) || $edit) { '', $classdisabledBecauseInPolicy ); - $table_simple->data[4][1] .= '
'.__('Max.').''; - $table_simple->data[4][1] .= html_print_input_text( + $table_simple->data[2][1] .= '
'.__('Max.').''; + $table_simple->data[2][1] .= html_print_input_text( 'max_warning', $max_warning, '', @@ -504,8 +413,8 @@ if (!modules_is_string_type($id_module_type) || $edit) { } if (modules_is_string_type($id_module_type) || $edit) { - $table_simple->data[4][1] .= ''.__('Str.').''; - $table_simple->data[4][1] .= html_print_input_text( + $table_simple->data[2][1] .= ''.__('Str.').''; + $table_simple->data[2][1] .= html_print_input_text( 'str_warning', str_replace('"', '', $str_warning), '', @@ -519,17 +428,17 @@ if (modules_is_string_type($id_module_type) || $edit) { ).''; } - $table_simple->data[4][1] .= '
'.__('Inverse interval').''; - $table_simple->data[4][1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true, $disabledBecauseInPolicy); + $table_simple->data[2][1] .= '
'.__('Inverse interval').''; + $table_simple->data[2][1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true, $disabledBecauseInPolicy); if (!modules_is_string_type($id_module_type) || $edit) { - $table_simple->data[4][2] = ' '; + $table_simple->data[2][2] = ' '; } -$table_simple->data[5][0] = __('Critical status'); +$table_simple->data[3][0] = __('Critical status'); if (!modules_is_string_type($id_module_type) || $edit) { - $table_simple->data[5][1] .= ''.__('Min. ').''; - $table_simple->data[5][1] .= html_print_input_text( + $table_simple->data[3][1] .= ''.__('Min. ').''; + $table_simple->data[3][1] .= html_print_input_text( 'min_critical', $min_critical, '', @@ -541,8 +450,8 @@ if (!modules_is_string_type($id_module_type) || $edit) { '', $classdisabledBecauseInPolicy ); - $table_simple->data[5][1] .= '
'.__('Max.').''; - $table_simple->data[5][1] .= html_print_input_text( + $table_simple->data[3][1] .= '
'.__('Max.').''; + $table_simple->data[3][1] .= html_print_input_text( 'max_critical', $max_critical, '', @@ -557,8 +466,8 @@ if (!modules_is_string_type($id_module_type) || $edit) { } if (modules_is_string_type($id_module_type) || $edit) { - $table_simple->data[5][1] .= ''.__('Str.').''; - $table_simple->data[5][1] .= html_print_input_text( + $table_simple->data[3][1] .= ''.__('Str.').''; + $table_simple->data[3][1] .= html_print_input_text( 'str_critical', str_replace('"', '', $str_critical), '', @@ -572,109 +481,24 @@ if (modules_is_string_type($id_module_type) || $edit) { ).''; } -$table_simple->data[5][1] .= '
'.__('Inverse interval').''; -$table_simple->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true, $disabledBecauseInPolicy); +$table_simple->data[3][1] .= '
'.__('Inverse interval').''; +$table_simple->data[3][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true, $disabledBecauseInPolicy); -// FF stands for Flip-flop. -$table_simple->data[6][0] = __('FF threshold').' '; - -$table_simple->data[6][1] .= __('Keep counters'); -$table_simple->data[6][1] .= html_print_checkbox( - 'ff_type', - 1, - $ff_type, - true, - $disabledBecauseInPolicy -).'
'; - -$table_simple->data[6][1] .= html_print_radio_button( - 'each_ff', - 0, - '', - $each_ff, - true, - $disabledBecauseInPolicy -); -$table_simple->data[6][1] .= ' '.__('All state changing').' : '; -$table_simple->data[6][1] .= html_print_input_text( - 'ff_event', - $ff_event, - '', - 5, - 15, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -).'
'; -$table_simple->data[6][1] .= html_print_radio_button( - 'each_ff', - 1, - '', - $each_ff, - true, - $disabledBecauseInPolicy -); - -$table_simple->data[6][1] .= ' '.__('Each state changing').' : '; -$table_simple->data[6][1] .= __('To normal'); -$table_simple->data[6][1] .= html_print_input_text( - 'ff_event_normal', - $ff_event_normal, - '', - 5, - 15, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -).' '; - -$table_simple->data[6][1] .= __('To warning'); -$table_simple->data[6][1] .= html_print_input_text( - 'ff_event_warning', - $ff_event_warning, - '', - 5, - 15, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -).' '; - -$table_simple->data[6][1] .= __('To critical'); -$table_simple->data[6][1] .= html_print_input_text( - 'ff_event_critical', - $ff_event_critical, - '', - 5, - 15, - true, - $disabledBecauseInPolicy, - false, - '', - $classdisabledBecauseInPolicy -); - -$table_simple->data[7][0] = __('Historical data'); +$table_simple->data[4][0] = __('Historical data'); if ($disabledBecauseInPolicy) { // If is disabled, we send a hidden in his place and print a false // checkbox because HTML dont send disabled fields // and could be disabled by error. - $table_simple->data[7][1] = html_print_checkbox( + $table_simple->data[4][1] = html_print_checkbox( 'history_data_fake', 1, $history_data, true, $disabledBecauseInPolicy ); - $table_simple->data[7][1] .= ''; + $table_simple->data[4][1] .= ''; } else { - $table_simple->data[7][1] = html_print_checkbox( + $table_simple->data[4][1] = html_print_checkbox( 'history_data', 1, $history_data, @@ -693,21 +517,11 @@ $table_advanced->style = []; $table_advanced->style[0] = $table_advanced->style[3] = $table_advanced->style[5] = 'font-weight: bold;'; $table_advanced->colspan = []; -$table_advanced->data[0][0] = __('Description'); -$table_advanced->colspan[0][1] = 6; -$table_advanced->data[0][1] = html_print_textarea( - 'description', - 2, - 65, - $description, - $disabledTextBecauseInPolicy, - true, - $largeClassDisabledBecauseInPolicy -); +$table_advanced->colspan[17][1] = 3; -$table_advanced->data[1][0] = __('Custom ID'); -$table_advanced->colspan[1][1] = 2; -$table_advanced->data[1][1] = html_print_input_text( +$table_advanced->data[0][0] = __('Custom ID'); +$table_advanced->colspan[0][1] = 2; +$table_advanced->data[0][1] = html_print_input_text( 'custom_id', $custom_id, '', @@ -720,11 +534,11 @@ $table_advanced->data[1][1] = html_print_input_text( $classdisabledBecauseInPolicy ); -$table_advanced->data[1][3] = __('Unit'); +$table_advanced->data[0][3] = __('Unit'); // $table_advanced->data[1][4] = html_print_input_text ('unit', $unit, '', 20, 65, true, // $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy); // $table_advanced->colspan[1][4] = 3; -$table_advanced->data[1][4] = html_print_extended_select_for_unit( +$table_advanced->data[0][4] = html_print_extended_select_for_unit( 'unit', $unit, '', @@ -735,7 +549,7 @@ $table_advanced->data[1][4] = html_print_extended_select_for_unit( false, false ); -$table_advanced->colspan[1][4] = 3; +$table_advanced->colspan[0][4] = 3; $module_id_policy_module = 0; if (isset($module['id_policy_module'])) { @@ -745,38 +559,38 @@ if (isset($module['id_policy_module'])) { // In the data modules, the interval is not in seconds. It is a factor // to be multiplied for the agent interval if ($moduletype == MODULE_DATA) { - $table_advanced->data[2][0] = __('Interval'); - $table_advanced->colspan[2][1] = 2; + $table_advanced->data[1][0] = __('Interval'); + $table_advanced->colspan[1][1] = 2; $interval_factor = 1; if (isset($id_agente)) { $agent_interval = agents_get_interval($id_agente); $interval_factor = ($interval / $agent_interval); - $table_advanced->data[2][1] = human_time_description_raw($interval).' ('.sprintf(__('Agent interval x %s'), $interval_factor).') '; + $table_advanced->data[1][1] = human_time_description_raw($interval).' ('.sprintf(__('Agent interval x %s'), $interval_factor).') '; } else { - $table_advanced->data[2][1] = sprintf(__('Agent interval x %s'), $interval_factor); + $table_advanced->data[1][1] = sprintf(__('Agent interval x %s'), $interval_factor); } if ($__code_from == 'policies') { // If is the policy form, module_interval will store the factor (not the seconds). // So server will transform it to interval in seconds - $table_advanced->data[2][1] = sprintf(__('Default').': 1', $interval_factor); - $table_advanced->data[2][1] .= html_print_input_hidden('module_interval', $interval_factor, true); + $table_advanced->data[1][1] = sprintf(__('Default').': 1', $interval_factor); + $table_advanced->data[1][1] .= html_print_input_hidden('module_interval', $interval_factor, true); } else if ($module_id_policy_module != 0) { - $table_advanced->data[2][1] .= ui_print_help_tip(__('The policy modules of data type will only update their intervals when policy is applied.'), true); + $table_advanced->data[1][1] .= ui_print_help_tip(__('The policy modules of data type will only update their intervals when policy is applied.'), true); } // If it is a non policy form, the module_interval will not provided and will // be taken the agent interval (this code is at configurar_agente.php) } else { - $table_advanced->data[2][0] = __('Interval'); - $table_advanced->colspan[2][1] = 2; - $table_advanced->data[2][1] = html_print_extended_select_for_time('module_interval', $interval, '', '', '0', false, true, false, false, $classdisabledBecauseInPolicy, $disabledBecauseInPolicy); + $table_advanced->data[1][0] = __('Interval'); + $table_advanced->colspan[1][1] = 2; + $table_advanced->data[1][1] = html_print_extended_select_for_time('module_interval', $interval, '', '', '0', false, true, false, false, $classdisabledBecauseInPolicy, $disabledBecauseInPolicy); } -$table_advanced->data[2][1] .= html_print_input_hidden('moduletype', $moduletype, true); +$table_advanced->data[1][1] .= html_print_input_hidden('moduletype', $moduletype, true); -$table_advanced->data[2][3] = __('Post process'); -$table_advanced->data[2][4] = html_print_extended_select_for_post_process( +$table_advanced->data[1][3] = __('Post process'); +$table_advanced->data[1][4] = html_print_extended_select_for_post_process( 'post_process', $post_process, '', @@ -788,17 +602,17 @@ $table_advanced->data[2][4] = html_print_extended_select_for_post_process( false, $disabledBecauseInPolicy ); +$table_advanced->colspan[1][4] = 3; + +$table_advanced->data[2][0] = __('Min. Value'); +$table_advanced->colspan[2][1] = 2; + +$table_advanced->data[2][1] = html_print_input_text('min', $min, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy).' '.ui_print_help_tip(__('Any value below this number is discarted.'), true); +$table_advanced->data[2][3] = __('Max. Value'); +$table_advanced->data[2][4] = html_print_input_text('max', $max, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy).' '.ui_print_help_tip(__('Any value over this number is discarted.'), true); $table_advanced->colspan[2][4] = 3; -$table_advanced->data[3][0] = __('Min. Value'); -$table_advanced->colspan[3][1] = 2; - -$table_advanced->data[3][1] = html_print_input_text('min', $min, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy).' '.ui_print_help_tip(__('Any value below this number is discarted.'), true); -$table_advanced->data[3][3] = __('Max. Value'); -$table_advanced->data[3][4] = html_print_input_text('max', $max, '', 5, 15, true, $disabledBecauseInPolicy, false, '', $classdisabledBecauseInPolicy).' '.ui_print_help_tip(__('Any value over this number is discarted.'), true); -$table_advanced->colspan[3][4] = 3; - -$table_advanced->data[4][0] = __('Export target'); +$table_advanced->data[3][0] = __('Export target'); // Default text message for export target select and disabled option $none_text = __('None'); $disabled_export = false; @@ -808,7 +622,7 @@ if ($__code_from == 'policies') { $disabled_export = true; } -$table_advanced->data[4][1] = html_print_select_from_sql( +$table_advanced->data[3][1] = html_print_select_from_sql( 'SELECT id, name FROM tserver_export ORDER BY name', 'id_export', $id_export, @@ -820,7 +634,7 @@ $table_advanced->data[4][1] = html_print_select_from_sql( false, $disabled_export ).ui_print_help_tip(__('In case you use an Export server you can link this module and export data to one these.'), true); -$table_advanced->colspan[4][1] = 2; +$table_advanced->colspan[3][1] = 2; // Code comes from module_editor if ($__code_from == 'modules') { @@ -831,18 +645,18 @@ if ($__code_from == 'modules') { $throw_unknown_events_check = policy_module_is_disable_type_event($__id_pol_mod, EVENTS_GOING_UNKNOWN); } -$table_advanced->data[4][3] = __('Discard unknown events'); -$table_advanced->data[4][4] = html_print_checkbox( +$table_advanced->data[3][3] = __('Discard unknown events'); +$table_advanced->data[3][4] = html_print_checkbox( 'throw_unknown_events', 1, $throw_unknown_events_check, true, $disabledBecauseInPolicy ); -$table_advanced->colspan[4][4] = 3; +$table_advanced->colspan[3][4] = 3; -$table_advanced->data[5][0] = __('FF interval'); -$table_advanced->data[5][1] = html_print_input_text( +$table_advanced->data[4][0] = __('FF interval'); +$table_advanced->data[4][1] = html_print_input_text( 'module_ff_interval', $ff_interval, '', @@ -854,14 +668,14 @@ $table_advanced->data[5][1] = html_print_input_text( '', $classdisabledBecauseInPolicy ).ui_print_help_tip(__('Module execution flip flop time interval (in secs).'), true); -$table_advanced->colspan[5][1] = 2; +$table_advanced->colspan[4][1] = 2; -$table_advanced->data[5][3] = __('FF timeout'); +$table_advanced->data[4][3] = __('FF timeout'); $module_type_name = modules_get_type_name($id_module_type); -$table_advanced->data[5][4] = ''; +$table_advanced->data[4][4] = ''; if (preg_match('/async/', $module_type_name) || $edit) { - $table_advanced->data[5][4] .= ''.html_print_input_text( + $table_advanced->data[4][4] .= ''.html_print_input_text( 'ff_timeout', $ff_timeout, '', @@ -873,16 +687,16 @@ if (preg_match('/async/', $module_type_name) || $edit) { } if (!preg_match('/async/', $module_type_name) || $edit) { - $table_advanced->data[5][4] .= ''.__('Disabled').ui_print_help_tip(__('This value can be set only in the async modules.'), true).''; + $table_advanced->data[4][4] .= ''.__('Disabled').ui_print_help_tip(__('This value can be set only in the async modules.'), true).''; } -$table_advanced->colspan[5][4] = 3; +$table_advanced->colspan[4][4] = 3; /* Tags */ // This var comes from module_manager_editor.php or policy_modules.php global $__code_from; -$table_advanced->data[6][0] = __('Tags available'); +$table_advanced->data[5][0] = __('Tags available'); // Code comes from module_editor if ($__code_from == 'modules') { $__table_modules = 'ttag_module'; @@ -902,7 +716,7 @@ if ($__code_from == 'modules') { } if (!tags_has_user_acl_tags($config['id_user'])) { - $table_advanced->data[6][1] = html_print_select_from_sql( + $table_advanced->data[5][1] = html_print_select_from_sql( "SELECT id_tag, name FROM ttag WHERE id_tag NOT IN ( @@ -927,7 +741,7 @@ if (!tags_has_user_acl_tags($config['id_user'])) { if (!empty($user_tags)) { $id_user_tags = array_keys($user_tags); - $table_advanced->data[6][1] = html_print_select_from_sql( + $table_advanced->data[5][1] = html_print_select_from_sql( 'SELECT id_tag, name FROM ttag WHERE id_tag IN ('.implode(',', $id_user_tags).") AND @@ -949,7 +763,7 @@ if (!tags_has_user_acl_tags($config['id_user'])) { '5' ); } else { - $table_advanced->data[6][1] = html_print_select_from_sql( + $table_advanced->data[5][1] = html_print_select_from_sql( "SELECT id_tag, name FROM ttag WHERE id_tag NOT IN ( @@ -972,12 +786,12 @@ if (!tags_has_user_acl_tags($config['id_user'])) { } } -$table_advanced->data[6][2] = html_print_image('images/darrowright.png', true, ['id' => 'right', 'title' => __('Add tags to module')]); +$table_advanced->data[5][2] = html_print_image('images/darrowright.png', true, ['id' => 'right', 'title' => __('Add tags to module')]); // html_print_input_image ('add', 'images/darrowright.png', 1, '', true, array ('title' => __('Add tags to module'))); -$table_advanced->data[6][2] .= '



'.html_print_image('images/darrowleft.png', true, ['id' => 'left', 'title' => __('Delete tags to module')]); +$table_advanced->data[5][2] .= '



'.html_print_image('images/darrowleft.png', true, ['id' => 'left', 'title' => __('Delete tags to module')]); // html_print_input_image ('add', 'images/darrowleft.png', 1, '', true, array ('title' => __('Delete tags to module'))); -$table_advanced->data[6][3] = ''.__('Tags selected').''; -$table_advanced->data[6][4] = html_print_select_from_sql( +$table_advanced->data[5][3] = ''.__('Tags selected').''; +$table_advanced->data[5][4] = html_print_select_from_sql( "SELECT a.id_tag, name FROM ttag a, $__table_modules b WHERE a.id_tag = b.id_tag AND $__id_where = $__id @@ -997,8 +811,8 @@ $table_advanced->data[6][4] = html_print_select_from_sql( ); if ($__code_from == 'modules') { - $table_advanced->data[6][5] = ''.__('Tags from policy').''; - $table_advanced->data[6][6] = html_print_select_from_sql( + $table_advanced->data[5][5] = ''.__('Tags from policy').''; + $table_advanced->data[5][6] = html_print_select_from_sql( "SELECT a.id_tag, name FROM ttag a, $__table_modules b WHERE a.id_tag = b.id_tag AND $__id_where = $__id @@ -1018,9 +832,9 @@ if ($__code_from == 'modules') { ); } -$table_advanced->data[7][0] = __('Quiet'); -$table_advanced->data[7][0] .= ui_print_help_tip(__('The module still stores data but the alerts and events will be stop'), true); -$table_advanced->data[7][1] = html_print_checkbox('quiet_module', 1, $quiet_module, true, $disabledBecauseInPolicy); +$table_advanced->data[6][0] = __('Quiet'); +$table_advanced->data[6][0] .= ui_print_help_tip(__('The module still stores data but the alerts and events will be stop'), true); +$table_advanced->data[6][1] = html_print_checkbox('quiet_module', 1, $quiet_module, true, $disabledBecauseInPolicy); $cps_array[-1] = __('Disabled'); if ($cps_module > 0) { @@ -1037,22 +851,37 @@ if ($cps_module > 0) { $cps_array[$cps_inc] = __('Enabled'); } -$table_advanced->data[7][2] = __('Cascade Protection Services'); -$table_advanced->data[7][2] .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true); -$table_advanced->colspan[7][3] = 5; -$table_advanced->data[7][3] = html_print_select($cps_array, 'cps_module', $cps_module, '', '', 0, true, false, true, '', $disabledBecauseInPolicy); +$table_advanced->data[6][2] = ''; +$table_advanced->data[6][3] = __('Cascade Protection Services'); +$table_advanced->data[6][3] .= ui_print_help_tip(__('Disable the alerts and events of the elements that belong to this service'), true); +$table_advanced->colspan[6][4] = 3; +$table_advanced->data[6][4] = html_print_select($cps_array, 'cps_module', $cps_module, '', '', 0, true, false, true, '', $disabledBecauseInPolicy); + +$textarea_custom_style = ' style="min-height: 0px;"'; + +$table_advanced->data[7][0] = __('Description'); +$table_advanced->colspan[7][1] = 6; +$table_advanced->data[7][1] = html_print_textarea( + 'description', + 3, + 65, + $description, + $disabledTextBecauseInPolicy.$textarea_custom_style, + true, + $largeClassDisabledBecauseInPolicy +); $table_advanced->data[8][0] = __('Critical instructions').ui_print_help_tip(__('Instructions when the status is critical'), true); -$table_advanced->data[8][1] = html_print_textarea('critical_instructions', 2, 65, $critical_instructions, $disabledTextBecauseInPolicy, true, $largeClassDisabledBecauseInPolicy); +$table_advanced->data[8][1] = html_print_textarea('critical_instructions', 3, 65, $critical_instructions, $disabledTextBecauseInPolicy.$textarea_custom_style, true, $largeClassDisabledBecauseInPolicy); $table_advanced->colspan[8][1] = 6; $table_advanced->data[9][0] = __('Warning instructions').ui_print_help_tip(__('Instructions when the status is warning'), true); -$table_advanced->data[9][1] = html_print_textarea('warning_instructions', 2, 65, $warning_instructions, $disabledTextBecauseInPolicy, true, $largeClassDisabledBecauseInPolicy); +$table_advanced->data[9][1] = html_print_textarea('warning_instructions', 3, 65, $warning_instructions, $disabledTextBecauseInPolicy.$textarea_custom_style, true, $largeClassDisabledBecauseInPolicy); $table_advanced->colspan[9][1] = 6; $table_advanced->data[10][0] = __('Unknown instructions').ui_print_help_tip(__('Instructions when the status is unknown'), true); -$table_advanced->data[10][1] = html_print_textarea('unknown_instructions', 2, 65, $unknown_instructions, $disabledTextBecauseInPolicy, true, $largeClassDisabledBecauseInPolicy); +$table_advanced->data[10][1] = html_print_textarea('unknown_instructions', 3, 65, $unknown_instructions, $disabledTextBecauseInPolicy.$textarea_custom_style, true, $largeClassDisabledBecauseInPolicy); $table_advanced->colspan[10][1] = 6; if (isset($id_agente) && $moduletype == MODULE_DATA) { @@ -1112,6 +941,175 @@ if (check_acl($config['id_user'], 0, 'PM')) { $table_advanced->data[13][4] .= html_print_input_hidden('id_category', $id_category, true); } +if (!$in_policy) { + // Cannot select the current module to be itself parent. + $module_parent_filter = ($id_agent_module) ? ['tagente_modulo.id_agente_modulo' => "<>$id_agent_module"] : ''; + $table_advanced->data[15][0] = __('Module parent'); + $modules_can_be_parent = agents_get_modules( + $id_agente, + false, + $module_parent_filter + ); + // If the user cannot have access to parent module, only print the name. + if ($parent_module_id != 0 + && !in_array($parent_module_id, array_keys($modules_can_be_parent)) + ) { + $table_advanced->data[15][1] = db_get_value( + 'nombre', + 'tagente_modulo', + 'id_agente_modulo', + $parent_module_id + ); + } else { + $table_advanced->data[15][1] = html_print_select( + $modules_can_be_parent, + 'parent_module_id', + $parent_module_id, + '', + __('Not assigned'), + '0', + true + ); + } +} + +$table_advanced->data[16][0] = __('Dynamic Threshold Interval'); +$table_advanced->data[16][1] = html_print_extended_select_for_time( + 'dynamic_interval', + $dynamic_interval, + '', + 'None', + '0', + 10, + true, + 'width:150px', + false, + $classdisabledBecauseInPolicy, + $disabledBecauseInPolicy +); +$table_advanced->data[16][1] .= ''.html_print_image('images/cog.png', true, ['title' => __('Advanced options Dynamic Threshold')]).''; + +$table_advanced->cellclass[16][2] = 'hide_dinamic'; +$table_advanced->cellclass[16][3] = 'hide_dinamic'; + + +$table_advanced->data[16][2] = ''.__('Dynamic Threshold Min. ').''; +$table_advanced->data[16][2] .= html_print_input_text( + 'dynamic_min', + $dynamic_min, + '', + 10, + 255, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy +); +$table_advanced->data[16][2] .= '
'.__('Dynamic Threshold Max. ').''; +$table_advanced->data[16][2] .= html_print_input_text( + 'dynamic_max', + $dynamic_max, + '', + 10, + 255, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy +); +$table_advanced->data[16][3] = ''.__('Dynamic Threshold Two Tailed: ').''; +$table_advanced->data[16][3] .= html_print_checkbox('dynamic_two_tailed', 1, $dynamic_two_tailed, true, $disabledBecauseInPolicy); + + + +// FF stands for Flip-flop. +$table_advanced->data[17][0] = __('FF threshold').' '; + +$table_advanced->data[17][1] .= __('Keep counters'); +$table_advanced->data[17][1] .= html_print_checkbox( + 'ff_type', + 1, + $ff_type, + true, + $disabledBecauseInPolicy +).'
'; + +$table_advanced->data[17][1] .= html_print_radio_button( + 'each_ff', + 0, + '', + $each_ff, + true, + $disabledBecauseInPolicy +); +$table_advanced->data[17][1] .= ' '.__('All state changing').' : '; +$table_advanced->data[17][1] .= html_print_input_text( + 'ff_event', + $ff_event, + '', + 5, + 15, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy +).'
'; +$table_advanced->data[17][1] .= html_print_radio_button( + 'each_ff', + 1, + '', + $each_ff, + true, + $disabledBecauseInPolicy +); + +$table_advanced->data[17][1] .= ' '.__('Each state changing').' : '; +$table_advanced->data[17][1] .= __('To normal'); +$table_advanced->data[17][1] .= html_print_input_text( + 'ff_event_normal', + $ff_event_normal, + '', + 5, + 15, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy +).' '; + +$table_advanced->data[17][1] .= __('To warning'); +$table_advanced->data[17][1] .= html_print_input_text( + 'ff_event_warning', + $ff_event_warning, + '', + 5, + 15, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy +).' '; + +$table_advanced->data[17][1] .= __('To critical'); +$table_advanced->data[17][1] .= html_print_input_text( + 'ff_event_critical', + $ff_event_critical, + '', + 5, + 15, + true, + $disabledBecauseInPolicy, + false, + '', + $classdisabledBecauseInPolicy +); + + // Advanced form part $table_macros = new stdClass(); $table_macros->id = 'module_macros';