diff --git a/pandora_console/extras/mr/30.sql b/pandora_console/extras/mr/30.sql index 0e37d30c35..2de6e9cc19 100644 --- a/pandora_console/extras/mr/30.sql +++ b/pandora_console/extras/mr/30.sql @@ -9,4 +9,6 @@ ALTER TABLE `treport_content` ADD COLUMN `failover_type` tinyint(1) DEFAULT '0'; ALTER TABLE `treport_content_template` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `failover_type` tinyint(1) DEFAULT '1'; +ALTER TABLE `tmodule_relationship` ADD COLUMN `type` ENUM('direct', 'failover') DEFAULT 'direct'; + COMMIT; \ No newline at end of file diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index fbdd620f77..f34013944b 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1101,9 +1101,8 @@ $macro_count++; html_print_input_hidden('module_macro_count', $macro_count); -/* - Advanced form part */ -// Add relationships +// Advanced form part. +// Add relationships. $table_new_relations = new stdClass(); $table_new_relations->id = 'module_new_relations'; $table_new_relations->width = '100%'; @@ -1114,7 +1113,8 @@ $table_new_relations->style[0] = 'width: 10%; font-weight: bold;'; $table_new_relations->style[1] = 'width: 25%; text-align: center;'; $table_new_relations->style[2] = 'width: 10%; font-weight: bold;'; $table_new_relations->style[3] = 'width: 25%; text-align: center;'; -$table_new_relations->style[4] = 'width: 30%; text-align: center;'; +$table_new_relations->style[4] = 'width: 10%; font-weight: bold;'; +$table_new_relations->style[5] = 'width: 25%; text-align: center;'; $table_new_relations->data[0][0] = __('Agent'); $params = []; @@ -1128,10 +1128,35 @@ $params['javascript_function_action_after_select_js_call'] = 'change_modules_aut $table_new_relations->data[0][1] = ui_print_agent_autocomplete_input($params); $table_new_relations->data[0][2] = __('Module'); $table_new_relations->data[0][3] = "
"; -$table_new_relations->data[0][4] = html_print_button(__('Add relationship'), 'add_relation', false, 'javascript: add_new_relation();', 'class="sub add"', true); -$table_new_relations->data[0][4] .= " "; -// Relationship list +$array_rel_type = []; +$array_rel_type['direct'] = __('Direct'); +$array_rel_type['failover'] = __('Failover'); +$table_new_relations->data[0][4] = __('Rel. type'); +$table_new_relations->data[0][5] = html_print_select( + $array_rel_type, + 'relation_type', + '', + '', + '', + 0, + true, + false, + true, + '' +); + +$table_new_relations->data[0][6] = html_print_button( + __('Add relationship'), + 'add_relation', + false, + 'javascript: add_new_relation();', + 'class="sub add"', + true +); +$table_new_relations->data[0][6] .= " "; + +// Relationship list. $table_relations = new stdClass(); $table_relations->id = 'module_relations'; $table_relations->width = '100%'; @@ -1141,19 +1166,26 @@ $table_relations->data = []; $table_relations->rowstyle = []; $table_relations->rowstyle[-1] = 'display: none;'; $table_relations->style = []; -$table_relations->style[2] = 'width: 10%; text-align: center;'; $table_relations->style[3] = 'width: 10%; text-align: center;'; +$table_relations->style[4] = 'width: 10%; text-align: center;'; $table_relations->head[0] = __('Agent'); $table_relations->head[1] = __('Module'); -$table_relations->head[2] = __('Changes').ui_print_help_tip(__('Activate this to prevent the relation from being updated or deleted'), true); -$table_relations->head[3] = __('Delete'); +$table_relations->head[2] = __('Type'); +$table_relations->head[3] = __('Changes').ui_print_help_tip( + __('Activate this to prevent the relation from being updated or deleted'), + true +); +$table_relations->head[4] = __('Delete'); -// Create an invisible row to use their html to add new rows +// Create an invisible row to use their html to add new rows. $table_relations->data[-1][0] = ''; $table_relations->data[-1][1] = ''; -$table_relations->data[-1][2] = ''.html_print_image('images/lock.png', true).''; -$table_relations->data[-1][3] = ''.html_print_image('images/cross.png', true).''; +$table_relations->data[-1][2] = ''; +$table_relations->data[-1][3] = ''; +$table_relations->data[-1][3] .= html_print_image('images/lock.png', true).''; +$table_relations->data[-1][4] = ''; +$table_relations->data[-1][4] .= html_print_image('images/cross.png', true).''; $module_relations = modules_get_relations(['id_module' => $id_agent_module]); if (!$module_relations) { @@ -1164,10 +1196,14 @@ $relations_count = 0; foreach ($module_relations as $key => $module_relation) { if ($module_relation['module_a'] == $id_agent_module) { $module_id = $module_relation['module_b']; - $agent_id = modules_give_agent_id_from_module_id($module_relation['module_b']); + $agent_id = modules_give_agent_id_from_module_id( + $module_relation['module_b'] + ); } else { $module_id = $module_relation['module_a']; - $agent_id = modules_give_agent_id_from_module_id($module_relation['module_a']); + $agent_id = modules_give_agent_id_from_module_id( + $module_relation['module_a'] + ); } $agent_name = ui_print_agent_name($agent_id, true); @@ -1183,14 +1219,16 @@ foreach ($module_relations as $key => $module_relation) { $disabled_update_class = 'alpha50'; } - // Agent name + // Agent name. $table_relations->data[$relations_count][0] = $agent_name; - // Module name + // Module name. $table_relations->data[$relations_count][1] = "".ui_print_truncate_text($module_name, 'module_medium', true, true, true, '[…]').''; - // Lock relationship updates - $table_relations->data[$relations_count][2] = ''.html_print_image('images/lock.png', true).''; - // Delete relationship - $table_relations->data[$relations_count][3] = ''.html_print_image('images/cross.png', true).''; + // Type. + $table_relations->data[$relations_count][2] = ($module_relation['type'] === 'direct') ? __('Direct') : __('Failover'); + // Lock relationship updates. + $table_relations->data[$relations_count][3] = ''.html_print_image('images/lock.png', true).''; + // Delete relationship. + $table_relations->data[$relations_count][4] = ''.html_print_image('images/cross.png', true).''; $relations_count++; } @@ -1198,7 +1236,6 @@ html_print_input_hidden('module_relations_count', $relations_count); ui_require_jquery_file('json'); - ?>