0,
'tagente_modulo.disabled' => 0),
array ('tagente.id_agente', 'tagente.nombre'),
$recursion);
echo json_encode (index_array ($agents_modules, 'id_agente', 'nombre'));
return;
}
return;
}
function process_manage_delete ($module_name, $id_agents) {
if (empty ($module_name)) {
echo '
'.__('No module selected').'
';
return false;
}
if (empty ($id_agents)) {
echo ''.__('No agents selected').'
';
return false;
}
db_process_sql_begin ();
$modules = agents_get_modules ($id_agents, 'id_agente_modulo',
array ('nombre' => $module_name), true);
$success = modules_delete_agent_module ($modules);
if (! $success) {
echo ''.__('There was an error deleting the modules, the operation has been cancelled').'
';
echo ''.__('Could not delete modules').'
';
db_process_sql_rollback ();
return false;
}
else {
echo ''.__('Successfully deleted').'
';
db_process_sql_commit ();
return true;
}
}
$id_group = (int) get_parameter ('id_group');
$id_agents = (array) get_parameter ('id_agents');
$module_name = (string) get_parameter ('module_name');
$recursion = get_parameter ('recursion');
$delete = (bool) get_parameter_post ('delete');
if ($delete) {
$result = process_manage_delete ($module_name, $id_agents);
if ($result) {
db_pandora_audit("Massive management", "Delete module ", false, false,
'Agent: ' . json_encode($id_agents) . ' Module: ' . $module_name);
}
else {
db_pandora_audit("Massive management", "Fail try to delete module", false, false,
'Agent: ' . json_encode($id_agents) . ' Module: ' . $module_name);
}
}
$groups = users_get_groups ();
$table->id = 'delete_table';
$table->width = '98%';
$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%';
$table->data = array ();
$table->data[0][0] = __('Modules');
$modules = agents_get_modules();
$modulesSelect = array();
foreach ($modules as $module) {
$modulesSelect[$module] = io_safe_output($module);
}
$table->data[0][1] = html_print_select($modulesSelect,
'module_name', $module_name, false, __('Select'), '', true);
$table->data[1][0] = __('Group');
$table->data[1][1] = html_print_select_groups(false, "AR", true, 'id_group', $id_group,
false, '', '', true, false, true, '', empty ($module_name));
$table->data[1][2] = __('Group recursion');
$table->data[1][3] = html_print_checkbox ("recursion", 1, $recursion, true, false);
$table->data[2][0] = __('Agent');
$table->data[2][0] .= '';
$table->data[2][0] .= html_print_image('images/spinner.png', true);
$table->data[2][0] .= '';
$agents = modules_get_agents_with_module_name ($module_name, $id_group,
array ('delete_pending' => 0,
'tagente_modulo.disabled' => 0),
array ('tagente.id_agente', 'tagente.nombre'));
$table->data[2][1] = html_print_select (index_array ($agents, 'id_agente', 'nombre'),
'id_agents[]', 0, false, __('None'), 0, true, true, true, '', empty ($module_name));
echo '';
echo '
';
ui_require_jquery_file ('form');
ui_require_jquery_file ('pandora.controls');
?>