diff --git a/includes/class-QueryEvent.php b/includes/class-QueryEvent.php index 61f2e96..8caaca2 100644 --- a/includes/class-QueryEvent.php +++ b/includes/class-QueryEvent.php @@ -1,196 +1,178 @@ . // load dependent traits class_exists( QueryConference::class, true ); class_exists( QueryChapter ::class, true ); class_exists( QueryTrack ::class, true ); class_exists( QueryRoom ::class, true ); /** * Methods for a QueryEvent class */ trait QueryEventTrait { use QueryConferenceTrait; /** * Where the Event is... * * @param object $event Event * @return self */ public function whereEvent( $event ) { return $this->whereEventID( $event->getEventID() ); } /** * Where the Event ID is... * * @param int $id Event ID * @return self */ public function whereEventID( $id ) { return $this->whereInt( $this->EVENT_ID, $id ); } /** * Where the Event UID is this one * * @param string $uid Event UID * @return self */ public function whereEventUID( $uid ) { return $this->whereStr( Event::UID, $uid ); } /** * Where the Event is editable by me */ public function whereEventIsEditable() { throw new Exception( "to be implemented" ); } } /** * Class able to query a FullEvent. */ class QueryEvent extends Query { use QueryEventTrait; use QueryChapterTrait; use QueryTrackTrait; use QueryRoomTrait; /** * Univoque Event ID column name * * @var */ protected $EVENT_ID = 'event.event_ID'; /** * Univoque Chapter ID column name * * @var */ protected $CHAPTER_ID = 'event.chapter_ID'; /* * Univoque Conference ID column name * * Used from ConferenceTrait#joinConference() * * @var */ protected $CONFERENCE_ID = 'event.conference_ID'; /** * Univoque Track ID column name * * @var */ protected $TRACK_ID = 'event.track_ID'; /** * Univoque Room ID column name * * @var */ protected $ROOM_ID = 'event.room_ID'; /** * Constructor */ public function __construct() { parent::__construct(); $this->from( Event::T ); $this->defaultClass( FullEvent::class ); } /** * Limit to a certain User * * @deprecated * * @param $user User * @return self */ public function whereUser( $user ) { return $this->joinEventUser() ->whereInt( EventUser::USER_, $user->getUserID() ); } - /** - * Join a table with the Track table - * - * @return self - */ - public function joinTrack() { - return $this->joinOn( 'INNER', Track::T, Track::ID_, $this->TRACK_ID ); - } - - /** - * Join a table with the Room table - * - * @return self - */ - public function joinRoom() { - return $this->joinOn( 'INNER', Room::T, Room::ID_, $this->ROOM_ID ); - } - /** * Join Events to User IDs * * You can call it multiple time safely. * * @return self */ public function joinEventUser() { if( empty( $this->joinedEventUser ) ) { $this->from( EventUser::T ); $this->equals( EventUser::EVENT_, Event::ID_ ); $this->joinedEventUser = true; } return $this; } /** * Join Events and their Track, Chapter and Room (can be NULL). * * You can call it multiple time safely. * * @return self */ public function joinTrackChapterRoom() { if( empty( $this->joinedTrackChapterRoom ) ) { $this->from( Room::T ) ->equals( Room::ID_, Event::ROOM_ ); $this->from( Track::T ) ->equals( Track::ID_, Event::TRACK_ ); $this->from( Chapter::T ) ->equals( Chapter::ID_, Event::CHAPTER_ ); $this->joinedTrackChapterRoom = true; } return $this; } }