2013-03-13 Miguel de Dios <miguel.dedios@artica.es>

* include/functions_modules.php: fixed the massive deletion of
	modules when only delete one module, the old code deleted all
	modules in the agents on operation.
	
	* godmode/massive/massive_delete_modules.php: cleaned source code
	style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7845 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-03-13 12:59:29 +00:00
parent 1df7a559d4
commit 87c5be69d8
3 changed files with 43 additions and 31 deletions

View File

@ -1,3 +1,12 @@
2013-03-13 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_modules.php: fixed the massive deletion of
modules when only delete one module, the old code deleted all
modules in the agents on operation.
* godmode/massive/massive_delete_modules.php: cleaned source code
style.
2013-03-13 Kikuchi Koichiro <koichiro@rworks.jp> 2013-03-13 Kikuchi Koichiro <koichiro@rworks.jp>
* extensions/update_manager/lib/functions.ajax.php: Added proxy * extensions/update_manager/lib/functions.ajax.php: Added proxy

View File

@ -72,10 +72,10 @@ function process_manage_delete ($module_name, $id_agents) {
// Selection mode by Agents // Selection mode by Agents
if ($selection_delete_mode == 'agents') { if ($selection_delete_mode == 'agents') {
// We are selecting "any" module for the selecteds agents // We are selecting "any" module for the selecteds agents
if (($module_name[0] == 0) and (is_array($module_name)) and (count($module_name) == 1)) if (($module_name[0] == "0") and (is_array($module_name)) and (count($module_name) == 1))
$filter_for_module_deletion = false; $filter_for_module_deletion = false;
else else
$filter_for_module_deletion = sprintf('nombre IN ("%s")', implode('","',$module_name)); $filter_for_module_deletion = sprintf('nombre IN ("%s")', implode('","', $module_name));
$modules = agents_get_modules ($id_agents, 'id_agente_modulo', $modules = agents_get_modules ($id_agents, 'id_agente_modulo',
$filter_for_module_deletion, true); $filter_for_module_deletion, true);
@ -117,7 +117,8 @@ $selection_mode = get_parameter('selection_mode', 'modules');
$recursion = get_parameter('recursion'); $recursion = get_parameter('recursion');
if ($delete) { if ($delete) {
if ($selection_mode == 'modules') { switch ($selection_mode) {
case 'modules':
$force = get_parameter('force_type', false); $force = get_parameter('force_type', false);
if ($agents_select == false) { if ($agents_select == false) {
@ -125,16 +126,17 @@ if ($delete) {
$agents_ = array(); $agents_ = array();
} }
foreach($agents_select as $agent_name) { foreach ($agents_select as $agent_name) {
$agents_[] = agents_get_agent_id($agent_name); $agents_[] = agents_get_agent_id($agent_name);
} }
$modules_ = $module_name; $modules_ = $module_name;
} break;
else if($selection_mode == 'agents') { case 'agents':
$force = get_parameter('force_group', false); $force = get_parameter('force_group', false);
$agents_ = $agents_id; $agents_ = $agents_id;
$modules_ = $modules_select; $modules_ = $modules_select;
break;
} }
$count = 0; $count = 0;
@ -153,7 +155,7 @@ if ($delete) {
foreach($agents_ as $id_agent) { foreach($agents_ as $id_agent) {
$module_name = db_get_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent['id_agente'], 'id_tipo_modulo' => $module_type, 'delete_pending' => 0),'nombre'); $module_name = db_get_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent['id_agente'], 'id_tipo_modulo' => $module_type, 'delete_pending' => 0),'nombre');
if($module_name == false) { if ($module_name == false) {
$module_name = array(); $module_name = array();
} }
foreach ($module_name as $mod_name) { foreach ($module_name as $mod_name) {
@ -167,7 +169,7 @@ if ($delete) {
$agents_ = array_keys (agents_get_group_agents ($group_select, false, "none")); $agents_ = array_keys (agents_get_group_agents ($group_select, false, "none"));
foreach ($agents_ as $id_agent) { foreach ($agents_ as $id_agent) {
$module_name = db_get_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent),'nombre'); $module_name = db_get_all_rows_filter('tagente_modulo', array('id_agente' => $id_agent),'nombre');
if($module_name == false) { if ($module_name == false) {
$module_name = array(); $module_name = array();
} }
else { else {
@ -181,8 +183,9 @@ if ($delete) {
$agents_ = array(); $agents_ = array();
} }
if (!$force) if (!$force) {
$result = process_manage_delete ($modules_, $agents_); $result = process_manage_delete ($modules_, $agents_);
}
if ($result) { if ($result) {
db_pandora_audit("Massive management", "Delete module ", false, false, db_pandora_audit("Massive management", "Delete module ", false, false,

View File

@ -91,14 +91,14 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
} }
// If the module is synthetic we duplicate the operations too // If the module is synthetic we duplicate the operations too
if($module['id_modulo'] == 5) { if ($module['id_modulo'] == 5) {
$synth_ops = db_get_all_rows_field_filter('tmodule_synth','id_agent_module_target',$module['id_agente_modulo']); $synth_ops = db_get_all_rows_field_filter('tmodule_synth','id_agent_module_target',$module['id_agente_modulo']);
if($synth_ops === false) { if ($synth_ops === false) {
$synth_ops = array(); $synth_ops = array();
} }
foreach($synth_ops as $synth_op) { foreach ($synth_ops as $synth_op) {
unset($synth_op['id']); unset($synth_op['id']);
$synth_op['id_agent_module_target'] = $id_new_module; $synth_op['id_agent_module_target'] = $id_new_module;
switch ($config['dbtype']) { switch ($config['dbtype']) {
@ -129,7 +129,7 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
$id_agente = modules_get_agentmodule_agent($id_agent_module); $id_agente = modules_get_agentmodule_agent($id_agent_module);
$agent_md5 = md5 (agents_get_name($id_agente), false); $agent_md5 = md5 (agents_get_name($id_agente), false);
$remote_conf = file_exists ($config["remote_config"]."/md5/".$agent_md5.".md5"); $remote_conf = file_exists ($config["remote_config"] . "/md5/" . $agent_md5 . ".md5");
if ($remote_conf) { if ($remote_conf) {
$result = enterprise_hook('config_agents_copy_agent_module_to_agent', $result = enterprise_hook('config_agents_copy_agent_module_to_agent',