mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
Added an option to use the metaconsole table when fetching the agents
Former-commit-id: d21627018f662d27f5612bf69bddfd8d298437ca
This commit is contained in:
parent
ebaa3506de
commit
3332e41f41
@ -328,14 +328,21 @@ function agents_get_alerts_simple($id_agent=false, $filter='', $options=false, $
|
||||
*
|
||||
* By default, it will return all the agents where the user has reading access.
|
||||
*
|
||||
* @param array filter options in an indexed array. See
|
||||
* db_format_array_where_clause_sql()
|
||||
* @param array Fields to get.
|
||||
* @param string Access needed in the agents groups.
|
||||
* @param array $order The order of agents, by default is upward for field nombre.
|
||||
* @param boolean $return Whether to return array with agents or false, or sql string statement
|
||||
* @param array $filter Filter options in an indexed array.
|
||||
* See db_format_array_where_clause_sql().
|
||||
* @param array $fields DB fields to get.
|
||||
* @param string $access ACL level needed in the agents groups.
|
||||
* @param array $order The order of agents, by default is upward
|
||||
* for field nombre.
|
||||
* @param boolean $return Whether to return array with agents or
|
||||
* the sql string statement.
|
||||
* @param boolean $disabled_agent Whether to return only the enabled agents
|
||||
* or not.
|
||||
* @param boolean $use_meta_table Whether to use the regular or the meta table
|
||||
* to retrieve the agents.
|
||||
*
|
||||
* @return mixed An array with all alerts defined for an agent or false in case no allowed groups are specified.
|
||||
* @return mixed An array with all alerts defined for an agent
|
||||
* or false in case no allowed groups are specified.
|
||||
*/
|
||||
function agents_get_agents(
|
||||
$filter=false,
|
||||
@ -346,7 +353,8 @@ function agents_get_agents(
|
||||
'order' => 'ASC',
|
||||
],
|
||||
$return=false,
|
||||
$disabled_agent=0
|
||||
$disabled_agent=0,
|
||||
$use_meta_table=false
|
||||
) {
|
||||
global $config;
|
||||
|
||||
@ -563,11 +571,15 @@ function agents_get_agents(
|
||||
);
|
||||
}
|
||||
|
||||
$table_name = ($use_meta_table === true) ? 'tmetaconsole_agent' : 'tagente';
|
||||
$sql = sprintf(
|
||||
'SELECT DISTINCT %s
|
||||
FROM tagente LEFT JOIN tagent_secondary_group ON tagent_secondary_group.id_agent=tagente.id_agente
|
||||
FROM `%s` tagente
|
||||
LEFT JOIN tagent_secondary_group
|
||||
ON tagent_secondary_group.id_agent=tagente.id_agente
|
||||
WHERE %s %s',
|
||||
implode(',', $fields),
|
||||
$table_name,
|
||||
$where,
|
||||
$order
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user