0 AND disable = 0'; break; case "disabled": $filter = ' AND disable = 1'; break; default: $filter = ''; } $id_modules = array_keys (get_agent_modules ($id_agent)); if (empty ($id_modules)) return array (); $sql = sprintf ("SELECT talert_template_modules.* FROM talert_template_modules WHERE id_agent_module in (%s)%s", implode (",", $id_modules), $filter); $alerts = get_db_all_rows_sql ($sql); if ($alerts === false) return array (); return $alerts; } /** * Get all the combined alerts of an agent. * * @param int $id_agent Agent id * * @return array An array with all combined alerts defined for an agent. */ function get_agent_alerts_combined ($id_agent, $filter = false) { /* TODO: Combined alerts */ return array (); switch ($filter) { case "notfired": $filter = ' AND times_fired = 0 AND disable = 0'; break; case "fired": $filter = ' AND times_fired > 0 AND disable = 0'; break; case "disabled": $filter = ' AND disable = 1'; break; default: $filter = ''; } $id_modules = array_keys (get_agent_modules ($id_agent)); if (empty ($id_modules)) return array (); $sql = sprintf ("SELECT * FROM talert_template_modules WHERE id_agent_module IN (%s)%s", implode (',', $id_modules), $filter); $alerts = get_db_all_rows_sql ($sql); if ($alerts === false) return array (); return $alerts; } /** * Get all the alerts of an agent, simple and combined. * * @param int $id_agent Agent id * * @return array An array with all alerts defined for an agent. */ function get_agent_alerts ($id_agent, $filter = false) { $simple_alerts = get_agent_alerts_simple ($id_agent, $filter); $combined_alerts = get_agent_alerts_combined ($id_agent, $filter); return array_merge ($simple_alerts, $combined_alerts); } ?>