getNextEvents(); if ($events->count() === 0) { return null; } return $events->first(); } public function getNextEvents() { $query = $this ->getQuery('SELECT id, path, titre, date_debut, date_fin, date_fin_appel_conferencier FROM afup_forum WHERE date_debut > NOW() ORDER BY date_debut') ; $events = $query->query($this->getCollection(new HydratorSingleObject())); return $events; } public function getNextEventForGithubUser(GithubUser $githubUser) { $events = $this ->getPreparedQuery('SELECT id, path, titre, date_debut, date_fin, date_fin_appel_conferencier FROM afup_forum WHERE date_debut > NOW() AND afup_forum.id IN ( SELECT afup_sessions.id_forum FROM afup_conferenciers_sessions JOIN afup_sessions ON (afup_conferenciers_sessions.session_id = afup_sessions.session_id) JOIN afup_conferenciers ON (afup_conferenciers_sessions.conferencier_id = afup_conferenciers.conferencier_id) WHERE afup_sessions.plannifie = 1 AND afup_conferenciers.user_github = :user_github_id ) ORDER BY date_debut LIMIT 1') ->setParams(['user_github_id' => $githubUser->getId()]) ->query($this->getCollection(new HydratorSingleObject())) ; if ($events->count() === 0) { return null; } return $events->first(); } public function getList($id = null) { $sql = <<0, 0, 1) as est_supprimable FROM afup_forum f LEFT JOIN afup_sessions s ON (f.id = s.id_forum) LEFT JOIN afup_inscription_forum i ON (f.id = i.id_forum) %s GROUP BY f.id, f.titre, f.path, f.nb_places, f.date_debut, f.date_fin, f.date_fin_appel_conferencier, f.date_fin_vente ORDER BY date_debut desc; ENDSQL; $sql = sprintf($sql, $id === null ? '':'WHERE f.id = :id'); $query = $this->getQuery($sql); if ($id !== null) { $query->setParams(['id'=>$id]); } return $query->query($this->getCollection(new HydratorArray())); } public function getAllPastEventWithSpeakerEmail($email) { $sql = <<getQuery($sql); $query->setParams(['email' => $email]); return $query->query($this->getCollection(new HydratorSingleObject())); } public function getAllPastEventWithTegistrationEmail($email) { $sql = <<getQuery($sql); $query->setParams([ 'email' => $email, 'status_paid' => Ticket::STATUS_PAID, 'status_guest' => Ticket::STATUS_GUEST, ]); return $query->query($this->getCollection(new HydratorSingleObject())); } /** * @return Event|null */ public function getCurrentEvent() { $query = $this ->getQuery('SELECT id, path FROM afup_forum WHERE (date_debut > NOW() OR (NOW() BETWEEN date_debut AND DATE_ADD(date_fin, INTERVAL 1 DAY))) ORDER BY date_debut LIMIT 1') ; $events = $query->query($this->getCollection(new HydratorSingleObject())); if ($events->count() === 0) { return null; } return $events->first(); } /** * @param int $eventCount * * @return \CCMBenchmark\Ting\Repository\CollectionInterface */ public function getPreviousEvents($eventCount) { $query = $this->getQuery('SELECT * FROM afup_forum WHERE date_debut < NOW() ORDER BY date_debut DESC LIMIT :limit'); $query->setParams(['limit' => $eventCount]); return $query->query($this->getCollection(new HydratorSingleObject())); } /** * @param $path * * @return Event|null */ public function getByPath($path) { return $this->getBy(['path' => $path])->first(); } public static function initMetadata(SerializerFactoryInterface $serializerFactory, array $options = []) { $metadata = new Metadata($serializerFactory); $metadata->setEntity(Event::class); $metadata->setConnectionName('main'); $metadata->setDatabase($options['database']); $metadata->setTable('afup_forum'); $metadata ->addField([ 'columnName' => 'id', 'fieldName' => 'id', 'primary' => true, 'autoincrement' => true, 'type' => 'int' ]) ->addField([ 'columnName' => 'titre', 'fieldName' => 'title', 'type' => 'string' ]) ->addField([ 'columnName' => 'nb_places', 'fieldName' => 'seats', 'type' => 'int' ]) ->addField([ 'columnName' => 'date_debut', 'fieldName' => 'dateStart', 'type' => 'datetime', 'serializer_options' => [ 'unserialize' => ['unSerializeUseFormat' => false] ] ]) ->addField([ 'columnName' => 'date_fin', 'fieldName' => 'dateEnd', 'type' => 'datetime', 'serializer_options' => [ 'unserialize' => ['unSerializeUseFormat' => false] ] ]) ->addField([ 'columnName' => 'date_fin_appel_projet', 'fieldName' => 'dateEndCallForProjects', 'type' => 'datetime', 'serializer_options' => [ 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'] ] ]) ->addField([ 'columnName' => 'date_fin_appel_conferencier', 'fieldName' => 'dateEndCallForPapers', 'type' => 'datetime', 'serializer_options' => [ 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'] ] ]) ->addField([ 'columnName' => 'date_fin_vote', 'fieldName' => 'dateEndVote', 'type' => 'datetime' ]) ->addField([ 'columnName' => 'date_fin_prevente', 'fieldName' => 'dateEndPreSales', 'type' => 'datetime', 'serializer_options' => [ 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'] ] ]) ->addField([ 'columnName' => 'date_fin_vente', 'fieldName' => 'dateEndSales', 'type' => 'datetime', 'serializer_options' => [ 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'] ] ]) ->addField([ 'columnName' => 'date_fin_saisie_repas_speakers', 'fieldName' => 'dateEndSpeakersDinerInfosCollection', 'type' => 'datetime', 'serializer_options' => [ 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'] ] ]) ->addField([ 'columnName' => 'date_annonce_planning', 'fieldName' => 'datePlanningAnnouncement', 'type' => 'datetime', 'serializer_options' => [ 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'] ] ]) ->addField([ 'columnName' => 'date_fin_saisie_nuites_hotel', 'fieldName' => 'dateEndHotelInfosCollection', 'type' => 'datetime', 'serializer_options' => [ 'unserialize' => ['unSerializeUseFormat' => true, 'format' => 'U'] ] ]) ->addField([ 'columnName' => 'text', 'fieldName' => 'cfp', 'type' => 'json', 'serializer_options' => [ 'unserialize' => ['assoc' => true] ] ]) ->addField([ 'columnName' => 'path', 'fieldName' => 'path', 'type' => 'string' ]) ->addField([ 'columnName' => 'trello_list_id', 'fieldName' => 'trelloListId', 'type' => 'string' ]) ->addField([ 'columnName' => 'logo_url', 'fieldName' => 'logoUrl', 'type' => 'string' ]) ->addField([ 'columnName' => 'place_name', 'fieldName' => 'placeName', 'type' => 'string' ]) ->addField([ 'columnName' => 'place_address', 'fieldName' => 'placeAddress', 'type' => 'string' ]) ->addField([ 'columnName' => 'vote_enabled', 'fieldName' => 'voteEnabled', 'type' => 'boolean' ]) ->addField([ 'columnName' => 'speakers_diner_enabled', 'fieldName' => 'speakersDinerEnabled', 'type' => 'boolean' ]) ->addField([ 'columnName' => 'accomodation_enabled', 'fieldName' => 'accomodationEnabled', 'type' => 'boolean' ]) ->addField([ 'columnName' => 'waiting_list_url', 'fieldName' => 'waitingListUrl', 'type' => 'string', ]) ; return $metadata; } }