/** * @desc Create or updates an alert in the database. It creates it whether it doesn't exist or updates it if it already exists. * @param AdministratorAlert $alert The alert to create or update. */ public static function save_alert($alert) { // If it exists already in the data base if ($alert->get_id() > 0) { //This line exists only to be compatible with PHP 4 (we cannot use $var->get_var()->method(), whe have to use a temp var) $creation_date = $alert->get_creation_date(); self::$db_querier->update(DB_TABLE_EVENTS, array('entitled' => $alert->get_entitled(), 'description' => $alert->get_properties(), 'fixing_url' => $alert->get_fixing_url(), 'current_status' => $alert->get_status(), 'creation_date' => $creation_date->get_timestamp(), 'id_in_module' => $alert->get_id_in_module(), 'identifier' => $alert->get_identifier(), 'type' => $alert->get_type(), 'priority' => $alert->get_priority()), 'WHERE id = :id', array('id' => $alert->get_id())); //Regeneration of the member cache file if ($alert->get_must_regenerate_cache()) { AdministratorAlertCache::invalidate(); $alert->set_must_regenerate_cache(false); } } else { $creation_date = new Date(); $result = self::$db_querier->insert(DB_TABLE_EVENTS, array('entitled' => $alert->get_entitled(), 'description' => $alert->get_properties(), 'fixing_url' => $alert->get_fixing_url(), 'current_status' => $alert->get_status(), 'creation_date' => $creation_date->get_timestamp(), 'id_in_module' => $alert->get_id_in_module(), 'identifier' => $alert->get_identifier(), 'type' => $alert->get_type(), 'priority' => $alert->get_priority())); $alert->set_id($result->get_last_inserted_id()); //Cache regeneration AdministratorAlertCache::invalidate(); } }