From 48798d4af5625d48655e1610fe10693a3e2bb647 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 20 Sep 2018 17:59:12 +0200 Subject: [PATCH] Added some secondary groups checks to meta --- pandora_console/include/functions_agents.php | 17 ++++++++++++----- pandora_console/include/functions_users.php | 7 +++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 5bdd03a418..45c72b2b83 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -2025,11 +2025,17 @@ function agents_get_agentmodule_group ($id_module) { * This function gets the group for a given agent * * @param int The agent id + * @param bool True to use the metaconsole tables * * @return int The group id */ -function agents_get_agent_group ($id_agent) { - return (int) db_get_value ('id_grupo', "tagente", 'id_agente', (int) $id_agent); +function agents_get_agent_group ($id_agent, $force_meta = false) { + return (int) db_get_value ( + 'id_grupo', + $force_meta ? "tmetaconsole_agent" : "tagente", + 'id_agente', + (int) $id_agent + ); } /** @@ -2680,20 +2686,21 @@ function agents_generate_name ($alias, $address = '') { * * @param int $id_agent * @param int $id_group. By default it will search for it in dtabase + * @param bool True to use the metaconsole tables * * @return Array with the main and secondary groups */ -function agents_get_all_groups_agent ($id_agent, $group = false) { +function agents_get_all_groups_agent ($id_agent, $group = false, $force_meta = false) { // Cache the agent id groups static $cache = array(); if (isset($cache[$id_agent])) return $cache[$id_agent]; // Get the group if is not defined - if ($group === false) $group = agents_get_agent_group($id_agent); + if ($group === false) $group = agents_get_agent_group($id_agent, $force_meta); // If cannot retrieve the group, it means that agent does not exist if (!$group) return array(); - $secondary_groups = enterprise_hook('agents_get_secondary_groups', array($id_agent)); + $secondary_groups = enterprise_hook('agents_get_secondary_groups', array($id_agent, $force_meta)); // Return only an array with the group in open version if ($secondary_groups == ENTERPRISE_NOT_HOOK) return array($group); diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index c11fff79fd..43603663a1 100755 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -418,10 +418,13 @@ function users_get_first_group ($id_user = false, $privilege = "AR", $all_group * @param int Agent id. * @param string Access mode to be checked. Default AR (Agent reading) * @param string User id. Current user by default + * @param bool True to use the metaconsole tables * * @return bool Access to that agent (false not, true yes) */ -function users_access_to_agent ($id_agent, $mode = "AR", $id_user = false) { +function users_access_to_agent ( + $id_agent, $mode = "AR", $id_user = false, $force_meta = false +) { if (empty ($id_agent)) return false; @@ -432,7 +435,7 @@ function users_access_to_agent ($id_agent, $mode = "AR", $id_user = false) { return (bool) check_acl_one_of_groups ( $id_user, - agents_get_all_groups_agent((int)$id_agent), + agents_get_all_groups_agent((int)$id_agent, false, $force_meta), $mode); }