2014-04-03 Miguel de Dios <miguel.dedios@artica.es>

* 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.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9714 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2014-04-03 14:50:03 +00:00
parent 5ac2b3fe10
commit fa9811e4f8
5 changed files with 88 additions and 39 deletions

View File

@ -1,3 +1,10 @@
2014-04-03 Miguel de Dios <miguel.dedios@artica.es>
* 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 <rnovoa@artica.es> 2014-04-03 Ramon Novoa <rnovoa@artica.es>
* images/os_icons/so_router.png, * images/os_icons/so_router.png,

View File

@ -322,7 +322,7 @@ if ($is_function_policies !== ENTERPRISE_NOT_HOOK) {
$policy_info = policies_info_module_policy($id_agent_module); $policy_info = policies_info_module_policy($id_agent_module);
$policy_id = $policy_info['id_policy']; $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')); ui_print_error_message(__('This policy is applying and cannot be modified'));
} }
else { else {
@ -428,18 +428,22 @@ echo '<h3 id="message" class="error invisible"></h3>';
echo '<form method="post" id="module_form">'; echo '<form method="post" id="module_form">';
html_print_table ($table_simple); html_print_table ($table_simple);
ui_toggle(html_print_table ($table_advanced, true), __('Advanced options')); ui_toggle(html_print_table ($table_advanced, true),
ui_toggle(html_print_table ($table_macros, true), __('Module macros') . ui_print_help_icon ('module_macros', true)); __('Advanced options'));
ui_toggle(html_print_table ($table_new_relations, true) . html_print_table ($table_relations, true), __('Module relations')); 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 // Submit
echo '<div class="action-buttons" style="width: '.$table_simple->width.'">'; echo '<div class="action-buttons" style="width: '.$table_simple->width.'">';
if ($id_agent_module) { if ($id_agent_module) {
html_print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); html_print_submit_button(__('Update'), 'updbutton', false,
html_print_input_hidden ('update_module', 1); 'class="sub upd"');
html_print_input_hidden ('id_agent_module', $id_agent_module); html_print_input_hidden('update_module', 1);
html_print_input_hidden ('id_module_type', $id_module_type); 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) { if ($config['enterprise_installed'] && $remote_conf) {
?> ?>
@ -450,7 +454,8 @@ if ($id_agent_module) {
} }
} }
else { 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 ('id_module', $moduletype);
html_print_input_hidden ('create_module', 1); html_print_input_hidden ('create_module', 1);

View File

@ -579,41 +579,46 @@ if (!$module_relations) {
$relations_count = 0; $relations_count = 0;
foreach ($module_relations as $key => $module_relation) { foreach ($module_relations as $key => $module_relation) {
if ($module_relation['module_a'] == $id_agent_module) { if ($module_relation['module_a'] == $id_agent_module) {
$module_id = $module_relation['module_b']; $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 { }
else {
$module_id = $module_relation['module_a']; $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); $agent_name = ui_print_agent_name ($agent_id, true);
$module_name = modules_get_agentmodule_name($module_id); $module_name = modules_get_agentmodule_name($module_id);
if (empty($module_name) || $module_name == 'false') { if (empty($module_name) || $module_name == 'false') {
$module_name = $module_id; $module_name = $module_id;
} }
if ($module_relation['disable_update']) { if ($module_relation['disable_update']) {
$disabled_update_class = ""; $disabled_update_class = "";
} else { }
else {
$disabled_update_class = "transparent"; $disabled_update_class = "transparent";
} }
// Agent name // Agent name
$table_relations->data[$relations_count][0] = $agent_name; $table_relations->data[$relations_count][0] = $agent_name;
// Module name // Module name
$table_relations->data[$relations_count][1] = "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=" . $agent_id . $table_relations->data[$relations_count][1] =
"&tab=module&edit_module=1&id_agent_module=" . $module_id . "'>" . "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=" . $agent_id .
ui_print_truncate_text($module_name, 'module_medium', true, true, true, '[&hellip;]') . "</a>"; "&tab=module&edit_module=1&id_agent_module=" . $module_id . "'>" .
ui_print_truncate_text($module_name, 'module_medium', true, true, true, '[&hellip;]') . "</a>";
// Lock relationship updates // Lock relationship updates
$table_relations->data[$relations_count][2] = '<a id="disable_updates_button" class="' . $disabled_update_class . '" $table_relations->data[$relations_count][2] =
href="javascript: change_lock_relation(' . $relations_count . ', ' . $module_relation['id'] . ');">' '<a id="disable_updates_button" class="' . $disabled_update_class .
. html_print_image('images/lock.png', true) . '</a>'; '"href="javascript: change_lock_relation(' . $relations_count . ', ' . $module_relation['id'] . ');">' .
html_print_image('images/lock.png', true) . '</a>';
// Delete relationship // Delete relationship
$table_relations->data[$relations_count][3] = '<a id="delete_relation_button" href="javascript: delete_relation(' . $relations_count . ', ' . $module_relation['id'] . ');">' $table_relations->data[$relations_count][3] =
. html_print_image('images/cross.png', true) . '</a>'; '<a id="delete_relation_button" href="javascript: delete_relation(' . $relations_count . ', ' . $module_relation['id'] . ');">' .
html_print_image('images/cross.png', true) . '</a>';
$relations_count++; $relations_count++;
} }
@ -640,6 +645,7 @@ $(document).ready (function () {
} }
}); });
}); });
$("#left").click (function () { $("#left").click (function () {
jQuery.each($("select[name='id_tag_selected[]'] option:selected"), function (key, value) { jQuery.each($("select[name='id_tag_selected[]'] option:selected"), function (key, value) {
tag_name = $(value).html(); tag_name = $(value).html();
@ -654,6 +660,7 @@ $(document).ready (function () {
} }
}); });
}); });
$("#submit-updbutton").click(function () { $("#submit-updbutton").click(function () {
$('#id_tag_selected option').map(function(){ $('#id_tag_selected option').map(function(){
$(this).attr('selected','selected'); $(this).attr('selected','selected');
@ -733,11 +740,11 @@ function change_modules_autocomplete_input () {
var module_autocomplete = $("#module_autocomplete"); var module_autocomplete = $("#module_autocomplete");
var load_icon = '<?php html_print_image ("images/spinner.gif", false) ?>'; var load_icon = '<?php html_print_image ("images/spinner.gif", false) ?>';
var error_icon = '<?php html_print_image ("images/error_red.png", false) ?>'; var error_icon = '<?php html_print_image ("images/error_red.png", false) ?>';
if (!module_autocomplete.hasClass('working')) { if (!module_autocomplete.hasClass('working')) {
module_autocomplete.addClass('working'); module_autocomplete.addClass('working');
module_autocomplete.html(load_icon); module_autocomplete.html(load_icon);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "ajax.php", url: "ajax.php",
@ -772,6 +779,7 @@ function change_modules_autocomplete_input () {
// Add a new relation // Add a new relation
function add_new_relation () { function add_new_relation () {
var module_a_id = parseInt($("#hidden-id_agent_module").val()); 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 module_b_name = $("#text-autocomplete_module_name").val();
var agent_b_name = $("#text-autocomplete_agent_name").val(); var agent_b_name = $("#text-autocomplete_agent_name").val();
var hiddenRow = $("#module_relations--1"); var hiddenRow = $("#module_relations--1");
@ -780,11 +788,12 @@ function add_new_relation () {
var load_icon = '<?php html_print_image ("images/spinner.gif", false, array("style"=>"vertical-align:middle;")) ?>'; var load_icon = '<?php html_print_image ("images/spinner.gif", false, array("style"=>"vertical-align:middle;")) ?>';
var suc_icon = '<?php html_print_image ("images/ok.png", false, array("style"=>"vertical-align:middle;")) ?>'; var suc_icon = '<?php html_print_image ("images/ok.png", false, array("style"=>"vertical-align:middle;")) ?>';
var error_icon = '<?php html_print_image ("images/error_red.png", false, array("style"=>"vertical-align:middle;")) ?>'; var error_icon = '<?php html_print_image ("images/error_red.png", false, array("style"=>"vertical-align:middle;")) ?>';
if (!button.hasClass('working')) { if (!button.hasClass('working')) {
button.addClass('working'); button.addClass('working');
iconPlaceholder.html(load_icon); iconPlaceholder.html(load_icon);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "ajax.php", url: "ajax.php",
@ -793,6 +802,7 @@ function add_new_relation () {
page: "include/ajax/module", page: "include/ajax/module",
add_module_relation: true, add_module_relation: true,
id_module_a: module_a_id, id_module_a: module_a_id,
id_module_b: module_b_id,
name_module_b: module_b_name name_module_b: module_b_name
}, },
success: function (data) { success: function (data) {
@ -800,18 +810,19 @@ function add_new_relation () {
if (data === false) { if (data === false) {
iconPlaceholder.html(error_icon); iconPlaceholder.html(error_icon);
setTimeout( function() { iconPlaceholder.html(''); }, 2000); setTimeout( function() { iconPlaceholder.html(''); }, 2000);
} else { }
else {
iconPlaceholder.html(suc_icon); iconPlaceholder.html(suc_icon);
setTimeout( function() { iconPlaceholder.html(''); }, 2000); setTimeout( function() { iconPlaceholder.html(''); }, 2000);
// Add the new row // Add the new row
var relationsCount = parseInt($("#hidden-module_relations_count").val()); var relationsCount = parseInt($("#hidden-module_relations_count").val());
var rowClass = "datos"; var rowClass = "datos";
if (relationsCount % 2 != 0) { if (relationsCount % 2 != 0) {
rowClass = "datos2"; rowClass = "datos2";
} }
var rowHTML = '<tr id="module_relations-' + relationsCount + '" class="' + rowClass + '">' + var rowHTML = '<tr id="module_relations-' + relationsCount + '" class="' + rowClass + '">' +
'<td id="module_relations-' + relationsCount + '-0"><b>' + agent_b_name + '</b></td>' + '<td id="module_relations-' + relationsCount + '-0"><b>' + agent_b_name + '</b></td>' +
'<td id="module_relations-' + relationsCount + '-1">' + module_b_name + '</td>' + '<td id="module_relations-' + relationsCount + '-1">' + module_b_name + '</td>' +

View File

@ -344,7 +344,8 @@ if ($get_module_autocomplete_input) {
ob_clean(); ob_clean();
if ($id_agent > 0) { 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;
} }
return; return;
@ -355,12 +356,13 @@ if ($add_module_relation) {
$result = false; $result = false;
$id_module_a = (int) get_parameter("id_module_a"); $id_module_a = (int) get_parameter("id_module_a");
$id_module_b = (int) get_parameter("id_module_b"); $id_module_b = (int) get_parameter("id_module_b");
if ($id_module_a < 1) { if ($id_module_a < 1) {
$name_module_a = get_parameter("name_module_a", ""); $name_module_a = get_parameter("name_module_a", "");
if ($name_module_a) { if ($name_module_a) {
$id_module_a = (int) db_get_value('id_agente_modulo', 'tagente_modulo', 'nombre', $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); echo json_encode($result);
return; return;
} }
@ -369,7 +371,8 @@ if ($add_module_relation) {
$name_module_b = get_parameter("name_module_b", ""); $name_module_b = get_parameter("name_module_b", "");
if ($name_module_b) { if ($name_module_b) {
$id_module_b = (int) db_get_value('id_agente_modulo', 'tagente_modulo', 'nombre', $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); echo json_encode($result);
return; return;
} }
@ -377,6 +380,7 @@ if ($add_module_relation) {
if ($id_module_a > 0 && $id_module_b > 0) { if ($id_module_a > 0 && $id_module_b > 0) {
$result = modules_add_relation($id_module_a, $id_module_b); $result = modules_add_relation($id_module_a, $id_module_b);
} }
echo json_encode($result); echo json_encode($result);
return; return;
} }
@ -387,6 +391,7 @@ if ($remove_module_relation) {
if ($id_relation > 0) { if ($id_relation > 0) {
$result = (bool) modules_delete_relation($id_relation); $result = (bool) modules_delete_relation($id_relation);
} }
echo json_encode($result); echo json_encode($result);
return; return;
} }

View File

@ -1895,7 +1895,10 @@ function html_html2rgb($htmlcolor)
* *
* @return mixed If the $return is true, return the output as string. * @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; global $config;
if ($id_agents === false) { 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 = users_get_groups($config['id_user'], "AW", false);
$groups = array_keys($groups); $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 { 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(); 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, '', html_print_input_text_extended ($name, $default, 'text-' . $name, '', 30, 100, false, '',
array('style' => 'background: url(images/input_module.png) no-repeat right;')); 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); ui_print_help_tip(__('Type at least two characters to search the module.'), false);
$javascript_ajax_page = $javascript_ajax_page =
@ -1977,9 +1984,23 @@ function html_print_autocomplete_modules($name = 'module', $default = '', $id_ag
timeout: 10000, timeout: 10000,
dataType: "json", dataType: "json",
success: function (data) { 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='<?php echo $name; ?>_hidden']")
.val(ui.item.value);
$("#text-<?php echo $name; ?>").val( ui.item.label );
return false;
} }
} }
); );