diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1625c2e1ba..e0f49f0375 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2014-04-03 Miguel de Dios + + * godmode/agentes/module_manager_editor.php, + godmode/agentes/module_manager_editor_common.php, + include/ajax/module.php, include/functions_html.php: fixed the + relationship between modules. + 2014-04-03 Ramon Novoa * images/os_icons/so_router.png, diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 2d258aa0c4..32ab54d044 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -322,7 +322,7 @@ if ($is_function_policies !== ENTERPRISE_NOT_HOOK) { $policy_info = policies_info_module_policy($id_agent_module); $policy_id = $policy_info['id_policy']; - if($relink_policy && policies_get_policy_queue_status ($policy_id) == STATUS_IN_QUEUE_APPLYING) { + if ($relink_policy && policies_get_policy_queue_status ($policy_id) == STATUS_IN_QUEUE_APPLYING) { ui_print_error_message(__('This policy is applying and cannot be modified')); } else { @@ -428,18 +428,22 @@ echo ''; echo '
'; html_print_table ($table_simple); -ui_toggle(html_print_table ($table_advanced, true), __('Advanced options')); -ui_toggle(html_print_table ($table_macros, true), __('Module macros') . ui_print_help_icon ('module_macros', true)); -ui_toggle(html_print_table ($table_new_relations, true) . html_print_table ($table_relations, true), __('Module relations')); +ui_toggle(html_print_table ($table_advanced, true), + __('Advanced options')); +ui_toggle(html_print_table ($table_macros, true), + __('Module macros') . ui_print_help_icon ('module_macros', true)); +ui_toggle(html_print_table ($table_new_relations, true) . + html_print_table ($table_relations, true), __('Module relations')); // Submit echo '
'; if ($id_agent_module) { - html_print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); - html_print_input_hidden ('update_module', 1); - html_print_input_hidden ('id_agent_module', $id_agent_module); - html_print_input_hidden ('id_module_type', $id_module_type); + html_print_submit_button(__('Update'), 'updbutton', false, + 'class="sub upd"'); + html_print_input_hidden('update_module', 1); + html_print_input_hidden('id_agent_module', $id_agent_module); + html_print_input_hidden('id_module_type', $id_module_type); if ($config['enterprise_installed'] && $remote_conf) { ?> @@ -450,7 +454,8 @@ if ($id_agent_module) { } } else { - html_print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"'); + html_print_submit_button (__('Create'), 'crtbutton', false, + 'class="sub wand"'); html_print_input_hidden ('id_module', $moduletype); html_print_input_hidden ('create_module', 1); diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index cc7ee4b490..91d1a72eb5 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -579,41 +579,46 @@ if (!$module_relations) { $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']); - } else { + } + else { $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); - + $module_name = modules_get_agentmodule_name($module_id); if (empty($module_name) || $module_name == 'false') { $module_name = $module_id; } - + if ($module_relation['disable_update']) { $disabled_update_class = ""; - } else { + } + else { $disabled_update_class = "transparent"; } - + // Agent name $table_relations->data[$relations_count][0] = $agent_name; // Module name - $table_relations->data[$relations_count][1] = "" . - ui_print_truncate_text($module_name, 'module_medium', true, true, true, '[…]') . ""; + $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) . ''; + $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) . ''; + $table_relations->data[$relations_count][3] = + '' . + html_print_image('images/cross.png', true) . ''; $relations_count++; } @@ -640,6 +645,7 @@ $(document).ready (function () { } }); }); + $("#left").click (function () { jQuery.each($("select[name='id_tag_selected[]'] option:selected"), function (key, value) { tag_name = $(value).html(); @@ -654,6 +660,7 @@ $(document).ready (function () { } }); }); + $("#submit-updbutton").click(function () { $('#id_tag_selected option').map(function(){ $(this).attr('selected','selected'); @@ -733,11 +740,11 @@ function change_modules_autocomplete_input () { var module_autocomplete = $("#module_autocomplete"); var load_icon = ''; var error_icon = ''; - + if (!module_autocomplete.hasClass('working')) { module_autocomplete.addClass('working'); module_autocomplete.html(load_icon); - + $.ajax({ type: "POST", url: "ajax.php", @@ -772,6 +779,7 @@ function change_modules_autocomplete_input () { // Add a new relation function add_new_relation () { var module_a_id = parseInt($("#hidden-id_agent_module").val()); + var module_b_id = parseInt($("#hidden-autocomplete_module_name_hidden").val()); var module_b_name = $("#text-autocomplete_module_name").val(); var agent_b_name = $("#text-autocomplete_agent_name").val(); var hiddenRow = $("#module_relations--1"); @@ -780,11 +788,12 @@ function add_new_relation () { var load_icon = '"vertical-align:middle;")) ?>'; var suc_icon = '"vertical-align:middle;")) ?>'; var error_icon = '"vertical-align:middle;")) ?>'; - + + if (!button.hasClass('working')) { button.addClass('working'); iconPlaceholder.html(load_icon); - + $.ajax({ type: "POST", url: "ajax.php", @@ -793,6 +802,7 @@ function add_new_relation () { page: "include/ajax/module", add_module_relation: true, id_module_a: module_a_id, + id_module_b: module_b_id, name_module_b: module_b_name }, success: function (data) { @@ -800,18 +810,19 @@ function add_new_relation () { if (data === false) { iconPlaceholder.html(error_icon); setTimeout( function() { iconPlaceholder.html(''); }, 2000); - } else { + } + else { iconPlaceholder.html(suc_icon); setTimeout( function() { iconPlaceholder.html(''); }, 2000); // Add the new row var relationsCount = parseInt($("#hidden-module_relations_count").val()); - + var rowClass = "datos"; if (relationsCount % 2 != 0) { rowClass = "datos2"; } - + var rowHTML = '' + '' + agent_b_name + '' + '' + module_b_name + '' + diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index c5645bd1ef..fa8a01681a 100644 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -344,7 +344,8 @@ if ($get_module_autocomplete_input) { ob_clean(); if ($id_agent > 0) { - html_print_autocomplete_modules('autocomplete_module_name', '', array($id_agent)); + html_print_autocomplete_modules( + 'autocomplete_module_name', '', array($id_agent)); return; } return; @@ -355,12 +356,13 @@ if ($add_module_relation) { $result = false; $id_module_a = (int) get_parameter("id_module_a"); $id_module_b = (int) get_parameter("id_module_b"); - + if ($id_module_a < 1) { $name_module_a = get_parameter("name_module_a", ""); if ($name_module_a) { $id_module_a = (int) db_get_value('id_agente_modulo', 'tagente_modulo', 'nombre', $name_module_a); - } else { + } + else { echo json_encode($result); return; } @@ -369,7 +371,8 @@ if ($add_module_relation) { $name_module_b = get_parameter("name_module_b", ""); if ($name_module_b) { $id_module_b = (int) db_get_value('id_agente_modulo', 'tagente_modulo', 'nombre', $name_module_b); - } else { + } + else { echo json_encode($result); return; } @@ -377,6 +380,7 @@ if ($add_module_relation) { if ($id_module_a > 0 && $id_module_b > 0) { $result = modules_add_relation($id_module_a, $id_module_b); } + echo json_encode($result); return; } @@ -387,6 +391,7 @@ if ($remove_module_relation) { if ($id_relation > 0) { $result = (bool) modules_delete_relation($id_relation); } + echo json_encode($result); return; } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 1afddf8f4b..953a05d14b 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1895,7 +1895,10 @@ function html_html2rgb($htmlcolor) * * @return mixed If the $return is true, return the output as string. */ -function html_print_autocomplete_modules($name = 'module', $default = '', $id_agents = false, $ACL = true, $scriptResult = '', $filter = array(), $return = false) { +function html_print_autocomplete_modules($name = 'module', + $default = '', $id_agents = false, $ACL = true, $scriptResult = '', + $filter = array(), $return = false) { + global $config; if ($id_agents === false) { @@ -1904,10 +1907,13 @@ function html_print_autocomplete_modules($name = 'module', $default = '', $id_ag $groups = users_get_groups($config['id_user'], "AW", false); $groups = array_keys($groups); - $agents = db_get_all_rows_sql('SELECT id_agente FROM tagente WHERE id_grupo IN (' . implode(',', $groups) . ')'); + $agents = db_get_all_rows_sql('SELECT id_agente + FROM tagente + WHERE id_grupo IN (' . implode(',', $groups) . ')'); } else { - $agents = db_get_all_rows_sql('SELECT id_agente FROM tagente'); + $agents = db_get_all_rows_sql('SELECT id_agente + FROM tagente'); } if ($agents === false) $agents = array(); @@ -1941,6 +1947,7 @@ function html_print_autocomplete_modules($name = 'module', $default = '', $id_ag html_print_input_text_extended ($name, $default, 'text-' . $name, '', 30, 100, false, '', array('style' => 'background: url(images/input_module.png) no-repeat right;')); + html_print_input_hidden($name . "_hidden", 0); ui_print_help_tip(__('Type at least two characters to search the module.'), false); $javascript_ajax_page = @@ -1977,9 +1984,23 @@ function html_print_autocomplete_modules($name = 'module', $default = '', $id_ag timeout: 10000, dataType: "json", success: function (data) { - response(data); + temp = []; + $.each(data, function (id, module) { + temp.push({ + 'value' : id, + 'label' : module}); + }); + + response(temp); } }); + }, + select: function( event, ui ) { + $("input[name='_hidden']") + .val(ui.item.value); + + $("#text-").val( ui.item.label ); + return false; } } );