From 19a26d6835e3fec2d4969d618a6a080aab899fce Mon Sep 17 00:00:00 2001 From: "edu.corral" Date: Wed, 22 Jun 2022 10:01:35 +0200 Subject: [PATCH] ent 9181 delete agent with delete pending modules --- pandora_console/include/functions_agents.php | 3 +-- pandora_console/include/lib/Module.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index d8da8f39fa..5b5d66c85f 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2598,10 +2598,9 @@ function agents_delete_agent($id_agents, $disableACL=false) 'tagente_modulo', $filter ); - if (is_array($rows) === true) { foreach ($rows as $row) { - $modules[] = PandoraFMS\Module::build($row); + $modules[] = PandoraFMS\Module::build($row, '\PandoraFMS\Module', true); } } diff --git a/pandora_console/include/lib/Module.php b/pandora_console/include/lib/Module.php index d885e33d14..fcd4acdcbc 100644 --- a/pandora_console/include/lib/Module.php +++ b/pandora_console/include/lib/Module.php @@ -145,14 +145,15 @@ class Module extends Entity /** * Creates a module object from given data. Avoid query duplication. * - * @param array $data Module information. - * @param string $class_str Class type. - * + * @param array $data Module information. + * @param string $class_str Class type. + * @param boolean $return_deleted_modules Check. * @return PandoraFMS\Module Object. */ public static function build( array $data=[], - string $class_str='\PandoraFMS\Module' + string $class_str='\PandoraFMS\Module', + bool $return_deleted_modules=false ) { $obj = new $class_str(); @@ -161,8 +162,9 @@ class Module extends Entity $obj->{$k}($v); } - if ($obj->nombre() === 'delete_pending' - || $obj->nombre() === 'pendingdelete' + if (($obj->nombre() === 'delete_pending' + || $obj->nombre() === 'pendingdelete') + && $return_deleted_modules === false ) { return null; }