diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 67ad7b949c..fd5e922e32 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -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 );