'.__('Agent configuration'). ' » '. __('Configuration Management').'';
function process_manage_config ($source_id_agent, $destiny_id_agents) {
if (empty ($source_id_agent)) {
echo '
'.__('No source agent to copy').'
';
return false;
}
if (empty ($destiny_id_agents)) {
echo ''.__('No destiny agent(s) to copy').'
';
return false;
}
$copy_modules = (bool) get_parameter ('copy_modules');
$copy_alerts = (bool) get_parameter ('copy_alerts');
if ($copy_modules) {
$target_modules = (array) get_parameter ('target_modules', array ());
if (empty ($target_modules)) {
echo ''.__('No modules have been selected').'
';
return false;
}
process_sql ('SET AUTOCOMMIT = 0');
process_sql ('START TRANSACTION');
$error = false;
$alerts = array ();
foreach ($destiny_id_agents as $id_destiny_agent) {
foreach ($target_modules as $id_agent_module) {
$result = copy_agent_module_to_agent ($id_agent_module,
$id_destiny_agent);
if ($result === false) {
$error = true;
break;
}
$id_destiny_module = $result;
if (! isset ($alerts[$id_agent_module]))
$alerts[$id_agent_module] = get_alerts_agent_module ($id_agent_module,
true);
if ($alerts[$id_agent_module] === false)
continue;
if ($copy_alerts) {
foreach ($alerts[$id_agent_module] as $alert) {
$result = copy_alert_agent_module_to_agent_module ($alert['id'],
$id_destiny_module);
if ($result === false) {
$error = true;
break;
}
}
}
}
if ($error)
break;
}
if ($error) {
echo ''.__('There was an error copying the agent configuration, the copy has been cancelled').'
';
process_sql ('ROLLBACK');
} else {
echo ''.__('Successfully copied').'
';
process_sql ('COMMIT');
}
process_sql ('SET AUTOCOMMIT = 1');
}
}
$source_id_group = (int) get_parameter ('source_id_group');
$source_id_agent = (int) get_parameter ('source_id_agent');
$destiny_id_group = (int) get_parameter ('destiny_id_group');
$destiny_id_agents = (array) get_parameter ('destiny_id_agent', array ());
$do_operation = (bool) get_parameter ('do_operation');
if ($do_operation) {
process_manage_config ($source_id_agent, $destiny_id_agents);
}
$groups = get_user_groups ();
$table->class = 'databox';
$table->width = '95%';
$table->data = array ();
$table->style = array ();
$table->style[0] = 'font-weight: bold; vertical-align:top';
$table->style[2] = 'font-weight: bold';
$table->size = array ();
$table->size[0] = '15%';
$table->size[1] = '35%';
$table->size[2] = '15%';
$table->size[3] = '35%';
/* Source selection */
$table->id = 'source_table';
$table->data[0][0] = __('Group');
$table->data[0][1] = print_select ($groups, 'source_id_group', $source_id_group,
false, '', '', true);
$table->data[0][2] = __('Agent');
$table->data[0][2] .= ' ';
$table->data[0][2] .= '
';
$table->data[0][2] .= '';
$table->data[0][3] = print_select (get_group_agents ($source_id_group, false, "none"),
'source_id_agent', $source_id_agent, false, __('Select'), 0, true);
echo '';
echo '
';
require_jquery_file ('form');
require_jquery_file ('pandora.controls');
?>