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 494dc8e5a1
commit 13f69122e9
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>
* extensions/update_manager/lib/functions.ajax.php: Added proxy

View File

@ -72,13 +72,13 @@ function process_manage_delete ($module_name, $id_agents) {
// Selection mode by Agents
if ($selection_delete_mode == '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;
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',
$filter_for_module_deletion, true);
$filter_for_module_deletion, true);
}
else {
@ -117,24 +117,26 @@ $selection_mode = get_parameter('selection_mode', 'modules');
$recursion = get_parameter('recursion');
if ($delete) {
if ($selection_mode == 'modules') {
$force = get_parameter('force_type', false);
if ($agents_select == false) {
$agents_select = array();
$agents_ = array();
}
foreach($agents_select as $agent_name) {
$agents_[] = agents_get_agent_id($agent_name);
}
$modules_ = $module_name;
}
else if($selection_mode == 'agents') {
$force = get_parameter('force_group', false);
$agents_ = $agents_id;
$modules_ = $modules_select;
switch ($selection_mode) {
case 'modules':
$force = get_parameter('force_type', false);
if ($agents_select == false) {
$agents_select = array();
$agents_ = array();
}
foreach ($agents_select as $agent_name) {
$agents_[] = agents_get_agent_id($agent_name);
}
$modules_ = $module_name;
break;
case 'agents':
$force = get_parameter('force_group', false);
$agents_ = $agents_id;
$modules_ = $modules_select;
break;
}
$count = 0;
@ -152,8 +154,8 @@ if ($delete) {
WHERE t1.id_agente = t2.id_agente AND t2.delete_pending = 0 ' . $condition);
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');
if($module_name == false) {
if ($module_name == false) {
$module_name = array();
}
foreach ($module_name as $mod_name) {
@ -167,7 +169,7 @@ if ($delete) {
$agents_ = array_keys (agents_get_group_agents ($group_select, false, "none"));
foreach ($agents_ as $id_agent) {
$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();
}
else {
@ -181,9 +183,10 @@ if ($delete) {
$agents_ = array();
}
if (!$force)
if (!$force) {
$result = process_manage_delete ($modules_, $agents_);
}
if ($result) {
db_pandora_audit("Massive management", "Delete module ", false, false,
'Agent: ' . json_encode($agents_) . ' Module: ' . $module_name);

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($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']);
if($synth_ops === false) {
if ($synth_ops === false) {
$synth_ops = array();
}
foreach($synth_ops as $synth_op) {
foreach ($synth_ops as $synth_op) {
unset($synth_op['id']);
$synth_op['id_agent_module_target'] = $id_new_module;
switch ($config['dbtype']) {
@ -120,7 +120,7 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent
if ($source_tags == false)
$source_tags = array();
tags_insert_module_tag($id_new_module, $source_tags);
//Added the config data if necesary
@ -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);
$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) {
$result = enterprise_hook('config_agents_copy_agent_module_to_agent',