From 63a9aa54a792548274c90ddbe83154451fe19603 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 5 Feb 2013 16:39:11 +0000 Subject: [PATCH] 2013-02-05 Miguel de Dios * include/functions_modules.php: added function "modules_check_agentmodule_exists". Fixes: #3602773 * include/functions_agents.php: cleaned source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7589 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 +++++++ pandora_console/include/functions_agents.php | 3 ++- pandora_console/include/functions_modules.php | 27 ++++++++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d3647ec53c..a1232e27cb 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2013-02-05 Miguel de Dios + + * include/functions_modules.php: added function + "modules_check_agentmodule_exists". + + Fixes: #3602773 + + * include/functions_agents.php: cleaned source code style. + 2013-02-05 Miguel de Dios * ajax.php: added the autologin hash for some ajax call of user diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 5640f76538..4f0d84d75b 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -50,7 +50,8 @@ function agents_check_agent_exists($id_agent, $show_disabled = true) { * @return int Id from the agent of the given id module. */ function agents_get_agent_id_by_module_id ($id_agente_modulo) { - return (int) db_get_value ('id_agente', 'tagente_modulo', 'id_agente_modulo', $id_agente_modulo); + return (int) db_get_value ('id_agente', 'tagente_modulo', + 'id_agente_modulo', $id_agente_modulo); } /** diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index f7e4a73439..3578627588 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -557,6 +557,7 @@ function modules_format_delete_log4x($id) if (check_acl ($config['id_user'], $group, "AW") ==1) { $txt = '' . html_print_image("images/cross.png", true, array("border" => '0')) . ''; } + return $txt; } @@ -597,6 +598,28 @@ function modules_get_agentmodule ($id_agentmodule) { } } +/** + * Check the module exists in the DB. + * + * @param int $id_agentmodule The agent id. + * @param boolean $show_disabled Show the agent found althought it is disabled. By default false. + * + * @return boolean The result to check if the agent is in the DB. + */ +function modules_check_agentmodule_exists($id_agentmodule, $show_disabled = true) { + $module = db_get_row_filter('tagente_modulo', + array('id_agente_modulo' => $id_agentmodule, 'disabled' => !$show_disabled)); + + if (!empty($module)) { + if ($module['delete_pending']) + return false; + else + return true; + } + else { + return false; + } +} /** * Get a id of module from his name and the agent id @@ -607,7 +630,9 @@ function modules_get_agentmodule ($id_agentmodule) { * @return int the agentmodule id */ function modules_get_agentmodule_id ($agentmodule_name, $agent_id) { - return db_get_row_filter ('tagente_modulo', array('nombre' => $agentmodule_name, 'id_agente' => $agent_id, 'delete_pending' => 0)); + return db_get_row_filter ('tagente_modulo', + array('nombre' => $agentmodule_name, + 'id_agente' => $agent_id, 'delete_pending' => 0)); } /**