Fixed secondary groups configuration in agent creation
This commit is contained in:
parent
72f9bc754c
commit
fec5299179
|
@ -659,6 +659,13 @@ ui_require_jquery_file('bgiframe');
|
|||
return
|
||||
}
|
||||
|
||||
// On agent creation PHP will update the secondary groups table (not via AJAX)
|
||||
if (id_agent == 0) {
|
||||
agent_manager_add_secondary_groups_ui();
|
||||
agent_manager_update_hidden_input_secondary();
|
||||
return;
|
||||
}
|
||||
|
||||
var selected_items = new Array();
|
||||
$("#secondary_groups option:selected").each(function(){
|
||||
selected_items.push($(this).val())
|
||||
|
@ -679,11 +686,7 @@ ui_require_jquery_file('bgiframe');
|
|||
data: data,
|
||||
success: function (data) {
|
||||
if (data == 1) {
|
||||
// Move from one input to the other
|
||||
$("#secondary_groups_selected option[value=0]").remove()
|
||||
$("#secondary_groups option:selected").each(function() {
|
||||
$(this).remove().appendTo("#secondary_groups_selected")
|
||||
})
|
||||
agent_manager_add_secondary_groups_ui();
|
||||
} else {
|
||||
console.error("Error in AJAX call to add secondary groups")
|
||||
}
|
||||
|
@ -697,6 +700,13 @@ ui_require_jquery_file('bgiframe');
|
|||
function agent_manager_remove_secondary_groups (event, id_agent) {
|
||||
event.preventDefault();
|
||||
|
||||
// On agent creation PHP will update the secondary groups table (not via AJAX)
|
||||
if (id_agent == 0) {
|
||||
agent_manager_remove_secondary_groups_ui();
|
||||
agent_manager_update_hidden_input_secondary();
|
||||
return;
|
||||
}
|
||||
|
||||
var selected_items = new Array();
|
||||
$("#secondary_groups_selected option:selected").each(function(){
|
||||
selected_items.push($(this).val())
|
||||
|
@ -717,18 +727,7 @@ ui_require_jquery_file('bgiframe');
|
|||
data: data,
|
||||
success: function (data) {
|
||||
if (data == 1) {
|
||||
// Remove the groups selected if success
|
||||
$("#secondary_groups_selected option:selected").each(function(){
|
||||
$(this).remove().appendTo("#secondary_groups")
|
||||
})
|
||||
|
||||
// Add none if empty select
|
||||
if ($("#secondary_groups_selected option").length == 0) {
|
||||
$("#secondary_groups_selected").append($('<option>',{
|
||||
value: 0,
|
||||
text: "<?php echo __("None");?>"
|
||||
}))
|
||||
}
|
||||
agent_manager_remove_secondary_groups_ui();
|
||||
} else {
|
||||
console.error("Error in AJAX call to add secondary groups")
|
||||
}
|
||||
|
@ -739,6 +738,46 @@ ui_require_jquery_file('bgiframe');
|
|||
});
|
||||
}
|
||||
|
||||
// Move from left input to right input
|
||||
function agent_manager_add_secondary_groups_ui () {
|
||||
$("#secondary_groups_selected option[value=0]").remove()
|
||||
$("#secondary_groups option:selected").each(function() {
|
||||
$(this).remove().appendTo("#secondary_groups_selected")
|
||||
})
|
||||
}
|
||||
|
||||
// Move from right input to left input
|
||||
function agent_manager_remove_secondary_groups_ui () {
|
||||
// Remove the groups selected if success
|
||||
$("#secondary_groups_selected option:selected").each(function(){
|
||||
$(this).remove().appendTo("#secondary_groups")
|
||||
})
|
||||
|
||||
// Add none if empty select
|
||||
if ($("#secondary_groups_selected option").length == 0) {
|
||||
$("#secondary_groups_selected").append($('<option>',{
|
||||
value: 0,
|
||||
text: "<?php echo __("None");?>"
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
function agent_manager_update_hidden_input_secondary () {
|
||||
var groups = [];
|
||||
if(!$('form[name="conf_agent"] #secondary_hidden').length) {
|
||||
$('form[name="conf_agent"]').append(
|
||||
'<input name="secondary_hidden" type="hidden" id="secondary_hidden">'
|
||||
);
|
||||
}
|
||||
|
||||
var groups = new Array();
|
||||
$("#secondary_groups_selected option").each(function() {
|
||||
groups.push($(this).val())
|
||||
})
|
||||
|
||||
$("#secondary_hidden").val(groups.join(','));
|
||||
}
|
||||
|
||||
$(document).ready (function() {
|
||||
$("select#id_os").pandoraSelectOS ();
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ if ($create_agent) {
|
|||
$update_gis_data = (int) get_parameter_post("update_gis_data", 0);
|
||||
$url_description = (string) get_parameter("url_description");
|
||||
$quiet = (int) get_parameter("quiet", 0);
|
||||
|
||||
$secondary_groups = (string) get_parameter("secondary_hidden", "");
|
||||
$fields = db_get_all_fields_in_table('tagent_custom_fields');
|
||||
|
||||
if ($fields === false) $fields = array();
|
||||
|
@ -283,7 +283,12 @@ if ($create_agent) {
|
|||
"Update GIS data":"' . $update_gis_data .'",
|
||||
"Url description":"' . $url_description .'",
|
||||
"Quiet":"' . (int)$quiet.'"}';
|
||||
|
||||
|
||||
// Create the secondary groups
|
||||
enterprise_hook('agents_update_secondary_groups',
|
||||
array($id_agente, explode(',', $secondary_groups), array())
|
||||
);
|
||||
|
||||
$unsafe_alias = io_safe_output($alias);
|
||||
db_pandora_audit("Agent management",
|
||||
"Created agent $unsafe_alias", false, true, $info);
|
||||
|
|
Loading…
Reference in New Issue