diff --git a/.gitignore b/.gitignore
index 56caf5ad..b214c01b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,7 +3,6 @@
composer.phar
composer.lock
.DS_Storeapp/storage
-/app/storage/*
.idea/*
app/config/dev/*
app/config/testing/*
@@ -23,4 +22,6 @@ doc/build
*.egg
*.egg-info
.env.testing
-.env
\ No newline at end of file
+.env
+storage/logs/*
+*.log
\ No newline at end of file
diff --git a/Libs/ModelSerializers/AbstractSerializer.php b/Libs/ModelSerializers/AbstractSerializer.php
new file mode 100644
index 00000000..2e65e844
--- /dev/null
+++ b/Libs/ModelSerializers/AbstractSerializer.php
@@ -0,0 +1,187 @@
+object = $object;
+
+ }
+
+ protected static $array_mappings = array();
+
+ protected static $allowed_fields = array();
+
+ protected static $allowed_relations = array();
+
+ /**
+ * @return array
+ */
+ protected function getAllowedFields()
+ {
+ $mappings = array();
+ $hierarchy = $this->getClassHierarchy();
+
+ foreach($hierarchy as $class_name){
+ if($class_name === 'Libs\ModelSerializers\AbstractSerializer') continue;
+ $class = new $class_name($this->object);
+ $mappings = array_merge($mappings, $class->getSelfAllowedFields());
+ }
+ $mappings = array_merge($mappings, $this->getSelfAllowedFields());
+ return $mappings;
+ }
+
+ private function getSelfAllowedFields(){
+ return static::$allowed_fields;
+ }
+
+ /**
+ * @return array
+ */
+ protected function getAllowedRelations()
+ {
+ $mappings = array();
+ $hierarchy = $this->getClassHierarchy();
+
+ foreach($hierarchy as $class_name){
+ if($class_name === 'Libs\ModelSerializers\AbstractSerializer') continue;
+ $class = new $class_name($this->object);
+ $mappings = array_merge($mappings, $class->getSelfAllowedRelations());
+ }
+ $mappings = array_merge($mappings, $this->getSelfAllowedRelations());
+ return $mappings;
+ }
+
+ private function getSelfAllowedRelations(){
+ return static::$allowed_relations;
+ }
+
+ /**
+ * @return array
+ */
+ private function getAttributeMappings()
+ {
+ $mappings = array();
+ $hierarchy = $this->getClassHierarchy();
+
+ foreach($hierarchy as $class_name){
+ if($class_name === 'Libs\ModelSerializers\AbstractSerializer') continue;
+ $class = new $class_name($this->object);
+ $mappings = array_merge($mappings, $class->getSelfMappings());
+ }
+ $mappings = array_merge($mappings, $this->getSelfMappings());
+ return $mappings;
+ }
+
+ private function getSelfMappings(){
+ return static::$array_mappings;
+ }
+
+ /**
+ * @return array
+ */
+ private function getClassHierarchy(){
+ return array_reverse($this->get_class_lineage($this));
+ }
+
+ private function get_class_lineage($object)
+ {
+ $class_name = get_class($object);
+ $parents = array_values(class_parents($class_name));
+ return array_merge(array($class_name), $parents);
+ }
+
+ /**
+ * @param null $expand
+ * @param array $fields
+ * @param array $relations
+ * @param array $params
+ * @return array
+ */
+ public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array() )
+ {
+ $values = array();
+ if(!count($fields)) $fields = $this->getAllowedFields();
+ $mappings = $this->getAttributeMappings();
+
+ if (count($mappings)) {
+ $new_values = array();
+ foreach ($mappings as $attribute => $mapping) {
+ $mapping = preg_split('/:/',$mapping);
+ $value = call_user_func( array( $this->object, 'get'.$attribute ) );
+ if(count($mapping) > 1)
+ {
+ //we have a formatter ...
+ switch(strtolower($mapping[1]))
+ {
+ case 'datetime_epoch':
+ {
+ if(!is_null($value)) {
+ $value = $value->getTimestamp();
+ }
+ }
+ break;
+ case 'json_string':
+ {
+ $value = JsonUtils::toJsonString($value);
+ }
+ break;
+ case 'json_boolean':
+ {
+ $value = JsonUtils::toJsonBoolean($value);
+ }
+ break;
+ case 'json_int':
+ {
+ $value = JsonUtils::toJsonInt($value);
+ }
+ break;
+ case 'json_float':
+ {
+ $value = JsonUtils::toJsonFloat($value);
+ }
+ break;
+ }
+ }
+ $new_values[$mapping[0]] = $value;
+ }
+ $values = $new_values;
+ }
+ //check requested fields
+ if(count($fields) > 0) {
+ foreach ($values as $field => $value) {
+ if (in_array($field, $fields)) continue;
+ unset($values[$field]);
+ }
+ }
+ return $values;
+ }
+}
\ No newline at end of file
diff --git a/Libs/ModelSerializers/IModelSerializer.php b/Libs/ModelSerializers/IModelSerializer.php
new file mode 100644
index 00000000..dcc7f461
--- /dev/null
+++ b/Libs/ModelSerializers/IModelSerializer.php
@@ -0,0 +1,25 @@
+comment(PHP_EOL.Inspiring::quote().PHP_EOL);
+ }
+}
diff --git a/app/Console/Commands/SummitJsonGenerator.php b/app/Console/Commands/SummitJsonGenerator.php
index d89d95d7..9b094ec4 100644
--- a/app/Console/Commands/SummitJsonGenerator.php
+++ b/app/Console/Commands/SummitJsonGenerator.php
@@ -1,19 +1,31 @@
repository->getCurrent();
- if(is_null($this->repository)) return;
- $this->info(sprintf("processing summit id %s", $summit->ID));
+ $summit_id = $this->argument('summit_id');
+
+ if(is_null($summit_id))// if we dont provide a summit id, then get current
+ $summit = $this->repository->getCurrent();
+ else
+ $summit = $this->repository->getById(intval($summit_id));
+
+ if(is_null($summit)) return;
+
+ $this->info(sprintf("processing summit id %s", $summit->getIdentifier()));
$start = time();
- $data = $this->service->getSummitData($summit, $expand = 'locations,sponsors,summit_types,event_types,presentation_categories,schedule');
+ $expand = 'locations,sponsors,summit_types,event_types,presentation_categories,schedule';
+
+ $data = SerializerRegistry::getInstance()->getSerializer($summit)->serialize($expand);
if(is_null($data)) return;
$end = time();
$delta = $end - $start;
$this->info(sprintf("execution call %s seconds", $delta));
$current_time = time();
- $key = '/api/v1/summits/current.expand=locations%2Csponsors%2Csummit_types%2Cevent_types%2Cpresentation_categories%2Cschedule';
+ $key_current = sprintf('/api/v1/summits/%s.expand=%s','current', urlencode($expand));
+ $key_id = sprintf('/api/v1/summits/%s.expand=%s',$summit->getIdentifier(), urlencode($expand));
+
$cache_lifetime = intval(Config::get('server.response_cache_lifetime', 300));
- $this->cache_service->setSingleValue($key, json_encode($data), $cache_lifetime);
- $this->cache_service->setSingleValue($key.".generated", $current_time, $cache_lifetime);
- $this->info(sprintf("regenerated cache for summit id %s", $summit->ID));
+
+ if($summit->isActive())
+ {
+ $this->cache_service->setSingleValue($key_current, json_encode($data), $cache_lifetime);
+ $this->cache_service->setSingleValue($key_current . ".generated", $current_time, $cache_lifetime);
+ }
+
+ $this->cache_service->setSingleValue($key_id, json_encode($data), $cache_lifetime);
+ $this->cache_service->setSingleValue($key_id.".generated", $current_time, $cache_lifetime);
+
+ $this->info(sprintf("regenerated cache for summit id %s", $summit->getIdentifier()));
}
}
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index a0e0d7f8..951ba586 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -1,29 +1,32 @@
-command('summit:json:generator')->everyTenMinutes();
- }
+ /**
+ * Define the application's command schedule.
+ *
+ * @param \Illuminate\Console\Scheduling\Schedule $schedule
+ * @return void
+ */
+ protected function schedule(Schedule $schedule)
+ {
+ // current
+ $schedule->command('summit:json-generator')->everyTenMinutes()->withoutOverlapping();
+ //austin
+ $schedule->command('summit:json-generator 6')->everyTenMinutes()->withoutOverlapping();
+ }
}
diff --git a/app/Events/Event.php b/app/Events/Event.php
index d59f7690..ba2f8883 100644
--- a/app/Events/Event.php
+++ b/app/Events/Event.php
@@ -1,7 +1,8 @@
-material = $material;
+ }
+
+ /**
+ * @return PresentationMaterial
+ */
+ public function getMaterial(){
+ return $this->material;
+ }
+}
\ No newline at end of file
diff --git a/app/Models/main/Image.php b/app/Events/SummitEventCreated.php
similarity index 72%
rename from app/Models/main/Image.php
rename to app/Events/SummitEventCreated.php
index b710fd15..0149d474 100644
--- a/app/Models/main/Image.php
+++ b/app/Events/SummitEventCreated.php
@@ -1,6 +1,6 @@
-summit_event = $summit_event;
+ $this->args = $args;
+ }
+
+ /**
+ * @return SummitEvent
+ */
+ public function getSummitEvent()
+ {
+ return $this->summit_event;
+ }
+
+ /**
+ * @return LifecycleEventArgs
+ */
+ public function getArgs()
+ {
+ return $this->args;
+ }
+
+}
\ No newline at end of file
diff --git a/app/Events/SummitEventUpdated.php b/app/Events/SummitEventUpdated.php
new file mode 100644
index 00000000..720306d8
--- /dev/null
+++ b/app/Events/SummitEventUpdated.php
@@ -0,0 +1,22 @@
+view('errors.404', [], 404);
}
-
}
diff --git a/app/Factories/FactoriesProvider.php b/app/Factories/FactoriesProvider.php
new file mode 100644
index 00000000..773d10d5
--- /dev/null
+++ b/app/Factories/FactoriesProvider.php
@@ -0,0 +1,32 @@
+setYoutubeId(trim($data['you_tube_id']));
+ $video->setDateUploaded($utc_now);
+
+ if(isset($data['name']))
+ $video->setName(trim($data['name']));
+
+ if(isset($data['description']))
+ $video->setDescription(trim($data['description']));
+
+ $video->setDisplayOnSite(isset($data['display_on_site']) ? (bool)$data['display_on_site'] : true);
+
+ return $video;
+ }
+}
\ No newline at end of file
diff --git a/app/Handlers/Commands/.gitkeep b/app/Handlers/Commands/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/Handlers/Events/.gitkeep b/app/Handlers/Events/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 27b3f452..c9fa9197 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -1,11 +1,16 @@
setCallback(Input::get('callback'));
}
-
return $res;
}
-
+ /**
+ * @param mixed $data
+ * @return mixed
+ */
protected function ok($data = 'ok')
{
$res = Response::json($data, 200);
diff --git a/app/Http/Controllers/apis/protected/summit/CheckAttendeeStrategyFactory.php b/app/Http/Controllers/apis/protected/summit/CheckAttendeeStrategyFactory.php
index 30f6e6ae..2b33c540 100644
--- a/app/Http/Controllers/apis/protected/summit/CheckAttendeeStrategyFactory.php
+++ b/app/Http/Controllers/apis/protected/summit/CheckAttendeeStrategyFactory.php
@@ -1,4 +1,4 @@
-presentation_service = $presentation_service;
+ $this->summit_repository = $summit_repository;
+ }
+
+ //presentations
+
+ //videos
+
+ public function getPresentationVideos($summit_id, $presentation_id){
+ try {
+ $summit = SummitFinderStrategyFactory::build($this->summit_repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ } catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+
+ public function getPresentationVideo($summit_id, $presentation_id,$video_id){
+ try {
+ $summit = SummitFinderStrategyFactory::build($this->summit_repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ } catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ public function addVideo(LaravelRequest $request, $summit_id, $presentation_id){
+ try {
+ $summit = SummitFinderStrategyFactory::build($this->summit_repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ if (!$request->isJson()) {
+ return $this->error412(array('invalid content type!'));
+ }
+ if(!Request::isJson()) return $this->error403();
+
+ $data = Input::json();
+
+ $rules = array
+ (
+ 'you_tube_id' => 'required|alpha_dash',
+ 'name' => 'sometimes|required|text:512',
+ 'description' => 'sometimes|required|text|max:512',
+ 'display_on_site' => 'sometimes|required|boolean',
+ );
+
+ $data = $data->all();
+ // Creates a Validator instance and validates the data.
+ $validation = Validator::make($data, $rules);
+
+ if ($validation->fails()) {
+ $ex = new ValidationException;
+ $ex->setMessages($validation->messages()->toArray());
+ throw $ex;
+ }
+
+ $video = $this->presentation_service->addVideoTo($presentation_id, $data);
+
+ return $this->created($video->getId());
+ }
+ 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/OAuth2SummitApiController.php b/app/Http/Controllers/apis/protected/summit/OAuth2SummitApiController.php
index 6e3ab639..f807afe4 100644
--- a/app/Http/Controllers/apis/protected/summit/OAuth2SummitApiController.php
+++ b/app/Http/Controllers/apis/protected/summit/OAuth2SummitApiController.php
@@ -1,27 +1,6 @@
repository = $summit_repository;
- $this->speaker_repository = $speaker_repository;
- $this->event_repository = $event_repository;
- $this->service = $service;
+ $this->repository = $summit_repository;
+ $this->speaker_repository = $speaker_repository;
+ $this->event_repository = $event_repository;
+ $this->event_feedback_repository = $event_feedback_repository;
+ $this->service = $service;
}
public function getSummits()
{
try {
- $summits = $this->repository->getAll();
+ $summits = array();
+ foreach($this->repository->getAll() as $summit){
+ $summits[] = SerializerRegistry::getInstance()->getSerializer($summit)->serialize();
+ }
return $this->ok($summits);
}
catch (Exception $ex) {
@@ -88,1114 +96,13 @@ class OAuth2SummitApiController extends OAuth2ProtectedController
try {
$summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
if (is_null($summit)) return $this->error404();
- $data = $this->service->getSummitData($summit, $expand);
- return $this->ok($data);
+ return $this->ok(SerializerRegistry::getInstance()->getSerializer($summit)->serialize($expand));
} catch (Exception $ex) {
Log::error($ex);
return $this->error500($ex);
}
}
- /**
- * Attendees endpoints
- */
-
- /**
- * @param $summit_id
- * @return mixed
- */
- public function getAttendees($summit_id)
- {
- try {
-
- $values = Input::all();
-
- $rules = array
- (
- 'page' => 'integer|min:1',
- 'per_page' => 'required_with:page|integer|min:5|max:100',
- );
-
- $validation = Validator::make($values, $rules);
-
- if ($validation->fails()) {
- $messages = $validation->messages()->toArray();
- return $this->error412($messages);
- }
-
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- // default values
- $page = 1;
- $per_page = 5;
-
- if (Input::has('page')) {
- $page = intval(Input::get('page'));
- $per_page = intval(Input::get('per_page'));
- }
-
- $filter = null;
- if (Input::has('filter')) {
- $filter = FilterParser::parse(Input::get('filter'), array
- (
- 'first_name' => array('=@', '=='),
- 'last_name' => array('=@', '=='),
- 'email' => array('=@', '=='),
- ));
- }
-
- $order = null;
- if (Input::has('order'))
- {
- $order = OrderParser::parse(Input::get('order'), array
- (
- 'first_name',
- 'last_name',
- ));
- }
-
- list($total, $per_page, $current_page, $last_page, $items) = $summit->attendees($page, $per_page, $filter, $order);
-
- return $this->ok
- (
- array
- (
- 'total' => $total,
- 'per_page' => $per_page,
- 'current_page' => $current_page,
- 'last_page' => $last_page,
- 'data' => $items,
- )
- );
-
- }
- catch (Exception $ex)
- {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $attendee_id
- * @return mixed
- */
- public function getAttendee($summit_id, $attendee_id)
- {
- $expand = Request::input('expand', '');
-
- try {
-
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- $attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
- if(is_null($attendee)) return $this->error404();
-
- $data = $attendee->toArray();
- $speaker = $summit->getSpeakerByMemberId(intval($data['member_id']));
-
- if (!is_null($speaker)) {
- $data['speaker_id'] = intval($speaker->ID);
- }
-
- if (!empty($expand)) {
- $expand = explode(',', $expand);
- foreach ($expand as $relation) {
- switch (trim($relation)) {
- case 'schedule': {
- unset($data['schedule']);
- $schedule = array();
- foreach ($attendee->schedule() as $event) {
- $event->setFromAttendee();
- array_push($schedule, $event->toArray());
- }
- $data['schedule'] = $schedule;
- }
- break;
- case 'ticket_type': {
- unset($data['tickets']);
- $tickets = array();
- foreach($attendee->tickets() as $t)
- {
- array_push($tickets, $t->ticket_type()->toArray());
- }
- $data['tickets'] = $tickets;
- }
- break;
- case 'speaker': {
- if (!is_null($speaker))
- {
- unset($data['speaker_id']);
- $data['speaker'] = $speaker->toArray();
- }
- }
- break;
- case 'feedback': {
- $feedback = array();
- foreach ($attendee->emitted_feedback() as $f) {
- array_push($feedback, $f->toArray());
- }
- $data['feedback'] = $feedback;
- }
- break;
- }
- }
- }
-
- return $this->ok($data);
- }
- catch (\HTTP401UnauthorizedException $ex1) {
- Log::warning($ex1);
- return $this->error401();
- }
- catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $attendee_id
- * @return mixed
- */
- public function getAttendeeSchedule($summit_id, $attendee_id)
- {
- try {
-
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- $attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
- if(is_null($attendee)) return $this->error404();
-
- $schedule = array();
- foreach ($attendee->schedule() as $event) {
- $event->setFromAttendee();
- array_push($schedule, $event->toArray());
- }
-
- return $this->ok($schedule);
- }
- catch (\HTTP401UnauthorizedException $ex1)
- {
- Log::warning($ex1);
- return $this->error401();
- }
- catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $attendee_id
- * @param $event_id
- * @return mixed
- */
- public function addEventToAttendeeSchedule($summit_id, $attendee_id, $event_id)
- {
- try {
-
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- $attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
- if (is_null($attendee)) return $this->error404();
-
- $res = $this->service->addEventToAttendeeSchedule($summit, $attendee, intval($event_id));
-
- return $res ? $this->created() : $this->error400();
- }
- catch (ValidationException $ex1)
- {
- Log::warning($ex1);
- return $this->error412(array( $ex1->getMessage()));
- }
- catch (EntityNotFoundException $ex2)
- {
- Log::warning($ex2);
- return $this->error404(array('message' => $ex2->getMessage()));
- }
- catch(\HTTP401UnauthorizedException $ex3)
- {
- Log::warning($ex3);
- return $this->error401();
- }
- catch (Exception $ex)
- {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $attendee_id
- * @param $event_id
- * @return mixed
- */
- public function removeEventFromAttendeeSchedule($summit_id, $attendee_id, $event_id)
- {
- try {
-
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- $attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
- if (is_null($attendee)) return $this->error404();
-
- $res = $this->service->removeEventFromAttendeeSchedule($summit, $attendee, intval($event_id));
-
- return $res ? $this->deleted() : $this->error400();
-
- }
- catch (ValidationException $ex1)
- {
- Log::warning($ex1);
- return $this->error412(array( $ex1->getMessage()));
- }
- catch (EntityNotFoundException $ex2)
- {
- Log::warning($ex2);
- return $this->error404(array('message' => $ex2->getMessage()));
- }
- catch(\HTTP401UnauthorizedException $ex3)
- {
- Log::warning($ex3);
- return $this->error401();
- }
- catch (Exception $ex)
- {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $attendee_id
- * @param $event_id
- * @return mixed
- */
- public function checkingAttendeeOnEvent($summit_id, $attendee_id, $event_id)
- {
- try {
-
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- $attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
- if (is_null($attendee)) return $this->error404();
-
- $res = $this->service->checkInAttendeeOnEvent($summit, $attendee, intval($event_id));
-
- return $res ? $this->updated() : $this->error400();
- }
- catch (ValidationException $ex1)
- {
- Log::warning($ex1);
- return $this->error412(array( $ex1->getMessage()));
- }
- catch (EntityNotFoundException $ex2)
- {
- Log::warning($ex2);
- return $this->error404(array('message' => $ex2->getMessage()));
- }
- catch(\HTTP401UnauthorizedException $ex3)
- {
- Log::warning($ex3);
- return $this->error401();
- }
- catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * Speakers endpoints
- */
-
- /**
- * @param $summit_id
- * @return mixed
- */
- public function getSpeakers($summit_id)
- {
- try {
-
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- $values = Input::all();
-
- $rules = array
- (
- 'page' => 'integer|min:1',
- 'per_page' => 'required_with:page|integer|min:10|max:100',
- );
-
- $validation = Validator::make($values, $rules);
-
- if ($validation->fails())
- {
- $messages = $validation->messages()->toArray();
-
- return $this->error412($messages);
- }
-
- // default values
- $page = 1;
- $per_page = 10;
-
- if (Input::has('page'))
- {
- $page = intval(Input::get('page'));
- $per_page = intval(Input::get('per_page'));
- }
-
- $filter = null;
- if (Input::has('filter'))
- {
- $filter = FilterParser::parse(Input::get('filter'), array
- (
- 'first_name' => array('=@', '=='),
- 'last_name' => array('=@', '=='),
- 'email' => array('=@', '=='),
- ));
- }
-
-
- $order = null;
- if (Input::has('order'))
- {
- $order = OrderParser::parse(Input::get('order'), array
- (
- 'first_name',
- 'last_name',
- ));
- }
-
- $result = $this->speaker_repository->getSpeakersBySummit($summit, new PagingInfo($page, $per_page), $filter, $order);
-
- return $this->ok
- (
- $result->toArray()
- );
- }
- catch (Exception $ex)
- {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $speaker_id
- * @return mixed
- */
- public function getSpeaker($summit_id, $speaker_id)
- {
- $expand = Request::input('expand', '');
-
- try {
-
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- $speaker = CheckSpeakerStrategyFactory::build(CheckSpeakerStrategyFactory::Me, $this->resource_server_context)->check($speaker_id, $summit);
- if (is_null($speaker)) return $this->error404();
-
- $data = $speaker->toArray($summit->ID);
-
- if (!empty($expand)) {
- $expand = explode(',', $expand);
- foreach ($expand as $relation) {
- switch (trim($relation)) {
- case 'presentations': {
- $presentations = array();
- unset($data['presentations']);
- foreach ($speaker->presentations($summit->ID) as $event) {
- $event->setFromSpeaker();
- array_push($presentations, $event->toArray());
- }
- $data['presentations'] = $presentations;
- }
- break;
- }
- }
- }
-
- return $this->ok($data);
-
- } catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * Events endpoints
- */
-
- /**
- * @param $summit_id
- * @return mixed
- */
- public function getEvents($summit_id)
- {
- try
- {
- $strategy = new RetrieveAllSummitEventsBySummitStrategy($this->repository);
- return $this->ok($strategy->getEvents(array('summit_id' => $summit_id))->toArray());
- }
- 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);
- }
- }
-
- /**
- * @param $summit_id
- * @return mixed
- */
- public function getScheduledEvents($summit_id)
- {
- try
- {
- $strategy = new RetrievePublishedSummitEventsBySummitStrategy($this->repository);
- return $this->ok($strategy->getEvents(array('summit_id' => $summit_id))->toArray());
- }
- 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);
- }
- }
-
- public function getAllEvents()
- {
- try
- {
- $strategy = new RetrieveAllSummitEventsStrategy($this->event_repository);
- return $this->ok($strategy->getEvents()->toArray());
- }
- 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);
- }
- }
-
- public function getAllScheduledEvents()
- {
- try
- {
- $strategy = new RetrieveAllPublishedSummitEventsStrategy($this->event_repository);
- return $this->ok($strategy->getEvents()->toArray());
- }
- 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);
- }
- }
-
- /**
- * @param $summit_id
- * @param $event_id
- * @param string $expand
- * @param string $fields
- * @param string $relations
- * @param bool $published
- * @return array
- * @throws EntityNotFoundException
- */
- private function _getSummitEvent($summit_id, $event_id, $expand = '', $fields = '', $relations = '', $published = true)
- {
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) throw new EntityNotFoundException;
-
- $event = $published ? $summit->getScheduleEvent(intval($event_id)) : $summit->getEvent(intval($event_id));
-
- if (is_null($event)) throw new EntityNotFoundException;
- $relations = !empty($relations) ? explode(',', $relations) : array();
- $fields = !empty($fields) ? explode(',', $fields) : array();
- $data = $event->toArray($fields, $relations);
-
- if (!empty($expand)) {
- foreach (explode(',', $expand) as $relation) {
- switch (trim($relation)) {
- case 'feedback': {
- $feedback = array();
- list($total, $per_page, $current_page, $last_page, $items) = $event->feedback(1, PHP_INT_MAX);
- foreach ($items as $f) {
- array_push($feedback, $f->toArray());
- }
- $data['feedback'] = $feedback;
- }
- break;
- case 'speakers':{
- if($event instanceof Presentation){
- unset($data['speakers']);
- $speakers = array();
- foreach($event->speakers() as $speaker)
- {
- array_push($speakers, $speaker->toArray());
- }
- $data['speakers'] = $speakers;
- }
- }
- break;
- case 'location': {
- $location = $event->getLocation();
- $data['location'] = $location->toArray();
- unset($data['location_id']);
- }
- break;
- }
- }
- }
- return $data;
- }
- /**
- * @param $summit_id
- * @param $event_id
- * @return mixed
- */
- public function getEvent($summit_id, $event_id)
- {
- try {
-
- $expand = Request::input('expand', '');
- $fields = Request::input('fields', '');
- $relations = Request::input('relations', '');
-
- $data = $this->_getSummitEvent($summit_id, $event_id, $expand, $fields, $relations, false);
- return $this->ok($data);
- }
- catch (EntityNotFoundException $ex1) {
- Log::warning($ex1);
- return $this->error404();
- }
- catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $event_id
- * @return mixed
- */
- public function getScheduledEvent($summit_id, $event_id)
- {
- try {
-
- $expand = Request::input('expand', '');
- $fields = Request::input('fields', '');
- $relations = Request::input('relations', '');
-
- $data = $this->_getSummitEvent($summit_id, $event_id, $expand, $fields, $relations, true);
- return $this->ok($data);
- }
- catch (EntityNotFoundException $ex1) {
- Log::warning($ex1);
- return $this->error404();
- }
- catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @return mixed
- */
- public function addEvent($summit_id)
- {
- try {
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
- if(!Request::isJson()) return $this->error403();
- $data = Input::json();
-
- $rules = array
- (
- 'title' => 'required|string|max:300',
- 'description' => 'required|string',
- 'location_id' => 'sometimes|required|integer',
- 'start_date' => 'sometimes|required|date_format:U',
- 'end_date' => 'sometimes|required_with:start_date|date_format:U|after:start_date',
- 'allow_feedback' => 'sometimes|required|boolean',
- 'type_id' => 'required|integer',
- 'summit_types_id' => 'required|int_array',
- 'tags' => 'sometimes|required|string_array',
- );
-
- // Creates a Validator instance and validates the data.
- $validation = Validator::make($data->all(), $rules);
-
- if ($validation->fails()) {
- $messages = $validation->messages()->toArray();
-
- return $this->error412
- (
- $messages
- );
- }
-
- $fields = array
- (
- 'title',
- 'description'
- );
-
- $event = $this->service->addEvent($summit, HTMLCleaner::cleanData($data->all(), $fields));
-
- return $this->created($event);
- }
- catch (ValidationException $ex1) {
- Log::warning($ex1);
- return $this->error412(array($ex1->getMessage()));
- }
- catch(EntityNotFoundException $ex2)
- {
- Log::warning($ex2);
- return $this->error404(array('message'=> $ex2->getMessage()));
- }
- catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $event_id
- * @return mixed
- */
- public function updateEvent($summit_id, $event_id)
- {
- try {
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- if(!Request::isJson()) return $this->error403();
- $data = Input::json();
-
- $rules = array
- (
- 'title' => 'sometimes|required|string|max:300',
- 'description' => 'sometimes|required|string',
- 'location_id' => 'sometimes|required|integer',
- 'start_date' => 'sometimes|required|date_format:U',
- 'end_date' => 'sometimes|required_with:start_date|date_format:U|after:start_date',
- 'allow_feedback' => 'sometimes|required|boolean',
- 'type_id' => 'sometimes|required|integer',
- 'summit_types_id' => 'sometimes|required|int_array',
- 'tags' => 'sometimes|required|string_array',
- );
-
- // Creates a Validator instance and validates the data.
- $validation = Validator::make($data->all(), $rules);
-
- if ($validation->fails()) {
- $messages = $validation->messages()->toArray();
-
- return $this->error412
- (
- $messages
- );
- }
-
- $fields = array
- (
- 'title',
- 'description'
- );
-
- $event = $this->service->updateEvent($summit, $event_id, HTMLCleaner::cleanData($data->all(), $fields));
-
- return $this->ok($event);
-
- }
- catch (ValidationException $ex1)
- {
- Log::warning($ex1);
- return $this->error412(array($ex1->getMessage()));
- }
- catch(EntityNotFoundException $ex2)
- {
- Log::warning($ex2);
- return $this->error404(array('message'=> $ex2->getMessage()));
- }
- catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $event_id
- * @return mixed
- */
- public function publishEvent($summit_id, $event_id)
- {
- try {
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- if(!Request::isJson()) return $this->error403();
- $data = Input::json();
-
- $rules = array
- (
- 'location_id' => 'sometimes|required|integer',
- 'start_date' => 'sometimes|required|date_format:U',
- 'end_date' => 'sometimes|required_with:start_date|date_format:U|after:start_date',
- );
-
- // Creates a Validator instance and validates the data.
- $validation = Validator::make($data->all(), $rules);
-
- if ($validation->fails()) {
- $messages = $validation->messages()->toArray();
-
- return $this->error412
- (
- $messages
- );
- }
-
- $this->service->publishEvent($summit, $event_id, $data->all());
-
- return $this->updated();
- }
- catch (ValidationException $ex1)
- {
- Log::warning($ex1);
- return $this->error412(array($ex1->getMessage()));
- }
- catch(EntityNotFoundException $ex2)
- {
- Log::warning($ex2);
- return $this->error404(array('message'=> $ex2->getMessage()));
- }
- catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $event_id
- * @return mixed
- */
- public function unPublishEvent($summit_id, $event_id)
- {
- try {
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- if(!Request::isJson()) return $this->error403();
-
-
- $this->service->unPublishEvent($summit, $event_id);
-
- return $this->deleted();
- }
- catch (ValidationException $ex1)
- {
- Log::warning($ex1);
- return $this->error412(array($ex1->getMessage()));
- }
- catch(EntityNotFoundException $ex2)
- {
- Log::warning($ex2);
- return $this->error404(array('message'=> $ex2->getMessage()));
- }
- catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $event_id
- * @return mixed
- */
- public function deleteEvent($summit_id, $event_id)
- {
- try {
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- $this->service->deleteEvent($summit, $event_id);
-
- return $this->deleted();
- }
- catch (ValidationException $ex1)
- {
- Log::warning($ex1);
- return $this->error412(array($ex1->getMessage()));
- }
- catch(EntityNotFoundException $ex2)
- {
- Log::warning($ex2);
- return $this->error404(array('message'=> $ex2->getMessage()));
- }
- catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
- /**
- * @param $summit_id
- * @param $event_id
- * @param $attendee_id
- * @return mixed
- */
- public function getEventFeedback($summit_id, $event_id, $attendee_id = null)
- {
-
- try {
-
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- $expand = Request::input('expand', '');
-
- $values = Input::all();
-
- $rules = array
- (
- 'page' => 'integer|min:1',
- 'per_page' => 'required_with:page|integer|min:5|max:100',
- );
-
- $validation = Validator::make($values, $rules);
-
- if ($validation->fails()) {
- $messages = $validation->messages()->toArray();
-
- return $this->error412($messages);
- }
-
- $event = $summit->getScheduleEvent(intval($event_id));
-
- if (is_null($event)) {
- return $this->error404();
- }
-
- $filter = null;
- if (!is_null($attendee_id)) // add filter by attendee, this case me
- {
- if($attendee_id !== 'me') return $this->error403();
- $member_id = $this->resource_server_context->getCurrentUserExternalId();
- if (is_null($member_id)) return $this->error404();
-
- $filter = FilterParser::parse(array('owner_id' => $member_id), array
- (
- 'owner_id' => array('=='),
- ));
- }
-
- // default values
- $page = 1;
- $per_page = 5;
-
- if (Input::has('page'))
- {
- $page = intval(Input::get('page'));
- $per_page = intval(Input::get('per_page'));
- }
-
- $order = null;
- if (Input::has('order'))
- {
- $order = OrderParser::parse(Input::get('order'), array
- (
- 'created_date',
- 'owner_id',
- 'rate',
- 'id',
- ));
- }
-
- list($total, $per_page, $current_page, $last_page, $feedback) = $event->feedback($page, $per_page, $filter, $order);
-
- if (!empty($expand))
- {
- foreach (explode(',', $expand) as $relation)
- {
- switch (trim($relation)) {
- case 'owner':
- {
- $res = array();
- foreach($feedback as $f)
- {
- array_push($res, $f->toArray(true));
- }
- $feedback = $res;
- }
- break;
- }
- }
- }
-
- return $this->ok
- (
- array
- (
- 'total' => $total,
- 'per_page' => $per_page,
- 'current_page' => $current_page,
- 'last_page' => $last_page,
- 'data' => $feedback,
- )
- );
-
- } catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param LaravelRequest $request
- * @param $summit_id
- * @param $event_id
- * @return mixed
- */
- public function addEventFeedback(LaravelRequest $request, $summit_id, $event_id)
- {
- try {
- if (!$request->isJson()) {
- return $this->error412(array('invalid content type!'));
- }
-
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
- if(!Request::isJson()) return $this->error403();
-
- $data = Input::json();
-
- $rules = array
- (
- 'rate' => 'required|integer|digits_between:0,10',
- 'note' => 'required|max:500',
- 'attendee_id' => 'required'
- );
-
- // Creates a Validator instance and validates the data.
- $validation = Validator::make($data->all(), $rules);
-
- if ($validation->fails()) {
- $messages = $validation->messages()->toArray();
-
- return $this->error412
- (
- $messages
- );
- }
-
- $event = $summit->getScheduleEvent(intval($event_id));
-
- if (is_null($event)) {
- return $this->error404();
- }
-
- $data = $data->all();
- $attendee_id = $data['attendee_id'];
-
- $attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
- if (is_null($attendee)) return $this->error404();
-
- $data['attendee_id'] = intval($attendee->ID);
-
- $res = $this->service->addEventFeedback
- (
- $summit,
- $event,
- $data
- );
-
- return !is_null($res) ? $this->created($res->ID) : $this->error400();
- }
- catch (EntityNotFoundException $ex1) {
- Log::warning($ex1);
- return $this->error404();
- }
- catch(ValidationException $ex2)
- {
- Log::warning($ex2);
- return $this->error412(array($ex2->getMessage()));
- }
- catch(\HTTP401UnauthorizedException $ex3)
- {
- Log::warning($ex3);
- return $this->error401();
- }
- catch (Exception $ex) {
- Log::error($ex);
-
- return $this->error500($ex);
- }
- }
-
/**
* @param $summit_id
* @return mixed
@@ -1280,174 +187,6 @@ class OAuth2SummitApiController extends OAuth2ProtectedController
}
}
- //venues
-
- public function getLocations($summit_id)
- {
- try {
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- //locations
- $locations = array();
- foreach ($summit->locations() as $location) {
- array_push($locations, $location->toArray());
- }
-
- return $this->ok($locations);
- } catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param $summit_id
- * @param $location_id
- * @return mixed
- */
- public function getLocation($summit_id, $location_id)
- {
- try {
-
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit)) return $this->error404();
-
- $location = $summit->getLocation($location_id);
- if (is_null($location)) {
- return $this->error404();
- }
- return $this->ok($location);
- } catch (Exception $ex) {
- Log::error($ex);
- return $this->error500($ex);
- }
- }
-
- /**
- * @param string $summit_id
- * @param int $location_id
- * @param bool $published
- * @return PagingResponse
- * @throws EntityNotFoundException
- * @throws ValidationException
- */
- private function _getLocationEvents($summit_id, $location_id, $published = true)
- {
- $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
- if (is_null($summit))
- throw new EntityNotFoundException;
-
- $location = $summit->getLocation($location_id);
- if (is_null($location))
- throw new EntityNotFoundException;
-
- $values = Input::all();
-
- $rules = array
- (
- 'page' => 'integer|min:1',
- 'per_page' => 'required_with:page|integer|min:5|max:100',
- );
-
- $validation = Validator::make($values, $rules);
-
- if ($validation->fails()) {
- $ex = new ValidationException();
- throw $ex->setMessages($validation->messages()->toArray());
- }
-
- // default values
- $page = 1;
- $per_page = 5;
-
- if (Input::has('page')) {
- $page = intval(Input::get('page'));
- $per_page = intval(Input::get('per_page'));
- }
-
- $filter = null;
- if (Input::has('filter')) {
- $filter = FilterParser::parse(Input::get('filter'), array
- (
- 'title' => array('=@', '=='),
- 'speaker' => array('=@', '=='),
- 'tags' => array('=@', '=='),
- 'start_date' => array('>', '<', '<=', '>=', '=='),
- 'end_date' => array('>', '<', '<=', '>=', '=='),
- 'summit_type_id' => array('=='),
- 'event_type_id' => array('=='),
- 'track_id' => array('=='),
- ));
- }
-
-
-
- list($total, $per_page, $current_page, $last_page, $events) = $location->events
- (
- $page, $per_page, $filter , $published
- );
-
- return new PagingResponse
- (
- $total,
- $per_page,
- $current_page,
- $last_page,
- $events
- );
- }
-
- /**
- * @param $summit_id
- * @param $location_id
- * @return mixed
- */
- public function getLocationEvents($summit_id, $location_id)
- {
- try {
-
- return $this->ok($this->_getLocationEvents($summit_id, $location_id, false)->toArray());
- }
- 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);
- }
- }
-
- /**
- * @param $summit_id
- * @param $location_id
- * @return mixed
- */
- public function getLocationPublishedEvents($summit_id, $location_id)
- {
- try {
-
- return $this->ok($this->_getLocationEvents($summit_id, $location_id, true)->toArray());
- }
- 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);
- }
- }
-
/**
* @param $summit_id
* @return mixed
@@ -1459,12 +198,13 @@ class OAuth2SummitApiController extends OAuth2ProtectedController
if (is_null($summit)) return $this->error404();
//event types
- $list = array();
- foreach ($summit->event_types() as $et) {
- array_push($list, $et->toArray());
+ $event_types = array();
+ foreach ($summit->getEventTypes() as $event_type)
+ {
+ $event_types[] =SerializerRegistry::getInstance()->getSerializer($event_type)->serialize();
}
- return $this->ok($list);
+ return $this->ok($event_types);
} catch (Exception $ex) {
Log::error($ex);
return $this->error500($ex);
@@ -1482,11 +222,13 @@ class OAuth2SummitApiController extends OAuth2ProtectedController
if (is_null($summit)) return $this->error404();
//summit types
- $list = array();
- foreach ($summit->summit_types() as $st) {
- array_push($list, $st->toArray());
+ $summit_types = array();
+ foreach ($summit->getSummitTypes() as $summit_type)
+ {
+ $summit_types[] =SerializerRegistry::getInstance()->getSerializer($summit_type)->serialize();
}
- return $this->ok($list);
+ return $this->ok($summit_types);
+
} catch (Exception $ex) {
Log::error($ex);
return $this->error500($ex);
@@ -1523,8 +265,19 @@ class OAuth2SummitApiController extends OAuth2ProtectedController
if (is_null($member_id)) {
throw new \HTTP401UnauthorizedException;
}
- $attendee = $this->service->confirmExternalOrderAttendee($summit, $member_id, $external_order_id, $external_attendee_id);
- return $this->ok($attendee);
+
+ $attendee = $this->service->confirmExternalOrderAttendee
+ (
+ new ConfirmationExternalOrderRequest
+ (
+ $summit,
+ intval($member_id),
+ trim($external_order_id),
+ trim($external_attendee_id)
+ )
+ );
+
+ return $this->ok(SerializerRegistry::getInstance()->getSerializer($attendee)->serialize());
}
catch (EntityNotFoundException $ex1) {
Log::warning($ex1);
diff --git a/app/Http/Controllers/apis/protected/summit/OAuth2SummitAttendeesApiController.php b/app/Http/Controllers/apis/protected/summit/OAuth2SummitAttendeesApiController.php
new file mode 100644
index 00000000..bef257c1
--- /dev/null
+++ b/app/Http/Controllers/apis/protected/summit/OAuth2SummitAttendeesApiController.php
@@ -0,0 +1,343 @@
+repository = $summit_repository;
+ $this->speaker_repository = $speaker_repository;
+ $this->event_repository = $event_repository;
+ $this->event_feedback_repository = $event_feedback_repository;
+ $this->service = $service;
+ }
+
+ /**
+ * Attendees endpoints
+ */
+
+ /**
+ * @param $summit_id
+ * @return mixed
+ */
+ /*public function getAttendees($summit_id)
+ {
+ try {
+
+ $values = Input::all();
+
+ $rules = array
+ (
+ 'page' => 'integer|min:1',
+ 'per_page' => 'required_with:page|integer|min:5|max:100',
+ );
+
+ $validation = Validator::make($values, $rules);
+
+ if ($validation->fails()) {
+ $messages = $validation->messages()->toArray();
+ return $this->error412($messages);
+ }
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ // default values
+ $page = 1;
+ $per_page = 5;
+
+ if (Input::has('page')) {
+ $page = intval(Input::get('page'));
+ $per_page = intval(Input::get('per_page'));
+ }
+
+ $filter = null;
+ if (Input::has('filter')) {
+ $filter = FilterParser::parse(Input::get('filter'), array
+ (
+ 'first_name' => array('=@', '=='),
+ 'last_name' => array('=@', '=='),
+ 'email' => array('=@', '=='),
+ ));
+ }
+
+ $order = null;
+ if (Input::has('order'))
+ {
+ $order = OrderParser::parse(Input::get('order'), array
+ (
+ 'first_name',
+ 'last_name',
+ ));
+ }
+
+ list($total, $per_page, $current_page, $last_page, $items) = $summit->attendees($page, $per_page, $filter, $order);
+
+ return $this->ok
+ (
+ array
+ (
+ 'total' => $total,
+ 'per_page' => $per_page,
+ 'current_page' => $current_page,
+ 'last_page' => $last_page,
+ 'data' => $items,
+ )
+ );
+
+ }
+ catch (Exception $ex)
+ {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }*/
+
+ /**
+ * @param $summit_id
+ * @param $attendee_id
+ * @return mixed
+ */
+ public function getAttendee($summit_id, $attendee_id)
+ {
+ $expand = Request::input('expand', '');
+
+ try {
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ $attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
+ if(is_null($attendee)) return $this->error404();
+
+ return $this->ok(SerializerRegistry::getInstance()->getSerializer($attendee)->serialize($expand));
+ }
+ catch (\HTTP401UnauthorizedException $ex1) {
+ Log::warning($ex1);
+ return $this->error401();
+ }
+ catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $attendee_id
+ * @return mixed
+ */
+ public function getAttendeeSchedule($summit_id, $attendee_id)
+ {
+ try {
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ $attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
+ if(is_null($attendee)) return $this->error404();
+
+ $schedule = array();
+ foreach ($attendee->getSchedule() as $attendee_schedule)
+ {
+ if(!$summit->isEventOnSchedule($attendee_schedule->getEvent()->getId())) continue;
+ $schedule[] = SerializerRegistry::getInstance()->getSerializer($attendee_schedule)->serialize();
+ }
+
+ return $this->ok($schedule);
+ }
+ catch (\HTTP401UnauthorizedException $ex1)
+ {
+ Log::warning($ex1);
+ return $this->error401();
+ }
+ catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $attendee_id
+ * @param $event_id
+ * @return mixed
+ */
+ public function addEventToAttendeeSchedule($summit_id, $attendee_id, $event_id)
+ {
+ try {
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ $attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
+ if (is_null($attendee)) return $this->error404();
+
+ $this->service->addEventToAttendeeSchedule($summit, $attendee, intval($event_id));
+
+ return $this->created();
+ }
+ catch (ValidationException $ex1)
+ {
+ Log::warning($ex1);
+ return $this->error412(array( $ex1->getMessage()));
+ }
+ catch (EntityNotFoundException $ex2)
+ {
+ Log::warning($ex2);
+ return $this->error404(array('message' => $ex2->getMessage()));
+ }
+ catch(\HTTP401UnauthorizedException $ex3)
+ {
+ Log::warning($ex3);
+ return $this->error401();
+ }
+ catch (Exception $ex)
+ {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $attendee_id
+ * @param $event_id
+ * @return mixed
+ */
+ public function removeEventFromAttendeeSchedule($summit_id, $attendee_id, $event_id)
+ {
+ try {
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ $attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
+ if (is_null($attendee)) return $this->error404();
+
+ $this->service->removeEventFromAttendeeSchedule($summit, $attendee, intval($event_id));
+
+ return $this->deleted();
+
+ }
+ catch (ValidationException $ex1)
+ {
+ Log::warning($ex1);
+ return $this->error412(array( $ex1->getMessage()));
+ }
+ catch (EntityNotFoundException $ex2)
+ {
+ Log::warning($ex2);
+ return $this->error404(array('message' => $ex2->getMessage()));
+ }
+ catch(\HTTP401UnauthorizedException $ex3)
+ {
+ Log::warning($ex3);
+ return $this->error401();
+ }
+ catch (Exception $ex)
+ {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $attendee_id
+ * @param $event_id
+ * @return mixed
+ */
+ public function checkingAttendeeOnEvent($summit_id, $attendee_id, $event_id)
+ {
+ try {
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ $attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
+ if (is_null($attendee)) return $this->error404();
+
+ $this->service->checkInAttendeeOnEvent($summit, $attendee, intval($event_id));
+
+ return $this->updated();
+ }
+ catch (ValidationException $ex1)
+ {
+ Log::warning($ex1);
+ return $this->error412(array( $ex1->getMessage()));
+ }
+ catch (EntityNotFoundException $ex2)
+ {
+ Log::warning($ex2);
+ return $this->error404(array('message' => $ex2->getMessage()));
+ }
+ catch(\HTTP401UnauthorizedException $ex3)
+ {
+ Log::warning($ex3);
+ return $this->error401();
+ }
+ 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/OAuth2SummitEventsApiController.php b/app/Http/Controllers/apis/protected/summit/OAuth2SummitEventsApiController.php
new file mode 100644
index 00000000..c3d70aef
--- /dev/null
+++ b/app/Http/Controllers/apis/protected/summit/OAuth2SummitEventsApiController.php
@@ -0,0 +1,767 @@
+repository = $summit_repository;
+ $this->speaker_repository = $speaker_repository;
+ $this->event_repository = $event_repository;
+ $this->event_feedback_repository = $event_feedback_repository;
+ $this->service = $service;
+ }
+
+ /**
+ * Events endpoints
+ */
+
+ /**
+ * @param $summit_id
+ * @return mixed
+ */
+ public function getEvents($summit_id)
+ {
+ try
+ {
+ $strategy = new RetrieveAllSummitEventsBySummitStrategy($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);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @return mixed
+ */
+ public function getScheduledEvents($summit_id)
+ {
+ try
+ {
+ $strategy = new RetrievePublishedSummitEventsBySummitStrategy($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);
+ }
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getAllEvents()
+ {
+ try
+ {
+ $strategy = new RetrieveAllSummitEventsStrategy($this->event_repository);
+ $response = $strategy->getEvents();
+ 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);
+ }
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getAllScheduledEvents()
+ {
+ try
+ {
+ $strategy = new RetrieveAllPublishedSummitEventsStrategy($this->event_repository);
+ $response = $strategy->getEvents();
+ 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);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $event_id
+ * @param string $expand
+ * @param string $fields
+ * @param string $relations
+ * @param bool $published
+ * @return array
+ * @throws EntityNotFoundException
+ */
+ private function _getSummitEvent($summit_id, $event_id, $expand = '', $fields = '', $relations = '', $published = true)
+ {
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) throw new EntityNotFoundException;
+
+ $event = $published ? $summit->getScheduleEvent(intval($event_id)) : $summit->getEvent(intval($event_id));
+
+ if (is_null($event)) throw new EntityNotFoundException;
+ $relations = !empty($relations) ? explode(',', $relations) : array();
+ $fields = !empty($fields) ? explode(',', $fields) : array();
+
+ return SerializerRegistry::getInstance()->getSerializer($event)->serialize($expand, $fields, $relations);
+ }
+ /**
+ * @param $summit_id
+ * @param $event_id
+ * @return mixed
+ */
+ public function getEvent($summit_id, $event_id)
+ {
+ try {
+
+ $expand = Request::input('expand', '');
+ $fields = Request::input('fields', '');
+ $relations = Request::input('relations', '');
+
+ return $this->ok($this->_getSummitEvent($summit_id, $event_id, $expand, $fields, $relations, false));
+ }
+ catch (EntityNotFoundException $ex1) {
+ Log::warning($ex1);
+ return $this->error404();
+ }
+ catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $event_id
+ * @return mixed
+ */
+ public function getScheduledEvent($summit_id, $event_id)
+ {
+ try {
+
+ $expand = Request::input('expand', '');
+ $fields = Request::input('fields', '');
+ $relations = Request::input('relations', '');
+
+ return $this->ok($this->_getSummitEvent($summit_id, $event_id, $expand, $fields, $relations, true));
+ }
+ catch (EntityNotFoundException $ex1) {
+ Log::warning($ex1);
+ return $this->error404();
+ }
+ catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @return mixed
+ */
+ public function addEvent($summit_id)
+ {
+ try {
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+ if(!Request::isJson()) return $this->error403();
+ $data = Input::json();
+
+ $rules = array
+ (
+ 'title' => 'required|string|max:300',
+ 'description' => 'required|string',
+ 'location_id' => 'sometimes|required|integer',
+ 'start_date' => 'sometimes|required|date_format:U',
+ 'end_date' => 'sometimes|required_with:start_date|date_format:U|after:start_date',
+ 'allow_feedback' => 'sometimes|required|boolean',
+ 'type_id' => 'required|integer',
+ 'summit_types_id' => 'required|int_array',
+ 'tags' => 'sometimes|required|string_array',
+ );
+
+ // Creates a Validator instance and validates the data.
+ $validation = Validator::make($data->all(), $rules);
+
+ if ($validation->fails()) {
+ $messages = $validation->messages()->toArray();
+
+ return $this->error412
+ (
+ $messages
+ );
+ }
+
+ $fields = array
+ (
+ 'title',
+ 'description'
+ );
+
+ $event = $this->service->addEvent($summit, HTMLCleaner::cleanData($data->all(), $fields));
+
+ return $this->created(SerializerRegistry::getInstance()->getSerializer($event)->serialize());
+ }
+ catch (ValidationException $ex1) {
+ Log::warning($ex1);
+ return $this->error412(array($ex1->getMessage()));
+ }
+ catch(EntityNotFoundException $ex2)
+ {
+ Log::warning($ex2);
+ return $this->error404(array('message'=> $ex2->getMessage()));
+ }
+ catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $event_id
+ * @return mixed
+ */
+ public function updateEvent($summit_id, $event_id)
+ {
+ try {
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ if(!Request::isJson()) return $this->error403();
+ $data = Input::json();
+
+ $rules = array
+ (
+ 'title' => 'sometimes|required|string|max:300',
+ 'description' => 'sometimes|required|string',
+ 'location_id' => 'sometimes|required|integer',
+ 'start_date' => 'sometimes|required|date_format:U',
+ 'end_date' => 'sometimes|required_with:start_date|date_format:U|after:start_date',
+ 'allow_feedback' => 'sometimes|required|boolean',
+ 'type_id' => 'sometimes|required|integer',
+ 'summit_types_id' => 'sometimes|required|int_array',
+ 'tags' => 'sometimes|required|string_array',
+ );
+
+ // Creates a Validator instance and validates the data.
+ $validation = Validator::make($data->all(), $rules);
+
+ if ($validation->fails()) {
+ $messages = $validation->messages()->toArray();
+
+ return $this->error412
+ (
+ $messages
+ );
+ }
+
+ $fields = array
+ (
+ 'title',
+ 'description'
+ );
+
+ $event = $this->service->updateEvent($summit, $event_id, HTMLCleaner::cleanData($data->all(), $fields));
+
+ return $this->ok(SerializerRegistry::getInstance()->getSerializer($event)->serialize());
+
+ }
+ catch (ValidationException $ex1)
+ {
+ Log::warning($ex1);
+ return $this->error412(array($ex1->getMessage()));
+ }
+ catch(EntityNotFoundException $ex2)
+ {
+ Log::warning($ex2);
+ return $this->error404(array('message'=> $ex2->getMessage()));
+ }
+ catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $event_id
+ * @return mixed
+ */
+ public function publishEvent($summit_id, $event_id)
+ {
+ try {
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ if(!Request::isJson()) return $this->error403();
+ $data = Input::json();
+
+ $rules = array
+ (
+ 'location_id' => 'sometimes|required|integer',
+ 'start_date' => 'sometimes|required|date_format:U',
+ 'end_date' => 'sometimes|required_with:start_date|date_format:U|after:start_date',
+ );
+
+ // Creates a Validator instance and validates the data.
+ $validation = Validator::make($data->all(), $rules);
+
+ if ($validation->fails()) {
+ $messages = $validation->messages()->toArray();
+
+ return $this->error412
+ (
+ $messages
+ );
+ }
+
+ $this->service->publishEvent($summit, $event_id, $data->all());
+
+ return $this->updated();
+ }
+ catch (ValidationException $ex1)
+ {
+ Log::warning($ex1);
+ return $this->error412(array($ex1->getMessage()));
+ }
+ catch(EntityNotFoundException $ex2)
+ {
+ Log::warning($ex2);
+ return $this->error404(array('message'=> $ex2->getMessage()));
+ }
+ catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $event_id
+ * @return mixed
+ */
+ public function unPublishEvent($summit_id, $event_id)
+ {
+ try {
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ if(!Request::isJson()) return $this->error403();
+
+
+ $this->service->unPublishEvent($summit, $event_id);
+
+ return $this->deleted();
+ }
+ catch (ValidationException $ex1)
+ {
+ Log::warning($ex1);
+ return $this->error412(array($ex1->getMessage()));
+ }
+ catch(EntityNotFoundException $ex2)
+ {
+ Log::warning($ex2);
+ return $this->error404(array('message'=> $ex2->getMessage()));
+ }
+ catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $event_id
+ * @return mixed
+ */
+ public function deleteEvent($summit_id, $event_id)
+ {
+ try {
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ $this->service->deleteEvent($summit, $event_id);
+
+ return $this->deleted();
+ }
+ catch (ValidationException $ex1)
+ {
+ Log::warning($ex1);
+ return $this->error412(array($ex1->getMessage()));
+ }
+ catch(EntityNotFoundException $ex2)
+ {
+ Log::warning($ex2);
+ return $this->error404(array('message'=> $ex2->getMessage()));
+ }
+ catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /** Feedback endpoints */
+
+ /**
+ * @param $summit_id
+ * @param $event_id
+ * @param $attendee_id
+ * @return mixed
+ */
+ public function getEventFeedback($summit_id, $event_id, $attendee_id = null)
+ {
+
+ try {
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ $values = Input::all();
+
+ $rules = array
+ (
+ 'page' => 'integer|min:1',
+ 'per_page' => 'required_with:page|integer|min:5|max:100',
+ );
+
+ $validation = Validator::make($values, $rules);
+
+ if ($validation->fails()) {
+ $messages = $validation->messages()->toArray();
+
+ return $this->error412($messages);
+ }
+
+ $event = $summit->getScheduleEvent(intval($event_id));
+
+ if (is_null($event)) {
+ return $this->error404();
+ }
+
+ $filter = null;
+ if (!is_null($attendee_id)) // add filter by attendee, this case me
+ {
+ if($attendee_id !== 'me') return $this->error403();
+ $member_id = $this->resource_server_context->getCurrentUserExternalId();
+ if (is_null($member_id)) return $this->error404();
+
+ $filter = FilterParser::parse('owner_id=='.$member_id, array
+ (
+ 'owner_id' => array('=='),
+ ));
+ }
+
+ // default values
+ $page = 1;
+ $per_page = 5;
+
+ if (Input::has('page'))
+ {
+ $page = intval(Input::get('page'));
+ $per_page = intval(Input::get('per_page'));
+ }
+
+ $order = null;
+ if (Input::has('order'))
+ {
+ $order = OrderParser::parse(Input::get('order'), array
+ (
+ 'created_date',
+ 'owner_id',
+ 'rate',
+ 'id',
+ ));
+ }
+
+ $response = $this->event_feedback_repository->getByEvent($event, new PagingInfo($page, $per_page), $filter, $order);
+
+ return $this->ok($response->toArray(Request::input('expand', '')));
+
+ } catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param LaravelRequest $request
+ * @param $summit_id
+ * @param $event_id
+ * @return mixed
+ */
+ public function addEventFeedback(LaravelRequest $request, $summit_id, $event_id)
+ {
+ try {
+ if (!$request->isJson()) {
+ return $this->error412(array('invalid content type!'));
+ }
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+ if(!Request::isJson()) return $this->error403();
+
+ $data = Input::json();
+
+ $rules = array
+ (
+ 'rate' => 'required|integer|digits_between:0,10',
+ 'note' => 'required|max:500',
+ 'attendee_id' => 'required'
+ );
+
+ // Creates a Validator instance and validates the data.
+ $validation = Validator::make($data->all(), $rules);
+
+ if ($validation->fails()) {
+ $messages = $validation->messages()->toArray();
+
+ return $this->error412
+ (
+ $messages
+ );
+ }
+
+ $event = $summit->getScheduleEvent(intval($event_id));
+
+ if (is_null($event)) {
+ return $this->error404();
+ }
+
+ $data = $data->all();
+ $attendee_id = $data['attendee_id'];
+
+ $attendee = CheckAttendeeStrategyFactory::build
+ (
+ CheckAttendeeStrategyFactory::Own,
+ $this->resource_server_context
+ )->check($attendee_id, $summit);
+
+ if (is_null($attendee)) return $this->error404();
+
+ $data['attendee_id'] = intval($attendee->getId());
+
+ $res = $this->service->addEventFeedback
+ (
+ $summit,
+ $event,
+ $data
+ );
+
+ return !is_null($res) ? $this->created($res->getId()) : $this->error400();
+ }
+ catch (EntityNotFoundException $ex1) {
+ Log::warning($ex1);
+ return $this->error404();
+ }
+ catch(ValidationException $ex2)
+ {
+ Log::warning($ex2);
+ return $this->error412(array($ex2->getMessage()));
+ }
+ catch(\HTTP401UnauthorizedException $ex3)
+ {
+ Log::warning($ex3);
+ return $this->error401();
+ }
+ catch (Exception $ex) {
+ Log::error($ex);
+
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param LaravelRequest $request
+ * @param $summit_id
+ * @param $event_id
+ * @return mixed
+ */
+ public function addEventFeedbackByMember(LaravelRequest $request, $summit_id, $event_id)
+ {
+ try {
+
+ if (!$request->isJson()) {
+ return $this->error412(array('invalid content type!'));
+ }
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+ if(!Request::isJson()) return $this->error403();
+
+ $data = Input::json();
+
+ $rules = array
+ (
+ 'rate' => 'required|integer|digits_between:0,10',
+ 'note' => 'required|max:500',
+ );
+
+ // Creates a Validator instance and validates the data.
+ $validation = Validator::make($data->all(), $rules);
+
+ if ($validation->fails()) {
+ $messages = $validation->messages()->toArray();
+
+ return $this->error412
+ (
+ $messages
+ );
+ }
+
+ $event = $summit->getScheduleEvent(intval($event_id));
+
+ if (is_null($event)) {
+ return $this->error404();
+ }
+
+ $data = $data->all();
+
+ $member_id = $this->resource_server_context->getCurrentUserExternalId();
+
+ if (is_null($member_id)) return $this->error403();
+
+ $data['member_id'] = intval($member_id);
+
+ $res = $this->service->addEventFeedback
+ (
+ $summit,
+ $event,
+ $data
+ );
+
+ return !is_null($res) ? $this->created($res->getId()) : $this->error400();
+ }
+ catch (EntityNotFoundException $ex1) {
+ Log::warning($ex1);
+ return $this->error404();
+ }
+ catch(ValidationException $ex2)
+ {
+ Log::warning($ex2);
+ return $this->error412(array($ex2->getMessage()));
+ }
+ catch(\HTTP401UnauthorizedException $ex3)
+ {
+ Log::warning($ex3);
+ return $this->error401();
+ }
+ 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/OAuth2SummitLocationsApiController.php b/app/Http/Controllers/apis/protected/summit/OAuth2SummitLocationsApiController.php
new file mode 100644
index 00000000..2b77771f
--- /dev/null
+++ b/app/Http/Controllers/apis/protected/summit/OAuth2SummitLocationsApiController.php
@@ -0,0 +1,240 @@
+repository = $summit_repository;
+ $this->speaker_repository = $speaker_repository;
+ $this->event_repository = $event_repository;
+ $this->event_feedback_repository = $event_feedback_repository;
+ $this->service = $service;
+ }
+
+ public function getLocations($summit_id)
+ {
+ try {
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ //locations
+ $locations = array();
+ foreach ($summit->getLocations() as $location)
+ {
+ $locations[] = SerializerRegistry::getInstance()->getSerializer($location)->serialize();
+ }
+
+ return $this->ok($locations);
+ } catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $location_id
+ * @return mixed
+ */
+ public function getLocation($summit_id, $location_id)
+ {
+ try {
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ $location = $summit->getLocation($location_id);
+ if (is_null($location)) {
+ return $this->error404();
+ }
+ return $this->ok(SerializerRegistry::getInstance()->getSerializer($location)->serialize());
+ } catch (Exception $ex) {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param string $summit_id
+ * @param int $location_id
+ * @param bool $published
+ * @return PagingResponse
+ * @throws EntityNotFoundException
+ * @throws ValidationException
+ */
+ private function _getLocationEvents($summit_id, $location_id, $published = true)
+ {
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit))
+ throw new EntityNotFoundException;
+
+ $location = $summit->getLocation($location_id);
+ if (is_null($location))
+ throw new EntityNotFoundException;
+
+ $values = Input::all();
+
+ $rules = array
+ (
+ 'page' => 'integer|min:1',
+ 'per_page' => 'required_with:page|integer|min:5|max:100',
+ );
+
+ $validation = Validator::make($values, $rules);
+
+ if ($validation->fails()) {
+ $ex = new ValidationException();
+ throw $ex->setMessages($validation->messages()->toArray());
+ }
+
+ // default values
+ $page = 1;
+ $per_page = 5;
+
+ if (Input::has('page')) {
+ $page = intval(Input::get('page'));
+ $per_page = intval(Input::get('per_page'));
+ }
+
+ $filter = null;
+ if (Input::has('filter')) {
+ $filter = FilterParser::parse(Input::get('filter'), array
+ (
+ 'title' => array('=@', '=='),
+ 'start_date' => array('>', '<', '<=', '>=', '=='),
+ 'end_date' => array('>', '<', '<=', '>=', '=='),
+ 'speaker' => array('=@', '=='),
+ 'tags' => array('=@', '=='),
+ 'summit_type_id' => array('=='),
+ 'event_type_id' => array('=='),
+ 'track_id' => array('=='),
+ ));
+ }
+
+ if(is_null($filter)) $filter = new Filter();
+
+ $filter->addFilterCondition(FilterParser::buildFilter('location_id','==', $location_id));
+
+ if($published)
+ {
+ $filter->addFilterCondition(FilterParser::buildFilter('published','==', 1));
+ }
+
+ return $this->event_repository->getAllByPage(new PagingInfo($page, $per_page), $filter);
+ }
+
+ /**
+ * @param $summit_id
+ * @param $location_id
+ * @return mixed
+ */
+ public function getLocationEvents($summit_id, $location_id)
+ {
+ try {
+
+ return $this->ok($this->_getLocationEvents($summit_id, $location_id, false)->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);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $location_id
+ * @return mixed
+ */
+ public function getLocationPublishedEvents($summit_id, $location_id)
+ {
+ try {
+
+ return $this->ok($this->_getLocationEvents($summit_id, $location_id, true)->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/OAuth2SummitMembersApiController.php b/app/Http/Controllers/apis/protected/summit/OAuth2SummitMembersApiController.php
new file mode 100644
index 00000000..55420a4f
--- /dev/null
+++ b/app/Http/Controllers/apis/protected/summit/OAuth2SummitMembersApiController.php
@@ -0,0 +1,86 @@
+summit_repository = $summit_repository;
+ $this->repository = $member_repository;
+ }
+
+
+ public function getMyMember($summit_id){
+
+ $summit = SummitFinderStrategyFactory::build($this->summit_repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ $current_member_id = $this->resource_server_context->getCurrentUserExternalId();
+ if (is_null($current_member_id)) return $this->error403();
+
+ $current_member = $this->repository->getById($current_member_id);
+ if (is_null($current_member)) return $this->error404();
+
+ return $this->ok
+ (
+ SerializerRegistry::getInstance()->getSerializer($current_member)->serialize
+ (
+ Request::input('expand', ''),
+ [],
+ [],
+ ['summit' => $summit]
+ )
+ );
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Controllers/apis/protected/summit/OAuth2SummitSpeakersApiController.php b/app/Http/Controllers/apis/protected/summit/OAuth2SummitSpeakersApiController.php
new file mode 100644
index 00000000..7c28d5a3
--- /dev/null
+++ b/app/Http/Controllers/apis/protected/summit/OAuth2SummitSpeakersApiController.php
@@ -0,0 +1,178 @@
+repository = $summit_repository;
+ $this->speaker_repository = $speaker_repository;
+ $this->event_repository = $event_repository;
+ $this->event_feedback_repository = $event_feedback_repository;
+ $this->service = $service;
+ }
+
+ /**
+ * Speakers endpoints
+ */
+
+ /**
+ * @param $summit_id
+ * @return mixed
+ */
+ public function getSpeakers($summit_id)
+ {
+ try {
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ $values = Input::all();
+
+ $rules = array
+ (
+ 'page' => 'integer|min:1',
+ 'per_page' => 'required_with:page|integer|min:10|max:100',
+ );
+
+ $validation = Validator::make($values, $rules);
+
+ if ($validation->fails())
+ {
+ $messages = $validation->messages()->toArray();
+
+ return $this->error412($messages);
+ }
+
+ // default values
+ $page = 1;
+ $per_page = 10;
+
+ if (Input::has('page'))
+ {
+ $page = intval(Input::get('page'));
+ $per_page = intval(Input::get('per_page'));
+ }
+
+ $filter = null;
+
+ if (Input::has('filter'))
+ {
+ $filter = FilterParser::parse(Input::get('filter'), array
+ (
+ 'first_name' => array('=@', '=='),
+ 'last_name' => array('=@', '=='),
+ 'email' => array('=@', '=='),
+ ));
+ }
+
+ $order = null;
+ if (Input::has('order'))
+ {
+ $order = OrderParser::parse(Input::get('order'), array
+ (
+ 'first_name',
+ 'last_name',
+ ));
+ }
+
+ $result = $this->speaker_repository->getSpeakersBySummit($summit, new PagingInfo($page, $per_page), $filter, $order);
+
+ return $this->ok
+ (
+ $result->toArray(Request::input('expand', ''),[],[],['summit_id' => $summit_id, 'published' => true])
+ );
+ }
+ catch (Exception $ex)
+ {
+ Log::error($ex);
+ return $this->error500($ex);
+ }
+ }
+
+ /**
+ * @param $summit_id
+ * @param $speaker_id
+ * @return mixed
+ */
+ public function getSpeaker($summit_id, $speaker_id)
+ {
+ try
+ {
+
+ $summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
+ if (is_null($summit)) return $this->error404();
+
+ $speaker = CheckSpeakerStrategyFactory::build(CheckSpeakerStrategyFactory::Me, $this->resource_server_context)->check($speaker_id, $summit);
+ if (is_null($speaker)) return $this->error404();
+
+ return $this->ok(SerializerRegistry::getInstance()->getSerializer($speaker)->serialize(Request::input('expand', '')));
+
+ } 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/SummitFinderStrategyFactory.php b/app/Http/Controllers/apis/protected/summit/SummitFinderStrategyFactory.php
index d2ec19a1..ed36f80c 100644
--- a/app/Http/Controllers/apis/protected/summit/SummitFinderStrategyFactory.php
+++ b/app/Http/Controllers/apis/protected/summit/SummitFinderStrategyFactory.php
@@ -1,4 +1,4 @@
-resource_server_context->getCurrentUserExternalId();
if (is_null($member_id)) {
- return $this->error404();
+ return null;
}
$speaker = $summit->getSpeakerByMemberId($member_id);
} else {
- $speaker = $summit->getSpeakerById(intval($speaker_id));
+ $speaker = $summit->getSpeaker(intval($speaker_id));
}
return $speaker;
}
diff --git a/app/Http/Controllers/apis/protected/summit/strategies/CheckMyOwnAttendeeStrategy.php b/app/Http/Controllers/apis/protected/summit/strategies/CheckMyOwnAttendeeStrategy.php
index 1daf66fd..843e365c 100644
--- a/app/Http/Controllers/apis/protected/summit/strategies/CheckMyOwnAttendeeStrategy.php
+++ b/app/Http/Controllers/apis/protected/summit/strategies/CheckMyOwnAttendeeStrategy.php
@@ -35,7 +35,7 @@ final class CheckMyOwnAttendeeStrategy extends CheckMeAttendeeStrategy implement
{
$attendee = parent::check($attendee_id, $summit);
if(!$attendee) return null;
- $attendee_member_id = intval($attendee->member()->ID);
+ $attendee_member_id = intval($attendee->getMember()->getId());
$member_id = $this->resource_server_context->getCurrentUserExternalId();
if(is_null($member_id) || ($attendee_member_id !== $member_id)) throw new \HTTP401UnauthorizedException;
return $attendee;
diff --git a/app/Http/Controllers/apis/protected/summit/strategies/CurrentSummitFinderStrategy.php b/app/Http/Controllers/apis/protected/summit/strategies/CurrentSummitFinderStrategy.php
index 2481b3d1..667b36b5 100644
--- a/app/Http/Controllers/apis/protected/summit/strategies/CurrentSummitFinderStrategy.php
+++ b/app/Http/Controllers/apis/protected/summit/strategies/CurrentSummitFinderStrategy.php
@@ -14,8 +14,8 @@
namespace App\Http\Controllers;
+use models\summit\ISummitRepository;
use models\summit\Summit;
-use repositories\summit\EloquentSummitRepository;
/**
* Class CurrentSummitFinderStrategy
@@ -25,11 +25,11 @@ class CurrentSummitFinderStrategy implements ISummitFinderStrategy
{
/**
- * @var EloquentSummitRepository
+ * @var ISummitRepository
*/
private $repository;
- public function __construct(EloquentSummitRepository $repository)
+ public function __construct(ISummitRepository $repository)
{
$this->repository = $repository;
}
diff --git a/app/Http/Controllers/apis/protected/summit/strategies/RetrieveSummitEventsStrategy.php b/app/Http/Controllers/apis/protected/summit/strategies/RetrieveSummitEventsStrategy.php
deleted file mode 100644
index 53848428..00000000
--- a/app/Http/Controllers/apis/protected/summit/strategies/RetrieveSummitEventsStrategy.php
+++ /dev/null
@@ -1,138 +0,0 @@
- 'integer|min:1',
- 'per_page' => 'required_with:page|integer|min:5|max:100',
- );
-
- $validation = Validator::make($values, $rules);
-
- if ($validation->fails()) {
- $ex = new ValidationException();
- throw $ex->setMessages($validation->messages()->toArray());
- }
-
- $expand = Request::input('expand', '');
-
- // default values
- $page = 1;
- $per_page = 5;
-
- if (Input::has('page')) {
- $page = intval(Input::get('page'));
- $per_page = intval(Input::get('per_page'));
- }
-
- $filter = null;
- if (Input::has('filter')) {
- $filter = FilterParser::parse(Input::get('filter'), $this->getValidFilters());
- }
-
- $events = array();
-
- list($total, $per_page, $current_page, $last_page, $items) = $this->retrieveEventsFromSource
- (
- $page, $per_page, $filter
- );
-
- foreach ($items as $event) {
- $data = $event->toArray();
- if (!empty($expand)) {
- foreach (explode(',', $expand) as $relation) {
- switch (trim($relation)) {
- case 'feedback': {
- $feedback = array();
- list($total2, $per_page2, $current_page2, $last_page2, $items2) = $event->feedback(1,
- PHP_INT_MAX);
- foreach ($items2 as $f) {
- array_push($feedback, $f->toArray());
- }
- $data['feedback'] = $feedback;
- }
- break;
- case 'location': {
- $location = $event->getLocation();
- if(is_null($location)) continue;
- $data['location'] = $location->toArray();
- unset($data['location_id']);
- }
- break;
- }
- }
- }
- array_push($events, $data);
- }
-
- return new PagingResponse
- (
- $total,
- $per_page,
- $current_page,
- $last_page,
- $events
- );
- }
-
- /**
- * @param $page
- * @param $per_page
- * @param Filter|null $filter
- * @return array
- */
- abstract public function retrieveEventsFromSource($page, $per_page, Filter $filter = null);
-
- /**
- * @return array
- */
- protected function getValidFilters()
- {
- return array
- (
- 'title' => array('=@', '=='),
- 'tags' => array('=@', '=='),
- 'start_date' => array('>', '<', '<=', '>=', '=='),
- 'end_date' => array('>', '<', '<=', '>=', '=='),
- 'summit_type_id' => array('=='),
- 'event_type_id' => array('=='),
- );
- }
-}
\ No newline at end of file
diff --git a/app/Http/Controllers/apis/protected/summit/strategies/RetrieveAllPublishedSummitEventsStrategy.php b/app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllPublishedSummitEventsStrategy.php
similarity index 62%
rename from app/Http/Controllers/apis/protected/summit/strategies/RetrieveAllPublishedSummitEventsStrategy.php
rename to app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllPublishedSummitEventsStrategy.php
index 2cd3277d..16bfec6f 100644
--- a/app/Http/Controllers/apis/protected/summit/strategies/RetrieveAllPublishedSummitEventsStrategy.php
+++ b/app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllPublishedSummitEventsStrategy.php
@@ -1,4 +1,4 @@
-event_repository->getAllPublishedByPage($page, $per_page, $filter);
+ $valid_filters = parent::getValidFilters();
+ $valid_filters['published'] = array('==');
+ return $valid_filters;
+ }
+
+ /**
+ * @return null|Filter
+ */
+ protected function buildFilter()
+ {
+ $filter = parent::buildFilter();
+ $filter->addFilterCondition(FilterParser::buildFilter('published','==','1'));
+ return $filter;
}
}
\ No newline at end of file
diff --git a/app/Http/Controllers/apis/protected/summit/strategies/RetrieveSummitEventsBySummitStrategy.php b/app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllSummitEventsBySummitStrategy.php
similarity index 50%
rename from app/Http/Controllers/apis/protected/summit/strategies/RetrieveSummitEventsBySummitStrategy.php
rename to app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllSummitEventsBySummitStrategy.php
index 760ccf5d..15958c07 100644
--- a/app/Http/Controllers/apis/protected/summit/strategies/RetrieveSummitEventsBySummitStrategy.php
+++ b/app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllSummitEventsBySummitStrategy.php
@@ -1,4 +1,5 @@
-events_repository = $events_repository;
$this->summit_repository = $summit_repository;
}
@@ -53,10 +62,46 @@ abstract class RetrieveSummitEventsBySummitStrategy extends RetrieveSummitEvents
*/
public function getEvents(array $params = array())
{
- $summit_id = isset($params['summit_id'])? $params['summit_id']:0;
+ $summit_id = isset($params['summit_id'])? $params['summit_id']:0;
$this->summit = SummitFinderStrategyFactory::build($this->summit_repository)->find($summit_id);
- if (is_null($this->summit)) throw new EntityNotFoundException;
+ if (is_null($this->summit)) throw new EntityNotFoundException('summit not found!');
+
return parent::getEvents($params);
}
+ /**
+ * @return array
+ */
+ protected function getValidFilters()
+ {
+ $valid_filters = parent::getValidFilters();
+ $valid_filters['summit_id'] = array('==');
+ return $valid_filters;
+ }
+
+ /**
+ * @return null|Filter
+ */
+ protected function buildFilter(){
+ $filter = parent::buildFilter();
+
+ if(is_null($filter))
+ {
+ $filter = new Filter([]);
+ }
+ $filter->addFilterCondition(FilterParser::buildFilter('summit_id','==',$this->summit->getId()));
+ return $filter;
+ }
+
+
+ /**
+ * @param PagingInfo $paging_info
+ * @param Filter|null $filter
+ * @return PagingResponse
+ */
+ public function retrieveEventsFromSource(PagingInfo $paging_info, Filter $filter = null)
+ {
+ return $this->events_repository->getAllByPage($paging_info, $filter);
+ }
+
}
\ No newline at end of file
diff --git a/app/Http/Controllers/apis/protected/summit/strategies/RetrieveAllSummitEventsStrategy.php b/app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllSummitEventsStrategy.php
similarity index 83%
rename from app/Http/Controllers/apis/protected/summit/strategies/RetrieveAllSummitEventsStrategy.php
rename to app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllSummitEventsStrategy.php
index 3fa63f2d..1f0604a5 100644
--- a/app/Http/Controllers/apis/protected/summit/strategies/RetrieveAllSummitEventsStrategy.php
+++ b/app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveAllSummitEventsStrategy.php
@@ -16,6 +16,8 @@ namespace App\Http\Controllers;
use models\summit\ISummitEventRepository;
use utils\Filter;
+use utils\PagingInfo;
+use utils\PagingResponse;
/**
* Class RetrieveAllSummitEventsStrategy
@@ -38,14 +40,13 @@ class RetrieveAllSummitEventsStrategy extends RetrieveSummitEventsStrategy
}
/**
- * @param $page
- * @param $per_page
+ * @param PagingInfo $paging_info
* @param Filter|null $filter
- * @return array
+ * @return PagingResponse
*/
- public function retrieveEventsFromSource($page, $per_page, Filter $filter = null)
+ public function retrieveEventsFromSource(PagingInfo $paging_info, Filter $filter = null)
{
- return $this->event_repository->getAllByPage($page, $per_page, $filter);
+ return $this->event_repository->getAllByPage($paging_info, $filter);
}
/**
diff --git a/app/Http/Controllers/apis/protected/summit/strategies/RetrievePublishedSummitEventsBySummitStrategy.php b/app/Http/Controllers/apis/protected/summit/strategies/events/RetrievePublishedSummitEventsBySummitStrategy.php
similarity index 61%
rename from app/Http/Controllers/apis/protected/summit/strategies/RetrievePublishedSummitEventsBySummitStrategy.php
rename to app/Http/Controllers/apis/protected/summit/strategies/events/RetrievePublishedSummitEventsBySummitStrategy.php
index 64f91a64..5387156f 100644
--- a/app/Http/Controllers/apis/protected/summit/strategies/RetrievePublishedSummitEventsBySummitStrategy.php
+++ b/app/Http/Controllers/apis/protected/summit/strategies/events/RetrievePublishedSummitEventsBySummitStrategy.php
@@ -1,4 +1,4 @@
-summit->schedule($page, $per_page, $filter);
+ $valid_filters = parent::getValidFilters();
+ $valid_filters['published'] = array('==');
+ return $valid_filters;
}
+
+ /**
+ * @return null|Filter
+ */
+ protected function buildFilter()
+ {
+ $filter = parent::buildFilter();
+ $filter->addFilterCondition(FilterParser::buildFilter('published','==','1'));
+ 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
new file mode 100644
index 00000000..27d0eff3
--- /dev/null
+++ b/app/Http/Controllers/apis/protected/summit/strategies/events/RetrieveSummitEventsStrategy.php
@@ -0,0 +1,98 @@
+ 'integer|min:1',
+ 'per_page' => 'required_with:page|integer|min:5|max:100',
+ );
+
+ $validation = Validator::make($values, $rules);
+
+ if ($validation->fails()) {
+ $ex = new ValidationException();
+ throw $ex->setMessages($validation->messages()->toArray());
+ }
+
+ // default values
+ $page = 1;
+ $per_page = 5;
+
+ if (Input::has('page')) {
+ $page = intval(Input::get('page'));
+ $per_page = intval(Input::get('per_page'));
+ }
+
+
+ return $this->retrieveEventsFromSource
+ (
+ new PagingInfo($page, $per_page), $this->buildFilter()
+ );
+ }
+
+ /**
+ * @return null|Filter
+ */
+ protected function buildFilter(){
+ $filter = null;
+ if (Input::has('filter')) {
+ $filter = FilterParser::parse(Input::get('filter'), $this->getValidFilters());
+ }
+ return $filter;
+ }
+ /**
+ * @param PagingInfo $paging_info
+ * @param Filter|null $filter
+ * @return PagingResponse
+ */
+ abstract public function retrieveEventsFromSource(PagingInfo $paging_info, Filter $filter = null);
+
+ /**
+ * @return array
+ */
+ protected function getValidFilters()
+ {
+ return array
+ (
+ 'title' => array('=@', '=='),
+ 'tags' => array('=@', '=='),
+ 'start_date' => array('>', '<', '<=', '>=', '=='),
+ 'end_date' => array('>', '<', '<=', '>=', '=='),
+ 'summit_type_id' => array('=='),
+ 'event_type_id' => array('=='),
+ );
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 5b280474..0481abf9 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -1,37 +1,57 @@
- [
+ ],
+ 'api' => [
+ ],
];
/**
* The application's route middleware.
+ *
+ * These middleware may be assigned to groups or used individually.
+ *
* @var array
*/
protected $routeMiddleware = [
- 'auth' => 'App\Http\Middleware\Authenticate',
- 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
- 'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
- 'oauth2.protected' => 'App\Http\Middleware\OAuth2BearerAccessTokenRequestValidator',
- 'rate.limit' => 'App\Http\Middleware\RateLimitMiddleware',
- 'etags' => 'App\Http\Middleware\ETagsMiddleware',
- 'cache' => 'App\Http\Middleware\CacheMiddleware',
- 'ssl' => 'App\Http\Middleware\SSLMiddleware',
+ 'auth' => \App\Http\Middleware\Authenticate::class,
+ 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
+ 'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
+ 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
+ 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
+ 'oauth2.protected' => \App\Http\Middleware\OAuth2BearerAccessTokenRequestValidator::class,
+ 'rate.limit' => \App\Http\Middleware\RateLimitMiddleware::class,
+ 'etags' => \App\Http\Middleware\ETagsMiddleware::class,
+ 'cache' => \App\Http\Middleware\CacheMiddleware::class,
+ 'ssl' => \App\Http\Middleware\SSLMiddleware::class,
];
-
-}
\ No newline at end of file
+}
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index 72a7613a..67abcaea 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -1,50 +1,30 @@
-auth = $auth;
- }
-
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- if ($this->auth->guest())
- {
- if ($request->ajax())
- {
- return response('Unauthorized.', 401);
- }
- else
- {
- return redirect()->guest('auth/login');
- }
- }
-
- return $next($request);
- }
+class Authenticate
+{
+ /**
+ * Handle an incoming request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @param string|null $guard
+ * @return mixed
+ */
+ public function handle($request, Closure $next, $guard = null)
+ {
+ if (Auth::guard($guard)->guest()) {
+ if ($request->ajax() || $request->wantsJson()) {
+ return response('Unauthorized.', 401);
+ } else {
+ return redirect()->guest('login');
+ }
+ }
+ return $next($request);
+ }
}
diff --git a/app/Http/Middleware/CORSMiddleware.php b/app/Http/Middleware/CORSMiddleware.php
index d4dda0b5..41c4beaf 100644
--- a/app/Http/Middleware/CORSMiddleware.php
+++ b/app/Http/Middleware/CORSMiddleware.php
@@ -16,7 +16,6 @@ use Closure;
use libs\utils\ICacheService;
use models\resource_server\IApiEndpoint;
use models\resource_server\IApiEndpointRepository;
-use Illuminate\Contracts\Routing\Middleware;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Support\Facades\Cache;
@@ -30,7 +29,7 @@ use libs\utils\RequestUtils;
* @package App\Http\Middleware\
* Implementation of http://www.w3.org/TR/cors/
*/
-class CORSMiddleware implements Middleware
+class CORSMiddleware
{
const CORS_IP_BLACKLIST_PREFIX = 'CORS_IP_BLACKLIST_PREFIX:';
diff --git a/app/Http/Middleware/CacheMiddleware.php b/app/Http/Middleware/CacheMiddleware.php
index 3eae6bff..0442f82e 100644
--- a/app/Http/Middleware/CacheMiddleware.php
+++ b/app/Http/Middleware/CacheMiddleware.php
@@ -1,4 +1,4 @@
-getMethod() !== 'GET')
{
- // shortcircuit
+ // short circuit
return $next($request);
}
diff --git a/app/Http/Middleware/ETagsMiddleware.php b/app/Http/Middleware/ETagsMiddleware.php
index 49be902e..35382f34 100644
--- a/app/Http/Middleware/ETagsMiddleware.php
+++ b/app/Http/Middleware/ETagsMiddleware.php
@@ -14,17 +14,15 @@
**/
use Closure;
-use Illuminate\Contracts\Routing\Middleware;
-use Log;
+use Illuminate\Support\Facades\Log;
/**
* Class ETagsMiddleware
* @package App\Http\Middleware
*/
-final class ETagsMiddleware implements Middleware
+final class ETagsMiddleware
{
-
/**
* Handle an incoming request.
* @param \Illuminate\Http\Request $request
diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php
new file mode 100644
index 00000000..3aa15f8d
--- /dev/null
+++ b/app/Http/Middleware/EncryptCookies.php
@@ -0,0 +1,17 @@
+auth = $auth;
- }
-
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- if ($this->auth->check())
- {
- return new RedirectResponse(url('/home'));
- }
-
- return $next($request);
- }
+class RedirectIfAuthenticated
+{
+ /**
+ * Handle an incoming request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @param string|null $guard
+ * @return mixed
+ */
+ public function handle($request, Closure $next, $guard = null)
+ {
+ if (Auth::guard($guard)->check()) {
+ return redirect('/');
+ }
+ return $next($request);
+ }
}
diff --git a/app/Http/Middleware/SSLMiddleware.php b/app/Http/Middleware/SSLMiddleware.php
index ea46dc14..d8513aa8 100644
--- a/app/Http/Middleware/SSLMiddleware.php
+++ b/app/Http/Middleware/SSLMiddleware.php
@@ -1,4 +1,4 @@
-alias = $alias;
+ }
+
+ /**
+ * @param FilterElement $filter
+ * @throws \Exception
+ */
+ public function toRawSQL(FilterElement $filter)
+ {
+ throw new \Exception;
+ }
+
+ /**
+ * @param QueryBuilder $query
+ * @param FilterElement $filter
+ * @return QueryBuilder
+ */
+ public function apply(QueryBuilder $query, FilterElement $filter){
+ $where = str_replace(":value", $filter->getValue(), $this->where);
+ $where = str_replace(":operator", $filter->getOperator(), $where);
+ return $query->innerJoin($this->table, $this->alias, Join::WITH, $where);
+ }
+
+ /**
+ * @param QueryBuilder $query
+ * @param FilterElement $filter
+ * @return QueryBuilder
+ */
+ public function applyOr(QueryBuilder $query, FilterElement $filter){
+ $where = str_replace(":value", $filter->getValue(), $this->where);
+ $where = str_replace(":operator", $filter->getOperator(), $where);
+ return $query->innerJoin($this->table, $this->alias, Join::WITH)->orWhere($where);
+ }
+}
\ No newline at end of file
diff --git a/app/Http/Utils/ExistsFilterManyManyMapping.php b/app/Http/Utils/ExistsFilterManyManyMapping.php
deleted file mode 100644
index 8855ed20..00000000
--- a/app/Http/Utils/ExistsFilterManyManyMapping.php
+++ /dev/null
@@ -1,55 +0,0 @@
-pivot_table = $pivot_table;
- }
-
- /**
- * @param FilterElement $filter
- * @return string
- */
- public function toRawSQL(FilterElement $filter)
- {
- $where = str_replace(":value", $filter->getValue(), $this->where);
- $where = str_replace(":operator", $filter->getOperator(), $where);
-
- $sql = <<
+ * An offset to check for.
+ *
+ * The return value will be casted to boolean if non-boolean was returned. + * @since 5.0.0 + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Offset to retrieve + * @link http://php.net/manual/en/arrayaccess.offsetget.php + * @param mixed $offset
+ * The offset to retrieve. + *
+ * @return mixed Can return all value types. + * @since 5.0.0 + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Offset to set + * @link http://php.net/manual/en/arrayaccess.offsetset.php + * @param mixed $offset+ * The offset to assign the value to. + *
+ * @param mixed $value+ * The value to set. + *
+ * @return void + * @since 5.0.0 + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + ++$this->idx; + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Offset to unset + * @link http://php.net/manual/en/arrayaccess.offsetunset.php + * @param mixed $offset+ * The offset to unset. + *
+ * @return void + * @since 5.0.0 + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/SummitEntityEventProcessContext.php b/app/Models/Foundation/Summit/EntityEvents/SummitEntityEventProcessContext.php new file mode 100644 index 00000000..51a35fa0 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/SummitEntityEventProcessContext.php @@ -0,0 +1,170 @@ +list = new EntityEventList(); + $this->current_member_id = $current_member_id; + } + + /** + * @return int|null + */ + public function getCurrentMemberId(){ return $this->current_member_id; } + + /** + * @param SummitEntityEvent $entity_event + * @return bool + */ + public function existsOpType(SummitEntityEvent $entity_event){ + switch($entity_event->getType()){ + case 'INSERT': return $this->existsInsertOp($entity_event);break; + case 'UPDATE': return $this->existsUpdateOp($entity_event);break; + case 'DELETE': return $this->existsDeleteOp($entity_event);break; + default: throw new \InvalidArgumentException;break; + } + } + + public function registerOpType(SummitEntityEvent $entity_event){ + switch($entity_event->getType()){ + case 'INSERT': return $this->registerInsertOp($entity_event);break; + case 'UPDATE': return $this->registerUpdateOp($entity_event);break; + case 'DELETE': return $this->registerDeleteOp($entity_event);break; + default: throw new \InvalidArgumentException;break; + } + } + /** + * @param SummitEntityEvent $entity_event + * @return bool + */ + public function existsDeleteOp(SummitEntityEvent $entity_event){ + return isset($this->delete_operations[$entity_event->getKey()]); + } + + /** + * @param SummitEntityEvent $entity_event + */ + public function registerDeleteOp(SummitEntityEvent $entity_event){ + $this->delete_operations[$entity_event->getKey()] = $entity_event->getKey(); + } + + /** + * @param SummitEntityEvent $entity_event + * @return bool + */ + public function existsUpdateOp(SummitEntityEvent $entity_event){ + return isset($this->update_operations[$entity_event->getKey()]); + } + + /** + * @param SummitEntityEvent $entity_event + */ + public function registerUpdateOp(SummitEntityEvent $entity_event){ + $this->update_operations[$entity_event->getKey()] = $entity_event->getKey(); + } + + /** + * @param SummitEntityEvent $entity_event + * @return bool + */ + public function existsInsertOp(SummitEntityEvent $entity_event){ + return isset($this->insert_operations[$entity_event->getKey()]); + } + + /** + * @param SummitEntityEvent $entity_event + */ + public function registerInsertOp(SummitEntityEvent $entity_event){ + $this->insert_operations[$entity_event->getKey()] = $entity_event->getKey(); + } + + /** + * @param SummitEntityEvent $entity_event + */ + public function registerSummitEventOp(SummitEntityEvent $entity_event){ + $key = $entity_event->getKey(); + if(!isset($this->summit_events_operations[$key])) $this->summit_events_operations[$key] = array(); + array_push($this->summit_events_operations[$key], ['idx' => $this->list->getIdx() - 1 , 'op' => $entity_event->getType()]); + } + + /** + * @param SummitEntityEvent $e + */ + public function registerEntityEvent(SummitEntityEvent $e){ + $this->list[] = SerializerRegistry::getInstance()->getSerializer($e)->serialize + ( + implode(',',['speakers','tracks','sponsors', 'floor']) + ); + } + + /** + * @return array + */ + public function getListValues(){ + return $this->list->values(); + } + + public function postProcessList(){ + foreach ($this->summit_events_operations as $key => $ops) { + $last_idx = null; + $last_op = null; + $must_insert = false; + foreach ($ops as $op) { + if (!is_null($last_idx)) + unset($this->list[$last_idx]); + $last_op = $op['op']; + $last_idx = intval($op['idx']); + $must_insert = !$must_insert && $last_op === 'INSERT' ? true : $must_insert; + } + $last_op = $must_insert && $last_op !== 'DELETE' ? 'INSERT' : $last_op; + $summit_events_ops[$key] = array(['idx' => $last_idx, 'op' => ($last_op)]); + // element update + $e = $this->list[$last_idx]; + $e['type'] = $last_op; + $this->list[$last_idx] = $e; + } + } + + /** + * @return int + */ + public function getListSize(){ + return $this->list->size(); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/EntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/EntityEventType.php new file mode 100644 index 00000000..6ca93a7c --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/EntityEventType.php @@ -0,0 +1,49 @@ +entity_event = $entity_event; + $this->process_ctx = $process_ctx; + } + + /** + * @return IEntity|null + */ + abstract protected function registerEntity(); +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/EntityEventTypeFactory.php b/app/Models/Foundation/Summit/EntityEvents/Types/EntityEventTypeFactory.php new file mode 100644 index 00000000..3a97964e --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/EntityEventTypeFactory.php @@ -0,0 +1,153 @@ +getEntityClassName()) + { + case 'Presentation': + case 'SummitEvent': + { + if ($e->getType() === 'UPDATE' || $e->getType() === "INSERT") + return new SummitEventEntityEventInsertOrUpdateType($e, $ctx); + return new SummitEventEntityEventDeleteType($e, $ctx); + } + break; + case 'MySchedule': + { + return new MyScheduleEntityEventType($e, $ctx); + } + break; + case 'Summit': + { + return new SummitEntityEventType($e, $ctx); + } + break; + case 'SummitType': + { + return new SummitTypeEntityEventType($e, $ctx); + } + break; + case 'SummitEventType': + { + return new SummitEventTypeEntityEventType($e, $ctx); + } + break; + case 'SummitVenue': + case 'SummitVenueRoom': + case 'SummitAirport': + case 'SummitHotel': + case 'SummitGeoLocatedLocation': + case 'SummitExternalLocation': + case 'SummitAbstractLocation': + case 'VenueFloorFromVenueRoom': + { + return new SummitLocationEntityEventType($e, $ctx); + } + break; + case 'PresentationSpeaker': + { + return new PresentationSpeakerEntityEventType($e, $ctx); + } + break; + case 'SummitTicketType': + { + return new SummitTicketTypeEntityEventType($e, $ctx); + } + break; + case 'SummitLocationImage': + case 'SummitLocationMap': + { + return new SummitLocationImageEventType($e, $ctx); + } + break; + case 'PresentationCategory': + { + return new PresentationCategoryEntityEventType($e, $ctx); + } + break; + case 'PresentationCategoryGroup': + { + return new PresentationCategoryGroupEntityEventType($e, $ctx); + } + break; + case 'PresentationSlide': + case 'PresentationVideo': + case 'PresentationLink': + { + return new PresentationMaterialEntityEventType($e, $ctx); + } + break; + case 'SpeakerFromPresentation': + case 'SummitTypeFromEvent': + case 'SponsorFromEvent': + { + return new SummitEventRelationEntityEventType($e, $ctx); + } + break; + case 'TrackFromTrackGroup': + { + return new TrackFromTrackGroupEventType($e, $ctx); + } + break; + case 'SummitVenueFloor': + { + return new SummitVenueFloorEntityEventType($e, $ctx); + } + break; + case 'WipeData': + { + return new WipeDataEntityEventType($e, $ctx); + } + break; + default: + throw new InvalidArgumentException(sprintf('invalid entity class name %s!', $e->getEntityClassName())); + break; + } + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/GenericSummitEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/GenericSummitEntityEventType.php new file mode 100644 index 00000000..14fe4504 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/GenericSummitEntityEventType.php @@ -0,0 +1,36 @@ +process_ctx->existsOpType($this->entity_event)) return; + $this->process_ctx->registerOpType($this->entity_event); + if ($this->entity_event->getType() === 'UPDATE' || $this->entity_event->getType() === "INSERT") { + $entity = $this->registerEntity(); + if (is_null($entity)) return; + } + $this->process_ctx->registerEntityEvent($this->entity_event); + } +} \ No newline at end of file diff --git a/app/Models/summit/SummitAirport.php b/app/Models/Foundation/Summit/EntityEvents/Types/IEntityEventType.php similarity index 74% rename from app/Models/summit/SummitAirport.php rename to app/Models/Foundation/Summit/EntityEvents/Types/IEntityEventType.php index 8107a8ef..91b0572a 100644 --- a/app/Models/summit/SummitAirport.php +++ b/app/Models/Foundation/Summit/EntityEvents/Types/IEntityEventType.php @@ -1,6 +1,7 @@ -process_ctx->getCurrentMemberId(); + if (is_null($member_id) || intval($member_id) !== $this->entity_event->getOwnerId()) return; + if($this->entity_event->getType() === 'INSERT'){ + $entity = $this->registerEntity(); + if (is_null($entity)) return; + } + $this->process_ctx->registerEntityEvent($this->entity_event); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/PresentationCategoryEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/PresentationCategoryEntityEventType.php new file mode 100644 index 00000000..9889098e --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/PresentationCategoryEntityEventType.php @@ -0,0 +1,32 @@ +entity_event->getSummit()->getPresentationCategory($this->entity_event->getEntityId()); + if(is_null($entity)) return null; + $this->entity_event->registerEntity($entity); + return $entity; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/PresentationCategoryGroupEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/PresentationCategoryGroupEntityEventType.php new file mode 100644 index 00000000..33244758 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/PresentationCategoryGroupEntityEventType.php @@ -0,0 +1,34 @@ +entity_event->getSummit()->getCategoryGroup($this->entity_event->getEntityId()); + if(is_null($entity)) return null; + $this->entity_event->registerEntity($entity); + return $entity; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/PresentationMaterialEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/PresentationMaterialEntityEventType.php new file mode 100644 index 00000000..c0f5b8d1 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/PresentationMaterialEntityEventType.php @@ -0,0 +1,37 @@ +entity_event->getMetadata(); + if(!isset($metadata['presentation_id'])) return null; + $presentation = $this->entity_event->getSummit()->getScheduleEvent(intval($metadata['presentation_id'])); + if (is_null($presentation)) return null; + $material = $presentation->getMaterial($this->entity_event->getEntityId()); + if(is_null($material)) return null; + $this->entity_event->registerEntity($material); + return $material; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/PresentationSpeakerEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/PresentationSpeakerEntityEventType.php new file mode 100644 index 00000000..f4f8b693 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/PresentationSpeakerEntityEventType.php @@ -0,0 +1,34 @@ +entity_event->getSummit()->getSpeaker($this->entity_event->getEntityId()); + if(!is_null($entity)) + $this->entity_event->registerEntity($entity); + return $entity; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/SummitEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEntityEventType.php new file mode 100644 index 00000000..cfcb7278 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEntityEventType.php @@ -0,0 +1,34 @@ +entity_event->getSummit(); + if(is_null($summit)) return null; + if($summit->getId() !== $this->entity_event->getEntityId()) return null; + return $this->entity_event->registerEntity($summit); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventEntityEventDeleteType.php b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventEntityEventDeleteType.php new file mode 100644 index 00000000..58aa2b0b --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventEntityEventDeleteType.php @@ -0,0 +1,30 @@ +process_ctx->existsDeleteOp($this->entity_event)) return; + $this->process_ctx->registerDeleteOp($this->entity_event); + $this->process_ctx->registerEntityEvent($this->entity_event); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventEntityEventInsertOrUpdateType.php b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventEntityEventInsertOrUpdateType.php new file mode 100644 index 00000000..4677dbb5 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventEntityEventInsertOrUpdateType.php @@ -0,0 +1,50 @@ +entity_event->getMetadata(); + $published_old = isset($metadata['pub_old']) ? (bool)intval($metadata['pub_old']) : false; + $published_current = isset($metadata['pub_new']) ? (bool)intval($metadata['pub_new']) : false; + + // the event was not published at the moment of UPDATE .. then skip it! + if (!$published_old && !$published_current) return; + $entity = $this->registerEntity(); + if (!is_null($entity)) // if event exists its bc its published + { + $this->entity_event->setType + ( + $published_current && isset($metadata['pub_old']) && !$published_old ? 'INSERT' : $this->entity_event->getType() + ); + + $this->process_ctx->registerEntityEvent($this->entity_event); + $this->process_ctx->registerSummitEventOp($this->entity_event); + return; + } + // if does not exists on schedule delete it + $this->entity_event->setType('DELETE'); + $chain = new SummitEventEntityEventDeleteType($this->entity_event, $this->process_ctx); + return $chain->process(); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventEntityEventType.php new file mode 100644 index 00000000..8a223060 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventEntityEventType.php @@ -0,0 +1,31 @@ +entity_event->getSummit()->getScheduleEvent($this->entity_event->getEntityId()); + if(!is_null($entity)) + $this->entity_event->registerEntity($entity); + return $entity; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventRelationEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventRelationEntityEventType.php new file mode 100644 index 00000000..719cdeea --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventRelationEntityEventType.php @@ -0,0 +1,51 @@ +entity_event->getMetadata(); + if(!isset($metadata['event_id'])) return null; + $event = $this->entity_event->getSummit()->getScheduleEvent(intval($metadata['event_id'])); + if (is_null($event)) return null; + $this->entity_event->setEntityClassName($event->getClassName()); + $this->entity_event->registerEntity($event); + return $event; + } + + /** + * @return void + */ + public function process() + { + $entity = $this->registerEntity(); + if(is_null($entity)) return; + $this->entity_event->setType('UPDATE'); + if($this->process_ctx->existsUpdateOp($this->entity_event)) return; + $this->process_ctx->registerUpdateOp($this->entity_event); + $this->process_ctx->registerEntityEvent($this->entity_event); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventTypeEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventTypeEntityEventType.php new file mode 100644 index 00000000..987a8600 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/SummitEventTypeEntityEventType.php @@ -0,0 +1,33 @@ +entity_event->getSummit()->getEventType($this->entity_event->getEntityId()); + if(!is_null($entity)) + $this->entity_event->registerEntity($entity); + return $entity; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/SummitLocationEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/SummitLocationEntityEventType.php new file mode 100644 index 00000000..214526f1 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/SummitLocationEntityEventType.php @@ -0,0 +1,37 @@ +entity_event->getType(); + // if there is an insert in place, skip it + if($type === 'UPDATE' && $this->process_ctx->existsInsertOp($this->entity_event)) return null; + $entity = $this->entity_event->getSummit()->getLocation($this->entity_event->getEntityId()); + if(is_null($entity)) return null; + return $this->entity_event->registerEntity($entity); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/SummitLocationImageEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/SummitLocationImageEventType.php new file mode 100644 index 00000000..3da2fb69 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/SummitLocationImageEventType.php @@ -0,0 +1,37 @@ +entity_event->getMetadata(); + if(!isset($metadata['location_id'])) return null; + $location = $this->entity_event->getSummit()->getLocation(intval($metadata['location_id'])); + if(is_null($location)) return null; + $entity = $location->getImage($this->entity_event->getEntityId()); + if(is_null($entity)) return null; + $this->entity_event->registerEntity($entity); + return $entity; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/SummitTicketTypeEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/SummitTicketTypeEntityEventType.php new file mode 100644 index 00000000..3119c3f1 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/SummitTicketTypeEntityEventType.php @@ -0,0 +1,33 @@ +entity_event->getSummit()->getTicketType($this->entity_event->getEntityId()); + if(!is_null($entity)) + $this->entity_event->registerEntity($entity); + return $entity; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/SummitTypeEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/SummitTypeEntityEventType.php new file mode 100644 index 00000000..907ae6a0 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/SummitTypeEntityEventType.php @@ -0,0 +1,34 @@ +entity_event->getSummit()->getSummitType($this->entity_event->getEntityId()); + if(!is_null($entity)) + $this->entity_event->registerEntity($entity); + return $entity; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/SummitVenueFloorEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/SummitVenueFloorEntityEventType.php new file mode 100644 index 00000000..b0c34f2e --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/SummitVenueFloorEntityEventType.php @@ -0,0 +1,37 @@ +entity_event->getMetadata(); + if(!isset($metadata['venue_id'])) return null; + $location = $this->entity_event->getSummit()->getLocation(intval($metadata['venue_id'])); + if (is_null($location)) return null; + $floor = $location->getFloor($this->entity_event->getEntityId()); + if(is_null($floor)) return null; + $this->entity_event->registerEntity($floor); + return $floor; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/TrackFromTrackGroupEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/TrackFromTrackGroupEventType.php new file mode 100644 index 00000000..876c4847 --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/TrackFromTrackGroupEventType.php @@ -0,0 +1,49 @@ +entity_event->getMetadata(); + if(!isset($metadata['group_id'])) return null; + $group = $this->entity_event->getSummit()->getCategoryGroup(intval($metadata['group_id'])); + if (is_null($group)) return null; + $this->entity_event->registerEntity($group); + return $group; + } + + /** + * @return void + */ + public function process() + { + $entity = $this->registerEntity(); + if(is_null($entity)) return; + $this->entity_event->setType('UPDATE'); + $this->entity_event->setEntityClassName('PresentationCategoryGroup'); + if($this->process_ctx->existsUpdateOp($this->entity_event)) return; + $this->process_ctx->registerUpdateOp($this->entity_event); + $this->process_ctx->registerEntityEvent($this->entity_event); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/EntityEvents/Types/WipeDataEntityEventType.php b/app/Models/Foundation/Summit/EntityEvents/Types/WipeDataEntityEventType.php new file mode 100644 index 00000000..42438cef --- /dev/null +++ b/app/Models/Foundation/Summit/EntityEvents/Types/WipeDataEntityEventType.php @@ -0,0 +1,48 @@ +entity_event->getEntityId() > 0) { + $attendee_id = intval($this->entity_event->getEntityId()); + $member_id = $this->process_ctx->getCurrentMemberId(); + $attendee = $this->entity_event->getSummit()->getAttendeeByMemberId($member_id); + // if we are not the recipient or its already processed then continue + if(is_null($attendee) || $attendee->getId() != $attendee_id) return; + } + $this->entity_event->setType('TRUNCATE'); + $this->process_ctx->registerEntityEvent($this->entity_event); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationLink.php b/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationLink.php new file mode 100644 index 00000000..bbefb953 --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationLink.php @@ -0,0 +1,52 @@ +link; + } + + /** + * @param string $link + */ + public function setLink($link) + { + $this->link = $link; + } + /** + * @ORM\Column(name="Link", type="string") + * @var string + */ + private $link; + +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationMaterial.php b/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationMaterial.php new file mode 100644 index 00000000..123e0bdf --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationMaterial.php @@ -0,0 +1,197 @@ +presentation; + } + + /** + * @param Presentation $presentation + */ + public function setPresentation(Presentation $presentation){ + $this->presentation = $presentation; + } + + /** + * @return int + */ + public function getPresentationId(){ + try { + return $this->presentation->getId(); + } + catch (\Exception $ex){ + return 0; + } + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return string + */ + public function getDisplayOnSite() + { + return $this->display_on_site; + } + + /** + * @param string $display_on_site + */ + public function setDisplayOnSite($display_on_site) + { + $this->display_on_site = $display_on_site; + } + + /** + * @return string + */ + public function getFeatured() + { + return $this->featured; + } + + /** + * @param string $featured + */ + public function setFeatured($featured) + { + $this->featured = $featured; + } + + /** + * @ORM\Column(name="Name", type="string") + * @var string + */ + protected $name; + + /** + * @ORM\Column(name="Description", type="string") + * @var string + */ + protected $description; + + /** + * @ORM\Column(name="DisplayOnSite", type="boolean") + * @var string + */ + protected $display_on_site; + + /** + * @ORM\Column(name="Order", type="integer") + * @var int + */ + protected $order; + + /** + * @return int + */ + public function getOrder() + { + return $this->order; + } + + /** + * @param int $order + */ + public function setOrder($order) + { + $this->order = $order; + } + + /** + * @ORM\Column(name="Featured", type="boolean") + * @var string + */ + protected $featured; + + public function __construct() + { + parent::__construct(); + $this->featured = false; + $this->display_on_site = false; + $this->order = 0; + } + + /** + * @ORM\PostPersist + */ + public function inserted($args){ + Event::fire(new PresentationMaterialCreated($this, $args)); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationSlide.php b/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationSlide.php new file mode 100644 index 00000000..7cf992af --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationSlide.php @@ -0,0 +1,98 @@ +slide; + } + + /** + * @param File $slide + */ + public function setSlide($slide) + { + $this->slide = $slide; + } + + /** + * @return string + */ + public function getLink() + { + return $this->link; + } + + /** + * @param string $link + */ + public function setLink($link) + { + $this->link = $link; + } + + /** + * @return bool + */ + public function hasSlide(){ + return $this->getSlideId() > 0; + } + + /** + * @return int + */ + public function getSlideId(){ + try{ + return !is_null($this->slide)?$this->slide->getId():0; + } + catch(\Exception $ex){ + return 0; + } + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationVideo.php b/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationVideo.php new file mode 100644 index 00000000..25c67a41 --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/Materials/PresentationVideo.php @@ -0,0 +1,128 @@ +youtube_id; + } + + /** + * @param string $youtube_id + */ + public function setYoutubeId($youtube_id) + { + $this->youtube_id = $youtube_id; + } + + /** + * @return \DateTime + */ + public function getDateUploaded() + { + return $this->date_uploaded; + } + + /** + * @param \DateTime $date_uploaded + */ + public function setDateUploaded($date_uploaded) + { + $this->date_uploaded = $date_uploaded; + } + + /** + * @return bool + */ + public function getHighlighted() + { + return (bool)$this->highlighted; + } + + /** + * @param bool $highlighted + */ + public function setHighlighted($highlighted) + { + $this->highlighted = $highlighted; + } + + /** + * @return int + */ + public function getViews() + { + return $this->views; + } + + /** + * @param int $views + */ + public function setViews($views) + { + $this->views = $views; + } + + /** + * @ORM\Column(name="DateUploaded", type="datetime") + * @var \DateTime + */ + private $date_uploaded; + + /** + * @ORM\Column(name="Highlighted", type="boolean") + * @var bool + */ + private $highlighted; + + /** + * @ORM\Column(name="Views", type="integer") + * @var int + */ + private $views; + + public function __construct() + { + parent::__construct(); + $this->highlighted = false; + $this->views = 0; + $this->date_uploaded = new \DateTime(); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/Presentations/Presentation.php b/app/Models/Foundation/Summit/Events/Presentations/Presentation.php new file mode 100644 index 00000000..fd7ed240 --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/Presentation.php @@ -0,0 +1,308 @@ +materials = new ArrayCollection(); + $this->speakers = new ArrayCollection(); + } + + /** + * @return string + */ + public function getLevel() + { + return $this->level; + } + + /** + * @param string $level + */ + public function setLevel($level) + { + $this->level = $level; + } + + /** + * @return string + */ + public function getProblemAddressed() + { + return $this->problem_addressed; + } + + /** + * @param string $problem_addressed + */ + public function setProblemAddressed($problem_addressed) + { + $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 + */ + public function getAttendeesExpectedLearnt() + { + return $this->attendees_expected_learnt; + } + + /** + * @param string $attendees_expected_learnt + */ + public function setAttendeesExpectedLearnt($attendees_expected_learnt) + { + $this->attendees_expected_learnt = $attendees_expected_learnt; + } + + /** + * @return string + */ + public function getClassName(){ + return "Presentation"; + } + + /** + * @return PresentationSpeaker[] + */ + public function getSpeakers() + { + return $this->speakers; + } + + /** + * @param PresentationSpeaker $speaker + */ + public function addSpeaker(PresentationSpeaker $speaker){ + $this->speakers->add($speaker); + $speaker->addPresentation($this); + } + + public function clearSpeakers(){ + $this->speakers->clear(); + } + + /** + * @return int[] + */ + public function getSpeakerIds() + { + return $this->speakers->map(function($entity) { + return $entity->getId(); + })->toArray(); + } + + /** + * @return PresentationVideo[] + */ + public function getVideos() + { + return $this->materials->filter(function( $element) { return $element instanceof PresentationVideo; }); + } + + /** + * @param int $material_id + * @return PresentationMaterial|null + */ + public function getMaterial($material_id){ + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('id', intval($material_id))); + $material = $this->materials->matching($criteria)->first(); + return $material === false ? null:$material; + } + + /** + * @param PresentationVideo $video + * @return $this + */ + public function addVideo(PresentationVideo $video){ + $this->materials->add($video); + $video->setPresentation($this); + } + + /** + * @return bool + */ + public function hasVideos(){ + return count($this->getVideos()) > 0; + } + + /** + * @return PresentationSlide[] + */ + public function getSlides() + { + return $this->materials->filter(function( $element) { return $element instanceof PresentationSlide; }); + } + + /** + * @param PresentationSlide $slide + * @return $this + */ + public function addSlide(PresentationSlide $slide){ + $this->materials->add($slide); + $slide->setPresentation($this); + } + + /** + * @return bool + */ + public function hasSlides(){ + return count($this->getSlides()) > 0; + } + + /** + * @return PresentationLink[] + */ + public function getLinks(){ + return $this->materials->filter(function($element) { return $element instanceof PresentationLink; }); + } + + /** + * @return bool + */ + public function hasLinks(){ + return count($this->getLinks()) > 0; + } + + /** + * @param PresentationLink $link + * @return $this + */ + public function addLink(PresentationLink $link){ + $this->materials->add($link); + $link->setPresentation($this); + } + + /** + * @return int + */ + public function getCategoryId(){ + try { + return !is_null($this->category)? $this->category->getId():0; + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @ORM\ManyToOne(targetEntity="PresentationCategory") + * @ORM\JoinColumn(name="CategoryID", referencedColumnName="ID") + * @var PresentationCategory + */ + private $category = null; + + /** + * @param PresentationCategory $category + * @return $this + */ + public function setCategory(PresentationCategory $category) + { + $this->category = $category; + return $this; + } + + /** + * @return PresentationCategory + */ + public function getCategory(){ + return $this->category; + } + + /** + * @return int + */ + public function getModeratorId(){ + try { + return !is_null($this->moderator)? $this->moderator->getId():0; + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @ORM\ManyToOne(targetEntity="PresentationSpeaker") + * @ORM\JoinColumn(name="ModeratorID", referencedColumnName="ID") + * @var PresentationSpeaker + */ + private $moderator; + + /** + * @return PresentationSpeaker + */ + public function getModerator() + { + return $this->moderator; + } + + /** + * @param PresentationSpeaker $moderator + */ + public function setModerator(PresentationSpeaker $moderator) + { + $this->moderator = $moderator; + } + + + public function unsetModerator(){ + $this->moderator = nul; + } + +} diff --git a/app/Models/Foundation/Summit/Events/Presentations/PresentationCategory.php b/app/Models/Foundation/Summit/Events/Presentations/PresentationCategory.php new file mode 100644 index 00000000..81907177 --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/PresentationCategory.php @@ -0,0 +1,132 @@ +description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * @param string $code + */ + public function setCode($code) + { + $this->code = $code; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string $title + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * @ORM\ManyToOne(targetEntity="Summit", inversedBy="presentation_categories") + * @ORM\JoinColumn(name="SummitID", referencedColumnName="ID") + * @var Summit + */ + protected $summit; + + public function setSummit($summit){ + $this->summit = $summit; + } + + /** + * @return Summit + */ + public function getSummit(){ + return $this->summit; + } + + /** + * @ORM\ManyToMany(targetEntity="models\summit\PresentationCategoryGroup", mappedBy="categories") + * @var PresentationCategoryGroup[] + */ + private $groups; + + public function __construct() + { + parent::__construct(); + $this->groups = new ArrayCollection(); + } + + /** + * @return PresentationCategoryGroup[] + */ + public function getGroups() + { + return $this->groups; + } + +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/Presentations/PresentationCategoryGroup.php b/app/Models/Foundation/Summit/Events/Presentations/PresentationCategoryGroup.php new file mode 100644 index 00000000..cea2a58d --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/PresentationCategoryGroup.php @@ -0,0 +1,139 @@ +name; + } + + /** + * @param mixed $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return mixed + */ + public function getColor() + { + return $this->color; + } + + /** + * @param mixed $color + */ + public function setColor($color) + { + $this->color = $color; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @ORM\ManyToOne(targetEntity="Summit", inversedBy="category_groups") + * @ORM\JoinColumn(name="SummitID", referencedColumnName="ID") + * @var Summit + */ + protected $summit; + + public function setSummit($summit){ + $this->summit = $summit; + } + + /** + * @return Summit + */ + public function getSummit(){ + return $this->summit; + } + + + + public function __construct() + { + parent::__construct(); + $this->categories = new ArrayCollection; + } + + /** + * @ORM\ManyToMany(targetEntity="models\summit\PresentationCategory", inversedBy="groups") + * @ORM\JoinTable(name="PresentationCategoryGroup_Categories", + * joinColumns={@ORM\JoinColumn(name="PresentationCategoryGroupID", referencedColumnName="ID")}, + * inverseJoinColumns={@ORM\JoinColumn(name="PresentationCategoryID", referencedColumnName="ID")} + * ) + * @var PresentationCategory[] + */ + private $categories; + + /** + * @return PresentationCategory[] + */ + public function getCategories() + { + return $this->categories; + } + +} \ 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 new file mode 100644 index 00000000..fcd8a328 --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/PresentationSpeaker.php @@ -0,0 +1,270 @@ +first_name; + } + + /** + * @param string $first_name + */ + public function setFirstName($first_name) + { + $this->first_name = $first_name; + } + + /** + * @return string + */ + public function getLastName() + { + return $this->last_name; + } + + /** + * @param string $last_name + */ + public function setLastName($last_name) + { + $this->last_name = $last_name; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string $title + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * @return string + */ + public function getBio() + { + return $this->bio; + } + + /** + * @param string $bio + */ + public function setBio($bio) + { + $this->bio = $bio; + } + + /** + * @return string + */ + public function getIrcHandle() + { + return $this->irc_handle; + } + + /** + * @param string $irc_handle + */ + public function setIrcHandle($irc_handle) + { + $this->irc_handle = $irc_handle; + } + + /** + * @return string + */ + public function getTwitterName() + { + return $this->twitter_name; + } + + /** + * @param string $twitter_name + */ + public function setTwitterName($twitter_name) + { + $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; + + public function __construct() + { + parent::__construct(); + $this->presentations = new ArrayCollection; + } + + /** + * @param Presentation $presentation + */ + public function addPresentation(Presentation $presentation){ + $this->presentations->add($presentation); + } + + /** + * @param null|int $summit_id + * @param bool|true $published_ones + * @return Presentation[] + */ + public function presentations($summit_id, $published_ones = true) + { + + return $this->presentations + ->filter(function($p) use($published_ones, $summit_id){ + $res = $published_ones? $p->isPublished(): true; + $res &= is_null($summit_id)? true : $p->getSummit()->getId() == $summit_id; + return $res; + }); + } + + /** + * @param int $presentation_id + * @return Presentation + */ + public function getPresentation($presentation_id) + { + return $this->presentations->get($presentation_id); + } + /** + * @param null $summit_id + * @param bool|true $published_ones + * @return array + */ + public function getPresentationIds($summit_id, $published_ones = true) + { + return $this->presentations($summit_id, $published_ones)->map(function($entity) { + return $entity->getId(); + })->toArray(); + } + + + /** + * @ORM\ManyToOne(targetEntity="models\main\File") + * @ORM\JoinColumn(name="PhotoID", referencedColumnName="ID") + * @var File + */ + protected $photo; + + /** + * @return File + */ + public function getPhoto() + { + return $this->photo; + } + + /** + * @ORM\ManyToOne(targetEntity="models\main\Member") + * @ORM\JoinColumn(name="MemberID", referencedColumnName="ID") + * @var Image + */ + private $member; + + /** + * @return Member + */ + public function getMember() + { + return $this->member; + } + + /** + * @return bool + */ + public function hasMember(){ + return $this->getMemberId() > 0; + } + + /** + * @return int + */ + public function getMemberId() + { + try{ + return $this->member->getId(); + } + catch(\Exception $ex){ + return 0; + } + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/SummitEntityEvent.php b/app/Models/Foundation/Summit/Events/SummitEntityEvent.php new file mode 100644 index 00000000..bea99939 --- /dev/null +++ b/app/Models/Foundation/Summit/Events/SummitEntityEvent.php @@ -0,0 +1,165 @@ +entity_id = $entity_id; + } + + /** + * @return int + */ + public function getEntityId(){return $this->entity_id;} + + /** + * @ORM\Column(name="EntityClassName", type="string") + */ + private $entity_class_name; + + /** + * @return string + */ + public function getEntityClassName(){return $this->entity_class_name;} + + /** + * @param string $entity_class_name + */ + public function setEntityClassName($entity_class_name){$this->entity_class_name = $entity_class_name;} + + /** + * @ORM\Column(name="Type", type="string") + */ + private $type; + + /** + * @return string + */ + public function getType(){return $this->type;} + + /** + * @param string $type + */ + public function setType($type){$this->type = $type;} + + /** + * @ORM\Column(name="Metadata", type="string") + */ + private $metadata; + + /** + * @param string $metadata + */ + public function setMetadata($metadata){ + $this->metadata = $metadata; + } + + /** + * @return array + */ + public function getMetadata(){ + return !empty($this->metadata) ? json_decode($this->metadata, true) : array(); + } + + /** + * @ORM\ManyToOne(targetEntity="models\main\Member", cascade={"persist"}) + * @ORM\JoinColumn(name="OwnerID", referencedColumnName="ID") + * @var Member + */ + private $owner; + + /** + * @return int + */ + public function getOwnerId(){ + try{ + return $this->owner->getId(); + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @return bool + */ + public function hasOwner(){ + return $this->getOwnerId() > 0; + } + + /** + * @return Member + */ + public function getOwner(){ + return $this->owner; + } + + /** + * @param Member $owner + */ + public function setOwner(Member $owner){ + $this->owner = $owner; + } + + /** + * @return string + */ + public function getKey(){ + return sprintf("%s.%s", $this->entity_class_name, $this->entity_id); + } + + /** + * @var IEntity + */ + private $entity; + + /** + * @return IEntity + */ + public function getEntity(){ + return $this->entity; + } + + /** + * @param IEntity $entity + * @return IEntity + */ + public function registerEntity(IEntity $entity){ + $this->entity = $entity; + return $this->entity; + } + +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/SummitEvent.php b/app/Models/Foundation/Summit/Events/SummitEvent.php new file mode 100644 index 00000000..fb72467e --- /dev/null +++ b/app/Models/Foundation/Summit/Events/SummitEvent.php @@ -0,0 +1,722 @@ +title; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @return boolean + */ + public function isAllowFeedback() + { + return $this->getAllowFeedback(); + } + + /** + * @return boolean + */ + public function getAllowFeedback() + { + return $this->allow_feedback; + } + + use SummitOwned; + + /** + * SummitEvent constructor. + */ + public function __construct() + { + parent::__construct(); + $this->allow_feedback = false; + $this->published = false; + $this->avg_feedback = 0; + $this->head_count = 0; + $this->tags = new ArrayCollection(); + $this->summit_types = new ArrayCollection(); + $this->feedback = new ArrayCollection(); + $this->attendees = new ArrayCollection(); + $this->sponsors = new ArrayCollection(); + } + + /** + * @ORM\Column(name="Title", type="string") + * @var string + */ + protected $title; + + /** + * @param string $title + * @return $this + */ + public function setTitle($title) + { + $this->title = $title; + return $this; + } + + /** + * @return string + */ + public function getClassName(){ + return "SummitEvent"; + } + + /** + * @ORM\Column(name="Description", type="string") + * @var string + */ + protected $description; + + /** + * @ORM\Column(name="ShortDescription", type="string") + * @var string + */ + protected $short_description; + + /** + * @param string $description + * @return $this + */ + public function setDescription($description) + { + $this->description = $description; + return $this; + } + + /** + * @ORM\Column(name="StartDate", type="datetime") + * @var \DateTime + */ + protected $start_date; + + /** + * @ORM\Column(name="RSVPTemplateID", type="integer") + * @var int + */ + protected $rsvp_template_id; + + /** + * @return string + */ + public function getShortDescription() + { + return $this->short_description; + } + + /** + * @param string $short_description + */ + public function setShortDescription($short_description) + { + $this->short_description = $short_description; + } + + /** + * @return DateTime + */ + public function getPublishedDate() + { + return $this->published_date; + } + + /** + * @param DateTime $published_date + */ + public function setPublishedDate($published_date) + { + $this->published_date = $published_date; + } + + /** + * @return float + */ + public function getAvgFeedbackRate() + { + return $this->avg_feedback; + } + + /** + * @param float $avg_feedback + */ + public function setAvgFeedbackRate($avg_feedback) + { + $this->avg_feedback = $avg_feedback; + } + + /** + * @return string + */ + public function getRsvpLink() + { + if($this->rsvp_template_id > 0){ + $summit = $this->getSummit(); + $main_page = $summit->getMainPage(); + $schedule_page = $summit->getSchedulePage(); + return sprintf("%ssummit/%s/%s/events/%s/%s/rsvp", + Config::get("server.assets_base_url", 'https://www.openstack.org/'), + $main_page, + $schedule_page, + $this->getId(), + $this->getSlug() + ); + } + return $this->rsvp_link; + } + + public function getSlug(){ + $slugify = new Slugify(); + return $slugify->slugify($this->title); + } + + /** + * @param string $rsvp_link + */ + public function setRsvpLink($rsvp_link) + { + $this->rsvp_link = $rsvp_link; + } + + /** + * @return int + */ + public function getHeadCount() + { + return $this->head_count; + } + + /** + * @param int $head_count + */ + public function setHeadCount($head_count) + { + $this->head_count = $head_count; + } + + /** + * @ORM\Column(name="EndDate", type="datetime") + * @var \DateTime + */ + protected $end_date; + + /** + * @ORM\Column(name="Published", type="boolean") + * @var bool + */ + protected $published; + + /** + * @ORM\Column(name="PublishedDate", type="datetime") + * @var \DateTime + */ + protected $published_date; + + /** + * @ORM\Column(name="AllowFeedBack", type="boolean") + * @var bool + */ + protected $allow_feedback; + + /** + * @ORM\Column(name="AvgFeedbackRate", type="float") + * @var float + */ + protected $avg_feedback; + + /** + * @ORM\Column(name="RSVPLink", type="string") + * @var string + */ + protected $rsvp_link; + + + /** + * @ORM\Column(name="HeadCount", type="integer") + * @var int + */ + protected $head_count; + + + /** + * @return bool + */ + public function hasLocation(){ + return $this->getLocationId() > 0; + } + + /** + * @return int + */ + public function getLocationId() + { + try { + return !is_null($this->location)? $this->location->getId():0; + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @param DateTime $value + * @return $this + */ + public function setStartDate(DateTime $value) + { + $summit = $this->getSummit(); + if(!is_null($summit)) + { + $value = $summit->convertDateFromTimeZone2UTC($value); + } + $this->start_date = $value; + return $this; + } + + /** + * @return DateTime|null + */ + public function getLocalStartDate() + { + $value = $this->start_date; + if(!empty($value)) { + $summit = $this->getSummit(); + if(!is_null($summit)) + { + $res = $summit->convertDateFromUTC2TimeZone($value); + } + return $res; + } + return null; + } + + /** + * @return \DateTime|null + */ + public function getStartDate() + { + return $this->start_date; + } + + /** + * @param DateTime $value + * @return $this + */ + public function setEndDate(DateTime $value) + { + $summit = $this->getSummit(); + if(!is_null($summit)) + { + $value = $summit->convertDateFromTimeZone2UTC($value); + } + $this->end_date = $value; + return $this; + } + + /** + * @return DateTime|null + */ + public function getLocalEndDate() + { + $value = $this->end_date; + if(!empty($value)) { + $summit = $this->getSummit(); + if(!is_null($summit)) + { + $res = $summit->convertDateFromUTC2TimeZone($value); + } + return $res; + } + return null; + } + + /** + * @return \DateTime|null + */ + public function getEndDate() + { + return $this->end_date; + } + + /** + * @param bool $allow_feeback + * @return $this + */ + public function setAllowFeedBack($allow_feeback) + { + $this->allow_feedback = $allow_feeback; + return $this; + } + + /** + * @return int + */ + public function getTypeId() + { + try { + return $this->type->getId(); + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @ORM\ManyToOne(targetEntity="SummitEventType") + * @ORM\JoinColumn(name="TypeID", referencedColumnName="ID") + * @var SummitEventType + */ + private $type; + + /** + * @param SummitEventType $type + * @return $this + */ + public function setType(SummitEventType $type) + { + $this->type = $type; + return $this; + } + + /** + * @return SummitEventType + */ + public function getType(){ + return $this->type; + } + + /** + * @ORM\ManyToOne(targetEntity="SummitAbstractLocation") + * @ORM\JoinColumn(name="LocationID", referencedColumnName="ID") + */ + private $location = null; + + /** + * @param SummitAbstractLocation $location + * @return $this + */ + public function setLocation(SummitAbstractLocation $location) + { + $this->location = $location; + return $this; + } + + /** + * @return SummitAbstractLocation + */ + public function getLocation() + { + return $this->location; + } + + /** + * @return array + */ + public function getSummitTypesIds() + { + return $this->summit_types->map(function($entity) { + return $entity->getId(); + })->toArray(); + } + + /** + * @return array + */ + public function getSponsorsIds() + { + return $this->sponsors->map(function($entity) { + return $entity->getId(); + })->toArray(); + } + + /** + * @ORM\ManyToMany(targetEntity="models\summit\SummitType") + * @ORM\JoinTable(name="SummitEvent_AllowedSummitTypes", + * joinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")}, + * inverseJoinColumns={@ORM\JoinColumn(name="SummitTypeID", referencedColumnName="ID")} + * ) + */ + protected $summit_types; + + /** + * @return ArrayCollection + */ + public function getSummitTypes(){ + return $this->summit_types; + } + + /** + * @param SummitType $summit_type + */ + public function addSummitType(SummitType $summit_type) + { + $this->summit_types->add($summit_type); + } + + public function clearSummitTypes() + { + $this->summit_types->clear(); + } + + /** + * @ORM\ManyToMany(targetEntity="models\main\Company", inversedBy="sponsorships") + * @ORM\JoinTable(name="SummitEvent_Sponsors", + * joinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")}, + * inverseJoinColumns={@ORM\JoinColumn(name="CompanyID", referencedColumnName="ID")} + * ) + */ + protected $sponsors; + + /** + * @return Company[] + */ + public function getSponsors() + { + return $this->sponsors; + } + + /** + * @ORM\ManyToMany(targetEntity="models\summit\SummitAttendee") + * @ORM\JoinTable(name="SummitAttendee_Schedule", + * joinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")}, + * inverseJoinColumns={@ORM\JoinColumn(name="SummitAttendeeID", referencedColumnName="ID")} + * ) + */ + protected $attendees; + + /** + * @return SummitAttendee[] + */ + public function getAttendees() + { + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('IsCheckedIn', 1)); + return $this->attendees->matching($criteria); + } + + /** + * @ORM\OneToMany(targetEntity="models\summit\SummitEventFeedback", mappedBy="event", cascade={"persist"}) + * @var SummitEventFeedback[] + */ + protected $feedback; + + public function addFeedBack(SummitEventFeedback $feedback) + { + $this->feedback->add($feedback); + $feedback->setEvent($this); + } + + /** + * @return SummitEventFeedback[] + */ + public function getFeedback(){ + $criteria = Criteria::create(); + $criteria = $criteria->orderBy(['created' => Criteria::DESC]); + return $this->feedback->matching($criteria); + } + + /** + * @ORM\ManyToMany(targetEntity="models\main\Tag", cascade={"persist"}) + * @ORM\JoinTable(name="SummitEvent_Tags", + * joinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")}, + * inverseJoinColumns={@ORM\JoinColumn(name="TagID", referencedColumnName="ID")} + * ) + */ + protected $tags; + + /** + * @return ArrayCollection + */ + public function getTags(){ + return $this->tags; + } + + /** + * @param string $tag + */ + public function addTag($tag) + { + $this->tags->add(new Tag($tag)); + } + + public function clearTags() + { + $this->tags->clear(); + } + + /** + * @throws EntityValidationException + * @throws ValidationException + * @return void + */ + public function publish() + { + if($this->isPublished()) + throw new ValidationException('Already published Summit Event'); + + if($this->getSummitTypes()->count() === 0) + throw new EntityValidationException('To publish this event you must associate a valid summit type!'); + + $start_date = $this->getStartDate(); + $end_date = $this->getEndDate(); + + if((is_null($start_date) || is_null($end_date))) + throw new ValidationException('To publish this event you must define a start/end datetime!'); + + $summit = $this->getSummit(); + + if(is_null($summit)) + throw new ValidationException('To publish you must assign a summit'); + + $timezone = $summit->getTimeZoneId(); + + if(empty($timezone)){ + throw new ValidationException('Invalid Summit TimeZone!'); + } + + if($end_date < $start_date) + throw new ValidationException('start datetime must be greather or equal than end datetime!'); + + if(!$summit->isEventInsideSummitDuration($this)) + throw new ValidationException + ( + sprintf + ( + 'start/end datetime must be between summit start/end datetime! (%s - %s)', + $summit->getLocalBeginDate(), + $summit->getLocalEndDate() + ) + ); + + $this->published = true; + $this->published_date = new DateTime(); + } + + /** + * @return bool + */ + public function isPublished() + { + return $this->getPublished(); + } + + /** + * @return bool + */ + public function getPublished() + { + return (bool)$this->published; + } + + /** + * @return void + */ + public function unPublish() + { + $this->published = false; + $this->published_date = null; + } + + // events + + /** + * @var PreRemoveEventArgs + */ + private $pre_remove_events; + /** + * @ORM\PreRemove: + */ + public function deleting($args){ + $this->pre_remove_events = new PreRemoveEventArgs(['id' => $this->id, 'class_name' => $this->getClassName(), 'summit' => $this->summit ]); + } + + /** + * @ORM\PostRemove: + */ + public function deleted($args){ + Event::fire(new SummitEventDeleted($this, $this->pre_remove_events )); + $this->pre_remove_events = null; + } + + /** + * @var PreUpdateEventArgs + */ + private $pre_update_args; + + /** + * @ORM\PreUpdate: + */ + public function updating(PreUpdateEventArgs $args){ + $this->pre_update_args = $args; + } + + + /** + * @ORM\PostUpdate: + */ + public function updated($args) + { + Event::fire(new SummitEventUpdated($this, $this->pre_update_args)); + $this->pre_update_args = null; + } + + /** + * @ORM\PostPersist + */ + public function inserted($args){ + Event::fire(new SummitEventCreated($this, $args)); + } + +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/SummitEventFeedback.php b/app/Models/Foundation/Summit/Events/SummitEventFeedback.php new file mode 100644 index 00000000..5841172f --- /dev/null +++ b/app/Models/Foundation/Summit/Events/SummitEventFeedback.php @@ -0,0 +1,148 @@ +rate; + } + + /** + * @param int $rate + */ + public function setRate($rate) + { + $this->rate = $rate; + } + + /** + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * @param string $note + */ + public function setNote($note) + { + $this->note = $note; + } + + /** + * @ORM\Column(name="note", type="string") + * @var string + */ + private $note; + + /** + * @ORM\ManyToOne(targetEntity="models\main\Member", inversedBy="feedback") + * @ORM\JoinColumn(name="OwnerID", referencedColumnName="ID") + * @var Member + */ + private $owner; + + /** + * @return Member + */ + public function getOwner() + { + return $this->owner; + } + + /** + * @param Member $owner + */ + public function setOwner(Member $owner){ + $this->owner = $owner; + } + + /** + * @ORM\ManyToOne(targetEntity="models\summit\SummitEvent", inversedBy="feedback", fetch="LAZY") + * @ORM\JoinColumn(name="EventID", referencedColumnName="ID") + * @var SummitEvent + */ + private $event; + + /** + * @return SummitEvent + */ + public function getEvent() + { + return $this->event; + } + + /** + * @return int + */ + public function getEventId(){ + try{ + return $this->event->getId(); + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @return bool + */ + public function hasOwner(){ + return $this->getOwnerId() > 0; + } + + /** + * @return int + */ + public function getOwnerId(){ + try{ + return $this->owner->getId(); + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @param SummitEvent $event + */ + public function setEvent(SummitEvent $event){ + $this->event = $event; + } + +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/SummitEventType.php b/app/Models/Foundation/Summit/Events/SummitEventType.php new file mode 100644 index 00000000..22a73d14 --- /dev/null +++ b/app/Models/Foundation/Summit/Events/SummitEventType.php @@ -0,0 +1,121 @@ +class_name === 'PresentationType'; + } + + /** + * @return bool + */ + public function allowsModerator(){ + return $this->isPresentationType() && in_array($this->type, ['Panel','Keynotes']); + } + + /** + * @ORM\Column(name="BlackoutTimes", type="boolean") + * @var bool + */ + private $blackout_times; + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * @return string + */ + public function getColor() + { + return $this->color; + } + + /** + * @param string $color + */ + public function setColor($color) + { + $this->color = $color; + } + + /** + * @return bool + */ + public function getBlackoutTimes() + { + return $this->blackout_times; + } + + /** + * @return bool + */ + public function isBlackoutTimes(){ + return $this->getBlackoutTimes(); + } + + /** + * @param bool $blackout_times + */ + public function setBlackoutTimes($blackout_times) + { + $this->blackout_times = $blackout_times; + } + +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Factories/IPresentationVideoFactory.php b/app/Models/Foundation/Summit/Factories/IPresentationVideoFactory.php new file mode 100644 index 00000000..3c83e04d --- /dev/null +++ b/app/Models/Foundation/Summit/Factories/IPresentationVideoFactory.php @@ -0,0 +1,26 @@ +Type === 'Presentation' ? new Presentation: new SummitEvent; + $event = in_array($type->getType(),[ 'Presentation', 'Keynotes' , 'Panel']) ? new Presentation: new SummitEvent; return $event; } } \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Locations/SummitAbstractLocation.php b/app/Models/Foundation/Summit/Locations/SummitAbstractLocation.php new file mode 100644 index 00000000..b591c6b3 --- /dev/null +++ b/app/Models/Foundation/Summit/Locations/SummitAbstractLocation.php @@ -0,0 +1,136 @@ +type = self::TypeNone; + } + + /** + * @return string + */ + public function getClassName(){ + return 'SummitAbstractLocation'; + } + + /** + * @return int + */ + public function getOrder() + { + return $this->order; + } + + /** + * @param int $order + */ + public function setOrder($order) + { + $this->order = $order; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return string + */ + public function getLocationType() + { + return $this->type; + } + + /** + * @param string $type + */ + public function setLocationType($type) + { + $this->type = $type; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + use SummitOwned; + + + /** + * @ORM\Column(name="Name", type="string") + */ + protected $name; + + /** + * @ORM\Column(name="Description", type="string") + */ + protected $description; + + + /** + * @ORM\Column(name="LocationType", type="string") + */ + protected $type; + + /** + * @ORM\Column(name="Order", type="integer") + */ + protected $order; + + +} \ No newline at end of file diff --git a/app/Repositories/summit/EloquentSummitRepository.php b/app/Models/Foundation/Summit/Locations/SummitAirport.php similarity index 50% rename from app/Repositories/summit/EloquentSummitRepository.php rename to app/Models/Foundation/Summit/Locations/SummitAirport.php index 71618583..5508d267 100644 --- a/app/Repositories/summit/EloquentSummitRepository.php +++ b/app/Models/Foundation/Summit/Locations/SummitAirport.php @@ -1,5 +1,4 @@ -entity = $summit; + public function getClassName(){ + return 'SummitAirport'; } /** - * @return Summit + * @return string */ - public function getCurrent() + public function getAirportType() { - //$now = new \DateTime('now', new DateTimeZone('UTC')); - return $this->entity - ->where('Active','=',1) - ->first(); + return $this->airport_type; } + + /** + * @param string $airport_type + */ + public function setAirportType($airport_type) + { + $this->airport_type = $airport_type; + } + + /** + * @ORM\Column(name="Type", type="string") + */ + private $airport_type; } \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Locations/SummitExternalLocation.php b/app/Models/Foundation/Summit/Locations/SummitExternalLocation.php new file mode 100644 index 00000000..7f33007c --- /dev/null +++ b/app/Models/Foundation/Summit/Locations/SummitExternalLocation.php @@ -0,0 +1,57 @@ +capacity; + } + + /** + * @param int $capacity + */ + public function setCapacity($capacity) + { + $this->capacity = $capacity; + } + + /** + * @ORM\Column(name="Capacity", type="integer") + */ + protected $capacity; + +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Locations/SummitGeoLocatedLocation.php b/app/Models/Foundation/Summit/Locations/SummitGeoLocatedLocation.php new file mode 100644 index 00000000..b1c7dbae --- /dev/null +++ b/app/Models/Foundation/Summit/Locations/SummitGeoLocatedLocation.php @@ -0,0 +1,341 @@ +address1; + } + + /** + * @param mixed $address1 + */ + public function setAddress1($address1) + { + $this->address1 = $address1; + } + + /** + * @return mixed + */ + public function getAddress2() + { + return $this->address2; + } + + /** + * @param mixed $address2 + */ + public function setAddress2($address2) + { + $this->address2 = $address2; + } + + /** + * @return mixed + */ + public function getZipCode() + { + return $this->zip_code; + } + + /** + * @param mixed $zip_code + */ + public function setZipCode($zip_code) + { + $this->zip_code = $zip_code; + } + + /** + * @return mixed + */ + public function getCity() + { + return $this->city; + } + + /** + * @param mixed $city + */ + public function setCity($city) + { + $this->city = $city; + } + + /** + * @return mixed + */ + public function getState() + { + return $this->state; + } + + /** + * @param mixed $state + */ + public function setState($state) + { + $this->state = $state; + } + + /** + * @return mixed + */ + public function getCountry() + { + return $this->country; + } + + /** + * @param mixed $country + */ + public function setCountry($country) + { + $this->country = $country; + } + + /** + * @return mixed + */ + public function getWebsiteUrl() + { + return $this->website_url; + } + + /** + * @param mixed $website_url + */ + public function setWebsiteUrl($website_url) + { + $this->website_url = $website_url; + } + + /** + * @return mixed + */ + public function getLng() + { + return $this->lng; + } + + /** + * @param mixed $lng + */ + public function setLng($lng) + { + $this->lng = $lng; + } + + /** + * @return mixed + */ + public function getLat() + { + return $this->lat; + } + + /** + * @param mixed $lat + */ + public function setLat($lat) + { + $this->lat = $lat; + } + + /** + * @return mixed + */ + public function getDisplayOnSite() + { + return $this->display_on_site; + } + + /** + * @param mixed $display_on_site + */ + public function setDisplayOnSite($display_on_site) + { + $this->display_on_site = $display_on_site; + } + + /** + * @return mixed + */ + public function getDetailsPage() + { + return $this->details_page; + } + + /** + * @param mixed $details_page + */ + public function setDetailsPage($details_page) + { + $this->details_page = $details_page; + } + + /** + * @return mixed + */ + public function getLocationMessage() + { + return $this->location_message; + } + + /** + * @param mixed $location_message + */ + public function setLocationMessage($location_message) + { + $this->location_message = $location_message; + } + + /** + * @ORM\Column(name="Address2", type="string") + */ + protected $address2; + + /** + * @ORM\Column(name="ZipCode", type="string") + */ + protected $zip_code; + + /** + * @ORM\Column(name="City", type="string") + */ + protected $city; + + /** + * @ORM\Column(name="State", type="string") + */ + protected $state; + + /** + * @ORM\Column(name="Country", type="string") + */ + protected $country; + + /** + * @ORM\Column(name="WebSiteUrl", type="string") + */ + protected $website_url; + + /** + * @ORM\Column(name="Lng", type="string") + */ + protected $lng; + + /** + * @ORM\Column(name="Lat", type="string") + */ + protected $lat; + + /** + * @ORM\Column(name="DisplayOnSite", type="boolean") + */ + protected $display_on_site; + + /** + * @ORM\Column(name="DetailsPage", type="boolean") + */ + protected $details_page; + + /** + * @ORM\Column(name="LocationMessage", type="string") + */ + protected $location_message; + + /** + * @ORM\OneToMany(targetEntity="models\summit\SummitLocationImage", mappedBy="location", cascade={"persist"}) + * @var SummitLocationImage[] + */ + protected $images; + + public function __construct() + { + parent::__construct(); + $this->images = new ArrayCollection(); + } + + /** + * @return SummitLocationImage[] + */ + public function getMaps() + { + return $this->images + ->matching + ( + Criteria::create() + ->where(Criteria::expr()->eq("class_name", "SummitLocationMap")) + ->orderBy(array("order" => Criteria::ASC)) + ); + } + + /** + * @return SummitLocationImage[] + */ + public function getImages() + { + + return $this->images + ->matching + ( + Criteria::create() + ->where(Criteria::expr()->eq("class_name", "SummitLocationImage")) + ->orderBy(array("order" => Criteria::ASC)) + ); + } + + /** + * @param int $image_id + * @return SummitLocationImage + */ + public function getImage($image_id){ + return $this->images + ->matching + ( + Criteria::create()->where(Criteria::expr()->eq("id", $image_id)) + + )->first(); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Locations/SummitHotel.php b/app/Models/Foundation/Summit/Locations/SummitHotel.php new file mode 100644 index 00000000..22694221 --- /dev/null +++ b/app/Models/Foundation/Summit/Locations/SummitHotel.php @@ -0,0 +1,94 @@ +booking_link; + } + + /** + * @param string $booking_link + */ + public function setBookingLink($booking_link) + { + $this->booking_link = $booking_link; + } + /** + * @ORM\Column(name="BookingLink", type="string") + */ + private $booking_link; + + /** + * @return bool + */ + public function getSoldOut() + { + return $this->sold_out; + } + + /** + * @param bool $sold_out + */ + public function setSoldOut($sold_out) + { + $this->sold_out = $sold_out; + } + + /** + * @return string + */ + public function getHotelType() + { + return $this->hotel_type; + } + + /** + * @param string $hotel_type + */ + public function setHotelType($hotel_type) + { + $this->hotel_type = $hotel_type; + } + + /** + * @ORM\Column(name="SoldOut", type="boolean") + */ + private $sold_out; + + /** + * @ORM\Column(name="Type", type="string") + */ + private $hotel_type; + +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Locations/SummitLocationImage.php b/app/Models/Foundation/Summit/Locations/SummitLocationImage.php new file mode 100644 index 00000000..8cb5d16f --- /dev/null +++ b/app/Models/Foundation/Summit/Locations/SummitLocationImage.php @@ -0,0 +1,174 @@ +name; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return int + */ + public function getOrder() + { + return $this->order; + } + + /** + * @param int $order + */ + public function setOrder($order) + { + $this->order = $order; + } + + /** + * @return File + */ + public function getPicture() + { + return $this->picture; + } + + /** + * @param File $picture + */ + public function setPicture($picture) + { + $this->picture = $picture; + } + + /** + * @return SummitAbstractLocation + */ + public function getLocation() + { + return $this->location; + } + + /** + * @param SummitAbstractLocation $location + */ + public function setLocation($location) + { + $this->location = $location; + } + + /** + * @ORM\Column(name="Name", type="string") + */ + protected $name; + + /** + * @ORM\Column(name="Description", type="string") + */ + protected $description; + + /** + * @ORM\Column(name="Order", type="integer") + */ + protected $order; + + /** + * @ORM\Column(name="ClassName", type="string") + */ + protected $class_name; + + /** + * @return string + */ + public function getClassName() + { + return $this->class_name; + } + + /** + * @param string $class_name + */ + public function setClassName($class_name) + { + $this->class_name = $class_name; + } + + /** + * @ORM\ManyToOne(targetEntity="models\main\File", fetch="EAGER") + * @ORM\JoinColumn(name="PictureID", referencedColumnName="ID") + * @var File + */ + protected $picture; + + /** + * @ORM\ManyToOne(targetEntity="models\summit\SummitAbstractLocation") + * @ORM\JoinColumn(name="LocationID", referencedColumnName="ID") + * @var SummitAbstractLocation + */ + protected $location; + + /** + * @return bool + */ + public function hasPicture(){ + return $this->getPictureId() > 0; + } + + /** + * @return int + */ + public function getPictureId(){ + try{ + return !is_null($this->picture) ? $this->picture->getId() : 0; + } + catch(\Exception $ex){ + return 0; + } + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Locations/SummitVenue.php b/app/Models/Foundation/Summit/Locations/SummitVenue.php new file mode 100644 index 00000000..cb5dd889 --- /dev/null +++ b/app/Models/Foundation/Summit/Locations/SummitVenue.php @@ -0,0 +1,112 @@ +rooms = new ArrayCollection(); + $this->floors = new ArrayCollection(); + } + + /** + * @ORM\Column(name="IsMain", type="boolean") + * @var bool + */ + private $is_main; + + /** + * @ORM\OneToMany(targetEntity="models\summit\SummitVenueRoom", mappedBy="venue", cascade={"persist"}) + * @var SummitVenueRoom[] + */ + private $rooms; + + /** + * @ORM\OneToMany(targetEntity="models\summit\SummitVenueFloor", mappedBy="venue", cascade={"persist"}) + * @var SummitVenueFloor[] + */ + private $floors; + + /** + * @return bool + */ + public function getIsMain() + { + return (bool)$this->is_main; + } + + /** + * @param bool $is_main + */ + public function setIsMain($is_main) + { + $this->is_main = $is_main; + } + + /** + * @return SummitVenueRoom[] + */ + public function getRooms(){ + return $this->rooms; + } + + /** + * @param int $room_id + * @return SummitVenueRoom|null + */ + public function getRoom($room_id){ + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('id', intval($room_id))); + $room = $this->rooms->matching($criteria)->first(); + return $room === false ? null:$room; + } + + /** + * @return SummitVenueFloor[] + */ + public function getFloors(){ + return $this->floors; + } + + /** + * @param int $floor_id + * @return SummitVenueFloor|null + */ + public function getFloor($floor_id){ + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('id', intval($floor_id))); + $floor = $this->floors->matching($criteria)->first(); + return $floor === false ? null:$floor; + } + +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Locations/SummitVenueFloor.php b/app/Models/Foundation/Summit/Locations/SummitVenueFloor.php new file mode 100644 index 00000000..da227490 --- /dev/null +++ b/app/Models/Foundation/Summit/Locations/SummitVenueFloor.php @@ -0,0 +1,161 @@ +name; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return int + */ + public function getNumber() + { + return $this->number; + } + + /** + * @param int $number + */ + public function setNumber($number) + { + $this->number = $number; + } + + /** + * @return SummitVenue + */ + public function getVenue() + { + return $this->venue; + } + + /** + * @return int + */ + public function getVenueId(){ + try{ + return $this->venue->getId(); + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @ORM\Column(name="Number", type="integer") + */ + private $number; + + /** + * @ORM\ManyToOne(targetEntity="models\main\File", fetch="EAGER") + * @ORM\JoinColumn(name="ImageID", referencedColumnName="ID") + * @var File + */ + private $image; + + /** + * @return File + */ + public function getImage() + { + return $this->image; + } + + /** + * + * @ORM\ManyToOne(targetEntity="models\summit\SummitVenue", inversedBy="floors") + * @ORM\JoinColumn(name="VenueID", referencedColumnName="ID") + * @var SummitVenue + */ + private $venue; + + /** + * @ORM\OneToMany(targetEntity="models\summit\SummitVenueRoom", mappedBy="floor", cascade={"persist"}) + * @var SummitVenueRoom[] + */ + private $rooms; + + /** + * @return SummitVenueRoom[] + */ + public function getRooms(){ + return $this->rooms; + } + + public function __construct() + { + parent::__construct(); + $this->rooms = new ArrayCollection(); + } + +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Locations/SummitVenueRoom.php b/app/Models/Foundation/Summit/Locations/SummitVenueRoom.php new file mode 100644 index 00000000..6a1471fa --- /dev/null +++ b/app/Models/Foundation/Summit/Locations/SummitVenueRoom.php @@ -0,0 +1,143 @@ +venue; + } + + /** + * @return int + */ + public function getVenueId(){ + try{ + return $this->venue->getId(); + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @return bool + */ + public function hasVenue(){ + return $this->getVenueId() > 0; + } + + /** + * @return SummitVenueFloor + */ + public function getFloor() + { + return $this->floor; + } + + /** + * @return int + */ + public function getFloorId(){ + try{ + return $this->floor->getId(); + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @return bool + */ + public function hasFloor(){ + return $this->getFloorId() > 0; + } + + /** + * @return int + */ + public function getCapacity() + { + return $this->capacity; + } + + /** + * @param int $capacity + */ + public function setCapacity($capacity) + { + $this->capacity = $capacity; + } + + /** + * @return boolean + */ + public function isOverrideBlackouts() + { + return $this->override_blackouts; + } + + /** + * @param boolean $override_blackouts + */ + public function setOverrideBlackouts($override_blackouts) + { + $this->override_blackouts = $override_blackouts; + } + /** + * @ORM\ManyToOne(targetEntity="models\summit\SummitVenue", inversedBy="rooms") + * @ORM\JoinColumn(name="VenueID", referencedColumnName="ID") + * @var SummitVenue + */ + private $venue; + + /** + * @ORM\ManyToOne(targetEntity="models\summit\SummitVenueFloor", inversedBy="rooms") + * @ORM\JoinColumn(name="FloorID", referencedColumnName="ID") + * @var SummitVenueFloor + */ + private $floor; + + /** + * @ORM\Column(name="Capacity", type="integer") + * @var int + */ + private $capacity; + + /** + * @ORM\Column(name="OverrideBlackouts", type="boolean") + * @var bool + */ + private $override_blackouts; +} \ No newline at end of file diff --git a/app/Http/Controllers/apis/protected/summit/strategies/RetrieveAllSummitEventsBySummitStrategy.php b/app/Models/Foundation/Summit/Repositories/IEventFeedbackRepository.php similarity index 53% rename from app/Http/Controllers/apis/protected/summit/strategies/RetrieveAllSummitEventsBySummitStrategy.php rename to app/Models/Foundation/Summit/Repositories/IEventFeedbackRepository.php index f28d1873..debf5285 100644 --- a/app/Http/Controllers/apis/protected/summit/strategies/RetrieveAllSummitEventsBySummitStrategy.php +++ b/app/Models/Foundation/Summit/Repositories/IEventFeedbackRepository.php @@ -1,6 +1,6 @@ -summit->events($page, $per_page, $filter); - } + public function getByEvent(SummitEvent $event, PagingInfo $paging_info, Filter $filter = null, Order $order = null); } \ No newline at end of file diff --git a/app/Models/summit/ISpeakerRepository.php b/app/Models/Foundation/Summit/Repositories/ISpeakerRepository.php similarity index 92% rename from app/Models/summit/ISpeakerRepository.php rename to app/Models/Foundation/Summit/Repositories/ISpeakerRepository.php index 1b2d2921..fd659245 100644 --- a/app/Models/summit/ISpeakerRepository.php +++ b/app/Models/Foundation/Summit/Repositories/ISpeakerRepository.php @@ -17,12 +17,13 @@ use utils\Order; use utils\PagingResponse; use utils\PagingInfo; use utils\Filter; +use models\utils\IBaseRepository; /** * Interface ISpeakerRepository * @package models\repositories */ -interface ISpeakerRepository +interface ISpeakerRepository extends IBaseRepository { /** * @param Summit $summit diff --git a/app/Models/summit/SummitHotel.php b/app/Models/Foundation/Summit/Repositories/ISummitAttendeeRepository.php similarity index 74% rename from app/Models/summit/SummitHotel.php rename to app/Models/Foundation/Summit/Repositories/ISummitAttendeeRepository.php index d9b736cc..9bae8266 100644 --- a/app/Models/summit/SummitHotel.php +++ b/app/Models/Foundation/Summit/Repositories/ISummitAttendeeRepository.php @@ -1,6 +1,6 @@ -name; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getExternalSummitId() + { + return $this->external_summit_id; + } + + /** + * @param string $external_summit_id + */ + public function setExternalSummitId($external_summit_id) + { + $this->external_summit_id = $external_summit_id; + } + + /** + * @return \DateTime + */ + public function getScheduleDefaultStartDate() + { + return $this->schedule_default_start_date; + } + + /** + * @param \DateTime $schedule_default_start_date + */ + public function setScheduleDefaultStartDate($schedule_default_start_date) + { + $this->schedule_default_start_date = $schedule_default_start_date; + } + + /** + * @return mixed + */ + public function getBeginDate() + { + return $this->begin_date; + } + + /** + * @param \DateTime $begin_date + */ + public function setBeginDate($begin_date) + { + $this->begin_date = $begin_date; + } + + /** + * @return \DateTime + */ + public function getEndDate() + { + return $this->end_date; + } + + /** + * @param \DateTime $end_date + */ + public function setEndDate($end_date) + { + $this->end_date = $end_date; + } + + /** + * @return bool + */ + public function getActive() + { + return $this->active; + } + + /** + * @param bool $active + */ + public function setActive($active) + { + $this->active = $active; + } + + /** + * @return \DateTime + */ + public function getStartShowingVenuesDate() + { + return $this->start_showing_venues_date; + } + + /** + * @param \DateTime $start_showing_venues_date + */ + public function setStartShowingVenuesDate($start_showing_venues_date) + { + $this->start_showing_venues_date = $start_showing_venues_date; + } + + /** + * @ORM\Column(name="Title", type="string") + * @var string + */ + private $name; + + /** + * @ORM\Column(name="SummitBeginDate", type="datetime") + * @var \DateTime + */ + private $begin_date; + + /** + * @ORM\Column(name="SummitEndDate", type="datetime") + * @var \DateTime + */ + private $end_date; + + /** + * @ORM\Column(name="Active", type="boolean") + * @var bool + */ + private $active; + + /** + * @ORM\Column(name="ExternalEventId", type="string") + * @var string + */ + private $external_summit_id; + + /** + * @ORM\Column(name="ScheduleDefaultStartDate", type="datetime") + * @var \DateTime + */ + private $schedule_default_start_date; + + /** + * @return string + */ + public function getSummitExternalId(){ return $this->external_summit_id; } + + /** + * @return bool + */ + public function isActive(){ + return $this->active; + } + + /** + * @ORM\Column(name="StartShowingVenuesDate", type="datetime") + */ + private $start_showing_venues_date; + + /** + * @ORM\Column(name="TimeZone", type="string") + * @var string + */ + private $time_zone_id; + + /** + * @return string + */ + public function getTimeZoneId() + { + return $this->time_zone_id; + } + + /** + * @param string $time_zone_id + */ + public function setTimeZoneId($time_zone_id) + { + $this->time_zone_id = $time_zone_id; + } + + // ... + /** + * @ORM\OneToMany(targetEntity="SummitAbstractLocation", mappedBy="summit", cascade={"persist"}) + */ + private $locations; + + /** + * @ORM\OneToMany(targetEntity="SummitEvent", mappedBy="summit", cascade={"persist"}) + */ + private $events; + + /** + * Summit constructor. + */ + public function __construct() + { + parent::__construct(); + $this->locations = new ArrayCollection(); + $this->events = new ArrayCollection(); + $this->event_types = new ArrayCollection(); + $this->summit_types = new ArrayCollection(); + $this->ticket_types = new ArrayCollection(); + $this->presentation_categories = new ArrayCollection(); + $this->category_groups = new ArrayCollection(); + $this->attendees = new ArrayCollection(); + $this->entity_events = new ArrayCollection(); + } + + /** + * @param DateTime $value + * @return null|DateTime + */ + public function convertDateFromTimeZone2UTC(DateTime $value) + { + $time_zone_id = $this->time_zone_id; + if(empty($time_zone_id)) return $value; + $time_zone_list = timezone_identifiers_list(); + + if(isset($time_zone_list[$time_zone_id]) && !empty($value)) + { + $utc_timezone = new DateTimeZone("UTC"); + $time_zone_name = $time_zone_list[$time_zone_id]; + $summit_time_zone = new DateTimeZone($time_zone_name); + $local_date = $value->setTimezone($summit_time_zone); + return $local_date->setTimezone($utc_timezone); + } + return null; + } + + /** + * @param DateTime $value + * @return null|DateTime + */ + public function convertDateFromUTC2TimeZone(DateTime $value) + { + $time_zone_id = $this->time_zone_id; + if(empty($time_zone_id)) return $value; + $time_zone_list = timezone_identifiers_list(); + + if(isset($time_zone_list[$time_zone_id]) && !empty($value)) + { + $utc_timezone = new DateTimeZone("UTC"); + $time_zone_name = $time_zone_list[$time_zone_id]; + $summit_time_zone = new DateTimeZone($time_zone_name); + $utc_date = $value->setTimezone($utc_timezone); + + return $utc_date->setTimezone($summit_time_zone); + } + return null; + } + + /** + * @return DateTime + */ + public function getLocalBeginDate() + { + return $this->convertDateFromUTC2TimeZone($this->begin_date); + } + + /** + * @return DateTime + */ + public function getLocalEndDate() + { + return $this->convertDateFromUTC2TimeZone($this->end_date); + } + + /** + * @param SummitAbstractLocation $location + */ + public function addLocation(SummitAbstractLocation $location){ + $this->locations->add($location); + $location->setSummit($this); + } + + /** + * @return ArrayCollection + */ + public function getLocations() + { + return $this->locations; + } + + /** + * @return SummitVenue[] + */ + public function getVenues(){ + return $this->locations->filter(function($e){ + return $e instanceof SummitVenue; + }); + } + + /** + * @return ArrayCollection + */ + public function getEvents(){ + return $this->events; + } + + /** + * @param SummitEvent $event + */ + public function addEvent(SummitEvent $event){ + $this->events->add($event); + $event->setSummit($this); + } + + /** + * @ORM\ManyToOne(targetEntity="models\main\File", fetch="EAGER") + * @ORM\JoinColumn(name="LogoID", referencedColumnName="ID") + * @var File + */ + private $logo; + + /** + * @return File + */ + public function getLogo() + { + return $this->logo; + } + + /** + * @return bool + */ + public function hasLogo(){ + return $this->getLogoId() > 0; + } + + /** + * @return int + */ + public function getLogoId(){ + try{ + return !is_null($this->logo)?$this->logo->getId():0; + } + catch(\Exception $ex){ + return 0; + } + } + + /** + * @param int $location_id + * @return SummitAbstractLocation + */ + public function getLocation($location_id) + { + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('id', intval($location_id))); + $location = $this->locations->matching($criteria)->first(); + return $location === false ? null:$location; + } + + /** + * @ORM\OneToMany(targetEntity="models\summit\SummitEventType", mappedBy="summit", cascade={"persist"}) + */ + private $event_types; + + /** + * @return SummitEventType[] + */ + public function getEventTypes() + { + return $this->event_types; + } + + /** + * @param int $event_type_id + * @return SummitEventType + */ + public function getEventType($event_type_id) + { + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('id', intval($event_type_id))); + $event_type = $this->event_types->matching($criteria)->first(); + return $event_type === false ? null:$event_type; + } + + /** + * @ORM\OneToMany(targetEntity="models\summit\SummitType", mappedBy="summit", cascade={"persist"}) + */ + private $summit_types; + + /** + * @return SummitType[] + */ + public function getSummitTypes() + { + return $this->summit_types; + } + + /** + * @param int $summit_type_id + * @return SummitType + */ + public function getSummitType($summit_type_id) + { + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('id', intval($summit_type_id))); + $summit_type = $this->summit_types->matching($criteria)->first(); + return $summit_type === false ? null:$summit_type; + } + + /** + * @ORM\OneToMany(targetEntity="models\summit\SummitTicketType", mappedBy="summit", cascade={"persist"}) + */ + private $ticket_types; + + /** + * @return SummitTicketType[] + */ + public function getTicketTypes() + { + return $this->ticket_types; + } + + /** + * @param int $ticket_type_id + * @return SummitTicketType|null + */ + public function getTicketType($ticket_type_id){ + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('id', intval($ticket_type_id))); + $ticket_type = $this->ticket_types->matching($criteria)->first(); + return $ticket_type === false ? null:$ticket_type; + } + + /** + * @param string $ticket_type_external_id + * @return SummitTicketType|null + */ + public function getTicketTypeByExternalId($ticket_type_external_id){ + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('external_id', $ticket_type_external_id)); + $ticket_type = $this->ticket_types->matching($criteria)->first(); + return $ticket_type === false ? null:$ticket_type; + } + + /** + * @param int $event_id + * @return null|SummitEvent + */ + public function getScheduleEvent($event_id) + { + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('published', 1)); + $criteria->andWhere(Criteria::expr()->eq('id', intval($event_id))); + $event = $this->events->matching($criteria)->first(); + return $event === false ? null:$event; + } + + /** + * @param int $event_id + * @return bool + */ + public function isEventOnSchedule($event_id){ + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('published', 1)); + $criteria->andWhere(Criteria::expr()->eq('id', intval($event_id))); + return $this->events->matching($criteria)->count() > 0; + } + + public function getScheduleEvents(){ + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('published', 1)); + $criteria->orderBy(["start_date" => Criteria::ASC, "end_date" => Criteria::ASC]); + return $this->events->matching($criteria); + } + + public function getPresentations(){ + $query = $this->createQuery("SELECT p from models\summit\Presentation p JOIN p.summit s WHERE s.id = :summit_id"); + return $query->setParameter('summit_id', $this->getIdentifier())->getResult(); + } + /** + * @param int $event_id + * @return null|SummitEvent + */ + public function getEvent($event_id) + { + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('id', intval($event_id))); + $event = $this->events->matching($criteria)->first(); + return $event === false ? null:$event; + } + + /** + * @ORM\OneToMany(targetEntity="models\summit\PresentationCategory", mappedBy="summit", cascade={"persist"}) + * @var PresentationCategory[] + */ + private $presentation_categories; + + /** + * @return PresentationCategory[] + */ + public function getPresentationCategories() + { + return $this->presentation_categories; + } + + /** + * @param int $category_id + * @return PresentationCategory + */ + public function getPresentationCategory($category_id){ + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('id', intval($category_id))); + $category = $this->presentation_categories->matching($criteria)->first(); + return $category === false ? null:$category; + } + + /** + * @ORM\OneToMany(targetEntity="models\summit\PresentationCategoryGroup", mappedBy="summit", cascade={"persist"}) + * @var PresentationCategoryGroup[] + */ + private $category_groups; + + /** + * @return PresentationCategoryGroup[] + */ + public function getCategoryGroups() + { + return $this->category_groups; + } + + /** + * @param int $group_id + * @return null|PresentationCategoryGroup + */ + public function getCategoryGroup($group_id) + { + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('id', intval($group_id))); + $group = $this->category_groups->matching($criteria)->first(); + return $group === false ? null:$group; + } + + /** + * @ORM\OneToMany(targetEntity="models\summit\SummitAttendee", mappedBy="summit", cascade={"persist"}) + * @var SummitAttendee[] + */ + private $attendees; + + /** + * @param int $member_id + * @return SummitAttendee + */ + public function getAttendeeByMemberId($member_id) + { + $builder = $this->createQueryBuilder(); + $members = $builder + ->select('a') + ->from('models\summit\SummitAttendee','a') + ->join('a.member','m') + ->join('a.summit','s') + ->where('s.id = :summit_id and m.id = :member_id') + ->setParameter('summit_id', $this->getId()) + ->setParameter('member_id', intval($member_id)) + ->getQuery()->getResult(); + return count($members) > 0 ? $members[0] : null; + } + + /** + * @param Member $member + * @return SummitAttendee|null + */ + public function getAttendeeByMember(Member $member){ + return $this->getAttendeeByMemberId($member->getId()); + } + + /** + * @param int $attendee_id + * @return SummitAttendee + */ + public function getAttendeeById($attendee_id) + { + $criteria = Criteria::create(); + $criteria->where(Criteria::expr()->eq('id', intval($attendee_id))); + $attendee = $this->attendees->matching($criteria)->first(); + return $attendee === false ? null:$attendee; + } + + /** + * @ORM\OneToMany(targetEntity="models\summit\SummitEntityEvent", mappedBy="summit", cascade={"persist"}) + * @var SummitEntityEvent[] + */ + private $entity_events; + + /** + * @param SummitEvent $summit_event + * @return bool + */ + public function isEventInsideSummitDuration(SummitEvent $summit_event) + { + $event_start_date = $summit_event->getLocalStartDate(); + $event_end_date = $summit_event->getLocalEndDate(); + $summit_start_date = $this->getLocalBeginDate(); + $summit_end_date = $this->getLocalEndDate(); + + return $event_start_date >= $summit_start_date && $event_start_date <= $summit_end_date && + $event_end_date <= $summit_end_date && $event_end_date >= $event_start_date; + } + + /** + * @return \Doctrine\ORM\QueryBuilder + */ + private function buildModeratorsQuery(){ + return $this->createQueryBuilder() + ->select('distinct ps') + ->from('models\summit\PresentationSpeaker','ps') + ->join('ps.presentations','p') + ->join('p.summit','s') + ->join('p.moderator','m') + ->where('s.id = :summit_id and p.published = 1 and m.id = ps.id') + ->setParameter('summit_id', $this->getId()); + } + + /** + * @return \Doctrine\ORM\QueryBuilder + */ + private function buildSpeakersQuery(){ + return $this->createQueryBuilder() + ->select('distinct ps') + ->from('models\summit\PresentationSpeaker','ps') + ->join('ps.presentations','p') + ->join('p.summit','s') + ->where("s.id = :summit_id and p.published = 1") + ->setParameter('summit_id', $this->getId()); + } + + /** + * @return PresentationSpeaker[] + */ + public function getSpeakers(){ + // moderators + $moderators = $this->buildModeratorsQuery()->getQuery()->getResult(); + // get moderators ids to exclude from speakers + $moderators_ids = array(); + foreach($moderators as $m){ + $moderators_ids[] = $m->getId(); + } + + // speakers + $sbuilder = $this->buildSpeakersQuery(); + + if(count($moderators_ids) > 0){ + $moderators_ids = implode(', ',$moderators_ids); + $sbuilder = $sbuilder->andWhere("ps.id not in ({$moderators_ids})"); + } + + $speakers = $sbuilder->getQuery()->getResult(); + + return array_merge($speakers, $moderators); + } + + /** + * @param Member $member + * @return PresentationSpeaker|null + */ + public function getSpeakerByMember(Member $member){ + return $this->getSpeakerByMemberId($member->getId()); + } + + /** + * @param int $member_id + * @return PresentationSpeaker|null + */ + public function getSpeakerByMemberId($member_id){ + // moderators + $moderator = $this->buildModeratorsQuery() + ->join('ps.member','mb') + ->andWhere('mb.id = :member_id') + ->setParameter('member_id', $member_id) + ->getQuery()->getOneOrNullResult(); + + if(!is_null($moderator)) return $moderator; + + // speakers + $speaker = $this->buildSpeakersQuery() + ->join('ps.member','mb') + ->andWhere('mb.id = :member_id') + ->setParameter('member_id', $member_id) + ->getQuery()->getOneOrNullResult(); + + if(!is_null($speaker)) return $speaker;; + + return null; + } + + /** + * @param int $speaker_id + * @return PresentationSpeaker|null + */ + public function getSpeaker($speaker_id){ + // moderators + $moderator = $this->buildModeratorsQuery() + ->andWhere('ps.id = :speaker_id') + ->setParameter('speaker_id', $speaker_id) + ->getQuery()->getOneOrNullResult(); + + if(!is_null($moderator)) return $moderator; + + // speakers + $speaker = $this->buildSpeakersQuery() + ->andWhere('ps.id = :speaker_id') + ->setParameter('speaker_id', $speaker_id) + ->getQuery()->getOneOrNullResult(); + + if(!is_null($speaker)) return $speaker;; + + return null; + } + + /** + * @return Company[] + */ + public function getSponsors(){ + $builder = $this->createQueryBuilder(); + return $builder + ->select('distinct c') + ->from('models\main\Company','c') + ->join('c.sponsorships','sp') + ->join('sp.summit','s') + ->where('s.id = :summit_id and sp.published = 1') + ->setParameter('summit_id', $this->getId())->getQuery()->getResult(); + } + + /** + * @return string + */ + public function getMainPage(){ + try { + $sql = <<- * An offset to check for. - *
- * @return boolean true on success or false on failure. - * - *- * The return value will be casted to boolean if non-boolean was returned. - * @since 5.0.0 - */ - public function offsetExists($offset) - { - return isset($this->container[$offset]); - } - - /** - * Offset to retrieve - * @link http://php.net/manual/en/arrayaccess.offsetget.php - * @param mixed $offset
- * The offset to retrieve. - *
- * @return mixed Can return all value types. - * @since 5.0.0 - */ - public function offsetGet($offset) - { - return isset($this->container[$offset]) ? $this->container[$offset] : null; - } - - /** - * Offset to set - * @link http://php.net/manual/en/arrayaccess.offsetset.php - * @param mixed $offset- * The offset to assign the value to. - *
- * @param mixed $value- * The value to set. - *
- * @return void - * @since 5.0.0 - */ - public function offsetSet($offset, $value) - { - if (is_null($offset)) { - ++$this->idx; - $this->container[] = $value; - } else { - $this->container[$offset] = $value; - } - } - - /** - * Offset to unset - * @link http://php.net/manual/en/arrayaccess.offsetunset.php - * @param mixed $offset- * The offset to unset. - *
- * @return void - * @since 5.0.0 - */ - public function offsetUnset($offset) - { - unset($this->container[$offset]); - } -} -/** - * Class SummitService - * @package services\model - */ -final class SummitService implements ISummitService -{ - - /** - * minimun number of minutes that an event must last - */ - const MIN_EVENT_MINUTES = 15; - /** - * @var ITransactionService - */ - private $tx_service; - - /** - * @var ISummitEventRepository - */ - private $event_repository; - - /** - * @var IEventbriteAPI - */ - private $eventbrite_api; - - /** - * @var ISpeakerRepository - */ - private $speaker_repository; - - - /** - * SummitService constructor. - * @param ISummitEventRepository $event_repository - * @param ISpeakerRepository $speaker_repository - * @param IEventbriteAPI $eventbrite_api - * @param ITransactionService $tx_service - */ - public function __construct - ( - ISummitEventRepository $event_repository, - ISpeakerRepository $speaker_repository, - IEventbriteAPI $eventbrite_api, - ITransactionService $tx_service - ) - { - $this->event_repository = $event_repository; - $this->speaker_repository = $speaker_repository; - $this->eventbrite_api = $eventbrite_api; - $this->tx_service = $tx_service; - } - - /** - * @param Summit $summit - * @param SummitAttendee $attendee - * @param int $event_id - * @return bool - * @throws EntityNotFoundException - */ - public function addEventToAttendeeSchedule(Summit $summit, SummitAttendee $attendee, $event_id) - { - $res = $this->tx_service->transaction(function() use($summit, $attendee, $event_id) { - $event = $summit->getScheduleEvent($event_id); - if (is_null($event)) { - throw new EntityNotFoundException('event not found on summit!'); - } - - return $attendee->add2Schedule($event); - }); - Event::fire(new MyScheduleAdd($attendee, $event_id)); - return $res; - } - - /** - * @param Summit $summit - * @param SummitAttendee $attendee - * @param $event_id - * @return bool - * @throws EntityNotFoundException - */ - public function checkInAttendeeOnEvent(Summit $summit, SummitAttendee $attendee, $event_id) - { - return $this->tx_service->transaction(function() use($summit, $attendee, $event_id) { - $event = $summit->getScheduleEvent($event_id); - if(is_null($event)) throw new EntityNotFoundException('event not found on summit!'); - return $attendee->checkIn($event); - }); - } - - /** - * @param Summit $summit - * @param SummitAttendee $attendee - * @param int $event_id - * @return bool - * @throws \Exception - */ - public function removeEventFromAttendeeSchedule(Summit $summit, SummitAttendee $attendee, $event_id) - { - $res = $this->tx_service->transaction(function() use($summit, $attendee, $event_id) { - $event = $summit->getScheduleEvent($event_id); - if(is_null($event)) throw new EntityNotFoundException('event not found on summit!'); - return $attendee->removeFromSchedule($event); - }); - Event::fire(new MyScheduleRemove($attendee, $event_id)); - return $res; - } - - /** - * @param Summit $summit - * @param SummitEvent $event - * @param array $feedback - * @return SummitEventFeedback - */ - public function addEventFeedback(Summit $summit, SummitEvent $event, array $feedback) - { - - return $this->tx_service->transaction(function() use($summit, $event, $feedback) { - - if(!$event->AllowFeedBack) - throw new ValidationException(sprintf("event id %s dont allow feedback", $event->ID)); - - $attendee_id = intval($feedback['attendee_id']); - $attendee = SummitAttendee::find($attendee_id); - if(is_null($attendee)) throw new EntityNotFoundException(); - - $newFeedback = new SummitEventFeedback(); - $newFeedback->Rate = $feedback['rate']; - $newFeedback->Note = $feedback['note']; - $newFeedback->OwnerID = $attendee->MemberID; - $newFeedback->EventID = $event->ID; - - $event->addFeedBack($newFeedback); - - return $newFeedback; - }); - } - - /** - * @param Summit $summit - * @param null|int $member_id - * @param null|\DateTime $from_date - * @param null|int $from_id - * @param int $limit - * @return array - */ - public function getSummitEntityEvents(Summit $summit, $member_id = null, \DateTime $from_date = null, $from_id = null, $limit = 25) - { - return $this->tx_service->transaction(function() use($summit, $member_id, $from_date, $from_id, $limit) { - - $global_last_id = $summit->getLastEntityEventId(); - $from_id = !is_null($from_id)? intval($from_id) : null; - $list = new EntityEventList; - $ops_dictionary = array(); - - $ops_dictionary['UPDATE'] = array(); - $ops_dictionary['DELETE'] = array(); - $ops_dictionary['INSERT'] = array(); - //special treatement for summit events - $summit_events_ops = array(); - do { - - $last_event_id = 0; - $last_event_date = 0; - - - // if we got a from id and its greater than the last one, then break - if(!is_null($from_id) && $global_last_id <= $from_id) break; - - $events = $summit->getEntityEvents($member_id, $from_id, $from_date, $limit); - - foreach ($events as $e) { - if($list->size() === $limit) break; - $last_event_id = intval($e->ID); - $last_event_date = $e->Created; - $metadata = $e->Metadata; - $key = $e->EntityClassName.'.'.$e->EntityID; - - switch ($e->EntityClassName) { - case 'Presentation': - case 'SummitEvent': - { - $entity = $summit->getScheduleEvent($e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $metadata = !empty($metadata) ? json_decode($metadata, true) : array(); - $published_old = isset($metadata['pub_old']) ? (bool)intval($metadata['pub_old']) : false; - $published_current = isset($metadata['pub_new']) ? (bool)intval($metadata['pub_new']) : false; - - // the event was not published at the moment of UPDATE .. then skip it! - if (!$published_old && !$published_current) continue; - - if (!is_null($entity)) // if event exists its bc its published - { - $type = $published_current && isset($metadata['pub_old']) && !$published_old ? 'INSERT' : $e->Type; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $type, $entity); - if(!isset($summit_events_ops[$key])) $summit_events_ops[$key] = array(); - array_push($summit_events_ops[$key], array('idx' => $list->getIdx() - 1 , 'op' => $type)); - continue; - } - // if does not exists on schedule delete it - - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary['DELETE'])) continue; - array_push($ops_dictionary['DELETE'], $e->EntityClassName . $e->EntityID); - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, 'DELETE'); - } - else if ($e->Type === 'DELETE') { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'MySchedule': { - if (!is_null($member_id) && intval($member_id) === intval($e->OwnerID)) { - if ($e->Type === 'INSERT') { - $entity = $summit->getScheduleEvent($e->EntityID); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - } - break; - case 'Summit': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - if (intval($e->EntityID) !== intval($summit->ID)) continue; // only current summit - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = Summit::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'SummitType': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = SummitType::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'SummitEventType': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = SummitEventType::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'PresentationSpeaker': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = PresentationSpeaker::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'SummitTicketType': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = SummitTicketType::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'SummitVenueRoom': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = SummitVenueRoom::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'SummitVenue': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = SummitVenue::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'SummitLocationMap': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = SummitLocationImage::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'SummitLocationImage': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = SummitLocationImage::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'SummitHotel': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = SummitHotel::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'SummitAirport': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = SummitAirport::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'PresentationCategory': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = PresentationCategory::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'PresentationCategoryGroup': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = PresentationCategoryGroup::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'TrackFromTrackGroup': { - $metadata = !empty($metadata) ? json_decode($metadata, true) : array(); - if (count($metadata) === 0) continue; - $group_id = isset($metadata['group_id']) ? intval($metadata['group_id']) : null; - if (is_null($group_id)) continue; - $entity = $summit->getCategoryGroup($group_id); - if (is_null($entity)) continue; - if (in_array('PresentationCategoryGroup' . $group_id, $ops_dictionary['UPDATE'])) continue; - array_push($ops_dictionary['UPDATE'], 'PresentationCategoryGroup' . $group_id); - $list[] = $this->serializeSummitEntityEvent($e, 'PresentationCategoryGroup', 'UPDATE', $entity); - } - break; - case 'PresentationSlide': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = PresentationSlide::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'PresentationVideo': { - if (in_array($e->EntityClassName . $e->EntityID, $ops_dictionary[$e->Type])) continue; - array_push($ops_dictionary[$e->Type], $e->EntityClassName . $e->EntityID); - - if ($e->Type === 'UPDATE' || $e->Type === "INSERT") { - $entity = PresentationVideo::find(intval($e->EntityID)); - if (is_null($entity)) continue; - $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type, $entity); - } else if ($e->Type === 'DELETE') { - $list[] = $this->serializeSummitEntityEvent($e, $e->EntityClassName, $e->Type); - } - } - break; - case 'SpeakerFromPresentation': { - $metadata = !empty($metadata) ? json_decode($metadata, true) : array(); - if (count($metadata) === 0) continue; - $presentation_id = isset($metadata['presentation_id']) ? intval($metadata['presentation_id']) : null; - if (is_null($presentation_id)) continue; - $entity = $summit->getScheduleEvent($presentation_id); - if (is_null($entity)) continue; - if (in_array('Presentation' . $presentation_id, $ops_dictionary['UPDATE'])) continue; - array_push($ops_dictionary['UPDATE'], 'Presentation' . $presentation_id); - $list[] = $this->serializeSummitEntityEvent($e, 'Presentation', 'UPDATE', $entity); - } - break; - case 'SummitTypeFromEvent': { - $metadata = !empty($metadata) ? json_decode($metadata, true) : array(); - if (count($metadata) === 0) continue; - $event_id = isset($metadata['event_id']) ? intval($metadata['event_id']) : null; - if (is_null($event_id)) continue; - $entity = $summit->getScheduleEvent($event_id); - if (is_null($entity)) continue; - if (in_array('SummitEvent' . $event_id, $ops_dictionary['UPDATE'])) continue; - array_push($ops_dictionary['UPDATE'], 'SummitEvent' . $event_id); - $list[] = $this->serializeSummitEntityEvent($e, 'SummitEvent', 'UPDATE', $entity); - } - break; - case 'SponsorFromEvent': { - $metadata = !empty($metadata) ? json_decode($metadata, true) : array(); - if (count($metadata) === 0) continue; - $event_id = isset($metadata['event_id']) ? intval($metadata['event_id']) : null; - if (is_null($event_id)) continue; - $entity = $summit->getScheduleEvent($event_id); - if (is_null($entity)) continue; - if (in_array('SummitEvent' . $event_id, $ops_dictionary['UPDATE'])) continue; - array_push($ops_dictionary['UPDATE'], 'SummitEvent' . $event_id); - $list[] = $this->serializeSummitEntityEvent($e, 'SummitEvent', 'UPDATE', $entity); - } - break; - case 'WipeData': { - // if event is for a particular user - if (intval($e->EntityID) > 0) { - // if we are not the recipient or its already processed then continue - if (intval($member_id) !== intval($e->EntityID)) - continue; - } - $list[] = $this->serializeSummitEntityEvent($e, 'TRUNCATE', 'TRUNCATE'); - } - break; - } - } - - // reset if we do not get any data so far, to get next batch - $from_id = $last_event_id; - $from_date = null; - //post process for summit events , we should send only te last one - foreach($summit_events_ops as $key => $ops) - { - $last_idx = null; - $last_op = null; - $must_insert = false; - foreach($ops as $op) - { - if(!is_null($last_idx)) - unset($list[$last_idx]); - $last_op = $op['op']; - $last_idx = intval($op['idx']); - $must_insert = !$must_insert && $last_op === 'INSERT' ? true : $must_insert; - } - $last_op = $must_insert && $last_op !== 'DELETE' ? 'INSERT' : $last_op; - $summit_events_ops[$key] = array([ 'idx' => $last_idx, 'op' => ( $last_op ) ]); - // element update - $e = $list[$last_idx]; - $e['type'] = $last_op; - $list[$last_idx] = $e; - } - // we do not have any any to process - if($last_event_id == 0 || $global_last_id <= $last_event_id) break; - } while($list->size() < $limit); - return array($last_event_id, $last_event_date, $list->values()); - }); - } - - /** - * @param SummitEntityEvent $e - * @param $class_name - * @param $type - * @param null $entity - * @return array - */ - private function serializeSummitEntityEvent(SummitEntityEvent $e, $class_name, $type, $entity = null) - { - $row = array - ( - 'id' => intval($e->ID), - 'created' => JsonUtils::toEpoch($e->Created), - 'class_name' => $class_name, - 'entity_id' => intval($e->EntityID), - 'type' => $type, - ); - - if(!is_null($entity)) - { - $data = $entity->toArray(); - if(isset($data['speakers'])) - { - unset($data['speakers']); - $speakers = array(); - foreach($entity->speakers() as $speaker) - { - array_push($speakers, $speaker->toArray()); - } - $data['speakers'] = $speakers; - } - - if(isset($data['sponsors'])) - { - unset($data['sponsors']); - $sponsors = array(); - foreach($entity->sponsors() as $sponsor) - { - array_push($sponsors, $sponsor->toArray()); - } - $data['sponsors'] = $sponsors; - } - - if($entity instanceof PresentationCategoryGroup) - { - $categories = array(); - foreach($entity->categories() as $c) - { - array_push($categories, $c->toArray()); - } - $data['tracks'] = $categories; - } - - $row['entity'] = $data; - } - - return $row; - } - - /** - * @param Summit $summit - * @param array $data - * @return SummitEvent - */ - public function addEvent(Summit $summit, array $data) - { - return $this->saveOrUpdateEvent($summit, $data); - } - - /** - * @param Summit $summit - * @param int $event_id - * @param array $data - * @return SummitEvent - */ - public function updateEvent(Summit $summit, $event_id, array $data) - { - return $this->saveOrUpdateEvent($summit, $data, $event_id); - } - - /** - * @param Summit $summit - * @param array $data - * @param null|int $event_id - * @return SummitEvent - */ - private function saveOrUpdateEvent(Summit $summit, array $data, $event_id = null) - { - $event_repository = $this->event_repository; - - return $this->tx_service->transaction(function() use($summit, $data, $event_id, $event_repository) { - - $start_datetime = null; - $end_datetime = null; - - if(isset($data['start_date']) && isset($data['end_date'])) - { - $start_datetime = intval($data['start_date']); - $start_datetime = new \DateTime("@$start_datetime"); - $end_datetime = intval($data['end_date']); - $end_datetime = new \DateTime("@$end_datetime"); - $interval = $end_datetime->diff($start_datetime); - if($interval->i < self::MIN_EVENT_MINUTES ) - throw new ValidationException - ( - sprintf - ( - "event should last at lest %s minutes - current duration %s", - self::MIN_EVENT_MINUTES, - $interval->i - ) - ); - } - - // check start/end datetime with summit - $event_type = null; - if(isset($data['type_id'])) { - $event_type = $summit->getEventType(intval($data['type_id'])); - if (is_null($event_type)) { - throw new EntityNotFoundException(sprintf("event type id %s does not exists!", $data['type_id'])); - } - } - - $location = null; - if(isset($data['location_id'])) { - $location = $summit->getLocation(intval($data['location_id'])); - if (is_null($location)) { - throw new EntityNotFoundException(sprintf("location id %s does not exists!", $data['location_id'])); - } - } - - $summit_types = array(); - if(isset($data['summit_types_id'])) { - foreach ($data['summit_types_id'] as $summit_type_id) { - $summit_type = $summit->getSummitType($summit_type_id); - if (is_null($summit_type)) { - throw new ValidationException(sprintf("summit type id %s does not exists!", $summit_type_id)); - } - array_push($summit_types, $summit_type); - } - } - - if(is_null($event_id)){ - $event = SummitEventFactory::build($event_type); - } - else - { - $event = $event_repository->getById($event_id); - if(is_null($event)) - throw new ValidationException(sprintf("event id %s does not exists!", $event_id)); - } - - if(isset($data['title'])) - $event->setTitle($data['title']); - - if(isset($data['description'])) - $event->setDescription($data['description']); - - if(isset($data['allow_feedback'])) - $event->setAllowFeedBack($data['allow_feedback']); - - if(!is_null($event_type)) - $event->setType($event_type); - - $event->setSummit($summit); - - if(!is_null($location)) - $event->setLocation($location); - - if(!is_null($start_datetime) && !is_null($end_datetime)) { - $event->StartDate = $start_datetime; - $event->EndDate = $end_datetime; - - if(!$summit->isEventInsideSummitDuration($event)) - throw new ValidationException - ( - sprintf - ( - "event start/end (%s - %s) does not match with summit start/end (%s - %s)", - $start_datetime->format('Y-m-d H:i:s'), - $end_datetime->format('Y-m-d H:i:s'), - $summit->getLocalBeginDate()>format('Y-m-d H:i:s'), - $summit->getLocalEndDate()>format('Y-m-d H:i:s') - ) - ); - } - - $event_repository->add($event); - - if(count($summit_types) > 0) { - $event->clearSummitTypes(); - foreach ($summit_types as $summit_type) { - $event->addSummitType($summit_type); - } - } - - if(isset($data['tags']) && count($data['tags']) > 0) { - $event->clearTags(); - foreach ($data['tags'] as $tag) { - $event->addTag($tag); - } - } - - return $event; - }); - } - - /** - * @param Summit $summit - * @param int $event_id - * @param array $data - * @return SummitEvent - */ - public function publishEvent(Summit $summit, $event_id, array $data) - { - $event_repository = $this->event_repository; - - return $this->tx_service->transaction(function () use ($summit, $data, $event_id, $event_repository) { - - $event = $event_repository->getById($event_id); - - if(is_null($event)) - throw new EntityNotFoundException(sprintf("event id %s does not exists!", $event_id)); - - if(is_null($event->getType())) - throw new EntityNotFoundException(sprintf("event type its not assigned to event id %s!", $event_id)); - - if(is_null($event->getSummit())) - throw new EntityNotFoundException(sprintf("summit its not assigned to event id %s!", $event_id)); - - if($event->getSummit()->getIdentifier() !== $summit->getIdentifier()) - throw new ValidationException(sprintf("event %s does not belongs to summit id %s", $event_id, $summit->getIdentifier())); - - $start_datetime = $event->StartDate; - $end_datetime = $event->EndDate; - - if(isset($data['start_date']) && isset($data['end_date'])) { - $start_datetime = intval($data['start_date']); - $start_datetime = new \DateTime("@$start_datetime"); - $end_datetime = intval($data['end_date']); - $end_datetime = new \DateTime("@$end_datetime"); - } - - if(is_null($start_datetime)) - throw new ValidationException(sprintf("start_date its not assigned to event id %s!", $event_id)); - - if(is_null($end_datetime)) - throw new ValidationException(sprintf("end_date its not assigned to event id %s!", $event_id)); - - if(isset($data['location_id'])) - { - $location = $summit->getLocation(intval($data['location_id'])); - if(is_null($location)) - throw new EntityNotFoundException(sprintf("location id %s does not exists!", $data['location_id'])); - - $event->setLocation($location); - } - - $current_event_location = $event->getLocation(); - - // validate blackout times - $conflict_events = $event_repository->getPublishedOnSameTimeFrame($event); - if(!is_null($conflict_events)) { - foreach ($conflict_events as $c_event) { - // if the published event is BlackoutTime or if there is a BlackoutTime event in this timeframe - if (($event->getType()->BlackoutTimes || $c_event->getType()->BlackoutTimes) && $event->ID != $c_event->ID) { - throw new ValidationException(sprintf("You can't publish on this time frame, it conflicts with event id %s", - $c_event->ID)); - } - // if trying to publish an event on a slot occupied by another event - if ($current_event_location->getIdentifier() == $c_event->getLocation()->getIdentifier() && $event->ID != $c_event->ID) { - throw new ValidationException(sprintf("You can't publish on this time frame, it conflicts with event id %s", - $c_event->ID)); - } - - // check speakers collisions - if ($event instanceof Presentation && $c_event instanceof Presentation && $event->ID != $c_event->ID) { - foreach ($event->speakers() as $current_speaker) { - foreach ($c_event->speakers() as $c_speaker) { - if (intval($c_speaker->ID) === intval($current_speaker->ID)) { - throw new ValidationException - ( - sprintf - ( - 'speaker id % belongs already to another event ( %s) on that time frame', - $c_speaker->ID, - $c_event->ID - ) - ); - } - } - } - } - - } - } - - $event->unPublish(); - $event->publish(); - $event_repository->add($event); - return $event; - }); - } - /** - * @param Summit $summit - * @param int $event_id - * @return mixed - */ - public function unPublishEvent(Summit $summit, $event_id) - { - $event_repository = $this->event_repository; - - return $this->tx_service->transaction(function () use ($summit, $event_id, $event_repository) { - - $event = $event_repository->getById($event_id); - - if(is_null($event)) - throw new EntityNotFoundException(sprintf("event id %s does not exists!", $event_id)); - - if($event->getSummit()->getIdentifier() !== $summit->getIdentifier()) - throw new ValidationException(sprintf("event %s does not belongs to summit id %s", $event_id, $summit->getIdentifier())); - - $event->unPublish(); - $event_repository->add($event); - $this->cleanupAttendeesSchedule($event_id); - return $event; - }); - } - - /** - * @param Summit $summit - * @param int $event_id - * @return mixed - */ - public function deleteEvent(Summit $summit, $event_id) - { - $event_repository = $this->event_repository; - - return $this->tx_service->transaction(function () use ($summit, $event_id, $event_repository) { - - $event = $event_repository->getById($event_id); - - if(is_null($event)) - throw new EntityNotFoundException(sprintf("event id %s does not exists!", $event_id)); - - if($event->getSummit()->getIdentifier() !== $summit->getIdentifier()) - throw new ValidationException(sprintf("event %s does not belongs to summit id %s", $event_id, $summit->getIdentifier())); - - $event_repository->delete($event); - // clean up summit attendees schedule - $this->cleanupAttendeesSchedule($event_id); - return true; - }); - } - - /** - * @param int $event_id - */ - private function cleanupAttendeesSchedule($event_id){ - DB::connection('ss')->delete("DELETE SummitAttendee_Schedule FROM SummitAttendee_Schedule WHERE SummitEventID = {$event_id};"); - } - /** - * @param Summit $summit - * @param $external_order_id - * @return array - * @throws ValidationException - * @throws EntityNotFoundException - * @throws Exception - */ - public function getExternalOrder(Summit $summit, $external_order_id) - { - try{ - $external_order = $this->eventbrite_api->getOrder($external_order_id); - if (isset($external_order['attendees'])) - { - $status = $external_order['status']; - $summit_external_id = $external_order['event_id']; - $order_summit = Summit::where('ExternalEventId', '=', $summit_external_id)->first(); - if(is_null($summit)) - throw new EntityNotFoundException('summit does not exists!'); - if(intval($summit->ID) !== intval($order_summit->ID)) - throw new ValidationException('order %s does not belongs to current summit!', $external_order_id); - if($status !== 'placed') - throw new ValidationException(sprintf('invalid order status %s for order %s',$status, $external_order_id)); - $attendees = array(); - foreach($external_order['attendees'] as $a) - { - - $ticket_external_id = intval($a['ticket_class_id']); - $ticket_type = SummitTicketType::where('ExternalId', '=', $ticket_external_id)->first(); - $redeem_attendee = SummitAttendeeTicket::where('ExternalOrderId', '=' , trim($external_order_id)) - ->where('ExternalAttendeeId','=',$a['id']) - ->first();; - - if(!is_null($redeem_attendee)) continue; - if(is_null($ticket_type)) - throw new EntityNotFoundException(sprintf('external ticket type %s not found!', $ticket_external_id)); - - array_push($attendees, array( - 'external_id' => intval($a['id']), - 'first_name' => $a['profile']['first_name'], - 'last_name' => $a['profile']['last_name'], - 'company' => $a['profile']['company'], - 'email' => $a['profile']['email'], - 'job_title' => $a['profile']['job_title'], - 'status' => $a['status'], - 'ticket_type' => array - ( - 'id' => intval($ticket_type->ID), - 'name' => $ticket_type->Name, - 'external_id' => $ticket_external_id, - ) - )); - } - if(count($attendees) === 0) - throw new ValidationException(sprintf('order %s already redeem!', $external_order_id)); - - return array('id' => intval($external_order_id), 'attendees' => $attendees); - } - } - catch(ClientException $ex1){ - if($ex1->getCode() === 400) - throw new EntityNotFoundException('external order does not exists!'); - if($ex1->getCode() === 403) - throw new EntityNotFoundException('external order does not exists!'); - throw $ex1; - } - catch(Exception $ex){ - throw $ex; - } - } - - /** - * @param Summit $summit - * @param int $me_id - * @param int $external_order_id - * @param int $external_attendee_id - * @return SummitAttendee - */ - public function confirmExternalOrderAttendee(Summit $summit, $me_id, $external_order_id, $external_attendee_id) - { - return $this->tx_service->transaction(function () use ($summit, $me_id, $external_order_id, $external_attendee_id){ - - try{ - $external_order = $this->eventbrite_api->getOrder($external_order_id); - if (isset($external_order['attendees'])) - { - $external_attendee = null; - foreach($external_order['attendees'] as $a) - { - if(intval($a['id']) === intval($external_attendee_id)) { - $external_attendee = $a; - break; - } - } - - if(is_null($external_attendee)) - throw new EntityNotFoundException(sprintf('attendee %s not found!', $external_attendee_id)); - - $ticket_external_id = intval($external_attendee['ticket_class_id']); - $ticket_type = SummitTicketType::where('ExternalId', '=', $ticket_external_id)->first(); - if(is_null($ticket_type)) - throw new EntityNotFoundException(sprintf('ticket type %s not found!', $ticket_external_id));; - - $status = $external_order['status']; - $summit_external_id = $external_order['event_id']; - $order_summit = Summit::where('ExternalEventId', '=', $summit_external_id)->first(); - if(is_null($summit)) - throw new EntityNotFoundException('summit does not exists!'); - if(intval($summit->ID) !== intval($order_summit->ID)) - throw new ValidationException('order %s does not belongs to current summit!', $external_order_id); - if($status !== 'placed') - throw new ValidationException(sprintf('invalid order status %s for order %s',$status, $external_order_id)); - - $old_attendee = SummitAttendee::where('MemberID', '=', $me_id)->where('SummitID','=', $summit->ID)->first(); - - if(!is_null($old_attendee)) - throw new ValidationException - ( - 'attendee already exist for current summit!' - ); - - $old_ticket = SummitAttendeeTicket - ::where('ExternalOrderId','=', $external_order_id) - ->where('ExternalAttendeeId','=', $external_attendee_id)->first(); - - if(!is_null($old_ticket)) - throw new ValidationException - ( - sprintf - ( - 'order %s already redeem for attendee id %s !', - $external_order_id, - $external_attendee_id - ) - ); - - $attendee = new SummitAttendee; - $attendee->MemberID = $me_id; - $attendee->SummitID = $summit->ID; - $attendee->save(); - - $ticket = new SummitAttendeeTicket; - $ticket->ExternalOrderId = intval($external_order_id); - $ticket->ExternalAttendeeId = intval($external_attendee_id); - $ticket->TicketBoughtDate = $external_attendee['created']; - $ticket->TicketChangedDate = $external_attendee['changed']; - $ticket->TicketTypeID = $ticket_type->getIdentifier(); - $ticket->OwnerID = $attendee->ID; - $ticket->save(); - - return $attendee; - } - } - catch(ClientException $ex1){ - if($ex1->getCode() === 400) - throw new EntityNotFoundException('external order does not exists!'); - if($ex1->getCode() === 403) - throw new EntityNotFoundException('external order does not exists!'); - throw $ex1; - } - catch(Exception $ex){ - throw $ex; - } - - }); - } - - /** - * @param Summit $summit - * @param string $expand - * @return array - */ - public function getSummitData(Summit $summit, $expand) - { - $data = $summit->toArray(); - // summit types - $summit_types = array(); - foreach ($summit->summit_types() as $type) { - array_push($summit_types, $type->toArray()); - } - $data['summit_types'] = $summit_types; - // tickets - $ticket_types = array(); - foreach ($summit->ticket_types() as $ticket) { - array_push($ticket_types, $ticket->toArray()); - } - $data['ticket_types'] = $ticket_types; - //locations - $locations = array(); - foreach ($summit->locations() as $location) { - array_push($locations, $location->toArray()); - } - $data['locations'] = $locations; - - $data['ticket_types'] = $ticket_types; - if (!empty($expand)) { - $expand = explode(',', $expand); - foreach ($expand as $relation) { - switch (trim($relation)) { - case 'schedule': { - $event_types = array(); - foreach ($summit->event_types() as $event_type) { - array_push($event_types, $event_type->toArray()); - } - $data['event_types'] = $event_types; - - $sponsors = array(); - foreach ($summit->sponsors() as $company) { - array_push($sponsors, $company->toArray()); - } - $data['sponsors'] = $sponsors; - - $speakers = array(); - $res = $this->speaker_repository->getSpeakersBySummit($summit, new PagingInfo(1 , PHP_INT_MAX)); - foreach ($res->getItems() as $speaker) { - array_push($speakers, $speaker->toArray($summit->ID)); - } - $data['speakers'] = $speakers; - - $presentation_categories = array(); - foreach ($summit->presentation_categories() as $cat) { - array_push($presentation_categories, $cat->toArray()); - } - $data['tracks'] = $presentation_categories; - - // track_groups - $track_groups = array(); - foreach ($summit->category_groups() as $group) { - array_push($track_groups, $group->toArray()); - } - $data['track_groups'] = $track_groups; - $schedule = array(); - list($total, $per_page, $current_page, $last_page, $items) = $summit->schedule(1, - PHP_INT_MAX); - foreach ($items as $event) { - array_push($schedule, $event->toArray()); - } - $data['schedule'] = $schedule; - - } - break; - } - } - } - $data['timestamp'] = time(); - return $data; - } -} \ No newline at end of file diff --git a/artisan b/artisan old mode 100755 new mode 100644 index eb5e2bb6..df630d0d --- a/artisan +++ b/artisan @@ -28,11 +28,11 @@ $app = require_once __DIR__.'/bootstrap/app.php'; | */ -$kernel = $app->make('Illuminate\Contracts\Console\Kernel'); +$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class); $status = $kernel->handle( - $input = new Symfony\Component\Console\Input\ArgvInput, - new Symfony\Component\Console\Output\ConsoleOutput + $input = new Symfony\Component\Console\Input\ArgvInput, + new Symfony\Component\Console\Output\ConsoleOutput ); /* diff --git a/bootstrap/app.php b/bootstrap/app.php index f9e94b4b..f2801adf 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -12,7 +12,7 @@ */ $app = new Illuminate\Foundation\Application( - realpath(__DIR__.'/../') + realpath(__DIR__.'/../') ); /* @@ -27,21 +27,20 @@ $app = new Illuminate\Foundation\Application( */ $app->singleton( - 'Illuminate\Contracts\Http\Kernel', - 'App\Http\Kernel' + Illuminate\Contracts\Http\Kernel::class, + App\Http\Kernel::class ); $app->singleton( - 'Illuminate\Contracts\Console\Kernel', - 'App\Console\Kernel' + Illuminate\Contracts\Console\Kernel::class, + App\Console\Kernel::class ); $app->singleton( - 'Illuminate\Contracts\Debug\ExceptionHandler', - 'App\Exceptions\Handler' + Illuminate\Contracts\Debug\ExceptionHandler::class, + App\Exceptions\Handler::class ); - /* |-------------------------------------------------------------------------- | Return The Application @@ -53,5 +52,4 @@ $app->singleton( | */ - -return $app; \ No newline at end of file +return $app; diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php index 17718f5d..38301379 100644 --- a/bootstrap/autoload.php +++ b/bootstrap/autoload.php @@ -27,9 +27,8 @@ require __DIR__.'/../vendor/autoload.php'; | */ -$compiledPath = __DIR__.'/../vendor/compiled.php'; +$compiledPath = __DIR__.'/cache/compiled.php'; -if (file_exists($compiledPath)) -{ - require $compiledPath; -} \ No newline at end of file +if (file_exists($compiledPath)) { + require $compiledPath; +} diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/bootstrap/cache/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/clear_logs.sh b/clear_logs.sh new file mode 100755 index 00000000..a8e1de13 --- /dev/null +++ b/clear_logs.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +sudo rm -R storage/logs/* diff --git a/composer.json b/composer.json index 270c2788..65c4077c 100644 --- a/composer.json +++ b/composer.json @@ -1,56 +1,63 @@ { - "name": "openstack-infra/openstackid-resources", - "description": "The OpenStackId Resource Server.", - "keywords": [ - "framework", - "laravel" - ], - "license": "MIT", - "type": "project", - "require": { - "laravel/framework": "5.0.*", - "predis/predis": "1.0.1", - "php": ">=5.4.0", - "guzzlehttp/guzzle": "5.3.0", - "ezyang/htmlpurifier": "4.7.0" - }, - "require-dev": { - "phpunit/phpunit": "4.6.6", - "phpspec/phpspec": "~2.1", - "mockery/mockery": "0.9.4", - "squizlabs/php_codesniffer": "2.*", - "pragmarx/laravelcs": "*", - "glenscott/url-normalizer" : "1.4.0" - }, - "autoload": { - "classmap": [ - "database", - "app" + "name": "openstack-infra/openstackid-resources", + "description": "The OpenStackId Resource Server.", + "keywords": [ + "framework", + "laravel" ], - "psr-4": { - "App\\": "app/" + "license": "MIT", + "type": "project", + "require": { + "php": ">=5.5.9", + "laravel/framework": "5.2.*", + "predis/predis": "1.0.1", + "guzzlehttp/guzzle": "5.3.0", + "ezyang/htmlpurifier": "4.7.0", + "glenscott/url-normalizer" : "^1.4", + "laravel-doctrine/orm":"1.1.*", + "laravel-doctrine/extensions": "^1.0", + "cocur/slugify": "^2.3" + }, + "require-dev": { + "fzaninotto/faker": "~1.4", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "~4.0", + "symfony/css-selector": "2.8.*|3.0.*", + "symfony/dom-crawler": "2.8.*|3.0.*" + }, + "autoload": { + "classmap": [ + "database", + "app", + "tests", + "Libs" + ], + "psr-4": { + "App\\": "app/" + } + }, + "autoload-dev": { + "classmap": [ + "tests/TestCase.php" + ] + }, + "scripts": { + "post-root-package-install": [ + "php -r \"copy('.env.example', '.env');\"" + ], + "post-create-project-cmd": [ + "php artisan key:generate" + ], + "post-install-cmd": [ + "Illuminate\\Foundation\\ComposerScripts::postInstall", + "php artisan optimize" + ], + "post-update-cmd": [ + "Illuminate\\Foundation\\ComposerScripts::postUpdate", + "php artisan optimize" + ] + }, + "config": { + "preferred-install": "dist" } - }, - "autoload-dev": { - "classmap": [ - "tests" - ] - }, - "scripts": { - "post-install-cmd": [ - "php artisan clear-compiled", - "php artisan optimize" - ], - "post-update-cmd": [ - "php artisan clear-compiled", - "php artisan optimize" - ], - "post-create-project-cmd": [ - "php -r \"copy('.env.example', '.env');\"", - "php artisan key:generate" - ] - }, - "config": { - "preferred-install": "dist" - } } diff --git a/config/app.php b/config/app.php index 39704521..519db62c 100644 --- a/config/app.php +++ b/config/app.php @@ -1,202 +1,217 @@ env('APP_OAUTH_2_0_CLIENT_ID'), - 'openstackid_client_secret' => env('APP_OAUTH_2_0_CLIENT_SECRET'), - 'openstackid_base_url' => env('APP_OAUTH_2_0_AUTH_SERVER_BASE_URL'), - /* - |-------------------------------------------------------------------------- - | Application Debug Mode - |-------------------------------------------------------------------------- - | - | When your application is in debug mode, detailed error messages with - | stack traces will be shown on every error that occurs within your - | application. If disabled, a simple generic error page is shown. - | - */ + 'openstackid_client_secret' => env('APP_OAUTH_2_0_CLIENT_SECRET'), + 'openstackid_base_url' => env('APP_OAUTH_2_0_AUTH_SERVER_BASE_URL'), + /* + |-------------------------------------------------------------------------- + | Application Environment + |-------------------------------------------------------------------------- + | + | This value determines the "environment" your application is currently + | running in. This may determine how you prefer to configure various + | services your application utilizes. Set this in your ".env" file. + | + */ - 'debug' => env('APP_DEBUG', false), + 'env' => env('APP_ENV', 'dev'), - /* - |-------------------------------------------------------------------------- - | Application URL - |-------------------------------------------------------------------------- - | - | This URL is used by the console to properly generate URLs when using - | the Artisan command line tool. You should set this to the root of - | your application so that it is used when running Artisan tasks. - | - */ + /* + |-------------------------------------------------------------------------- + | Application Debug Mode + |-------------------------------------------------------------------------- + | + | When your application is in debug mode, detailed error messages with + | stack traces will be shown on every error that occurs within your + | application. If disabled, a simple generic error page is shown. + | + */ - 'url' => env('APP_URL', 'http://localhost'), + 'debug' => env('APP_DEBUG', true), - /* - |-------------------------------------------------------------------------- - | Application Timezone - |-------------------------------------------------------------------------- - | - | Here you may specify the default timezone for your application, which - | will be used by the PHP date and date-time functions. We have gone - | ahead and set this to a sensible default for you out of the box. - | - */ + /* + |-------------------------------------------------------------------------- + | Application URL + |-------------------------------------------------------------------------- + | + | This URL is used by the console to properly generate URLs when using + | the Artisan command line tool. You should set this to the root of + | your application so that it is used when running Artisan tasks. + | + */ - 'timezone' => 'UTC', + 'url' => env('APP_URL', 'http://localhost'), - /* - |-------------------------------------------------------------------------- - | Application Locale Configuration - |-------------------------------------------------------------------------- - | - | The application locale determines the default locale that will be used - | by the translation service provider. You are free to set this value - | to any of the locales which will be supported by the application. - | - */ + /* + |-------------------------------------------------------------------------- + | Application Timezone + |-------------------------------------------------------------------------- + | + | Here you may specify the default timezone for your application, which + | will be used by the PHP date and date-time functions. We have gone + | ahead and set this to a sensible default for you out of the box. + | + */ - 'locale' => 'en', + 'timezone' => 'UTC', - /* - |-------------------------------------------------------------------------- - | Application Fallback Locale - |-------------------------------------------------------------------------- - | - | The fallback locale determines the locale to use when the current one - | is not available. You may change the value to correspond to any of - | the language folders that are provided through your application. - | - */ + /* + |-------------------------------------------------------------------------- + | Application Locale Configuration + |-------------------------------------------------------------------------- + | + | The application locale determines the default locale that will be used + | by the translation service provider. You are free to set this value + | to any of the locales which will be supported by the application. + | + */ - 'fallback_locale' => 'en', + 'locale' => 'en', - /* - |-------------------------------------------------------------------------- - | Encryption Key - |-------------------------------------------------------------------------- - | - | This key is used by the Illuminate encrypter service and should be set - | to a random, 32 character string, otherwise these encrypted strings - | will not be safe. Please do this before deploying an application! - | - */ + /* + |-------------------------------------------------------------------------- + | Application Fallback Locale + |-------------------------------------------------------------------------- + | + | The fallback locale determines the locale to use when the current one + | is not available. You may change the value to correspond to any of + | the language folders that are provided through your application. + | + */ - 'key' => env('APP_KEY', 'SomeRandomString'), + 'fallback_locale' => 'en', - 'cipher' => MCRYPT_RIJNDAEL_128, + /* + |-------------------------------------------------------------------------- + | Encryption Key + |-------------------------------------------------------------------------- + | + | This key is used by the Illuminate encrypter service and should be set + | to a random, 32 character string, otherwise these encrypted strings + | will not be safe. Please do this before deploying an application! + | + */ - /* - |-------------------------------------------------------------------------- - | Logging Configuration - |-------------------------------------------------------------------------- - | - | Here you may configure the log settings for your application. Out of - | the box, Laravel uses the Monolog PHP logging library. This gives - | you a variety of powerful log handlers / formatters to utilize. - | - | Available Settings: "single", "daily", "syslog", "errorlog" - | - */ + 'key' => env('APP_KEY'), - 'log' => 'daily', + 'cipher' => 'AES-256-CBC', - /* - |-------------------------------------------------------------------------- - | Autoloaded Service Providers - |-------------------------------------------------------------------------- - | - | The service providers listed here will be automatically loaded on the - | request to your application. Feel free to add your own services to - | this array to grant expanded functionality to your applications. - | - */ + /* + |-------------------------------------------------------------------------- + | Logging Configuration + |-------------------------------------------------------------------------- + | + | Here you may configure the log settings for your application. Out of + | the box, Laravel uses the Monolog PHP logging library. This gives + | you a variety of powerful log handlers / formatters to utilize. + | + | Available Settings: "single", "daily", "syslog", "errorlog" + | + */ - 'providers' => [ + 'log' => env('APP_LOG', 'daily'), - /* - * Laravel Framework Service Providers... - */ - 'Illuminate\Foundation\Providers\ArtisanServiceProvider', - 'Illuminate\Auth\AuthServiceProvider', - 'Illuminate\Bus\BusServiceProvider', - 'Illuminate\Cache\CacheServiceProvider', - 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', - 'Illuminate\Routing\ControllerServiceProvider', - 'Illuminate\Cookie\CookieServiceProvider', - 'Illuminate\Database\DatabaseServiceProvider', - 'Illuminate\Encryption\EncryptionServiceProvider', - 'Illuminate\Filesystem\FilesystemServiceProvider', - 'Illuminate\Foundation\Providers\FoundationServiceProvider', - 'Illuminate\Hashing\HashServiceProvider', - 'Illuminate\Mail\MailServiceProvider', - 'Illuminate\Pagination\PaginationServiceProvider', - 'Illuminate\Pipeline\PipelineServiceProvider', - 'Illuminate\Queue\QueueServiceProvider', - 'Illuminate\Redis\RedisServiceProvider', - 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', - 'Illuminate\Session\SessionServiceProvider', - 'Illuminate\Translation\TranslationServiceProvider', - 'Illuminate\Validation\ValidationServiceProvider', - 'Illuminate\View\ViewServiceProvider', + /* + |-------------------------------------------------------------------------- + | Autoloaded Service Providers + |-------------------------------------------------------------------------- + | + | The service providers listed here will be automatically loaded on the + | request to your application. Feel free to add your own services to + | this array to grant expanded functionality to your applications. + | + */ - /* - * Application Service Providers... - */ - 'App\Providers\AppServiceProvider', - 'App\Providers\BusServiceProvider', - 'App\Providers\ConfigServiceProvider', - 'App\Providers\EventServiceProvider', - 'App\Providers\RouteServiceProvider', - 'repositories\RepositoriesProvider', - 'services\ServicesProvider', - ], + 'providers' => [ - /* - |-------------------------------------------------------------------------- - | Class Aliases - |-------------------------------------------------------------------------- - | - | This array of class aliases will be registered when this application - | is started. However, feel free to register as many as you wish as - | the aliases are "lazy" loaded so they don't hinder performance. - | - */ + /* + * Laravel Framework Service Providers... + */ + Illuminate\Auth\AuthServiceProvider::class, + Illuminate\Broadcasting\BroadcastServiceProvider::class, + Illuminate\Bus\BusServiceProvider::class, + Illuminate\Cache\CacheServiceProvider::class, + Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, + Illuminate\Cookie\CookieServiceProvider::class, + Illuminate\Database\DatabaseServiceProvider::class, + Illuminate\Encryption\EncryptionServiceProvider::class, + Illuminate\Filesystem\FilesystemServiceProvider::class, + Illuminate\Foundation\Providers\FoundationServiceProvider::class, + Illuminate\Hashing\HashServiceProvider::class, + Illuminate\Mail\MailServiceProvider::class, + Illuminate\Pagination\PaginationServiceProvider::class, + Illuminate\Pipeline\PipelineServiceProvider::class, + Illuminate\Queue\QueueServiceProvider::class, + Illuminate\Redis\RedisServiceProvider::class, + Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, + Illuminate\Session\SessionServiceProvider::class, + Illuminate\Translation\TranslationServiceProvider::class, + Illuminate\Validation\ValidationServiceProvider::class, + Illuminate\View\ViewServiceProvider::class, - 'aliases' => [ + /* + * Application Service Providers... + */ + App\Providers\AppServiceProvider::class, + App\Providers\AuthServiceProvider::class, + App\Providers\EventServiceProvider::class, + App\Providers\RouteServiceProvider::class, + \repositories\RepositoriesProvider::class, + \services\ServicesProvider::class, + \factories\FactoriesProvider::class, + \LaravelDoctrine\ORM\DoctrineServiceProvider::class, + \LaravelDoctrine\Extensions\BeberleiExtensionsServiceProvider::class, + ], - 'App' => 'Illuminate\Support\Facades\App', - 'Artisan' => 'Illuminate\Support\Facades\Artisan', - 'Auth' => 'Illuminate\Support\Facades\Auth', - 'Blade' => 'Illuminate\Support\Facades\Blade', - 'Bus' => 'Illuminate\Support\Facades\Bus', - 'Cache' => 'Illuminate\Support\Facades\Cache', - 'Config' => 'Illuminate\Support\Facades\Config', - 'Cookie' => 'Illuminate\Support\Facades\Cookie', - 'Crypt' => 'Illuminate\Support\Facades\Crypt', - 'DB' => 'Illuminate\Support\Facades\DB', - 'Eloquent' => 'Illuminate\Database\Eloquent\Model', - 'Event' => 'Illuminate\Support\Facades\Event', - 'File' => 'Illuminate\Support\Facades\File', - 'Hash' => 'Illuminate\Support\Facades\Hash', - 'Input' => 'Illuminate\Support\Facades\Input', - 'Inspiring' => 'Illuminate\Foundation\Inspiring', - 'Lang' => 'Illuminate\Support\Facades\Lang', - 'Log' => 'Illuminate\Support\Facades\Log', - 'Mail' => 'Illuminate\Support\Facades\Mail', - 'Password' => 'Illuminate\Support\Facades\Password', - 'Queue' => 'Illuminate\Support\Facades\Queue', - 'Redirect' => 'Illuminate\Support\Facades\Redirect', - 'Redis' => 'Illuminate\Support\Facades\Redis', - 'Request' => 'Illuminate\Support\Facades\Request', - 'Response' => 'Illuminate\Support\Facades\Response', - 'Route' => 'Illuminate\Support\Facades\Route', - 'Schema' => 'Illuminate\Support\Facades\Schema', - 'Session' => 'Illuminate\Support\Facades\Session', - 'Storage' => 'Illuminate\Support\Facades\Storage', - 'URL' => 'Illuminate\Support\Facades\URL', - 'Validator' => 'Illuminate\Support\Facades\Validator', - 'View' => 'Illuminate\Support\Facades\View', + /* + |-------------------------------------------------------------------------- + | Class Aliases + |-------------------------------------------------------------------------- + | + | This array of class aliases will be registered when this application + | is started. However, feel free to register as many as you wish as + | the aliases are "lazy" loaded so they don't hinder performance. + | + */ - ], + 'aliases' => [ -]; \ No newline at end of file + 'App' => Illuminate\Support\Facades\App::class, + 'Artisan' => Illuminate\Support\Facades\Artisan::class, + 'Auth' => Illuminate\Support\Facades\Auth::class, + 'Blade' => Illuminate\Support\Facades\Blade::class, + 'Cache' => Illuminate\Support\Facades\Cache::class, + 'Config' => Illuminate\Support\Facades\Config::class, + 'Cookie' => Illuminate\Support\Facades\Cookie::class, + 'Crypt' => Illuminate\Support\Facades\Crypt::class, + 'DB' => Illuminate\Support\Facades\DB::class, + 'Eloquent' => Illuminate\Database\Eloquent\Model::class, + 'Event' => Illuminate\Support\Facades\Event::class, + 'File' => Illuminate\Support\Facades\File::class, + 'Gate' => Illuminate\Support\Facades\Gate::class, + 'Hash' => Illuminate\Support\Facades\Hash::class, + 'Lang' => Illuminate\Support\Facades\Lang::class, + 'Log' => Illuminate\Support\Facades\Log::class, + 'Mail' => Illuminate\Support\Facades\Mail::class, + 'Password' => Illuminate\Support\Facades\Password::class, + 'Queue' => Illuminate\Support\Facades\Queue::class, + 'Redirect' => Illuminate\Support\Facades\Redirect::class, + 'Redis' => Illuminate\Support\Facades\Redis::class, + 'Request' => Illuminate\Support\Facades\Request::class, + 'Response' => Illuminate\Support\Facades\Response::class, + 'Route' => Illuminate\Support\Facades\Route::class, + 'Schema' => Illuminate\Support\Facades\Schema::class, + 'Session' => Illuminate\Support\Facades\Session::class, + 'Storage' => Illuminate\Support\Facades\Storage::class, + 'URL' => Illuminate\Support\Facades\URL::class, + 'Validator' => Illuminate\Support\Facades\Validator::class, + 'View' => Illuminate\Support\Facades\View::class, + 'EntityManager' => LaravelDoctrine\ORM\Facades\EntityManager::class, + 'Registry' => LaravelDoctrine\ORM\Facades\Registry::class, + 'Doctrine' => LaravelDoctrine\ORM\Facades\Doctrine::class, + ], + +]; diff --git a/config/auth.php b/config/auth.php index ee6316fd..c25b92e2 100644 --- a/config/auth.php +++ b/config/auth.php @@ -2,66 +2,106 @@ return [ - /* - |-------------------------------------------------------------------------- - | Default Authentication Driver - |-------------------------------------------------------------------------- - | - | This option controls the authentication driver that will be utilized. - | This driver manages the retrieval and authentication of the users - | attempting to get access to protected areas of your application. - | - | Supported: "database", "eloquent" - | - */ + /* + |-------------------------------------------------------------------------- + | Authentication Defaults + |-------------------------------------------------------------------------- + | + | This option controls the default authentication "guard" and password + | reset options for your application. You may change these defaults + | as required, but they're a perfect start for most applications. + | + */ - 'driver' => 'eloquent', + 'defaults' => [ + 'guard' => 'web', + 'passwords' => 'users', + ], - /* - |-------------------------------------------------------------------------- - | Authentication Model - |-------------------------------------------------------------------------- - | - | When using the "Eloquent" authentication driver, we need to know which - | Eloquent model should be used to retrieve your users. Of course, it - | is often just the "User" model but you may use whatever you like. - | - */ + /* + |-------------------------------------------------------------------------- + | Authentication Guards + |-------------------------------------------------------------------------- + | + | Next, you may define every authentication guard for your application. + | Of course, a great default configuration has been defined for you + | here which uses session storage and the Eloquent user provider. + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | Supported: "session", "token" + | + */ - 'model' => 'App\User', + 'guards' => [ + 'web' => [ + 'driver' => 'session', + 'provider' => 'users', + ], - /* - |-------------------------------------------------------------------------- - | Authentication Table - |-------------------------------------------------------------------------- - | - | When using the "Database" authentication driver, we need to know which - | table should be used to retrieve your users. We have chosen a basic - | default value but you may easily change it to any table you like. - | - */ + 'api' => [ + 'driver' => 'token', + 'provider' => 'users', + ], + ], - 'table' => 'users', + /* + |-------------------------------------------------------------------------- + | User Providers + |-------------------------------------------------------------------------- + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | If you have multiple user tables or models you may configure multiple + | sources which represent each model / table. These sources may then + | be assigned to any extra authentication guards you have defined. + | + | Supported: "database", "eloquent" + | + */ - /* - |-------------------------------------------------------------------------- - | Password Reset Settings - |-------------------------------------------------------------------------- - | - | Here you may set the options for resetting passwords including the view - | that is your password reset e-mail. You can also set the name of the - | table that maintains all of the reset tokens for your application. - | - | The expire time is the number of minutes that the reset token should be - | considered valid. This security feature keeps tokens short-lived so - | they have less time to be guessed. You may change this as needed. - | - */ + 'providers' => [ + 'users' => [ + 'driver' => 'eloquent', + //'model' => App\User::class, + ], - 'password' => [ - 'email' => 'emails.password', - 'table' => 'password_resets', - 'expire' => 60, - ], + // 'users' => [ + // 'driver' => 'database', + // 'table' => 'users', + // ], + ], -]; \ No newline at end of file + /* + |-------------------------------------------------------------------------- + | Resetting Passwords + |-------------------------------------------------------------------------- + | + | Here you may set the options for resetting passwords including the view + | that is your password reset e-mail. You may also set the name of the + | table that maintains all of the reset tokens for your application. + | + | You may specify multiple password reset configurations if you have more + | than one user table or model in the application and you want to have + | separate password reset settings based on the specific user types. + | + | The expire time is the number of minutes that the reset token should be + | considered valid. This security feature keeps tokens short-lived so + | they have less time to be guessed. You may change this as needed. + | + */ + + 'passwords' => [ + 'users' => [ + 'provider' => 'users', + 'email' => 'auth.emails.password', + 'table' => 'password_resets', + 'expire' => 60, + ], + ], + +]; diff --git a/config/broadcasting.php b/config/broadcasting.php new file mode 100644 index 00000000..abaaac32 --- /dev/null +++ b/config/broadcasting.php @@ -0,0 +1,52 @@ + env('BROADCAST_DRIVER', 'pusher'), + + /* + |-------------------------------------------------------------------------- + | Broadcast Connections + |-------------------------------------------------------------------------- + | + | Here you may define all of the broadcast connections that will be used + | to broadcast events to other systems or over websockets. Samples of + | each available type of connection are provided inside this array. + | + */ + + 'connections' => [ + + 'pusher' => [ + 'driver' => 'pusher', + 'key' => env('PUSHER_KEY'), + 'secret' => env('PUSHER_SECRET'), + 'app_id' => env('PUSHER_APP_ID'), + 'options' => [ + // + ], + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'default', + ], + + 'log' => [ + 'driver' => 'log', + ], + + ], + +]; diff --git a/config/cache.php b/config/cache.php index f9f5b576..3ffa840b 100644 --- a/config/cache.php +++ b/config/cache.php @@ -2,49 +2,80 @@ return [ - /* - |-------------------------------------------------------------------------- - | Default Cache Store - |-------------------------------------------------------------------------- - | - | This option controls the default cache connection that gets used while - | using this caching library. This connection is used when another is - | not explicitly specified when executing a given caching function. - | - */ + /* + |-------------------------------------------------------------------------- + | Default Cache Store + |-------------------------------------------------------------------------- + | + | This option controls the default cache connection that gets used while + | using this caching library. This connection is used when another is + | not explicitly specified when executing a given caching function. + | + */ - 'default' => env('CACHE_DRIVER', 'redis'), + 'default' => env('CACHE_DRIVER', 'file'), - /* - |-------------------------------------------------------------------------- - | Cache Stores - |-------------------------------------------------------------------------- - | - | Here you may define all of the cache "stores" for your application as - | well as their drivers. You may even define multiple stores for the - | same cache driver to group types of items stored in your caches. - | - */ + /* + |-------------------------------------------------------------------------- + | Cache Stores + |-------------------------------------------------------------------------- + | + | Here you may define all of the cache "stores" for your application as + | well as their drivers. You may even define multiple stores for the + | same cache driver to group types of items stored in your caches. + | + */ - 'stores' => [ - 'redis' => [ - 'driver' => 'redis', - 'connection' => 'default', - ], + 'stores' => [ - ], + 'apc' => [ + 'driver' => 'apc', + ], - /* - |-------------------------------------------------------------------------- - | Cache Key Prefix - |-------------------------------------------------------------------------- - | - | When utilizing a RAM based store such as APC or Memcached, there might - | be other applications utilizing the same cache. So, we'll specify a - | value to get prefixed to all our keys so we can avoid collisions. - | - */ + 'array' => [ + 'driver' => 'array', + ], - 'prefix' => 'laravel', + 'database' => [ + 'driver' => 'database', + 'table' => 'cache', + 'connection' => null, + ], -]; \ No newline at end of file + 'file' => [ + 'driver' => 'file', + 'path' => storage_path('framework/cache'), + ], + + 'memcached' => [ + 'driver' => 'memcached', + 'servers' => [ + [ + 'host' => env('MEMCACHED_HOST', '127.0.0.1'), + 'port' => env('MEMCACHED_PORT', 11211), + 'weight' => 100, + ], + ], + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'default', + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Cache Key Prefix + |-------------------------------------------------------------------------- + | + | When utilizing a RAM based store such as APC or Memcached, there might + | be other applications utilizing the same cache. So, we'll specify a + | value to get prefixed to all our keys so we can avoid collisions. + | + */ + + 'prefix' => 'laravel', + +]; diff --git a/config/compile.php b/config/compile.php index fc20d82c..04807eac 100644 --- a/config/compile.php +++ b/config/compile.php @@ -2,40 +2,34 @@ return [ - /* - |-------------------------------------------------------------------------- - | Additional Compiled Classes - |-------------------------------------------------------------------------- - | - | Here you may specify additional classes to include in the compiled file - | generated by the `artisan optimize` command. These should be classes - | that are included on basically every request into the application. - | - */ + /* + |-------------------------------------------------------------------------- + | Additional Compiled Classes + |-------------------------------------------------------------------------- + | + | Here you may specify additional classes to include in the compiled file + | generated by the `artisan optimize` command. These should be classes + | that are included on basically every request into the application. + | + */ - 'files' => [ + 'files' => [ + // + ], - realpath(__DIR__.'/../app/Providers/AppServiceProvider.php'), - realpath(__DIR__.'/../app/Providers/BusServiceProvider.php'), - realpath(__DIR__.'/../app/Providers/ConfigServiceProvider.php'), - realpath(__DIR__.'/../app/Providers/EventServiceProvider.php'), - realpath(__DIR__.'/../app/Providers/RouteServiceProvider.php'), + /* + |-------------------------------------------------------------------------- + | Compiled File Providers + |-------------------------------------------------------------------------- + | + | Here you may list service providers which define a "compiles" function + | that returns additional files that should be compiled, providing an + | easy way to get common files from any packages you are utilizing. + | + */ - ], + 'providers' => [ + // + ], - /* - |-------------------------------------------------------------------------- - | Compiled File Providers - |-------------------------------------------------------------------------- - | - | Here you may list service providers which define a "compiles" function - | that returns additional files that should be compiled, providing an - | easy way to get common files from any packages you are utilizing. - | - */ - - 'providers' => [ - // - ], - -]; \ No newline at end of file +]; diff --git a/config/database.php b/config/database.php index ccc9bdac..86fbc787 100644 --- a/config/database.php +++ b/config/database.php @@ -2,110 +2,112 @@ return [ - /* - |-------------------------------------------------------------------------- - | PDO Fetch Style - |-------------------------------------------------------------------------- - | - | By default, database results will be returned as instances of the PHP - | stdClass object; however, you may desire to retrieve records in an - | array format for simplicity. Here you can tweak the fetch style. - | - */ + /* + |-------------------------------------------------------------------------- + | PDO Fetch Style + |-------------------------------------------------------------------------- + | + | By default, database results will be returned as instances of the PHP + | stdClass object; however, you may desire to retrieve records in an + | array format for simplicity. Here you can tweak the fetch style. + | + */ - 'fetch' => PDO::FETCH_CLASS, + 'fetch' => PDO::FETCH_CLASS, - /* - |-------------------------------------------------------------------------- - | Default Database Connection Name - |-------------------------------------------------------------------------- - | - | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of course - | you may use many connections at once using the Database library. - | - */ + /* + |-------------------------------------------------------------------------- + | Default Database Connection Name + |-------------------------------------------------------------------------- + | + | Here you may specify which of the database connections below you wish + | to use as your default connection for all database work. Of course + | you may use many connections at once using the Database library. + | + */ - 'default' => 'openstackid_resources', + 'default' => env('DB_CONNECTION', 'openstackid_resources'), - /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. - | - */ + /* + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Here are each of the database connections setup for your application. + | Of course, examples of configuring each database platform that is + | supported by Laravel is shown below to make development simple. + | + | + | All database work in Laravel is done through the PHP PDO facilities + | so make sure you have the driver for your particular database of + | choice installed on your machine before you begin development. + | + */ - 'connections' => [ - //primary DB - 'openstackid_resources' => array( - 'driver' => 'mysql', - 'host' => env('DB_HOST'), - 'database' => env('DB_DATABASE'), - 'username' => env('DB_USERNAME'), - 'password' => env('DB_PASSWORD'), + 'connections' => [ + + //primary DB + 'openstackid_resources' => array( + 'driver' => 'mysql', + 'host' => env('DB_HOST'), + 'database' => env('DB_DATABASE'), + 'username' => env('DB_USERNAME'), + 'password' => env('DB_PASSWORD'), 'port' => env('DB_PORT', 3306), - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - ), - //secondary DB (SS OS) - 'ss' => array( - 'driver' => 'mysql', - 'host' => env('SS_DB_HOST'), - 'database' => env('SS_DATABASE'), - 'username' => env('SS_DB_USERNAME'), - 'password' => env('SS_DB_PASSWORD'), + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'prefix' => '', + ), + //secondary DB (SS OS) + 'ss' => array( + 'driver' => 'mysql', + 'host' => env('SS_DB_HOST'), + 'database' => env('SS_DATABASE'), + 'username' => env('SS_DB_USERNAME'), + 'password' => env('SS_DB_PASSWORD'), 'port' => env('SS_DB_PORT', 3306), - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - ), - ], + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'prefix' => '', + ), - /* - |-------------------------------------------------------------------------- - | Migration Repository Table - |-------------------------------------------------------------------------- - | - | This table keeps track of all the migrations that have already run for - | your application. Using this information, we can determine which of - | the migrations on disk haven't actually been run in the database. - | - */ + ], - 'migrations' => 'migrations', + /* + |-------------------------------------------------------------------------- + | Migration Repository Table + |-------------------------------------------------------------------------- + | + | This table keeps track of all the migrations that have already run for + | your application. Using this information, we can determine which of + | the migrations on disk haven't actually been run in the database. + | + */ - /* - |-------------------------------------------------------------------------- - | Redis Databases - |-------------------------------------------------------------------------- - | - | Redis is an open source, fast, and advanced key-value store that also - | provides a richer set of commands than a typical key-value systems - | such as APC or Memcached. Laravel makes it easy to dig right in. - | - */ + 'migrations' => 'migrations', - 'redis' => [ + /* + |-------------------------------------------------------------------------- + | Redis Databases + |-------------------------------------------------------------------------- + | + | Redis is an open source, fast, and advanced key-value store that also + | provides a richer set of commands than a typical key-value systems + | such as APC or Memcached. Laravel makes it easy to dig right in. + | + */ - 'cluster' => false, + 'redis' => [ - 'default' => [ - 'host' => env('REDIS_HOST'), - 'port' => env('REDIS_PORT'), - 'database' => env('REDIS_DB'), + 'cluster' => false, + + 'default' => [ + 'host' => env('REDIS_HOST'), + 'port' => env('REDIS_PORT'), + 'database' => env('REDIS_DB'), 'password' => env('REDIS_PASSWORD'), - ], + ], - ], + ], -]; \ No newline at end of file +]; diff --git a/config/doctrine.php b/config/doctrine.php new file mode 100644 index 00000000..a16cc165 --- /dev/null +++ b/config/doctrine.php @@ -0,0 +1,231 @@ + Warning: Proxy auto generation should only be enabled in dev! + | + */ + 'managers' => [ + 'default' => [ + 'dev' => env('APP_DEBUG'), + 'meta' => env('DOCTRINE_METADATA', 'annotations'), + 'connection' => env('DB_CONNECTION', 'openstackid_resources'), + 'namespaces' => [ + 'App' + ], + 'paths' => [ + base_path('app/Models/ResourceServer') + ], + 'repository' => Doctrine\ORM\EntityRepository::class, + 'proxies' => [ + 'namespace' => false, + 'path' => storage_path('proxies'), + 'auto_generate' => env('DOCTRINE_PROXY_AUTOGENERATE', false) + ], + /* + |-------------------------------------------------------------------------- + | Doctrine events + |-------------------------------------------------------------------------- + | + | The listener array expects the key to be a Doctrine event + | e.g. Doctrine\ORM\Events::onFlush + | + */ + 'events' => [ + 'listeners' => [], + 'subscribers' => [] + ], + 'filters' => [], + /* + |-------------------------------------------------------------------------- + | Doctrine mapping types + |-------------------------------------------------------------------------- + | + | Link a Database Type to a Local Doctrine Type + | + | Using 'enum' => 'string' is the same of: + | $doctrineManager->extendAll(function (\Doctrine\ORM\Configuration $configuration, + | \Doctrine\DBAL\Connection $connection, + | \Doctrine\Common\EventManager $eventManager) { + | $connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); + | }); + | + | References: + | http://doctrine-orm.readthedocs.org/en/latest/cookbook/custom-mapping-types.html + | http://doctrine-dbal.readthedocs.org/en/latest/reference/types.html#custom-mapping-types + | http://doctrine-orm.readthedocs.org/en/latest/cookbook/advanced-field-value-conversion-using-custom-mapping-types.html + | http://doctrine-orm.readthedocs.org/en/latest/reference/basic-mapping.html#reference-mapping-types + | http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool + |-------------------------------------------------------------------------- + */ + 'mapping_types' => [ + //'enum' => 'string' + ] + ], + 'ss' => [ + 'dev' => env('APP_DEBUG'), + 'meta' => env('DOCTRINE_METADATA', 'annotations'), + 'connection' => 'ss', + 'namespaces' => [ + 'App' + ], + 'paths' => [ + base_path('app/Models/Foundation') + ], + 'repository' => Doctrine\ORM\EntityRepository::class, + 'proxies' => [ + 'namespace' => false, + 'path' => storage_path('proxies'), + 'auto_generate' => env('DOCTRINE_PROXY_AUTOGENERATE', false) + ], + /* + |-------------------------------------------------------------------------- + | Doctrine events + |-------------------------------------------------------------------------- + | + | The listener array expects the key to be a Doctrine event + | e.g. Doctrine\ORM\Events::onFlush + | + */ + 'events' => [ + 'listeners' => [], + 'subscribers' => [] + ], + 'filters' => [], + /* + |-------------------------------------------------------------------------- + | Doctrine mapping types + |-------------------------------------------------------------------------- + | + | Link a Database Type to a Local Doctrine Type + | + | Using 'enum' => 'string' is the same of: + | $doctrineManager->extendAll(function (\Doctrine\ORM\Configuration $configuration, + | \Doctrine\DBAL\Connection $connection, + | \Doctrine\Common\EventManager $eventManager) { + | $connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); + | }); + | + | References: + | http://doctrine-orm.readthedocs.org/en/latest/cookbook/custom-mapping-types.html + | http://doctrine-dbal.readthedocs.org/en/latest/reference/types.html#custom-mapping-types + | http://doctrine-orm.readthedocs.org/en/latest/cookbook/advanced-field-value-conversion-using-custom-mapping-types.html + | http://doctrine-orm.readthedocs.org/en/latest/reference/basic-mapping.html#reference-mapping-types + | http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool + |-------------------------------------------------------------------------- + */ + 'mapping_types' => [ + //'enum' => 'string' + ] + ] + ], + /* + |-------------------------------------------------------------------------- + | Doctrine Extensions + |-------------------------------------------------------------------------- + | + | Enable/disable Doctrine Extensions by adding or removing them from the list + | + | If you want to require custom extensions you will have to require + | laravel-doctrine/extensions in your composer.json + | + */ + 'extensions' => [ + //LaravelDoctrine\ORM\Extensions\TablePrefix\TablePrefixExtension::class, + //LaravelDoctrine\Extensions\Timestamps\TimestampableExtension::class, + //LaravelDoctrine\Extensions\SoftDeletes\SoftDeleteableExtension::class, + //LaravelDoctrine\Extensions\Sluggable\SluggableExtension::class, + //LaravelDoctrine\Extensions\Sortable\SortableExtension::class, + //LaravelDoctrine\Extensions\Tree\TreeExtension::class, + //LaravelDoctrine\Extensions\Loggable\LoggableExtension::class, + //LaravelDoctrine\Extensions\Blameable\BlameableExtension::class, + //LaravelDoctrine\Extensions\IpTraceable\IpTraceableExtension::class, + //LaravelDoctrine\Extensions\Translatable\TranslatableExtension::class + ], + /* + |-------------------------------------------------------------------------- + | Doctrine custom types + |-------------------------------------------------------------------------- + | + | Create a custom or override a Doctrine Type + |-------------------------------------------------------------------------- + */ + 'custom_types' => [ + 'json' => LaravelDoctrine\ORM\Types\Json::class + ], + /* + |-------------------------------------------------------------------------- + | DQL custom datetime functions + |-------------------------------------------------------------------------- + */ + 'custom_datetime_functions' => [], + /* + |-------------------------------------------------------------------------- + | DQL custom numeric functions + |-------------------------------------------------------------------------- + */ + 'custom_numeric_functions' => [], + /* + |-------------------------------------------------------------------------- + | DQL custom string functions + |-------------------------------------------------------------------------- + */ + 'custom_string_functions' => [], + /* + |-------------------------------------------------------------------------- + | Enable query logging with laravel file logging, + | debugbar, clockwork or an own implementation. + | Setting it to false, will disable logging + | + | Available: + | - LaravelDoctrine\ORM\Loggers\LaravelDebugbarLogger + | - LaravelDoctrine\ORM\Loggers\ClockworkLogger + | - LaravelDoctrine\ORM\Loggers\FileLogger + |-------------------------------------------------------------------------- + */ + 'logger' => env('DOCTRINE_LOGGER', 'LaravelDoctrine\ORM\Loggers\FileLogger'), + /* + |-------------------------------------------------------------------------- + | Cache + |-------------------------------------------------------------------------- + | + | Configure meta-data, query and result caching here. + | Optionally you can enable second level caching. + | + | Available: acp|array|file|memcached|redis|void + | + */ + 'cache' => [ + 'default' => env('DOCTRINE_CACHE', 'redis'), + 'namespace' => null, + 'second_level' => true, + ], + /* + |-------------------------------------------------------------------------- + | Gedmo extensions + |-------------------------------------------------------------------------- + | + | Settings for Gedmo extensions + | If you want to use this you will have to require + | laravel-doctrine/extensions in your composer.json + | + */ + 'gedmo' => [ + 'all_mappings' => false + ] +]; diff --git a/config/filesystems.php b/config/filesystems.php index 300b790b..75b50022 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -2,70 +2,66 @@ return [ - /* - |-------------------------------------------------------------------------- - | Default Filesystem Disk - |-------------------------------------------------------------------------- - | - | Here you may specify the default filesystem disk that should be used - | by the framework. A "local" driver, as well as a variety of cloud - | based drivers are available for your choosing. Just store away! - | - | Supported: "local", "s3", "rackspace" - | - */ + /* + |-------------------------------------------------------------------------- + | Default Filesystem Disk + |-------------------------------------------------------------------------- + | + | Here you may specify the default filesystem disk that should be used + | by the framework. A "local" driver, as well as a variety of cloud + | based drivers are available for your choosing. Just store away! + | + | Supported: "local", "ftp", "s3", "rackspace" + | + */ - 'default' => 'local', + 'default' => 'local', - /* - |-------------------------------------------------------------------------- - | Default Cloud Filesystem Disk - |-------------------------------------------------------------------------- - | - | Many applications store files both locally and in the cloud. For this - | reason, you may specify a default "cloud" driver here. This driver - | will be bound as the Cloud disk implementation in the container. - | - */ + /* + |-------------------------------------------------------------------------- + | Default Cloud Filesystem Disk + |-------------------------------------------------------------------------- + | + | Many applications store files both locally and in the cloud. For this + | reason, you may specify a default "cloud" driver here. This driver + | will be bound as the Cloud disk implementation in the container. + | + */ - 'cloud' => 's3', + 'cloud' => 's3', - /* - |-------------------------------------------------------------------------- - | Filesystem Disks - |-------------------------------------------------------------------------- - | - | Here you may configure as many filesystem "disks" as you wish, and you - | may even configure multiple disks of the same driver. Defaults have - | been setup for each driver as an example of the required options. - | - */ + /* + |-------------------------------------------------------------------------- + | Filesystem Disks + |-------------------------------------------------------------------------- + | + | Here you may configure as many filesystem "disks" as you wish, and you + | may even configure multiple disks of the same driver. Defaults have + | been setup for each driver as an example of the required options. + | + */ - 'disks' => [ + 'disks' => [ - 'local' => [ - 'driver' => 'local', - 'root' => storage_path().'/app', - ], + 'local' => [ + 'driver' => 'local', + 'root' => storage_path('app'), + ], - 's3' => [ - 'driver' => 's3', - 'key' => 'your-key', - 'secret' => 'your-secret', - 'region' => 'your-region', - 'bucket' => 'your-bucket', - ], + 'public' => [ + 'driver' => 'local', + 'root' => storage_path('app/public'), + 'visibility' => 'public', + ], - 'rackspace' => [ - 'driver' => 'rackspace', - 'username' => 'your-username', - 'key' => 'your-key', - 'container' => 'your-container', - 'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/', - 'region' => 'IAD', - 'url_type' => 'publicURL' - ], + 's3' => [ + 'driver' => 's3', + 'key' => 'your-key', + 'secret' => 'your-secret', + 'region' => 'your-region', + 'bucket' => 'your-bucket', + ], - ], + ], -]; \ No newline at end of file +]; diff --git a/config/mail.php b/config/mail.php index 5905b1dd..a0765885 100644 --- a/config/mail.php +++ b/config/mail.php @@ -2,123 +2,111 @@ return [ - /* - |-------------------------------------------------------------------------- - | Mail Driver - |-------------------------------------------------------------------------- - | - | Laravel supports both SMTP and PHP's "mail" function as drivers for the - | sending of e-mail. You may specify which one you're using throughout - | your application here. By default, Laravel is setup for SMTP mail. - | - | Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log" - | - */ + /* + |-------------------------------------------------------------------------- + | Mail Driver + |-------------------------------------------------------------------------- + | + | Laravel supports both SMTP and PHP's "mail" function as drivers for the + | sending of e-mail. You may specify which one you're using throughout + | your application here. By default, Laravel is setup for SMTP mail. + | + | Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", + | "ses", "sparkpost", "log" + | + */ - 'driver' => env('MAIL_DRIVER', 'smtp'), + 'driver' => env('MAIL_DRIVER', 'smtp'), - /* - |-------------------------------------------------------------------------- - | SMTP Host Address - |-------------------------------------------------------------------------- - | - | Here you may provide the host address of the SMTP server used by your - | applications. A default option is provided that is compatible with - | the Mailgun mail service which will provide reliable deliveries. - | - */ + /* + |-------------------------------------------------------------------------- + | SMTP Host Address + |-------------------------------------------------------------------------- + | + | Here you may provide the host address of the SMTP server used by your + | applications. A default option is provided that is compatible with + | the Mailgun mail service which will provide reliable deliveries. + | + */ - 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), - /* - |-------------------------------------------------------------------------- - | SMTP Host Port - |-------------------------------------------------------------------------- - | - | This is the SMTP port used by your application to deliver e-mails to - | users of the application. Like the host we have set this value to - | stay compatible with the Mailgun e-mail application by default. - | - */ + /* + |-------------------------------------------------------------------------- + | SMTP Host Port + |-------------------------------------------------------------------------- + | + | This is the SMTP port used by your application to deliver e-mails to + | users of the application. Like the host we have set this value to + | stay compatible with the Mailgun e-mail application by default. + | + */ - 'port' => env('MAIL_PORT', 587), + 'port' => env('MAIL_PORT', 587), - /* - |-------------------------------------------------------------------------- - | Global "From" Address - |-------------------------------------------------------------------------- - | - | You may wish for all e-mails sent by your application to be sent from - | the same address. Here, you may specify a name and address that is - | used globally for all e-mails that are sent by your application. - | - */ + /* + |-------------------------------------------------------------------------- + | Global "From" Address + |-------------------------------------------------------------------------- + | + | You may wish for all e-mails sent by your application to be sent from + | the same address. Here, you may specify a name and address that is + | used globally for all e-mails that are sent by your application. + | + */ - 'from' => ['address' => null, 'name' => null], + 'from' => ['address' => null, 'name' => null], - /* - |-------------------------------------------------------------------------- - | E-Mail Encryption Protocol - |-------------------------------------------------------------------------- - | - | Here you may specify the encryption protocol that should be used when - | the application send e-mail messages. A sensible default using the - | transport layer security protocol should provide great security. - | - */ + /* + |-------------------------------------------------------------------------- + | E-Mail Encryption Protocol + |-------------------------------------------------------------------------- + | + | Here you may specify the encryption protocol that should be used when + | the application send e-mail messages. A sensible default using the + | transport layer security protocol should provide great security. + | + */ - 'encryption' => 'tls', + 'encryption' => env('MAIL_ENCRYPTION', 'tls'), - /* - |-------------------------------------------------------------------------- - | SMTP Server Username - |-------------------------------------------------------------------------- - | - | If your SMTP server requires a username for authentication, you should - | set it here. This will get used to authenticate with your server on - | connection. You may also set the "password" value below this one. - | - */ + /* + |-------------------------------------------------------------------------- + | SMTP Server Username + |-------------------------------------------------------------------------- + | + | If your SMTP server requires a username for authentication, you should + | set it here. This will get used to authenticate with your server on + | connection. You may also set the "password" value below this one. + | + */ - 'username' => env('MAIL_USERNAME'), + 'username' => env('MAIL_USERNAME'), - /* - |-------------------------------------------------------------------------- - | SMTP Server Password - |-------------------------------------------------------------------------- - | - | Here you may set the password required by your SMTP server to send out - | messages from your application. This will be given to the server on - | connection so that the application will be able to send messages. - | - */ + /* + |-------------------------------------------------------------------------- + | SMTP Server Password + |-------------------------------------------------------------------------- + | + | Here you may set the password required by your SMTP server to send out + | messages from your application. This will be given to the server on + | connection so that the application will be able to send messages. + | + */ - 'password' => env('MAIL_PASSWORD'), + 'password' => env('MAIL_PASSWORD'), - /* - |-------------------------------------------------------------------------- - | Sendmail System Path - |-------------------------------------------------------------------------- - | - | When using the "sendmail" driver to send e-mails, we will need to know - | the path to where Sendmail lives on this server. A default path has - | been provided here, which will work well on most of your systems. - | - */ + /* + |-------------------------------------------------------------------------- + | Sendmail System Path + |-------------------------------------------------------------------------- + | + | When using the "sendmail" driver to send e-mails, we will need to know + | the path to where Sendmail lives on this server. A default path has + | been provided here, which will work well on most of your systems. + | + */ - 'sendmail' => '/usr/sbin/sendmail -bs', + 'sendmail' => '/usr/sbin/sendmail -bs', - /* - |-------------------------------------------------------------------------- - | Mail "Pretend" - |-------------------------------------------------------------------------- - | - | When this option is enabled, e-mail will not actually be sent over the - | web and will instead be written to your application's logs files so - | you may inspect the message. This is great for local development. - | - */ - - 'pretend' => false, - -]; \ No newline at end of file +]; diff --git a/config/queue.php b/config/queue.php index d5c7ea90..d0f732a6 100644 --- a/config/queue.php +++ b/config/queue.php @@ -2,91 +2,84 @@ return [ - /* - |-------------------------------------------------------------------------- - | Default Queue Driver - |-------------------------------------------------------------------------- - | - | The Laravel queue API supports a variety of back-ends via an unified - | API, giving you convenient access to each back-end using the same - | syntax for each one. Here you may set the default queue driver. - | - | Supported: "null", "sync", "database", "beanstalkd", - | "sqs", "iron", "redis" - | - */ + /* + |-------------------------------------------------------------------------- + | Default Queue Driver + |-------------------------------------------------------------------------- + | + | The Laravel queue API supports a variety of back-ends via an unified + | API, giving you convenient access to each back-end using the same + | syntax for each one. Here you may set the default queue driver. + | + | Supported: "null", "sync", "database", "beanstalkd", "sqs", "redis" + | + */ - 'default' => env('QUEUE_DRIVER', 'sync'), + 'default' => env('QUEUE_DRIVER', 'sync'), - /* - |-------------------------------------------------------------------------- - | Queue Connections - |-------------------------------------------------------------------------- - | - | Here you may configure the connection information for each server that - | is used by your application. A default configuration has been added - | for each back-end shipped with Laravel. You are free to add more. - | - */ + /* + |-------------------------------------------------------------------------- + | Queue Connections + |-------------------------------------------------------------------------- + | + | Here you may configure the connection information for each server that + | is used by your application. A default configuration has been added + | for each back-end shipped with Laravel. You are free to add more. + | + */ - 'connections' => [ + 'connections' => [ - 'sync' => [ - 'driver' => 'sync', - ], + 'sync' => [ + 'driver' => 'sync', + ], - 'database' => [ - 'driver' => 'database', - 'table' => 'jobs', - 'queue' => 'default', - 'expire' => 60, - ], + 'database' => [ + 'driver' => 'database', + 'table' => 'jobs', + 'queue' => 'default', + 'expire' => 60, + ], - 'beanstalkd' => [ - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'ttr' => 60, - ], + 'beanstalkd' => [ + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'ttr' => 60, + ], - 'sqs' => [ - 'driver' => 'sqs', - 'key' => 'your-public-key', - 'secret' => 'your-secret-key', - 'queue' => 'your-queue-url', - 'region' => 'us-east-1', - ], + 'sqs' => [ + 'driver' => 'sqs', + 'key' => 'your-public-key', + 'secret' => 'your-secret-key', + 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', + 'queue' => 'your-queue-name', + 'region' => 'us-east-1', + ], - 'iron' => [ - 'driver' => 'iron', - 'host' => 'mq-aws-us-east-1.iron.io', - 'token' => 'your-token', - 'project' => 'your-project-id', - 'queue' => 'your-queue-name', - 'encrypt' => true, - ], + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'default', + 'queue' => 'default', + 'expire' => 60, + ], - 'redis' => [ - 'driver' => 'redis', - 'queue' => 'default', - 'expire' => 60, - ], + ], - ], + /* + |-------------------------------------------------------------------------- + | Failed Queue Jobs + |-------------------------------------------------------------------------- + | + | These options configure the behavior of failed queue job logging so you + | can control which database and table are used to store the jobs that + | have failed. You may change them to any database / table you wish. + | + */ - /* - |-------------------------------------------------------------------------- - | Failed Queue Jobs - |-------------------------------------------------------------------------- - | - | These options configure the behavior of failed queue job logging so you - | can control which database and table are used to store the jobs that - | have failed. You may change them to any database / table you wish. - | - */ + 'failed' => [ + 'database' => env('DB_CONNECTION', 'mysql'), + 'table' => 'failed_jobs', + ], - 'failed' => [ - 'database' => 'mysql', 'table' => 'failed_jobs', - ], - -]; \ No newline at end of file +]; diff --git a/config/services.php b/config/services.php index 65abbac7..287b1186 100644 --- a/config/services.php +++ b/config/services.php @@ -2,36 +2,37 @@ return [ - /* - |-------------------------------------------------------------------------- - | Third Party Services - |-------------------------------------------------------------------------- - | - | This file is for storing the credentials for third party services such - | as Stripe, Mailgun, Mandrill, and others. This file provides a sane - | default location for this type of information, allowing packages - | to have a conventional place to find your various credentials. - | - */ + /* + |-------------------------------------------------------------------------- + | Third Party Services + |-------------------------------------------------------------------------- + | + | This file is for storing the credentials for third party services such + | as Stripe, Mailgun, Mandrill, and others. This file provides a sane + | default location for this type of information, allowing packages + | to have a conventional place to find your various credentials. + | + */ - 'mailgun' => [ - 'domain' => '', - 'secret' => '', - ], + 'mailgun' => [ + 'domain' => env('MAILGUN_DOMAIN'), + 'secret' => env('MAILGUN_SECRET'), + ], - 'mandrill' => [ - 'secret' => '', - ], + 'ses' => [ + 'key' => env('SES_KEY'), + 'secret' => env('SES_SECRET'), + 'region' => 'us-east-1', + ], - 'ses' => [ - 'key' => '', - 'secret' => '', - 'region' => 'us-east-1', - ], + 'sparkpost' => [ + 'secret' => env('SPARKPOST_SECRET'), + ], - 'stripe' => [ - 'model' => 'App\User', - 'secret' => '', - ], + 'stripe' => [ + 'model' => App\User::class, + 'key' => env('STRIPE_KEY'), + 'secret' => env('STRIPE_SECRET'), + ], -]; \ No newline at end of file +]; diff --git a/config/session.php b/config/session.php index 901149db..b21ffee2 100644 --- a/config/session.php +++ b/config/session.php @@ -2,152 +2,165 @@ return [ - /* - |-------------------------------------------------------------------------- - | Default Session Driver - |-------------------------------------------------------------------------- - | - | This option controls the default session "driver" that will be used on - | requests. By default, we will use the lightweight native driver but - | you may specify any of the other wonderful drivers provided here. - | - | Supported: "file", "cookie", "database", "apc", - | "memcached", "redis", "array" - | - */ + /* + |-------------------------------------------------------------------------- + | Default Session Driver + |-------------------------------------------------------------------------- + | + | This option controls the default session "driver" that will be used on + | requests. By default, we will use the lightweight native driver but + | you may specify any of the other wonderful drivers provided here. + | + | Supported: "file", "cookie", "database", "apc", + | "memcached", "redis", "array" + | + */ - 'driver' => env('SESSION_DRIVER', 'redis'), + 'driver' => env('SESSION_DRIVER', 'redis'), - /* - |-------------------------------------------------------------------------- - | Session Lifetime - |-------------------------------------------------------------------------- - | - | Here you may specify the number of minutes that you wish the session - | to be allowed to remain idle before it expires. If you want them - | to immediately expire on the browser closing, set that option. - | - */ + /* + |-------------------------------------------------------------------------- + | Session Lifetime + |-------------------------------------------------------------------------- + | + | Here you may specify the number of minutes that you wish the session + | to be allowed to remain idle before it expires. If you want them + | to immediately expire on the browser closing, set that option. + | + */ - 'lifetime' => 120, + 'lifetime' => 120, - 'expire_on_close' => false, + 'expire_on_close' => false, - /* - |-------------------------------------------------------------------------- - | Session Encryption - |-------------------------------------------------------------------------- - | - | This option allows you to easily specify that all of your session data - | should be encrypted before it is stored. All encryption will be run - | automatically by Laravel and you can use the Session like normal. - | - */ + /* + |-------------------------------------------------------------------------- + | Session Encryption + |-------------------------------------------------------------------------- + | + | This option allows you to easily specify that all of your session data + | should be encrypted before it is stored. All encryption will be run + | automatically by Laravel and you can use the Session like normal. + | + */ - 'encrypt' => false, + 'encrypt' => false, - /* - |-------------------------------------------------------------------------- - | Session File Location - |-------------------------------------------------------------------------- - | - | When using the native session driver, we need a location where session - | files may be stored. A default has been set for you but a different - | location may be specified. This is only needed for file sessions. - | - */ + /* + |-------------------------------------------------------------------------- + | Session File Location + |-------------------------------------------------------------------------- + | + | When using the native session driver, we need a location where session + | files may be stored. A default has been set for you but a different + | location may be specified. This is only needed for file sessions. + | + */ - 'files' => storage_path().'/framework/sessions', + 'files' => storage_path('framework/sessions'), - /* - |-------------------------------------------------------------------------- - | Session Database Connection - |-------------------------------------------------------------------------- - | - | When using the "database" or "redis" session drivers, you may specify a - | connection that should be used to manage these sessions. This should - | correspond to a connection in your database configuration options. - | - */ + /* + |-------------------------------------------------------------------------- + | Session Database Connection + |-------------------------------------------------------------------------- + | + | When using the "database" or "redis" session drivers, you may specify a + | connection that should be used to manage these sessions. This should + | correspond to a connection in your database configuration options. + | + */ - 'connection' => null, + 'connection' => null, - /* - |-------------------------------------------------------------------------- - | Session Database Table - |-------------------------------------------------------------------------- - | - | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of course, a sensible default is - | provided for you; however, you are free to change this as needed. - | - */ + /* + |-------------------------------------------------------------------------- + | Session Database Table + |-------------------------------------------------------------------------- + | + | When using the "database" session driver, you may specify the table we + | should use to manage the sessions. Of course, a sensible default is + | provided for you; however, you are free to change this as needed. + | + */ - 'table' => 'sessions', + 'table' => 'sessions', - /* - |-------------------------------------------------------------------------- - | Session Sweeping Lottery - |-------------------------------------------------------------------------- - | - | Some session drivers must manually sweep their storage location to get - | rid of old sessions from storage. Here are the chances that it will - | happen on a given request. By default, the odds are 2 out of 100. - | - */ + /* + |-------------------------------------------------------------------------- + | Session Sweeping Lottery + |-------------------------------------------------------------------------- + | + | Some session drivers must manually sweep their storage location to get + | rid of old sessions from storage. Here are the chances that it will + | happen on a given request. By default, the odds are 2 out of 100. + | + */ - 'lottery' => [2, 100], + 'lottery' => [2, 100], - /* - |-------------------------------------------------------------------------- - | Session Cookie Name - |-------------------------------------------------------------------------- - | - | Here you may change the name of the cookie used to identify a session - | instance by ID. The name specified here will get used every time a - | new session cookie is created by the framework for every driver. - | - */ + /* + |-------------------------------------------------------------------------- + | Session Cookie Name + |-------------------------------------------------------------------------- + | + | Here you may change the name of the cookie used to identify a session + | instance by ID. The name specified here will get used every time a + | new session cookie is created by the framework for every driver. + | + */ - 'cookie' => 'openstackid_resources', + 'cookie' => 'openstackid_resources', - /* - |-------------------------------------------------------------------------- - | Session Cookie Path - |-------------------------------------------------------------------------- - | - | The session cookie path determines the path for which the cookie will - | be regarded as available. Typically, this will be the root path of - | your application but you are free to change this when necessary. - | - */ + /* + |-------------------------------------------------------------------------- + | Session Cookie Path + |-------------------------------------------------------------------------- + | + | The session cookie path determines the path for which the cookie will + | be regarded as available. Typically, this will be the root path of + | your application but you are free to change this when necessary. + | + */ - 'path' => '/', + 'path' => '/', - /* - |-------------------------------------------------------------------------- - | Session Cookie Domain - |-------------------------------------------------------------------------- - | - | Here you may change the domain of the cookie used to identify a session - | in your application. This will determine which domains the cookie is - | available to in your application. A sensible default has been set. - | - */ + /* + |-------------------------------------------------------------------------- + | Session Cookie Domain + |-------------------------------------------------------------------------- + | + | Here you may change the domain of the cookie used to identify a session + | in your application. This will determine which domains the cookie is + | available to in your application. A sensible default has been set. + | + */ - 'domain' => env('SESSION_COOKIE_DOMAIN'), + 'domain' => env('SESSION_COOKIE_DOMAIN'), - /* - |-------------------------------------------------------------------------- - | HTTPS Only Cookies - |-------------------------------------------------------------------------- - | - | By setting this option to true, session cookies will only be sent back - | to the server if the browser has a HTTPS connection. This will keep - | the cookie from being sent to you if it can not be done securely. - | - */ + /* + |-------------------------------------------------------------------------- + | HTTPS Only Cookies + |-------------------------------------------------------------------------- + | + | By setting this option to true, session cookies will only be sent back + | to the server if the browser has a HTTPS connection. This will keep + | the cookie from being sent to you if it can not be done securely. + | + */ - 'secure' => env('SESSION_COOKIE_SECURE', false), + 'secure' => env('SESSION_COOKIE_SECURE', false), -]; \ No newline at end of file + /* + |-------------------------------------------------------------------------- + | HTTP Access Only + |-------------------------------------------------------------------------- + | + | Setting this value to true will prevent JavaScript from accessing the + | value of the cookie and the cookie will only be accessible through + | the HTTP protocol. You are free to modify this option if needed. + | + */ + + 'http_only' => true, + +]; diff --git a/config/view.php b/config/view.php index 48e9f929..e193ab61 100644 --- a/config/view.php +++ b/config/view.php @@ -2,32 +2,32 @@ return [ - /* - |-------------------------------------------------------------------------- - | View Storage Paths - |-------------------------------------------------------------------------- - | - | Most templating systems load templates from disk. Here you may specify - | an array of paths that should be checked for your views. Of course - | the usual Laravel view path has already been registered for you. - | - */ + /* + |-------------------------------------------------------------------------- + | View Storage Paths + |-------------------------------------------------------------------------- + | + | Most templating systems load templates from disk. Here you may specify + | an array of paths that should be checked for your views. Of course + | the usual Laravel view path has already been registered for you. + | + */ - 'paths' => [ - realpath(base_path('resources/views')) - ], + 'paths' => [ + realpath(base_path('resources/views')), + ], - /* - |-------------------------------------------------------------------------- - | Compiled View Path - |-------------------------------------------------------------------------- - | - | This option determines where all the compiled Blade templates will be - | stored for your application. Typically, this is within the storage - | directory. However, as usual, you are free to change this value. - | - */ + /* + |-------------------------------------------------------------------------- + | Compiled View Path + |-------------------------------------------------------------------------- + | + | This option determines where all the compiled Blade templates will be + | stored for your application. Typically, this is within the storage + | directory. However, as usual, you are free to change this value. + | + */ - 'compiled' => realpath(storage_path().'/framework/views'), + 'compiled' => realpath(storage_path('framework/views')), -]; \ No newline at end of file +]; diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php new file mode 100644 index 00000000..f596d0b5 --- /dev/null +++ b/database/factories/ModelFactory.php @@ -0,0 +1,21 @@ +define(App\User::class, function (Faker\Generator $faker) { + return [ + 'name' => $faker->name, + 'email' => $faker->safeEmail, + 'password' => bcrypt(str_random(10)), + 'remember_token' => str_random(10), + ]; +}); diff --git a/database/migrations/.gitkeep b/database/migrations/.gitkeep index e69de29b..8b137891 100644 --- a/database/migrations/.gitkeep +++ b/database/migrations/.gitkeep @@ -0,0 +1 @@ + diff --git a/database/seeds/.gitkeep b/database/seeds/.gitkeep index e69de29b..8b137891 100644 --- a/database/seeds/.gitkeep +++ b/database/seeds/.gitkeep @@ -0,0 +1 @@ + diff --git a/database/seeds/ApiEndpointsSeeder.php b/database/seeds/ApiEndpointsSeeder.php index 491c02c6..cf55f3d9 100644 --- a/database/seeds/ApiEndpointsSeeder.php +++ b/database/seeds/ApiEndpointsSeeder.php @@ -440,6 +440,16 @@ class ApiEndpointsSeeder extends Seeder ) ); + ApiEndpoint::create( + array( + 'name' => 'add-event-feedback-v2', + 'active' => true, + 'api_id' => $summit->id, + 'route' => '/api/v2/summits/{id}/events/{event_id}/feedback', + 'http_method' => 'POST' + ) + ); + ApiEndpoint::create( array( 'name' => 'get-event-feedback', @@ -538,6 +548,32 @@ class ApiEndpointsSeeder extends Seeder ) ); + //videos + + + ApiEndpoint::create( + array( + 'name' => 'create-presentation-video', + 'active' => true, + 'api_id' => $summit->id, + 'route' => '/api/v1/summits/{id}/presentations/{presentation_id}/videos', + 'http_method' => 'POST' + ) + ); + + //members + + ApiEndpoint::create( + array( + 'name' => 'get-own-member', + 'active' => true, + 'api_id' => $summit->id, + 'route' => '/api/v1/summits/{id}/members/me', + 'http_method' => 'GET' + ) + ); + + $member_read_scope = ApiScope::where('name', '=', sprintf('%s/me/read', $current_realm))->first(); $summit_read_scope = ApiScope::where('name', '=', sprintf('%s/summits/read', $current_realm))->first(); $summit_write_scope = ApiScope::where('name', '=', sprintf('%s/summits/write', $current_realm))->first(); $summit_write_event_scope = ApiScope::where('name', '=', sprintf('%s/summits/write-event', $current_realm))->first(); @@ -545,10 +581,13 @@ class ApiEndpointsSeeder extends Seeder $summit_delete_event_scope = ApiScope::where('name', '=', sprintf('%s/summits/delete-event', $current_realm))->first(); $summit_external_order_read = ApiScope::where('name', '=', sprintf('%s/summits/read-external-orders', $current_realm))->first(); $summit_external_order_confirm = ApiScope::where('name', '=', sprintf('%s/summits/confirm-external-orders', $current_realm))->first(); + $write_videos_scope = ApiScope::where('name', '=', sprintf('%s/summits/write-videos', $current_realm))->first(); // read $endpoint = ApiEndpoint::where('name', '=', 'get-summits')->first(); $endpoint->scopes()->attach($summit_read_scope->id); + $endpoint = ApiEndpoint::where('name', '=', 'get-own-member')->first(); + $endpoint->scopes()->attach($member_read_scope->id); $endpoint = ApiEndpoint::where('name', '=', 'get-summit')->first(); $endpoint->scopes()->attach($summit_read_scope->id); $endpoint = ApiEndpoint::where('name', '=', 'get-summit-entity-events')->first(); @@ -607,6 +646,9 @@ class ApiEndpointsSeeder extends Seeder $endpoint = ApiEndpoint::where('name', '=', 'add-event-feedback')->first(); $endpoint->scopes()->attach($summit_write_scope->id); + $endpoint = ApiEndpoint::where('name', '=', 'add-event-feedback-v2')->first(); + $endpoint->scopes()->attach($summit_write_scope->id); + // write events $endpoint = ApiEndpoint::where('name', '=', 'add-event')->first(); $endpoint->scopes()->attach($summit_write_event_scope->id); @@ -627,6 +669,11 @@ class ApiEndpointsSeeder extends Seeder $endpoint = ApiEndpoint::where('name', '=', 'confirm-external-order')->first(); $endpoint->scopes()->attach($summit_external_order_confirm->id); + //write videos + $endpoint = ApiEndpoint::where('name', '=', 'create-presentation-video')->first(); + $endpoint->scopes()->attach($write_videos_scope->id); + + } } \ No newline at end of file diff --git a/database/seeds/ApiScopesSeeder.php b/database/seeds/ApiScopesSeeder.php index 93683456..387eaa2f 100644 --- a/database/seeds/ApiScopesSeeder.php +++ b/database/seeds/ApiScopesSeeder.php @@ -101,6 +101,16 @@ class ApiScopesSeeder extends Seeder ) ); + ApiScope::create( + array( + 'name' => sprintf('%s/me/read', $current_realm), + 'short_description' => 'Get own member data', + 'description' => 'Grants read only access for our own member data', + 'api_id' => $summits->id, + 'system' => false + ) + ); + ApiScope::create( array( 'name' => sprintf('%s/summits/write', $current_realm), @@ -160,6 +170,16 @@ class ApiScopesSeeder extends Seeder 'system' => false ) ); + + ApiScope::create( + array( + 'name' => sprintf('%s/summits/write-videos', $current_realm), + 'short_description' => 'Allow to write presentation videos', + 'description' => 'Allow to write presentation videos', + 'api_id' => $summits->id, + 'system' => false + ) + ); } } \ No newline at end of file diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index b3d8fc03..982214f9 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -1,20 +1,21 @@ call(UsersTableSeeder::class); + Model::unguard(); $this->call('ApiSeeder'); $this->call('ApiScopesSeeder'); $this->call('ApiEndpointsSeeder'); } -} \ No newline at end of file +} diff --git a/gulpfile.js b/gulpfile.js index 7cf62673..dc6f1ebb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,11 +6,11 @@ var elixir = require('laravel-elixir'); |-------------------------------------------------------------------------- | | Elixir provides a clean, fluent API for defining some basic Gulp tasks - | for your Laravel application. By default, we are compiling the Less + | for your Laravel application. By default, we are compiling the Sass | file for our application, as well as publishing vendor resources. | */ elixir(function(mix) { - mix.less('app.less'); + mix.sass('app.scss'); }); diff --git a/package.json b/package.json index 5595f071..87481c73 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,12 @@ { "private": true, + "scripts": { + "prod": "gulp --production", + "dev": "gulp watch" + }, "devDependencies": { - "gulp": "^3.8.8", - "laravel-elixir": "*" + "gulp": "^3.9.1", + "laravel-elixir": "^5.0.0", + "bootstrap-sass": "^3.3.0" } } diff --git a/phpspec.yml b/phpspec.yml deleted file mode 100644 index eb57939e..00000000 --- a/phpspec.yml +++ /dev/null @@ -1,5 +0,0 @@ -suites: - main: - namespace: App - psr4_prefix: App - src_path: app \ No newline at end of file diff --git a/public/.htaccess b/public/.htaccess index 77827ae7..903f6392 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -5,11 +5,16 @@ RewriteEngine On - # Redirect Trailing Slashes... + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] + + # Handle Authorization Header + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] diff --git a/public/index.php b/public/index.php index 37f19c23..c5820533 100644 --- a/public/index.php +++ b/public/index.php @@ -1,4 +1,5 @@ make('Illuminate\Contracts\Http\Kernel'); +$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); $response = $kernel->handle( - $request = Illuminate\Http\Request::capture() + $request = Illuminate\Http\Request::capture() ); $response->send(); diff --git a/public/web.config b/public/web.config new file mode 100644 index 00000000..624c1760 --- /dev/null +++ b/public/web.config @@ -0,0 +1,23 @@ +