
Doc https://docs.google.com/document/d/1gOAceevwutF3QHYWD0_6aESQMZEiIz3YVBVXlyUuRy8 * Summit Registration External Feed https://docs.google.com/document/d/1_2QZUK--A350jxh2USKBtVtisKrrcUcVjdKnbcZ7-4M/edit# * Multi Stripe Config * Added stripe payment configuration per summit * Added webhook automatic creation * Added CRUD endpoints for payment profiles per summit GET api/v1/summits/{id}/payment-gateway-profiles filters active ['=='] application_type ['=@', '=='] scopes summits/read/all summits/payment-gateway-profiles/read POST api/v1/summits/{id}/payment-gateway-profiles payload 'active' => 'sometimes|boolean', 'application_type' => 'sometimes|string|in:Registration,BookableRooms' 'provider' => 'required|string|in:Stripe', 'test_mode_enabled' => 'required|boolean', 'live_secret_key' => 'sometimes|string', 'live_publishable_key' => 'required_with:live_secret_key|string', 'test_secret_key' => 'sometimes|string', 'test_publishable_key' => 'required_with:test_secret_key|string' scopes summits/write summits/payment-gateway-profiles/write GET api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id} scopes summits/read/all summits/payment-gateway-profiles/read PUT api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id} payload 'active' => 'sometimes|boolean', 'application_type' => 'sometimes|string|in:Registration,BookableRooms' 'provider' => 'required|string|in:Stripe', 'test_mode_enabled' => 'required|boolean', 'live_secret_key' => 'sometimes|string', 'live_publishable_key' => 'required_with:live_secret_key|string', 'test_secret_key' => 'sometimes|string', 'test_publishable_key' => 'required_with:test_secret_key|string' scopes summits/payment-gateway-profiles/write summits/write DELETE api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id} scopes summits/payment-gateway-profiles/write summits/write Stripe Webhooks default webhook (SECRET set per application under .env, should be created previously on stripe default account) POST api/public/v1/summits/all/payments/{application_name}/confirm where application_name could be Registration or BookableRooms otherwise if a stripe account is set per summit, when the profile gets activated a webhook will be automatically be created using following url POST api/public/v1/summits/{id}/payments/{application_name}/confirm * Email API Integration * moved all blade templates to mail api ( DB Seeding) * defined email events flows per summmit * created endpoint to set up templates per email events on each flow PUT /api/v1/summits/{id}/email-flows-events/{event_id} payload email_template_identifier: string * added endpoint to get all email events per summit GET /api/v1/summits/{id}/email-flows-events * added endpoint to get email event per summit/id GET /api/v1/summits/{id}/email-flows-events/{event_id} Summit Documents endpoints add summit document POST /api/v1/summits/{id}/summit-documents payload file (mandatory|file stream) label ( mandatory|string) name ( mandatory|string) description (optional|string) get all summit documents GET /api/v1/summits/{id}/summit-documents get by id GET /api/v1/summits/{id}/summit-documents/{document_id} update PUT GET /api/v1/summits/{id}/summit-documents/{document_id} file (optional|file stream) label (optional|string) name (optional|string) description (optional|string) delete DELETE GET /api/v1/summits/{id}/summit-documents/{document_id} add event type to doc PUT /api/v1/summits/{id}/summit-documents/{document_id}/event-types/{event_type_id} delete event type from doc DELETE /api/v1/summits/{id}/summit-documents/{document_id}/event-types/{event_type_id} add document to event type PUT /api/v1/summits/{id}/event-types/{event_type_id}/summit-documents/{document_id} delete document from event type DELETE /api/v1/summits/{id}/event-types/{event_type_id}/summit-documents/{document_id} Updated Summit events to support streaming url, meeting_url and etherpad link * Summit Registration - Invite only Summit Administrator Permission Groups GET /api/v1/summit-administrator-groups filter * title * member_first_name * member_last_name * member_full_name * member_email * summit_id * member_id ordering id title scopes %s/summit-administrator-groups/read /api/v1/summit-administrator-groups/{group_id} scopes %s/summit-administrator-groups/read POST /api/v1/summit-administrator-groups title summits members scopes %s/summit-administrator-groups/write PUT /api/v1/summit-administrator-groups/{group_id} title summits members scopes %s/summit-administrator-groups/write DELETE /api/v1/summit-administrator-groups/{group_id} scopes %s/summit-administrator-groups/write PUT /api/v1/summit-administrator-groups/{group_id}/members/{member_id} DELETE /api/v1/summit-administrator-groups/{group_id}/members/{member_id} PUT /api/v1/summit-administrator-groups/{group_id}/summits/{summit_id} DELETE /api/v1/summit-administrator-groups/{group_id}/summits/{summit_id} Room Metrics PUT /api/v1/summits/{id}/members/{member_id}/schedule/{event_id}/enter Scopes %s/me/summits/events/enter PUT /api/v1/summits/{id}/members/{member_id}/schedule/{event_id}/leave %s/me/summits/events/leave update summit_event serializer new fields total_attendance_count current_attendance_count attendance current_attendance Added new Speakers Endpoints GET /api/v1/summits/{id}/speakers/on-schedule retrieves all speakers on summit schedule filters 'first_name' => ['=@', '=='], 'last_name' => ['=@', '=='], 'email' => ['=@', '=='], 'id' => ['=='], 'full_name' => ['=@', '=='], 'start_date' => ['>', '<', '<=', '>=', '=='], 'end_date' => ['>', '<', '<=', '>=', '=='], Summit Events Image POST /api/v1/summits/{id}/events/{event_id}/image DELETE /api/v1/summits/{id}/events/{event_id}/image Speakers Image Big Pic POST /api/v1/speakers/{speaker_id}/big-photo DELETE /api/v1/speakers/{speaker_id}/big-photo CFP - multiple summits Presentation Materials - Media Uploads New Endpoints GET api/v1/summit-media-file-types filter 'name' => ['=@', '=='] order id, name POST api/v1/summit-media-file-types payload 'name' => 'required|string|max:255', 'description' => 'sometimes|string|max:255', 'allowed_extensions' => 'required|string_array', GET api/v1/summit-media-file-types/{id} PUT api/v1/summit-media-file-types/{id} payload 'name' => 'sometimes|string|max:255', 'description' => 'sometimes|string|max:255', 'allowed_extensions' => 'required|string_array', DELETE api/v1/summit-media-file-types/{id} GET api/v1/summits/{id}/media-upload-types POST payload 'name' => 'required|string|max:255', 'description' => 'sometimes|string|max:255', 'is_mandatory' => 'required|boolean', 'max_size' => 'required|int|megabyte_aligned', 'private_storage_type' => 'required|string|in:None,DropBox,Swift,Local', 'public_storage_type' => 'required|string|in:None,DropBox,Swift,Local' 'type_id' => 'required|int', 'presentation_types' => 'sometimes|int_array', GET api/v1/summits/{id}/media-upload-types/{media_upload_type_id} PUT api/v1/summits/{id}/media-upload-types/{media_upload_type_id} payload 'name' => 'sometimes|string|max:255', 'description' => 'sometimes|string|max:255', 'is_mandatory' => 'sometimes|boolean', 'max_size' => 'sometimes|int|megabyte_aligned', 'private_storage_type' => 'sometimes|string|in:None,DropBox,Swift,Local', 'public_storage_type' => 'sometimes|string|in:None,DropBox,Swift,Local' 'type_id' => 'sometimes|int', 'presentation_types' => 'sometimes|int_array', DELETE api/v1/summits/{id}/media-upload-types/{media_upload_type_id} PUT api/v1/summits/{id}/media-upload-types/{media_upload_type_id}/presentation-types/{event_type_id} DELETE api/v1/summits/{id}/media-upload-types/{media_upload_type_id}/presentation-types/{event_type_id} GET api/v1/summits/{id}/presentations/{presentation_id}/media-uploads POST api/v1/summits/{id}/presentations/{presentation_id}/media-uploads payload multiform file media_upload_type_id GET api/v1/summits/{id}/presentations/{presentation_id}/media-uploads/{media_upload_id} PUT api/v1/summits/{id}/presentations/{presentation_id}/media-uploads/{media_upload_id} payload multiform file DELETE api/v1/summits/{id}/presentations/{presentation_id}/media-uploads/{media_upload_id} POST /api/v1/summits/{id}/media-upload-types/all/clone/{to_summit_id} Summit Invitation Only endpoints V2 CRUD invitations Change-Id: Ia23c247a59c3810f2a738265efdd890fe6f59dfb Signed-off-by: smarcet <smarcet@gmail.com>
1384 lines
49 KiB
PHP
1384 lines
49 KiB
PHP
<?php namespace App\Http\Controllers;
|
|
/**
|
|
* Copyright 2016 OpenStack Foundation
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
**/
|
|
use App\Models\Foundation\Summit\Repositories\ISelectionPlanRepository;
|
|
use Exception;
|
|
use Illuminate\Support\Facades\Input;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Request;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use libs\utils\HTMLCleaner;
|
|
use models\exceptions\EntityNotFoundException;
|
|
use models\exceptions\ValidationException;
|
|
use models\main\IMemberRepository;
|
|
use models\oauth2\IResourceServerContext;
|
|
use models\summit\IEventFeedbackRepository;
|
|
use models\summit\ISpeakerRepository;
|
|
use models\summit\ISummitEventRepository;
|
|
use models\summit\ISummitRepository;
|
|
use models\summit\PresentationSpeaker;
|
|
use ModelSerializers\ISerializerTypeSelector;
|
|
use ModelSerializers\SerializerRegistry;
|
|
use services\model\ISpeakerService;
|
|
use services\model\ISummitService;
|
|
use utils\PagingInfo;
|
|
use Illuminate\Http\Request as LaravelRequest;
|
|
use utils\PagingResponse;
|
|
/**
|
|
* Class OAuth2SummitSpeakersApiController
|
|
* @package App\Http\Controllers
|
|
*/
|
|
final class OAuth2SummitSpeakersApiController extends OAuth2ProtectedController
|
|
{
|
|
/**
|
|
* @var ISpeakerService
|
|
*/
|
|
private $service;
|
|
|
|
/**
|
|
* @var ISpeakerRepository
|
|
*/
|
|
private $speaker_repository;
|
|
|
|
/**
|
|
* @var ISummitEventRepository
|
|
*/
|
|
private $event_repository;
|
|
|
|
/**
|
|
* @var IEventFeedbackRepository
|
|
*/
|
|
private $event_feedback_repository;
|
|
|
|
/**
|
|
* @var IMemberRepository
|
|
*/
|
|
private $member_repository;
|
|
|
|
/**
|
|
* @var ISerializerTypeSelector
|
|
*/
|
|
private $serializer_type_selector;
|
|
|
|
/**
|
|
* @var ISelectionPlanRepository
|
|
*/
|
|
private $selection_plan_repository;
|
|
|
|
/**
|
|
* @var ISummitService
|
|
*/
|
|
private $summit_service;
|
|
|
|
/**
|
|
* OAuth2SummitSpeakersApiController constructor.
|
|
* @param ISummitRepository $summit_repository
|
|
* @param ISummitEventRepository $event_repository
|
|
* @param ISpeakerRepository $speaker_repository
|
|
* @param IEventFeedbackRepository $event_feedback_repository
|
|
* @param IMemberRepository $member_repository
|
|
* @param ISelectionPlanRepository $selection_plan_repository
|
|
* @param ISpeakerService $service
|
|
* @param ISummitService $summit_service
|
|
* @param ISerializerTypeSelector $serializer_type_selector
|
|
* @param IResourceServerContext $resource_server_context
|
|
*/
|
|
public function __construct
|
|
(
|
|
ISummitRepository $summit_repository,
|
|
ISummitEventRepository $event_repository,
|
|
ISpeakerRepository $speaker_repository,
|
|
IEventFeedbackRepository $event_feedback_repository,
|
|
IMemberRepository $member_repository,
|
|
ISelectionPlanRepository $selection_plan_repository,
|
|
ISpeakerService $service,
|
|
ISummitService $summit_service,
|
|
ISerializerTypeSelector $serializer_type_selector,
|
|
IResourceServerContext $resource_server_context
|
|
)
|
|
{
|
|
parent::__construct($resource_server_context);
|
|
$this->repository = $summit_repository;
|
|
$this->speaker_repository = $speaker_repository;
|
|
$this->event_repository = $event_repository;
|
|
$this->member_repository = $member_repository;
|
|
$this->event_feedback_repository = $event_feedback_repository;
|
|
$this->selection_plan_repository = $selection_plan_repository;
|
|
$this->service = $service;
|
|
$this->summit_service = $summit_service;
|
|
$this->serializer_type_selector = $serializer_type_selector;
|
|
}
|
|
|
|
/**
|
|
* Speakers endpoints
|
|
*/
|
|
|
|
use ParametrizedGetAll;
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function getSpeakers($summit_id)
|
|
{
|
|
$summit = SummitFinderStrategyFactory::build($this->getRepository(), $this->getResourceServerContext())->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
return $this->_getAll(
|
|
function(){
|
|
return [
|
|
'first_name' => ['=@', '=='],
|
|
'last_name' => ['=@', '=='],
|
|
'email' => ['=@', '=='],
|
|
'id' => ['=='],
|
|
'full_name' => ['=@', '=='],
|
|
];
|
|
},
|
|
function(){
|
|
return [
|
|
'first_name' => 'sometimes|string',
|
|
'last_name' => 'sometimes|string',
|
|
'email' => 'sometimes|string',
|
|
'id' => 'sometimes|integer',
|
|
'full_name' => 'sometimes|string',
|
|
];
|
|
},
|
|
function()
|
|
{
|
|
return [
|
|
'first_name',
|
|
'last_name',
|
|
'id',
|
|
'email',
|
|
];
|
|
},
|
|
function($filter) use($summit){
|
|
return $filter;
|
|
},
|
|
function(){
|
|
return $this->serializer_type_selector->getSerializerType();
|
|
},
|
|
null,
|
|
null,
|
|
function ($page, $per_page, $filter, $order, $applyExtraFilters) use($summit) {
|
|
return $this->speaker_repository->getSpeakersBySummit
|
|
(
|
|
$summit,
|
|
new PagingInfo($page, $per_page),
|
|
call_user_func($applyExtraFilters, $filter),
|
|
$order
|
|
);
|
|
},
|
|
[
|
|
'summit_id' => $summit_id,
|
|
'published' => true,
|
|
'summit' => $summit
|
|
]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function getSpeakersOnSchedule($summit_id)
|
|
{
|
|
$summit = SummitFinderStrategyFactory::build($this->getRepository(), $this->getResourceServerContext())->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
return $this->_getAll(
|
|
function(){
|
|
return [
|
|
'first_name' => ['=@', '=='],
|
|
'last_name' => ['=@', '=='],
|
|
'email' => ['=@', '=='],
|
|
'id' => ['=='],
|
|
'full_name' => ['=@', '=='],
|
|
'event_start_date' => ['>', '<', '<=', '>=', '=='],
|
|
'event_end_date' => ['>', '<', '<=', '>=', '=='],
|
|
];
|
|
},
|
|
function(){
|
|
return [
|
|
'first_name' => 'sometimes|string',
|
|
'last_name' => 'sometimes|string',
|
|
'email' => 'sometimes|string',
|
|
'id' => 'sometimes|integer',
|
|
'full_name' => 'sometimes|string',
|
|
'event_start_date' => 'sometimes|date_format:U',
|
|
'event_end_date' => 'sometimes|date_format:U',
|
|
];
|
|
},
|
|
function()
|
|
{
|
|
return [
|
|
'first_name',
|
|
'last_name',
|
|
'id',
|
|
'email',
|
|
];
|
|
},
|
|
function($filter) use($summit){
|
|
return $filter;
|
|
},
|
|
function(){
|
|
return $this->serializer_type_selector->getSerializerType();
|
|
},
|
|
null,
|
|
null,
|
|
function ($page, $per_page, $filter, $order, $applyExtraFilters) use($summit) {
|
|
return $this->speaker_repository->getSpeakersBySummitAndOnSchedule
|
|
(
|
|
$summit,
|
|
new PagingInfo($page, $per_page),
|
|
call_user_func($applyExtraFilters, $filter),
|
|
$order
|
|
);
|
|
},
|
|
[
|
|
'summit_id' => $summit_id,
|
|
'published' => true,
|
|
'summit' => $summit
|
|
]
|
|
);
|
|
}
|
|
|
|
/**
|
|
* get all speakers without summit
|
|
* @return mixed
|
|
*/
|
|
public function getAll()
|
|
{
|
|
return $this->_getAll(
|
|
function(){
|
|
return [
|
|
'first_name' => ['=@', '=='],
|
|
'last_name' => ['=@', '=='],
|
|
'email' => ['=@', '=='],
|
|
'id' => ['=='],
|
|
'full_name' => ['=@', '=='],
|
|
];
|
|
},
|
|
function(){
|
|
return [
|
|
'first_name' => 'sometimes|string',
|
|
'last_name' => 'sometimes|string',
|
|
'email' => 'sometimes|string',
|
|
'id' => 'sometimes|integer',
|
|
'full_name' => 'sometimes|string',
|
|
];
|
|
},
|
|
function()
|
|
{
|
|
return [
|
|
'first_name',
|
|
'last_name',
|
|
'id',
|
|
'email',
|
|
];
|
|
},
|
|
function($filter){
|
|
return $filter;
|
|
},
|
|
function(){
|
|
return $this->serializer_type_selector->getSerializerType();
|
|
},
|
|
null,
|
|
null,
|
|
function ($page, $per_page, $filter, $order, $applyExtraFilters) {
|
|
return $this->speaker_repository->getAllByPage
|
|
(
|
|
new PagingInfo($page, $per_page),
|
|
call_user_func($applyExtraFilters, $filter),
|
|
$order
|
|
);
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $speaker_id
|
|
* @return mixed
|
|
*/
|
|
public function getSummitSpeaker($summit_id, $speaker_id)
|
|
{
|
|
try {
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->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();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
$serializer_type = SerializerRegistry::SerializerType_Public;
|
|
// if speaker profile belongs to current member
|
|
if (!is_null($current_member)){
|
|
if($speaker->getMemberId() == $current_member->getId())
|
|
$serializer_type = SerializerRegistry::SerializerType_Private;
|
|
}
|
|
|
|
return $this->ok
|
|
(
|
|
SerializerRegistry::getInstance()->getSerializer($speaker, $serializer_type)->serialize
|
|
(
|
|
Request::input('expand', ''),
|
|
[],
|
|
[],
|
|
['summit_id' => $summit_id, 'published' => true, 'summit' => $summit]
|
|
)
|
|
);
|
|
|
|
} catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
} 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
|
|
* @return mixed
|
|
*/
|
|
public function getMySummitSpeaker($summit_id){
|
|
try {
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$speaker = CheckSpeakerStrategyFactory::build(CheckSpeakerStrategyFactory::Me, $this->resource_server_context)->check('me', $summit);
|
|
if (is_null($speaker)) return $this->error404();
|
|
|
|
$serializer_type = SerializerRegistry::SerializerType_Private;
|
|
|
|
return $this->ok
|
|
(
|
|
SerializerRegistry::getInstance()->getSerializer($speaker, $serializer_type)->serialize
|
|
(
|
|
Request::input('expand', ''),
|
|
[],
|
|
[],
|
|
[
|
|
'summit_id' => $summit_id,
|
|
'published' => Request::input('published', false),
|
|
'summit' => $summit
|
|
]
|
|
)
|
|
);
|
|
|
|
} catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
} catch (EntityNotFoundException $ex2) {
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message' => $ex2->getMessage()));
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getMySpeaker()
|
|
{
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$speaker = $this->speaker_repository->getByMember($current_member);
|
|
if (is_null($speaker)) return $this->error404();
|
|
|
|
$serializer_type = SerializerRegistry::SerializerType_Private;
|
|
|
|
return $this->ok
|
|
(
|
|
SerializerRegistry::getInstance()->getSerializer($speaker, $serializer_type)->serialize
|
|
(
|
|
Request::input('expand', ''),
|
|
[],
|
|
[],
|
|
[]
|
|
)
|
|
);
|
|
|
|
} catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
} catch (EntityNotFoundException $ex2) {
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message' => $ex2->getMessage()));
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function createMySpeaker()
|
|
{
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
// set data from current member ...
|
|
$speaker = $this->service->addSpeaker([
|
|
'member_id' => $current_member->getId(),
|
|
'first_name' => $current_member->getFirstName(),
|
|
'last_name' => $current_member->getLastName(),
|
|
'bio' => $current_member->getBio(),
|
|
'twitter' => $current_member->getTwitterHandle(),
|
|
'irc' => $current_member->getIrcHandle(),
|
|
]);
|
|
|
|
$serializer_type = SerializerRegistry::SerializerType_Private;
|
|
|
|
return $this->ok
|
|
(
|
|
SerializerRegistry::getInstance()->getSerializer($speaker, $serializer_type)->serialize
|
|
(
|
|
Request::input('expand', ''),
|
|
[],
|
|
[],
|
|
[]
|
|
)
|
|
);
|
|
|
|
} catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
} catch (EntityNotFoundException $ex2) {
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message' => $ex2->getMessage()));
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function updateMySpeaker()
|
|
{
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$speaker = $this->speaker_repository->getByMember($current_member);
|
|
if (is_null($speaker)) return $this->error404();
|
|
|
|
return $this->updateSpeaker($speaker->getId());
|
|
|
|
} catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
} catch (EntityNotFoundException $ex2) {
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message' => $ex2->getMessage()));
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $speaker_id
|
|
* @return mixed
|
|
*/
|
|
public function getSpeaker($speaker_id)
|
|
{
|
|
try {
|
|
|
|
$speaker = $this->speaker_repository->getById($speaker_id);
|
|
if (is_null($speaker) || !$speaker instanceof PresentationSpeaker) return $this->error404();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
$serializer_type = SerializerRegistry::SerializerType_Public;
|
|
// if speaker profile belongs to current member
|
|
if (!is_null($current_member)){
|
|
if($speaker->getMemberId() == $current_member->getId() || $speaker->canBeEditedBy($current_member))
|
|
$serializer_type = SerializerRegistry::SerializerType_Private;
|
|
}
|
|
|
|
return $this->ok
|
|
(
|
|
SerializerRegistry::getInstance()->getSerializer($speaker, $serializer_type)->serialize
|
|
(
|
|
Request::input('expand', ''),
|
|
[],
|
|
[],
|
|
[]
|
|
)
|
|
);
|
|
|
|
} catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
} 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
|
|
* @return mixed
|
|
*/
|
|
public function addSpeakerBySummit($summit_id)
|
|
{
|
|
try {
|
|
if (!Request::isJson()) return $this->error400();
|
|
$data = Input::json();
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$rules = [
|
|
'title' => 'required|string|max:100',
|
|
'first_name' => 'required|string|max:100',
|
|
'last_name' => 'required|string|max:100',
|
|
'bio' => 'sometimes|string',
|
|
'irc' => 'sometimes|string|max:50',
|
|
'twitter' => 'sometimes|string|max:50',
|
|
'member_id' => 'sometimes|integer',
|
|
'email' => 'sometimes|email:rfc|max:50',
|
|
'on_site_phone' => 'sometimes|string|max:50',
|
|
'registered' => 'sometimes|boolean',
|
|
'is_confirmed' => 'sometimes|boolean',
|
|
'checked_in' => 'sometimes|boolean',
|
|
'registration_code' => 'sometimes|string',
|
|
'available_for_bureau' => 'sometimes|boolean',
|
|
'funded_travel' => 'sometimes|boolean',
|
|
'willing_to_travel' => 'sometimes|boolean',
|
|
'willing_to_present_video' => 'sometimes|boolean',
|
|
'org_has_cloud' => 'sometimes|boolean',
|
|
'country' => 'sometimes|string|country_iso_alpha2_code',
|
|
// collections
|
|
'languages' => 'sometimes|int_array',
|
|
'areas_of_expertise' => 'sometimes|string_array',
|
|
'other_presentation_links' => 'sometimes|link_array',
|
|
'travel_preferences' => 'sometimes|string_array',
|
|
'organizational_roles' => 'sometimes|int_array',
|
|
'other_organizational_rol' => 'sometimes|string|max:255',
|
|
'active_involvements' => 'sometimes|int_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 = [
|
|
'title',
|
|
'bio',
|
|
];
|
|
|
|
$speaker = $this->service->addSpeakerBySummit($summit, HTMLCleaner::cleanData($data->all(), $fields));
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($speaker)->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 $speaker_id
|
|
* @return mixed
|
|
*/
|
|
public function updateSpeakerBySummit($summit_id, $speaker_id)
|
|
{
|
|
try {
|
|
if (!Request::isJson()) return $this->error400();
|
|
$data = Input::json();
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$speaker = $this->speaker_repository->getById($speaker_id);
|
|
if (is_null($speaker)) return $this->error404();
|
|
|
|
$rules = [
|
|
'title' => 'sometimes|string|max:100',
|
|
'first_name' => 'sometimes|string|max:100',
|
|
'last_name' => 'sometimes|string|max:100',
|
|
'bio' => 'sometimes|string',
|
|
'irc' => 'sometimes|string|max:50',
|
|
'twitter' => 'sometimes|string|max:50',
|
|
'member_id' => 'sometimes|integer',
|
|
'email' => 'sometimes|email:rfc|max:50',
|
|
'on_site_phone' => 'sometimes|string|max:50',
|
|
'registered' => 'sometimes|boolean',
|
|
'is_confirmed' => 'sometimes|boolean',
|
|
'checked_in' => 'sometimes|boolean',
|
|
'registration_code' => 'sometimes|string',
|
|
'available_for_bureau' => 'sometimes|boolean',
|
|
'funded_travel' => 'sometimes|boolean',
|
|
'willing_to_travel' => 'sometimes|boolean',
|
|
'willing_to_present_video' => 'sometimes|boolean',
|
|
'org_has_cloud' => 'sometimes|boolean',
|
|
'country' => 'sometimes|country_iso_alpha2_code',
|
|
// collections
|
|
'languages' => 'sometimes|int_array',
|
|
'areas_of_expertise' => 'sometimes|string_array',
|
|
'other_presentation_links' => 'sometimes|link_array',
|
|
'travel_preferences' => 'sometimes|string_array',
|
|
'organizational_roles' => 'sometimes|int_array',
|
|
'other_organizational_rol' => 'sometimes|string|max:255',
|
|
'active_involvements' => 'sometimes|int_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 = [
|
|
'title',
|
|
'bio',
|
|
];
|
|
|
|
$speaker = $this->service->updateSpeakerBySummit($summit, $speaker, HTMLCleaner::cleanData($data->all(), $fields));
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer($speaker)->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);
|
|
}
|
|
}
|
|
|
|
public function addMySpeakerPhoto(LaravelRequest $request){
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$speaker = $this->speaker_repository->getByMember($current_member);
|
|
if (is_null($speaker)) return $this->error404();
|
|
|
|
return $this->addSpeakerPhoto($request, $speaker->getId());
|
|
|
|
} catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
} catch (EntityNotFoundException $ex2) {
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message' => $ex2->getMessage()));
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $speaker_from_id
|
|
* @param $speaker_to_id
|
|
* @return mixed
|
|
*/
|
|
public function merge($speaker_from_id, $speaker_to_id)
|
|
{
|
|
try {
|
|
if (!Request::isJson()) return $this->error400();
|
|
$data = Input::json();
|
|
|
|
$speaker_from = $this->speaker_repository->getById($speaker_from_id);
|
|
if (is_null($speaker_from)) return $this->error404();
|
|
|
|
$speaker_to = $this->speaker_repository->getById($speaker_to_id);
|
|
if (is_null($speaker_to)) return $this->error404();
|
|
|
|
$this->service->merge($speaker_from, $speaker_to, $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);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function addSpeaker()
|
|
{
|
|
try {
|
|
if (!Request::isJson()) return $this->error400();
|
|
$data = Input::json();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$rules = [
|
|
'title' => 'required|string|max:100',
|
|
'first_name' => 'required|string|max:100',
|
|
'last_name' => 'required|string|max:100',
|
|
'bio' => 'sometimes|string',
|
|
'notes' => 'sometimes|string',
|
|
'irc' => 'sometimes|string|max:50',
|
|
'twitter' => 'sometimes|string|max:50',
|
|
'member_id' => 'sometimes|integer',
|
|
'email' => 'sometimes|email:rfc|max:50',
|
|
'funded_travel' => 'sometimes|boolean',
|
|
'willing_to_travel' => 'sometimes|boolean',
|
|
'willing_to_present_video' => 'sometimes|boolean',
|
|
'org_has_cloud' => 'sometimes|boolean',
|
|
'available_for_bureau' => 'sometimes|boolean',
|
|
'country' => 'sometimes|country_iso_alpha2_code',
|
|
// collections
|
|
'languages' => 'sometimes|int_array',
|
|
'areas_of_expertise' => 'sometimes|string_array',
|
|
'other_presentation_links' => 'sometimes|link_array',
|
|
'travel_preferences' => 'sometimes|string_array',
|
|
'organizational_roles' => 'sometimes|int_array',
|
|
'other_organizational_rol' => 'sometimes|string|max:255',
|
|
'active_involvements' => 'sometimes|int_array',
|
|
'company' => 'sometimes|string|max:255',
|
|
'phone_number' => 'sometimes|string|max:255',
|
|
];
|
|
|
|
// 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 = [
|
|
'title',
|
|
'bio',
|
|
'notes'
|
|
];
|
|
|
|
$speaker = $this->service->addSpeaker(HTMLCleaner::cleanData($data->all(), $fields), $current_member);
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($speaker, SerializerRegistry::SerializerType_Private)->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 $speaker_id
|
|
* @return mixed
|
|
*/
|
|
public function updateSpeaker($speaker_id)
|
|
{
|
|
try {
|
|
if (!Request::isJson()) return $this->error400();
|
|
$data = Input::json();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$speaker = $this->speaker_repository->getById($speaker_id);
|
|
if (is_null($speaker)) return $this->error404();
|
|
|
|
if(!$speaker->canBeEditedBy($current_member)){
|
|
return $this->error403();
|
|
}
|
|
|
|
$rules = [
|
|
'title' => 'required|string|max:100',
|
|
'first_name' => 'required|string|max:100',
|
|
'last_name' => 'required|string|max:100',
|
|
'bio' => 'sometimes|string',
|
|
'notes' => 'sometimes|string',
|
|
'irc' => 'sometimes|string|max:50',
|
|
'twitter' => 'sometimes|string|max:50',
|
|
'member_id' => 'sometimes|integer',
|
|
'email' => 'sometimes|email:rfc|max:50',
|
|
'available_for_bureau' => 'sometimes|boolean',
|
|
'funded_travel' => 'sometimes|boolean',
|
|
'willing_to_travel' => 'sometimes|boolean',
|
|
'willing_to_present_video' => 'sometimes|boolean',
|
|
'org_has_cloud' => 'sometimes|boolean',
|
|
'country' => 'sometimes|country_iso_alpha2_code',
|
|
// collections
|
|
'languages' => 'sometimes|int_array',
|
|
'areas_of_expertise' => 'sometimes|string_array',
|
|
'other_presentation_links' => 'sometimes|link_array',
|
|
'travel_preferences' => 'sometimes|string_array',
|
|
'organizational_roles' => 'sometimes|int_array',
|
|
'other_organizational_rol' => 'sometimes|string|max:255',
|
|
'active_involvements' => 'sometimes|int_array',
|
|
'company' => 'sometimes|string|max:255',
|
|
'phone_number' => 'sometimes|string|max:255',
|
|
];
|
|
|
|
// 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 = [
|
|
'title',
|
|
'bio',
|
|
'notes',
|
|
];
|
|
|
|
$speaker = $this->service->updateSpeaker($speaker, HTMLCleaner::cleanData($data->all(), $fields));
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer($speaker, SerializerRegistry::SerializerType_Private)->serialize());
|
|
} catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412([$ex1->getMessage()]);
|
|
} catch (EntityNotFoundException $ex2) {
|
|
Log::warning($ex2);
|
|
return $this->error404(['message' => $ex2->getMessage()]);
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $speaker_id
|
|
* @return mixed
|
|
*/
|
|
public function deleteSpeaker($speaker_id)
|
|
{
|
|
try {
|
|
|
|
$speaker = $this->speaker_repository->getById($speaker_id);
|
|
if (is_null($speaker)) return $this->error404();
|
|
$this->service->deleteSpeaker($speaker_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 $role
|
|
* @param $selection_plan_id
|
|
* @return mixedf
|
|
*/
|
|
public function getMySpeakerPresentationsByRoleAndBySelectionPlan($role, $selection_plan_id)
|
|
{
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$speaker = $this->speaker_repository->getByMember($current_member);
|
|
if (is_null($speaker))
|
|
return $this->error403();
|
|
|
|
$selection_plan = $this->selection_plan_repository->getById($selection_plan_id);
|
|
if (is_null($selection_plan))
|
|
return $this->error404(['message' => 'missing selection plan']);
|
|
|
|
switch ($role) {
|
|
case 'creator':
|
|
$role = PresentationSpeaker::ROLE_CREATOR;
|
|
break;
|
|
case 'speaker':
|
|
$role = PresentationSpeaker::ROLE_SPEAKER;
|
|
break;
|
|
case 'moderator':
|
|
$role = PresentationSpeaker::ROLE_MODERATOR;
|
|
break;
|
|
}
|
|
$presentations = $speaker->getPresentationsBySelectionPlanAndRole($selection_plan, $role);
|
|
|
|
$response = new PagingResponse
|
|
(
|
|
count($presentations),
|
|
count($presentations),
|
|
1,
|
|
1,
|
|
$presentations
|
|
);
|
|
|
|
return $this->ok($response->toArray($expand = Input::get('expand', '')));
|
|
} 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 $role
|
|
* @param $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function getMySpeakerPresentationsByRoleAndBySummit($role, $summit_id)
|
|
{
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$speaker = $this->speaker_repository->getByMember($current_member);
|
|
if (is_null($speaker))
|
|
return $this->error403();
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404(['message' => 'missing selection summit']);
|
|
|
|
|
|
switch ($role) {
|
|
case 'creator':
|
|
$role = PresentationSpeaker::ROLE_CREATOR;
|
|
break;
|
|
case 'speaker':
|
|
$role = PresentationSpeaker::ROLE_SPEAKER;
|
|
break;
|
|
case 'moderator':
|
|
$role = PresentationSpeaker::ROLE_MODERATOR;
|
|
break;
|
|
}
|
|
$presentations = $speaker->getPresentationsBySummitAndRole($summit, $role);
|
|
|
|
$response = new PagingResponse
|
|
(
|
|
count($presentations),
|
|
count($presentations),
|
|
1,
|
|
1,
|
|
$presentations
|
|
);
|
|
|
|
return $this->ok($response->toArray($expand = Input::get('expand', '')));
|
|
} 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 $presentation_id
|
|
* @param $speaker_id
|
|
* @return mixed
|
|
*/
|
|
public function addSpeakerToMyPresentation($presentation_id, $speaker_id){
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$this->summit_service->addSpeaker2Presentation($current_member->getId(), $speaker_id, $presentation_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 (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $presentation_id
|
|
* @param $speaker_id
|
|
* @return mixed
|
|
*/
|
|
public function addModeratorToMyPresentation($presentation_id, $speaker_id){
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$this->summit_service->addModerator2Presentation($current_member->getId(), $speaker_id, $presentation_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 (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $presentation_id
|
|
* @param $speaker_id
|
|
* @return mixed
|
|
*/
|
|
public function removeSpeakerFromMyPresentation($presentation_id, $speaker_id){
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$this->summit_service->removeSpeakerFromPresentation($current_member->getId(), $speaker_id, $presentation_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 $presentation_id
|
|
* @param $speaker_id
|
|
* @return mixed
|
|
*/
|
|
public function removeModeratorFromMyPresentation($presentation_id, $speaker_id){
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$this->summit_service->removeModeratorFromPresentation($current_member->getId(), $speaker_id, $presentation_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 $speaker_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function requestSpeakerEditPermission($speaker_id){
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$request = $this->service->requestSpeakerEditPermission($current_member->getId(), $speaker_id);
|
|
|
|
return $this->created(
|
|
SerializerRegistry::getInstance()->getSerializer($request)
|
|
);
|
|
|
|
} 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 $speaker_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function getSpeakerEditPermission($speaker_id){
|
|
try {
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$request = $this->service->getSpeakerEditPermission($current_member->getId(), $speaker_id);
|
|
|
|
return $this->ok(
|
|
SerializerRegistry::getInstance()->getSerializer($request)->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 $speaker_id
|
|
* @param $hash
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function approveSpeakerEditPermission($speaker_id, $hash){
|
|
try {
|
|
$request = $this->service->approveSpeakerEditPermission($hash, $speaker_id);
|
|
return response()->view('speakers.edit_permissions.approved', [], 200);
|
|
} catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return response()->view('speakers.edit_permissions.approved_validation_error', [], 412);
|
|
} catch (EntityNotFoundException $ex2) {
|
|
Log::warning($ex2);
|
|
return response()->view('speakers.edit_permissions.approved_error', [], 404);
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return response()->view('speakers.edit_permissions.approved_error', [], 500);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $speaker_id
|
|
* @param $hash
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function declineSpeakerEditPermission($speaker_id, $hash){
|
|
try {
|
|
|
|
$request = $this->service->rejectSpeakerEditPermission($hash, $speaker_id);
|
|
return response()->view('speakers.edit_permissions.rejected', [], 200);
|
|
} catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return response()->view('speakers.edit_permissions.rejected_validation_error', [], 412);
|
|
} catch (EntityNotFoundException $ex2) {
|
|
Log::warning($ex2);
|
|
return response()->view('speakers.edit_permissions.rejected_error', [], 404);
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return response()->view('speakers.edit_permissions.rejected_error', [], 500);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param LaravelRequest $request
|
|
* @param $speaker_id
|
|
* @return mixed
|
|
*/
|
|
public function addSpeakerPhoto(LaravelRequest $request, $speaker_id)
|
|
{
|
|
try {
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$speaker = $this->speaker_repository->getById($speaker_id);
|
|
if (is_null($speaker)) return $this->error404();
|
|
|
|
if(!$speaker->canBeEditedBy($current_member)){
|
|
return $this->error403();
|
|
}
|
|
|
|
$file = $request->file('file');
|
|
if (is_null($file)) {
|
|
return $this->error412(array('file param not set!'));
|
|
}
|
|
|
|
$photo = $this->service->addSpeakerPhoto($speaker_id, $file);
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($photo)->serialize());
|
|
|
|
} 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);
|
|
}
|
|
}
|
|
|
|
public function deleteSpeakerPhoto($speaker_id){
|
|
try {
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$speaker = $this->speaker_repository->getById($speaker_id);
|
|
if (is_null($speaker)) return $this->error404();
|
|
|
|
if(!$speaker->canBeEditedBy($current_member)){
|
|
return $this->error403();
|
|
}
|
|
|
|
$this->service->deleteSpeakerPhoto($speaker_id);
|
|
|
|
return $this->deleted();
|
|
|
|
} 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);
|
|
}
|
|
}
|
|
|
|
public function addSpeakerBigPhoto(LaravelRequest $request, $speaker_id){
|
|
try {
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$speaker = $this->speaker_repository->getById($speaker_id);
|
|
if (is_null($speaker)) return $this->error404();
|
|
|
|
if(!$speaker->canBeEditedBy($current_member)){
|
|
return $this->error403();
|
|
}
|
|
|
|
$file = $request->file('file');
|
|
if (is_null($file)) {
|
|
return $this->error412(array('file param not set!'));
|
|
}
|
|
|
|
$photo = $this->service->addSpeakerBigPhoto($speaker_id, $file);
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($photo)->serialize());
|
|
|
|
} 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);
|
|
}
|
|
}
|
|
|
|
public function deleteSpeakerBigPhoto($speaker_id){
|
|
try {
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$speaker = $this->speaker_repository->getById($speaker_id);
|
|
if (is_null($speaker)) return $this->error404();
|
|
|
|
if(!$speaker->canBeEditedBy($current_member)){
|
|
return $this->error403();
|
|
}
|
|
|
|
$this->service->deleteSpeakerBigPhoto($speaker_id);
|
|
|
|
return $this->deleted();
|
|
|
|
} 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);
|
|
}
|
|
}
|
|
|
|
|
|
} |