added cache to function agents_get_all_groups_agent

This commit is contained in:
daniel 2018-08-23 14:50:19 +02:00
parent 3e71513e4e
commit 24f7dbd420

View File

@ -2678,6 +2678,9 @@ function agents_generate_name ($alias, $address = '') {
* @return Array with the main and secondary groups
*/
function agents_get_all_groups_agent ($id_agent, $group = 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);
@ -2691,6 +2694,7 @@ function agents_get_all_groups_agent ($id_agent, $group = false) {
// Add a list of groups
$secondary_groups['plain'][] = $group;
$cache[$id_agent] = $secondary_groups['plain'];
return $secondary_groups['plain'];
}