diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitEventsApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitEventsApiController.php index 3aaa7e8e..0d8cbea9 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitEventsApiController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitEventsApiController.php @@ -821,7 +821,6 @@ final class OAuth2SummitEventsApiController extends OAuth2ProtectedController return [$summit, $event, $data]; } - public function addEventAttachment(LaravelRequest $request, $summit_id, $event_id){ try { @@ -859,4 +858,29 @@ final class OAuth2SummitEventsApiController extends OAuth2ProtectedController } } + public function getUnpublishedEvents($summit_id){ + + try + { + $strategy = new RetrieveAllUnPublishedSummitEventsStrategy($this->repository, $this->event_repository); + $response = $strategy->getEvents(['summit_id' => $summit_id]); + return $this->ok($response->toArray(Request::input('expand', ''))); + } + catch (EntityNotFoundException $ex1) + { + Log::warning($ex1); + return $this->error404(); + } + catch (ValidationException $ex2) + { + Log::warning($ex2); + return $this->error412($ex2->getMessages()); + } + catch (Exception $ex) + { + Log::error($ex); + return $this->error500($ex); + } + } + } \ No newline at end of file diff --git a/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveAllUnPublishedSummitEventsStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveAllUnPublishedSummitEventsStrategy.php new file mode 100644 index 00000000..6ceca8fc --- /dev/null +++ b/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveAllUnPublishedSummitEventsStrategy.php @@ -0,0 +1,41 @@ +addFilterCondition(FilterParser::buildFilter('published','==','0')); + return $filter; + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveSummitEventsStrategy.php b/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveSummitEventsStrategy.php index f0f2a59e..bfae5139 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveSummitEventsStrategy.php +++ b/app/Http/Controllers/Apis/Protected/Summit/Strategies/events/RetrieveSummitEventsStrategy.php @@ -109,12 +109,18 @@ abstract class RetrieveSummitEventsStrategy { return array ( - 'title' => array('=@', '=='), - 'tags' => array('=@', '=='), - 'start_date' => array('>', '<', '<=', '>=', '=='), - 'end_date' => array('>', '<', '<=', '>=', '=='), - 'summit_type_id' => array('=='), - 'event_type_id' => array('=='), + 'title' => ['=@', '=='], + 'abstract' => ['=@', '=='], + 'social_summary' => ['=@', '=='], + 'tags' => ['=@', '=='], + 'start_date' => ['>', '<', '<=', '>=', '=='], + 'end_date' => ['>', '<', '<=', '>=', '=='], + 'summit_type_id' => ['=='], + 'event_type_id' => ['=='], + 'track_id' => ['=='], + 'speaker' => ['=@', '=='], + 'speaker_email' => ['=@', '=='], + 'selection_status' => ['=='], ); } } \ No newline at end of file diff --git a/app/Http/Utils/Filters/DoctrineCaseFilterMapping.php b/app/Http/Utils/Filters/DoctrineCaseFilterMapping.php new file mode 100644 index 00000000..422ad4e8 --- /dev/null +++ b/app/Http/Utils/Filters/DoctrineCaseFilterMapping.php @@ -0,0 +1,53 @@ +value = $value; + $this->condition = $condition; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * @return string + */ + public function getCondition() + { + return $this->condition; + } +} \ No newline at end of file diff --git a/app/Http/Utils/Filters/DoctrineFilterMapping.php b/app/Http/Utils/Filters/DoctrineFilterMapping.php new file mode 100644 index 00000000..f0e3bb7f --- /dev/null +++ b/app/Http/Utils/Filters/DoctrineFilterMapping.php @@ -0,0 +1,63 @@ +getValue(), $this->where); + $where = str_replace(":operator", $filter->getOperator(), $where); + return $query->andWhere($where); + } + + /** + * @param QueryBuilder $query + * @param FilterElement $filter + * @return string + */ + public function applyOr(QueryBuilder $query, FilterElement $filter){ + $where = str_replace(":value", $filter->getValue(), $this->where); + $where = str_replace(":operator", $filter->getOperator(), $where); + return $where; + } +} \ No newline at end of file diff --git a/app/Http/Utils/Filters/DoctrineSwitchFilterMapping.php b/app/Http/Utils/Filters/DoctrineSwitchFilterMapping.php new file mode 100644 index 00000000..5c55d4a3 --- /dev/null +++ b/app/Http/Utils/Filters/DoctrineSwitchFilterMapping.php @@ -0,0 +1,64 @@ +case_statements = $case_statements; + } + + /** + * @param FilterElement $filter + * @return string + */ + public function toRawSQL(FilterElement $filter) + { + throw new \Exception; + } + + /** + * @param QueryBuilder $query + * @param FilterElement $filter + * @return QueryBuilder + */ + public function apply(QueryBuilder $query, FilterElement $filter){ + if(!isset($this->case_statements[$filter->getValue()])) return $query; + $case_statement = $this->case_statements[$filter->getValue()]; + return $query->andWhere($case_statement->getCondition()); + } + + /** + * @param QueryBuilder $query + * @param FilterElement $filter + * @return string + */ + public function applyOr(QueryBuilder $query, FilterElement $filter){ + if(!isset($this->case_statements[$filter->getValue()])) return $query; + $case_statement = $this->case_statements[$filter->getValue()]; + return $case_statement->getCondition(); + } +} \ No newline at end of file diff --git a/app/Http/Utils/Filters/Filter.php b/app/Http/Utils/Filters/Filter.php index 36a89a80..d9190dde 100644 --- a/app/Http/Utils/Filters/Filter.php +++ b/app/Http/Utils/Filters/Filter.php @@ -74,6 +74,14 @@ final class Filter return $res; } + /** + * @param string $field + * @return bool + */ + public function hasFilter($field){ + return count($this->getFilter($field)) > 0; + } + /** * @param string $field * @return null|FilterElement[] @@ -166,6 +174,14 @@ final class Filter $query = $mapping->apply($query, $filter); continue; } + if ($mapping instanceof DoctrineSwitchFilterMapping) { + $query = $mapping->apply($query, $filter); + continue; + } + if ($mapping instanceof DoctrineFilterMapping) { + $query = $mapping->apply($query, $filter); + continue; + } else if(is_array($mapping)){ $condition = ''; foreach ($mapping as $mapping_or){ @@ -203,7 +219,19 @@ final class Filter $mapping = $mappings[$e->getField()]; if ($mapping instanceof DoctrineJoinFilterMapping) { $condition = $mapping->applyOr($query, $e); - if(!empty($condition)) $condition .= ' OR '; + if(!empty($sub_or_query)) $sub_or_query .= ' OR '; + $sub_or_query .= $condition; + continue; + } + if ($mapping instanceof DoctrineSwitchFilterMapping) { + $condition = $mapping->applyOr($query, $e); + if(!empty($sub_or_query)) $sub_or_query .= ' OR '; + $sub_or_query .= $condition; + continue; + } + if ($mapping instanceof DoctrineFilterMapping) { + $condition = $mapping->applyOr($query, $e); + if(!empty($sub_or_query)) $sub_or_query .= ' OR '; $sub_or_query .= $condition; continue; } diff --git a/app/Http/routes.php b/app/Http/routes.php index 42a834b3..42c4b34a 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -183,6 +183,10 @@ Route::group([ Route::group(array('prefix' => 'events'), function () { Route::get('', 'OAuth2SummitEventsApiController@getEvents'); + Route::group(array('prefix' => 'unpublished'), function () { + Route::get('', 'OAuth2SummitEventsApiController@getUnpublishedEvents'); + //Route::get('{event_id}', 'OAuth2SummitEventsApiController@getUnpublisedEvent'); + }); Route::get('/published', 'OAuth2SummitEventsApiController@getScheduledEvents'); Route::post('', [ 'middleware' => 'auth.user:administrators', 'uses' => 'OAuth2SummitEventsApiController@addEvent']); Route::group(array('prefix' => '{event_id}'), function () { diff --git a/app/Models/Foundation/Summit/Events/Presentations/Presentation.php b/app/Models/Foundation/Summit/Events/Presentations/Presentation.php index 084afb68..f2c02c1e 100644 --- a/app/Models/Foundation/Summit/Events/Presentations/Presentation.php +++ b/app/Models/Foundation/Summit/Events/Presentations/Presentation.php @@ -25,6 +25,84 @@ use Doctrine\Common\Collections\ArrayCollection; class Presentation extends SummitEvent { + /** + * Defines the phase that a presentation has been created, but + * no information has been saved to it. + */ + const PHASE_NEW = 0; + + /** + * Defines the phase where a presenation has been given a summary, + * but no speakers have been added + */ + const PHASE_SUMMARY = 1; + + /** + * defines a phase where a presentation has a tags + */ + const PHASE_TAGS = 2; + + /** + * defines a phase where a presentation has a summary and speakers + */ + const PHASE_SPEAKERS = 3; + + + /** + * Defines a phase where a presentation has been submitted successfully + */ + const PHASE_COMPLETE = 4; + + /** + * + */ + const STATUS_RECEIVED = 'Received'; + + const ClassNamePresentation = 'Presentation'; + + /** + * @ORM\Column(name="Level", type="string") + * @var string + */ + private $level; + + /** + * @ORM\Column(name="Status", type="string") + * @var string + */ + private $status; + + /** + * @ORM\Column(name="Progress", type="integer") + * @var int + */ + private $progress; + + /** + * @ORM\Column(name="ProblemAddressed", type="string") + * @var string + */ + private $problem_addressed; + + /** + * @ORM\Column(name="AttendeesExpectedLearnt", type="string") + * @var string + */ + private $attendees_expected_learnt; + + /** + * @ORM\Column(name="ToRecord", type="boolean") + * @var bool + */ + protected $to_record; + + /** + * @ORM\ManyToOne(targetEntity="PresentationSpeaker", inversedBy="moderated_presentations") + * @ORM\JoinColumn(name="ModeratorID", referencedColumnName="ID") + * @var PresentationSpeaker + */ + private $moderator; + /** * @ORM\OneToMany(targetEntity="models\summit\PresentationMaterial", mappedBy="presentation", cascade={"persist"}, orphanRemoval=true) * @var PresentationMaterial[] @@ -38,10 +116,10 @@ class Presentation extends SummitEvent private $speakers; /** - * @ORM\Column(name="ToRecord", type="boolean") - * @var bool + * @ORM\OneToMany(targetEntity="models\summit\SummitSelectedPresentation", mappedBy="presentation", cascade={"persist"}, orphanRemoval=true) + * @var SummitSelectedPresentation[] */ - protected $to_record; + private $selected_presentations; /** * @return bool @@ -107,23 +185,6 @@ class Presentation extends SummitEvent $this->problem_addressed = $problem_addressed; } - /** - * @ORM\Column(name="Level", type="string") - * @var string - */ - private $level; - - /** - * @ORM\Column(name="ProblemAddressed", type="string") - * @var string - */ - private $problem_addressed; - - /** - * @ORM\Column(name="AttendeesExpectedLearnt", type="string") - * @var string - */ - private $attendees_expected_learnt; /** * @return string @@ -148,8 +209,6 @@ class Presentation extends SummitEvent return self::ClassNamePresentation; } - const ClassNamePresentation = 'Presentation'; - /** * @return PresentationSpeaker[] */ @@ -292,13 +351,6 @@ class Presentation extends SummitEvent } } - /** - * @ORM\ManyToOne(targetEntity="PresentationSpeaker", inversedBy="moderated_presentations") - * @ORM\JoinColumn(name="ModeratorID", referencedColumnName="ID") - * @var PresentationSpeaker - */ - private $moderator; - /** * @return PresentationSpeaker */ @@ -319,4 +371,68 @@ class Presentation extends SummitEvent $this->moderator = null; } + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * @return mixed + */ + public function getProgress() + { + return $this->progress; + } + + /** + * @param mixed $progress + */ + public function setProgress($progress) + { + $this->progress = $progress; + } + + /** + * @return PresentationMaterial[] + */ + public function getMaterials() + { + return $this->materials; + } + + /** + * @param PresentationMaterial[] $materials + */ + public function setMaterials($materials) + { + $this->materials = $materials; + } + + /** + * @return SummitSelectedPresentation[] + */ + public function getSelectedPresentations() + { + return $this->selected_presentations; + } + + /** + * @param SummitSelectedPresentation[] $selected_presentations + */ + public function setSelectedPresentations($selected_presentations) + { + $this->selected_presentations = $selected_presentations; + } + } diff --git a/app/Models/Foundation/Summit/Events/Presentations/PresentationCategory.php b/app/Models/Foundation/Summit/Events/Presentations/PresentationCategory.php index 81907177..aa233209 100644 --- a/app/Models/Foundation/Summit/Events/Presentations/PresentationCategory.php +++ b/app/Models/Foundation/Summit/Events/Presentations/PresentationCategory.php @@ -43,6 +43,31 @@ class PresentationCategory extends SilverstripeBaseModel */ private $code; + /** + * @ORM\Column(name="SessionCount", type="integer") + * @var int + */ + private $session_count; + + /** + * @ORM\Column(name="AlternateCount", type="integer") + * @var int + */ + private $alternate_count; + + /** + * @ORM\Column(name="LightningCount", type="integer") + * @var int + */ + private $lightning_count; + + /** + * @ORM\Column(name="LightningAlternateCount", type="integer") + * @var int + */ + private $lightning_alternate_count; + + /** * @return string */ @@ -129,4 +154,67 @@ class PresentationCategory extends SilverstripeBaseModel return $this->groups; } + /** + * @return int + */ + public function getSessionCount() + { + return $this->session_count; + } + + /** + * @param int $session_count + */ + public function setSessionCount($session_count) + { + $this->session_count = $session_count; + } + + /** + * @return int + */ + public function getAlternateCount() + { + return $this->alternate_count; + } + + /** + * @param int $alternate_count + */ + public function setAlternateCount($alternate_count) + { + $this->alternate_count = $alternate_count; + } + + /** + * @return int + */ + public function getLightningCount() + { + return $this->lightning_count; + } + + /** + * @param int $lightning_count + */ + public function setLightningCount($lightning_count) + { + $this->lightning_count = $lightning_count; + } + + /** + * @return int + */ + public function getLightningAlternateCount() + { + return $this->lightning_alternate_count; + } + + /** + * @param int $lightning_alternate_count + */ + public function setLightningAlternateCount($lightning_alternate_count) + { + $this->lightning_alternate_count = $lightning_alternate_count; + } } \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/Presentations/PresentationSpeaker.php b/app/Models/Foundation/Summit/Events/Presentations/PresentationSpeaker.php index 7f309a94..ba5cdd96 100644 --- a/app/Models/Foundation/Summit/Events/Presentations/PresentationSpeaker.php +++ b/app/Models/Foundation/Summit/Events/Presentations/PresentationSpeaker.php @@ -34,6 +34,73 @@ class PresentationSpeaker extends SilverstripeBaseModel */ private $first_name; + /** + * @ORM\Column(name="LastName", type="string") + */ + private $last_name; + + /** + * @ORM\Column(name="Title", type="string") + */ + private $title; + + /** + * @ORM\Column(name="Bio", type="string") + */ + private $bio; + + /** + * @ORM\Column(name="IRCHandle", type="string") + */ + private $irc_handle; + + /** + * @ORM\Column(name="TwitterName", type="string") + */ + private $twitter_name; + + /** + * @ORM\ManyToOne(targetEntity="SpeakerRegistrationRequest") + * @ORM\JoinColumn(name="RegistrationRequestID", referencedColumnName="ID") + * @var SpeakerRegistrationRequest + */ + private $registration_request; + + + /** + * @ORM\ManyToMany(targetEntity="models\summit\Presentation", inversedBy="speakers") + * @ORM\JoinTable(name="Presentation_Speakers", + * joinColumns={ + * @ORM\JoinColumn(name="PresentationSpeakerID", referencedColumnName="ID") + * }, + * inverseJoinColumns={ + * @ORM\JoinColumn(name="PresentationID", referencedColumnName="ID") + * } + * ) + */ + private $presentations; + + /** + * @ORM\OneToMany(targetEntity="Presentation", mappedBy="moderator", cascade={"persist"}) + * @var Presentation[] + */ + private $moderated_presentations; + + + /** + * @ORM\ManyToOne(targetEntity="models\main\File") + * @ORM\JoinColumn(name="PhotoID", referencedColumnName="ID") + * @var File + */ + private $photo; + + /** + * @ORM\ManyToOne(targetEntity="models\main\Member") + * @ORM\JoinColumn(name="MemberID", referencedColumnName="ID") + * @var Member + */ + private $member; + /** * @return mixed */ @@ -130,50 +197,6 @@ class PresentationSpeaker extends SilverstripeBaseModel $this->twitter_name = $twitter_name; } - /** - * @ORM\Column(name="LastName", type="string") - */ - private $last_name; - - /** - * @ORM\Column(name="Title", type="string") - */ - private $title; - - /** - * @ORM\Column(name="Bio", type="string") - */ - private $bio; - - /** - * @ORM\Column(name="IRCHandle", type="string") - */ - private $irc_handle; - - /** - * @ORM\Column(name="TwitterName", type="string") - */ - private $twitter_name; - - /** - * @ORM\ManyToMany(targetEntity="models\summit\Presentation", inversedBy="speakers") - * @ORM\JoinTable(name="Presentation_Speakers", - * joinColumns={ - * @ORM\JoinColumn(name="PresentationSpeakerID", referencedColumnName="ID") - * }, - * inverseJoinColumns={ - * @ORM\JoinColumn(name="PresentationID", referencedColumnName="ID") - * } - * ) - */ - private $presentations; - - /** - * @ORM\OneToMany(targetEntity="Presentation", mappedBy="moderator", cascade={"persist"}) - * @var Presentation[] - */ - private $moderated_presentations; - public function __construct() { parent::__construct(); @@ -278,14 +301,6 @@ class PresentationSpeaker extends SilverstripeBaseModel })->toArray(); } - - /** - * @ORM\ManyToOne(targetEntity="models\main\File") - * @ORM\JoinColumn(name="PhotoID", referencedColumnName="ID") - * @var File - */ - protected $photo; - /** * @return File */ @@ -294,13 +309,6 @@ class PresentationSpeaker extends SilverstripeBaseModel return $this->photo; } - /** - * @ORM\ManyToOne(targetEntity="models\main\Member") - * @ORM\JoinColumn(name="MemberID", referencedColumnName="ID") - * @var Member - */ - private $member; - /** * @return Member */ @@ -328,4 +336,20 @@ class PresentationSpeaker extends SilverstripeBaseModel return 0; } } + + /** + * @return SpeakerRegistrationRequest + */ + public function getRegistrationRequest() + { + return $this->registration_request; + } + + /** + * @param SpeakerRegistrationRequest $registration_request + */ + public function setRegistrationRequest($registration_request) + { + $this->registration_request = $registration_request; + } } \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/Presentations/SpeakerRegistrationRequest.php b/app/Models/Foundation/Summit/Events/Presentations/SpeakerRegistrationRequest.php new file mode 100644 index 00000000..98cf34aa --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/SpeakerRegistrationRequest.php @@ -0,0 +1,140 @@ +email; + } + + /** + * @param mixed $email + */ + public function setEmail($email) + { + $this->email = $email; + } + + /** + * @return mixed + */ + public function isConfirmed() + { + return $this->is_confirmed; + } + + /** + * @param mixed $is_confirmed + */ + public function setIsConfirmed($is_confirmed) + { + $this->is_confirmed = $is_confirmed; + } + + /** + * @return mixed + */ + public function getConfirmationDate() + { + return $this->confirmation_date; + } + + /** + * @param mixed $confirmation_date + */ + public function setConfirmationDate($confirmation_date) + { + $this->confirmation_date = $confirmation_date; + } + + /** + * @return PresentationSpeaker + */ + public function getModerator() + { + return $this->moderator; + } + + /** + * @param PresentationSpeaker $moderator + */ + public function setModerator($moderator) + { + $this->moderator = $moderator; + } + + /** + * @return Member + */ + public function getProposer() + { + return $this->proposer; + } + + /** + * @param Member $proposer + */ + public function setProposer($proposer) + { + $this->proposer = $proposer; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/Presentations/SummitSelectedPresentation.php b/app/Models/Foundation/Summit/Events/Presentations/SummitSelectedPresentation.php new file mode 100644 index 00000000..21a3c975 --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/SummitSelectedPresentation.php @@ -0,0 +1,144 @@ +collection; + } + + /** + * @param string $collection + */ + public function setCollection($collection) + { + $this->collection = $collection; + } + + /** + * @return int + */ + public function getOrder() + { + return $this->order; + } + + /** + * @param int $order + */ + public function setOrder($order) + { + $this->order = $order; + } + + /** + * @return SummitSelectedPresentationList + */ + public function getList() + { + return $this->list; + } + + /** + * @param SummitSelectedPresentationList $list + */ + public function setList($list) + { + $this->list = $list; + } + + /** + * @return Presentation + */ + public function getPresentation() + { + return $this->presentation; + } + + /** + * @param Presentation $presentation + */ + public function setPresentation($presentation) + { + $this->presentation = $presentation; + } + + /** + * @return Member + */ + public function getMember() + { + return $this->member; + } + + /** + * @param Member $member + */ + public function setMember($member) + { + $this->member = $member; + } +} diff --git a/app/Models/Foundation/Summit/Events/Presentations/SummitSelectedPresentationList.php b/app/Models/Foundation/Summit/Events/Presentations/SummitSelectedPresentationList.php new file mode 100644 index 00000000..06388126 --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/SummitSelectedPresentationList.php @@ -0,0 +1,193 @@ +selected_presentations = new ArrayCollection(); + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getListType() + { + return $this->list_type; + } + + /** + * @param string $list_type + */ + public function setListType($list_type) + { + $this->list_type = $list_type; + } + + /** + * @return string + */ + public function getListClass() + { + return $this->list_class; + } + + /** + * @param string $list_class + */ + public function setListClass($list_class) + { + $this->list_class = $list_class; + } + + /** + * @return string + */ + public function getHash() + { + return $this->hash; + } + + /** + * @param string $hash + */ + public function setHash($hash) + { + $this->hash = $hash; + } + + /** + * @return PresentationCategory + */ + public function getCategory() + { + return $this->category; + } + + /** + * @param PresentationCategory $category + */ + public function setCategory($category) + { + $this->category = $category; + } + + /** + * @return Member + */ + public function getMember() + { + return $this->member; + } + + /** + * @param Member $member + */ + public function setMember($member) + { + $this->member = $member; + } + + /** + * @return SummitSelectedPresentation[] + */ + public function getSelectedPresentations() + { + return $this->selected_presentations; + } + + /** + * @param SummitSelectedPresentation[] $selected_presentations + */ + public function setSelectedPresentations($selected_presentations) + { + $this->selected_presentations = $selected_presentations; + } +} \ No newline at end of file diff --git a/app/Repositories/Summit/DoctrineSummitEventRepository.php b/app/Repositories/Summit/DoctrineSummitEventRepository.php index 36d0ae16..bd88edbb 100644 --- a/app/Repositories/Summit/DoctrineSummitEventRepository.php +++ b/app/Repositories/Summit/DoctrineSummitEventRepository.php @@ -17,7 +17,10 @@ use Doctrine\ORM\Tools\Pagination\Paginator; use models\summit\ISummitEventRepository; use models\summit\SummitEvent; use App\Repositories\SilverStripeDoctrineRepository; +use utils\DoctrineCaseFilterMapping; +use utils\DoctrineFilterMapping; use utils\DoctrineJoinFilterMapping; +use utils\DoctrineSwitchFilterMapping; use utils\Filter; use utils\Order; use utils\PagingInfo; @@ -66,11 +69,13 @@ final class DoctrineSummitEventRepository protected function getFilterMappings() { return [ - 'title' => 'e.title:json_string', - 'published' => 'e.published', - 'start_date' => 'e.start_date:datetime_epoch', - 'end_date' => 'e.end_date:datetime_epoch', - 'tags' => new DoctrineJoinFilterMapping + 'title' => 'e.title:json_string', + 'abstract' => 'e.abstract:json_string', + 'social_summary' => 'e.social_summary:json_string', + 'published' => 'e.published', + 'start_date' => 'e.start_date:datetime_epoch', + 'end_date' => 'e.end_date:datetime_epoch', + 'tags' => new DoctrineJoinFilterMapping ( 'e.tags', 't', @@ -100,11 +105,44 @@ final class DoctrineSummitEventRepository 'c', "c.id :operator :value" ), - 'speaker' => new DoctrineJoinFilterMapping + 'speaker' => new DoctrineFilterMapping ( - 'e.speakers', - 'sp', - "concat(sp.first_name, ' ', sp.last_name) :operator ':value'" + "( concat(sp.first_name, ' ', sp.last_name) :operator ':value' ". + "OR concat(spm.first_name, ' ', spm.last_name) :operator ':value' ". + "OR concat(spmm.first_name, ' ', spmm.last_name) :operator ':value' ". + "OR sp.first_name :operator ':value' ". + "OR sp.last_name :operator ':value' ". + "OR spm.first_name :operator ':value' ". + "OR spm.last_name :operator ':value' ". + "OR spmm.first_name :operator ':value' ". + "OR spmm.last_name :operator ':value' )" + ), + 'speaker_email' => new DoctrineFilterMapping + ( + "(sprr.email :operator ':value' OR spmm.email :operator ':value')" + ), + 'selection_status' => new DoctrineSwitchFilterMapping([ + 'selected' => new DoctrineCaseFilterMapping( + 'selected', + "ssp.order is not null and sspl.list_type = 'Group' and sspl.category = e.category" + ), + 'accepted' => new DoctrineCaseFilterMapping( + 'accepted', + "ssp.`order` is not null and ssp.order <= e.category.session_count and sspl.list_type = 'Group' and sspl.list_class = 'Session' and sspl.category = e.category" + ), + 'alternate' => new DoctrineCaseFilterMapping( + 'alternate', + "ssp.`order` is not null and ssp.`order` > e.category.session_count and sspl.list_type = 'Group' and sspl.list_class = 'Session' and sspl.category = e.category" + ), + 'lightning-accepted' => new DoctrineCaseFilterMapping( + 'lightning-accepted', + "ssp.`order` is not null and ssp.`order` <= e.category.lightning_count and sspl.list_type = 'Group' and sspl.list_class = 'Lightning' and sspl.category = e.category" + ), + 'lightning-alternate' => new DoctrineCaseFilterMapping( + 'lightning-alternate', + "ssp.`order` is not null and ssp.`order` > e.category.lightning_count and sspl.list_type = 'Group' and sspl.list_class = 'Lightning' and sspl.category = e.category" + ), + ] ), ]; } @@ -131,8 +169,10 @@ final class DoctrineSummitEventRepository */ public function getAllByPage(PagingInfo $paging_info, Filter $filter = null, Order $order = null) { - $class = count($filter->getFilter('speaker')) > 0? - \models\summit\Presentation::class : + $class = $filter->hasFilter('speaker') + || $filter->hasFilter('selection_status') + || $filter->hasFilter('speaker_email')? + \models\summit\Presentation::class: \models\summit\SummitEvent::class; $query = $this->getEntityManager()->createQueryBuilder() @@ -140,7 +180,6 @@ final class DoctrineSummitEventRepository ->from($class, "e"); if(!is_null($filter)){ - $filter->apply2Query($query, $this->getFilterMappings()); } @@ -152,17 +191,26 @@ final class DoctrineSummitEventRepository $query = $query->addOrderBy("e.end_date", 'ASC'); } - $query= $query + if($class == \models\summit\Presentation::class) { + $query = $query->innerJoin("e.speakers", "sp", Join::WITH); + $query = $query->leftJoin('e.selected_presentations', "ssp", Join::LEFT_JOIN); + $query = $query->leftJoin('ssp.list', "sspl", Join::LEFT_JOIN); + $query = $query->leftJoin('e.moderator', "spm", Join::LEFT_JOIN); + $query = $query->leftJoin('sp.member', "spmm", Join::LEFT_JOIN); + $query = $query->leftJoin('sp.registration_request', "sprr", Join::LEFT_JOIN); + } + + $query = $query ->andWhere("not e INSTANCE OF ('" . implode("','", self::$forbidded_classes) . "')") ->setFirstResult($paging_info->getOffset()) ->setMaxResults($paging_info->getPerPage()); $paginator = new Paginator($query, $fetchJoinCollection = true); $total = $paginator->count(); - $data = array(); + $data = []; foreach($paginator as $entity) - array_push($data, $entity); + $data[]= $entity; return new PagingResponse ( diff --git a/database/seeds/ApiEndpointsSeeder.php b/database/seeds/ApiEndpointsSeeder.php index 453328d9..0d50829b 100644 --- a/database/seeds/ApiEndpointsSeeder.php +++ b/database/seeds/ApiEndpointsSeeder.php @@ -170,6 +170,12 @@ class ApiEndpointsSeeder extends Seeder 'http_method' => 'GET', 'scopes' => [sprintf('%s/summits/read', $current_realm)], ), + array( + 'name' => 'get-unpublished-events', + 'route' => '/api/v1/summits/{id}/events/unpublished', + 'http_method' => 'GET', + 'scopes' => [sprintf('%s/summits/read', $current_realm)], + ), array( 'name' => 'get-all-events', 'route' => '/api/v1/summits/events', diff --git a/tests/OAuth2SummitApiTest.php b/tests/OAuth2SummitApiTest.php index 8a1194af..28fdd9d7 100644 --- a/tests/OAuth2SummitApiTest.php +++ b/tests/OAuth2SummitApiTest.php @@ -2389,4 +2389,38 @@ final class OAuth2SummitApiTest extends ProtectedApiTest $content = $response->getContent(); $this->assertResponseStatus(204); } + + public function testGetUnpublishedEventBySummit() + { + $params = [ + + 'id' => 23, + //'filter' => ['speaker=@Jimmy', 'speaker=@Chimmy'], + 'filter' => ['speaker=@Jimmy,speaker=@Chimmy'], + 'expand' => 'speakers', + ]; + + $headers = [ + + "HTTP_Authorization" => " Bearer " . $this->access_token, + "CONTENT_TYPE" => "application/json" + ]; + + $response = $this->action + ( + "GET", + "OAuth2SummitEventsApiController@getUnpublishedEvents", + $params, + [], + [], + [], + $headers + ); + + $content = $response->getContent(); + $this->assertResponseStatus(200); + + $events = json_decode($content); + $this->assertTrue(!is_null($events)); + } } \ No newline at end of file