Fixed meta regex agent matching ids

This commit is contained in:
Luis Calvo 2019-12-18 19:00:34 +01:00
parent 56f22dbd71
commit 22eb76b56b
1 changed files with 9 additions and 4 deletions

View File

@ -3512,13 +3512,18 @@ function agents_get_status_animation($up=true)
function agents_get_agent_id_by_alias_regex($alias_regex, $flag='i', $limit=0)
{
$agents_id = [];
$all_agents = agents_get_agents(false, ['id_agente', 'alias']);
if (is_metaconsole()) {
$all_agents = agents_meta_get_agents('AR', '|');
} else {
$all_agents = agents_get_group_agents(0, true, 'lower', false, false, true, '|');
}
$agent_match = '/'.$alias_regex.'/'.$flag;
foreach ($all_agents as $agent) {
$result_agent_match = preg_match($agent_match, $agent['alias']);
foreach ($all_agents as $agent_id => $agent_alias) {
$result_agent_match = preg_match($agent_match, $agent_alias);
if ($result_agent_match) {
$agents_id[] = $agent['id_agente'];
$agents_id[] = $agent_id;
$i++;
if ($i === $limit) {
break;