Merge branch 'ent-5649-visor-de-log-en-metaconsola' into 'develop'

Added log_viewer in metaconsole

See merge request artica/pandorafms!3312
This commit is contained in:
Daniel Rodriguez 2020-06-30 15:51:51 +02:00
commit f0cbd61ad3
1 changed files with 51 additions and 0 deletions

View File

@ -1666,6 +1666,57 @@ function agents_get_alias($id_agent, $case='none')
}
/**
* Get alias of an agent in metaconsole (cached function).
*
* @param integer $id_agent Agent id.
* @param string $case Case (upper, lower, none).
* @param integer $id_server server id.
*
* @return string Alias of the given agent.
*/
function agents_get_alias_metaconsole($id_agent, $case='none', $id_server=false)
{
global $config;
// Prepare cache.
static $cache = [];
if (empty($case)) {
$case = 'none';
}
// Check cache.
if (isset($cache[$case][$id_server][$id_agent])) {
return $cache[$case][$id_server][$id_agent];
}
$alias = (string) db_get_value_filter(
'alias',
'tmetaconsole_agent',
[
'id_tagente' => $id_agent,
'id_tmetaconsole_setup' => $id_server,
]
);
switch ($case) {
case 'upper':
$alias = mb_strtoupper($alias, 'UTF-8');
break;
case 'lower':
$alias = mb_strtolower($alias, 'UTF-8');
break;
default:
// Not posible.
break;
}
$cache[$case][$id_server][$id_agent] = $alias;
return $alias;
}
function agents_get_alias_by_name($name, $case='none')
{
if (is_metaconsole()) {