/** * @desc Create or update a contribution in the database. * @param Contribution $contribution The contribution to synchronize with the data base. */ public static function save_contribution($contribution) { // If it exists already in the data base if ($contribution->get_id() > 0) { //We write it for PHP 4 which doesn't understand (object->get_object()->method()) $creation_date = $contribution->get_creation_date(); $fixing_date = $contribution->get_fixing_date(); self::$db_querier->update(DB_TABLE_EVENTS, array('entitled' => $contribution->get_entitled(), 'description' => $contribution->get_description(), 'fixing_url' => $contribution->get_fixing_url(), 'module' => $contribution->get_module(), 'current_status' => $contribution->get_status(), 'creation_date' => $creation_date->get_timestamp(), 'fixing_date' => $fixing_date->get_timestamp(), 'auth' => serialize($contribution->get_auth()), 'poster_id' => $contribution->get_poster_id(), 'fixer_id' => $contribution->get_fixer_id(), 'id_in_module' => $contribution->get_id_in_module(), 'identifier' => $contribution->get_identifier(), 'type' => $contribution->get_type()), 'WHERE id = :id', array('id' => $contribution->get_id())); } else { $creation_date = $contribution->get_creation_date(); $result = self::$db_querier->insert(DB_TABLE_EVENTS, array('entitled' => $contribution->get_entitled(), 'description' => $contribution->get_description(), 'fixing_url' => $contribution->get_fixing_url(), 'module' => $contribution->get_module(), 'current_status' => $contribution->get_status(), 'creation_date' => $creation_date->get_timestamp(), 'fixing_date' => 0, 'auth' => serialize($contribution->get_auth()), 'poster_id' => $contribution->get_poster_id(), 'fixer_id' => $contribution->get_fixer_id(), 'id_in_module' => $contribution->get_id_in_module(), 'identifier' => $contribution->get_identifier(), 'type' => $contribution->get_type(), 'contribution_type' => self::CONTRIBUTION_TYPE)); $contribution->set_id($result->get_last_inserted_id()); } //Regeneration of the member cache file if ($contribution->get_must_regenerate_cache()) { UnreadContributionsCache::invalidate(); $contribution->set_must_regenerate_cache(false); } }