0 AND disabled = 0'; break; case "disabled": $filter = ' AND disabled = 1'; break; default: $filter = ''; } $id_agent = (array) $id_agent; $id_modules = array_keys (get_agent_modules ($id_agent)); if (empty ($id_modules)) return array (); if (is_array ($options)) { $filter .= format_array_to_where_clause_sql ($options); } $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 * @param string Special filter. Can be: "notfired", "fired" or "disabled". * @param array Extra filter options in an indexed array. See * format_array_to_where_clause_sql() * * @return array An array with all combined alerts defined for an agent. */ function get_agent_alerts_compound ($id_agent, $filter = '', $options = false) { switch ($filter) { case "notfired": $filter = ' AND times_fired = 0 AND disabled = 0'; break; case "fired": $filter = ' AND times_fired > 0 AND disabled = 0'; break; case "disabled": $filter = ' AND disabled = 1'; break; default: $filter = ''; } if (is_array ($options)) { $filter .= format_array_to_where_clause_sql ($options); } $id_agent = array ($id_agent); $sql = sprintf ("SELECT * FROM talert_compound WHERE id_agent in (%s)%s", implode (',', $id_agent), $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 * @param string Special filter. Can be: "notfired", "fired" or "disabled". * @param array Extra filter options in an indexed array. See * format_array_to_where_clause_sql() * * @return array An array with all alerts defined for an agent. */ function get_agent_alerts ($id_agent, $filter = false, $options = false) { $simple_alerts = get_agent_alerts_simple ($id_agent, $filter, $options); $combined_alerts = get_agent_alerts_compound ($id_agent, $filter, $options); return array ('simple' => $simple_alerts, 'compounds' => $combined_alerts); } /** * Copy the agents config from one agent to the other * * @param int Agent id * @param mixed Agent id or id's (array) to copy to * @param bool Whether to copy modules as well (defaults to $_REQUEST['copy_modules']) * @param bool Whether to copy alerts as well * @param array Which modules to copy. * @param array Which alerts to copy. Only will be used if target_modules is empty. * * @return bool True in case of good, false in case of bad */ function process_manage_config ($source_id_agent, $destiny_id_agents, $copy_modules = false, $copy_alerts = false, $target_modules = false, $target_alerts = false) { if (empty ($source_id_agent)) { echo '