
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>
1256 lines
43 KiB
PHP
1256 lines
43 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\Http\Utils\FileTypes;
|
|
use App\Http\Utils\MultipartFormDataCleaner;
|
|
use libs\utils\HTMLCleaner;
|
|
use models\exceptions\EntityNotFoundException;
|
|
use models\exceptions\ValidationException;
|
|
use models\main\IMemberRepository;
|
|
use models\oauth2\IResourceServerContext;
|
|
use models\summit\ISummitEventRepository;
|
|
use models\summit\ISummitRepository;
|
|
use Illuminate\Support\Facades\Request;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Support\Facades\Input;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Http\Request as LaravelRequest;
|
|
use Exception;
|
|
use models\summit\Presentation;
|
|
use models\utils\IEntity;
|
|
use ModelSerializers\SerializerRegistry;
|
|
use services\model\IPresentationService;
|
|
/**
|
|
* Class OAuth2PresentationApiController
|
|
* @package App\Http\Controllers
|
|
*/
|
|
final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
|
{
|
|
/**
|
|
* @var ISummitRepository
|
|
*/
|
|
private $summit_repository;
|
|
|
|
/**
|
|
* @var IPresentationService
|
|
*/
|
|
private $presentation_service;
|
|
|
|
/**
|
|
* @var ISummitEventRepository
|
|
*/
|
|
private $presentation_repository;
|
|
|
|
/**
|
|
* @var IMemberRepository
|
|
*/
|
|
private $member_repository;
|
|
|
|
/**
|
|
* OAuth2PresentationApiController constructor.
|
|
* @param IPresentationService $presentation_service
|
|
* @param ISummitRepository $summit_repository
|
|
* @param ISummitEventRepository $presentation_repository
|
|
* @param IMemberRepository $member_repository
|
|
* @param IResourceServerContext $resource_server_context
|
|
*/
|
|
public function __construct
|
|
(
|
|
IPresentationService $presentation_service,
|
|
ISummitRepository $summit_repository,
|
|
ISummitEventRepository $presentation_repository,
|
|
IMemberRepository $member_repository,
|
|
IResourceServerContext $resource_server_context
|
|
)
|
|
{
|
|
parent::__construct($resource_server_context);
|
|
$this->presentation_repository = $presentation_repository;
|
|
$this->presentation_service = $presentation_service;
|
|
$this->member_repository = $member_repository;
|
|
$this->summit_repository = $summit_repository;
|
|
}
|
|
|
|
//presentations
|
|
|
|
//videos
|
|
|
|
public function getPresentationVideos($summit_id, $presentation_id){
|
|
try {
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$presentation = $this->presentation_repository->getById($presentation_id);
|
|
|
|
if (is_null($presentation)) return $this->error404();
|
|
|
|
$videos = $presentation->getVideos();
|
|
|
|
$items = [];
|
|
foreach($videos as $i)
|
|
{
|
|
if($i instanceof IEntity)
|
|
{
|
|
$i = SerializerRegistry::getInstance()->getSerializer($i)->serialize();
|
|
}
|
|
$items[] = $i;
|
|
}
|
|
|
|
return $this->ok($items);
|
|
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @param $video_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function getPresentationVideo($summit_id, $presentation_id, $video_id){
|
|
try {
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$presentation = $this->presentation_repository->getById($presentation_id);
|
|
|
|
if (is_null($presentation)) return $this->error404();
|
|
|
|
$video = $presentation->getVideoBy($video_id);
|
|
|
|
if (is_null($video)) return $this->error404();
|
|
|
|
return $this->ok(SerializerRegistry::getInstance()->getSerializer($video)->serialize());
|
|
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param LaravelRequest $request
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function addVideo(LaravelRequest $request, $summit_id, $presentation_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
if(!Request::isJson()) return $this->error400();
|
|
|
|
$data = Input::json();
|
|
|
|
$rules =
|
|
[
|
|
'youtube_id' => 'required|alpha_dash',
|
|
'name' => 'sometimes|required|string:512',
|
|
'description' => 'sometimes|required|string',
|
|
'featured' => 'sometimes|required|boolean',
|
|
'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;
|
|
}
|
|
|
|
$fields = [
|
|
'name',
|
|
'description',
|
|
];
|
|
|
|
$video = $this->presentation_service->addVideoTo($presentation_id, HTMLCleaner::cleanData($data, $fields));
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($video)->serialize());
|
|
}
|
|
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 LaravelRequest $request
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @param $video_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function updateVideo(LaravelRequest $request, $summit_id, $presentation_id, $video_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
if(!Request::isJson()) return $this->error400();
|
|
|
|
$data = Input::json();
|
|
|
|
$rules = [
|
|
'youtube_id' => 'required|alpha_dash',
|
|
'name' => 'sometimes|required|string:512',
|
|
'description' => 'sometimes|required|string',
|
|
'display_on_site' => 'sometimes|required|boolean',
|
|
'featured' => 'sometimes|required|boolean',
|
|
'order' => 'sometimes|integer|min:1',
|
|
];
|
|
|
|
$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;
|
|
}
|
|
|
|
$fields = [
|
|
'name',
|
|
'description',
|
|
];
|
|
|
|
$video = $this->presentation_service->updateVideo($presentation_id, $video_id, HTMLCleaner::cleanData($data, $fields));
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer($video)->serialize());
|
|
}
|
|
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 $presentation_id
|
|
* @param $video_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function deleteVideo($summit_id, $presentation_id, $video_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$this->presentation_service->deleteVideo($presentation_id, $video_id);
|
|
|
|
return $this->deleted();
|
|
}
|
|
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 submitPresentation($summit_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
if(!Request::isJson()) return $this->error400();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$data = Input::json();
|
|
|
|
$rules =
|
|
[
|
|
'title' => 'required|string|max:255',
|
|
'description' => 'required|string|max:1100',
|
|
'social_description' => 'required|string|max:110',
|
|
'level' => 'required|in:Beginner,Intermediate,Advanced,N/A',
|
|
'attendees_expected_learnt' => 'required|string|max:1100',
|
|
'type_id' => 'required|integer',
|
|
'track_id' => 'required|integer',
|
|
'attending_media' => 'required|boolean',
|
|
'links' => 'sometimes|url_array',
|
|
'extra_questions' => 'sometimes|entity_value_array',
|
|
'tags' => 'sometimes|string_array',
|
|
];
|
|
|
|
$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;
|
|
}
|
|
|
|
$fields = [
|
|
'title',
|
|
'description',
|
|
'social_summary',
|
|
'attendees_expected_learnt',
|
|
];
|
|
|
|
$presentation = $this->presentation_service->submitPresentation($summit, $current_member, HTMLCleaner::cleanData($data, $fields));
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($presentation)->serialize(Request::input('expand', '')));
|
|
}
|
|
catch (EntityNotFoundException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error404(['message' => $ex1->getMessage()]);
|
|
}
|
|
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 $presentation_id
|
|
* @return mixed
|
|
*/
|
|
public function updatePresentationSubmission($summit_id, $presentation_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
if(!Request::isJson()) return $this->error400();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$data = Input::json();
|
|
|
|
$rules =
|
|
[
|
|
'title' => 'required|string|max:255',
|
|
'description' => 'required|string|max:1100',
|
|
'social_description' => 'required|string|max:110',
|
|
'level' => 'required|in:Beginner,Intermediate,Advanced,N/A',
|
|
'attendees_expected_learnt' => 'required|string|max:1100',
|
|
'type_id' => 'required|integer',
|
|
'track_id' => 'required|integer',
|
|
'attending_media' => 'required|boolean',
|
|
'links' => 'sometimes|url_array',
|
|
'extra_questions' => 'sometimes|entity_value_array',
|
|
'tags' => 'sometimes|string_array',
|
|
];
|
|
|
|
$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;
|
|
}
|
|
|
|
$fields = [
|
|
'title',
|
|
'description',
|
|
'social_summary',
|
|
'attendees_expected_learnt',
|
|
];
|
|
|
|
$presentation = $this->presentation_service->updatePresentationSubmission(
|
|
$summit,
|
|
$presentation_id,
|
|
$current_member,
|
|
HTMLCleaner::cleanData($data, $fields)
|
|
);
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer($presentation)->serialize(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 $presentation_id
|
|
* @return mixed
|
|
*/
|
|
public function completePresentationSubmission($summit_id, $presentation_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$presentation = $this->presentation_service->completePresentationSubmission
|
|
(
|
|
$summit,
|
|
$presentation_id,
|
|
$current_member
|
|
);
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer($presentation)->serialize(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 $presentation_id
|
|
* @return mixed
|
|
*/
|
|
public function deletePresentation($summit_id, $presentation_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
$this->presentation_service->deletePresentation($summit, $current_member, $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);
|
|
}
|
|
}
|
|
|
|
// Slides
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function getPresentationSlides($summit_id, $presentation_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$presentation = $this->presentation_repository->getById($presentation_id);
|
|
|
|
if (is_null($presentation)) return $this->error404();
|
|
|
|
$slides = $presentation->getSlides();
|
|
|
|
$items = [];
|
|
foreach($slides as $i)
|
|
{
|
|
if($i instanceof IEntity)
|
|
{
|
|
$i = SerializerRegistry::getInstance()->getSerializer($i)->serialize();
|
|
}
|
|
$items[] = $i;
|
|
}
|
|
|
|
return $this->ok($items);
|
|
|
|
} 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 $presentation_id
|
|
* @param $slide_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function getPresentationSlide($summit_id, $presentation_id, $slide_id){
|
|
try {
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$presentation = $this->presentation_repository->getById($presentation_id);
|
|
|
|
if (is_null($presentation)) return $this->error404();
|
|
|
|
$slide = $presentation->getSlideBy($slide_id);
|
|
|
|
if (is_null($slide)) return $this->error404();
|
|
|
|
return $this->ok(SerializerRegistry::getInstance()->getSerializer($slide)->serialize());
|
|
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param LaravelRequest $request
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function addPresentationSlide(LaravelRequest $request, $summit_id, $presentation_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
if(!$current_member->isAdmin()){
|
|
// check if we could edit presentation
|
|
$presentation = $summit->getEvent($presentation_id);
|
|
if(is_null($presentation) || !$presentation instanceof Presentation)
|
|
return $this->error404();
|
|
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
|
return $this->error403();
|
|
}
|
|
|
|
$data = $request->all();
|
|
$data = MultipartFormDataCleaner::cleanBool('display_on_site', $data);
|
|
$data = MultipartFormDataCleaner::cleanBool('featured', $data);
|
|
|
|
$rules = [
|
|
'file' => 'required_without:link',
|
|
'link' => 'required_without:file|url',
|
|
'name' => 'required|string:512',
|
|
'description' => 'nullable|string',
|
|
'display_on_site' => 'nullable|boolean',
|
|
'featured' => 'nullable|boolean',
|
|
];
|
|
|
|
// 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;
|
|
}
|
|
|
|
$fields = [
|
|
'name',
|
|
'description',
|
|
];
|
|
|
|
$slide = $this->presentation_service->addSlideTo
|
|
(
|
|
$request,
|
|
$presentation_id,
|
|
HTMLCleaner::cleanData($data, $fields),
|
|
array_merge(FileTypes::ImagesExntesions, FileTypes::SlidesExtensions)
|
|
);
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($slide)->serialize());
|
|
}
|
|
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 LaravelRequest $request
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @param $slide_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function updatePresentationSlide(LaravelRequest $request, $summit_id, $presentation_id, $slide_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
|
|
if(!$current_member->isAdmin()){
|
|
// check if we could edit presentation
|
|
$presentation = $summit->getEvent($presentation_id);
|
|
if(is_null($presentation) || !$presentation instanceof Presentation)
|
|
return $this->error404();
|
|
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
|
return $this->error403();
|
|
}
|
|
|
|
$data = $request->all();
|
|
$data = MultipartFormDataCleaner::cleanBool('display_on_site', $data);
|
|
$data = MultipartFormDataCleaner::cleanBool('featured', $data);
|
|
$data = MultipartFormDataCleaner::cleanInt('order', $data);
|
|
|
|
$rules = [
|
|
'link' => 'nullable|url',
|
|
'name' => 'nullable|string:512',
|
|
'description' => 'nullable|string',
|
|
'display_on_site' => 'nullable|boolean',
|
|
'featured' => 'nullable|boolean',
|
|
'order' => 'nullable|integer|min:1',
|
|
];
|
|
|
|
// 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;
|
|
}
|
|
|
|
$fields = [
|
|
'name',
|
|
'description',
|
|
];
|
|
|
|
$slide = $this->presentation_service->updateSlide
|
|
(
|
|
$request,
|
|
$presentation_id,
|
|
$slide_id,
|
|
HTMLCleaner::cleanData($data, $fields),
|
|
array_merge(FileTypes::ImagesExntesions, FileTypes::SlidesExtensions)
|
|
);
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer($slide)->serialize());
|
|
}
|
|
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 $presentation_id
|
|
* @param $slide_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function deletePresentationSlide($summit_id, $presentation_id, $slide_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$this->presentation_service->deleteSlide($presentation_id, $slide_id);
|
|
|
|
return $this->deleted();
|
|
}
|
|
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);
|
|
}
|
|
}
|
|
|
|
// Links
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function getPresentationLinks($summit_id, $presentation_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$presentation = $this->presentation_repository->getById($presentation_id);
|
|
|
|
if (is_null($presentation)) return $this->error404();
|
|
|
|
$links = $presentation->getLinks();
|
|
|
|
$items = [];
|
|
foreach($links as $i)
|
|
{
|
|
if($i instanceof IEntity)
|
|
{
|
|
$i = SerializerRegistry::getInstance()->getSerializer($i)->serialize();
|
|
}
|
|
$items[] = $i;
|
|
}
|
|
|
|
return $this->ok($items);
|
|
|
|
} 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 $presentation_id
|
|
* @param $link_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function getPresentationLink($summit_id, $presentation_id, $link_id){
|
|
try {
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$presentation = $this->presentation_repository->getById($presentation_id);
|
|
|
|
if (is_null($presentation)) return $this->error404();
|
|
|
|
$link = $presentation->getLinkBy($link_id);
|
|
|
|
if (is_null($link)) return $this->error404();
|
|
|
|
return $this->ok(SerializerRegistry::getInstance()->getSerializer($link)->serialize());
|
|
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param LaravelRequest $request
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function addPresentationLink(LaravelRequest $request, $summit_id, $presentation_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$data = $request->all();
|
|
$data = MultipartFormDataCleaner::cleanBool('display_on_site', $data);
|
|
$data = MultipartFormDataCleaner::cleanBool('featured', $data);
|
|
|
|
$rules = [
|
|
'link' => 'required|url',
|
|
'name' => 'required|string:512',
|
|
'description' => 'nullable|string',
|
|
'display_on_site' => 'nullable|boolean',
|
|
'featured' => 'nullable|boolean',
|
|
];
|
|
|
|
// 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;
|
|
}
|
|
|
|
$fields = [
|
|
'name',
|
|
'description',
|
|
];
|
|
|
|
$link = $this->presentation_service->addLinkTo($presentation_id, HTMLCleaner::cleanData($data, $fields));
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($link)->serialize());
|
|
}
|
|
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 LaravelRequest $request
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @param $link_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function updatePresentationLink(LaravelRequest $request, $summit_id, $presentation_id, $link_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$data = $request->all();
|
|
$data = MultipartFormDataCleaner::cleanBool('display_on_site', $data);
|
|
$data = MultipartFormDataCleaner::cleanBool('featured', $data);
|
|
$data = MultipartFormDataCleaner::cleanInt('order', $data);
|
|
|
|
$rules = [
|
|
'link' => 'sometimes|required|url',
|
|
'name' => 'sometimes|required|string:512',
|
|
'description' => 'nullable|string',
|
|
'display_on_site' => 'nullable|boolean',
|
|
'featured' => 'nullable|boolean',
|
|
'order' => 'nullable|integer|min:1',
|
|
];
|
|
|
|
// 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;
|
|
}
|
|
|
|
$fields = [
|
|
'name',
|
|
'description',
|
|
];
|
|
|
|
$link = $this->presentation_service->updateLink($presentation_id, $link_id, HTMLCleaner::cleanData($data, $fields));
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer($link)->serialize());
|
|
}
|
|
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 $presentation_id
|
|
* @param $link_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function deletePresentationLink($summit_id, $presentation_id, $link_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$this->presentation_service->deleteLink($presentation_id, $link_id);
|
|
|
|
return $this->deleted();
|
|
}
|
|
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);
|
|
}
|
|
}
|
|
|
|
// MediaUploads
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function getPresentationMediaUploads($summit_id, $presentation_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$presentation = $this->presentation_repository->getById($presentation_id);
|
|
|
|
if (is_null($presentation) || !$presentation instanceof Presentation) return $this->error404();
|
|
|
|
$mediaUploads = $presentation->getMediaUploads();
|
|
|
|
$items = [];
|
|
foreach($mediaUploads as $i)
|
|
{
|
|
if($i instanceof IEntity)
|
|
{
|
|
$i = SerializerRegistry::getInstance()->getSerializer($i)->serialize();
|
|
}
|
|
$items[] = $i;
|
|
}
|
|
|
|
return $this->ok($items);
|
|
|
|
} 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 $presentation_id
|
|
* @param $media_upload_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function getPresentationMediaUpload($summit_id, $presentation_id, $media_upload_id){
|
|
try {
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$presentation = $this->presentation_repository->getById($presentation_id);
|
|
|
|
if (is_null($presentation) || !$presentation instanceof Presentation) return $this->error404();
|
|
|
|
$mediaUpload = $presentation->getMediaUploadBy($media_upload_id);
|
|
|
|
if (is_null($mediaUpload)) return $this->error404();
|
|
|
|
return $this->ok(SerializerRegistry::getInstance()->getSerializer($mediaUpload)->serialize());
|
|
|
|
} catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param LaravelRequest $request
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function addPresentationMediaUpload(LaravelRequest $request, $summit_id, $presentation_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
$serializeType = SerializerRegistry::SerializerType_Private;
|
|
if(!$current_member->isAdmin()){
|
|
$serializeType = SerializerRegistry::SerializerType_Public;
|
|
// check if we could edit presentation
|
|
$presentation = $summit->getEvent($presentation_id);
|
|
if(is_null($presentation) || !$presentation instanceof Presentation)
|
|
return $this->error404();
|
|
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
|
return $this->error403();
|
|
}
|
|
|
|
$data = $request->all();
|
|
|
|
$rules = [
|
|
'media_upload_type_id' => 'required|integer',
|
|
];
|
|
|
|
// 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;
|
|
}
|
|
|
|
$mediaUpload = $this->presentation_service->addMediaUploadTo
|
|
(
|
|
$request,
|
|
$summit,
|
|
intval($presentation_id),
|
|
$data
|
|
);
|
|
|
|
$fields = Request::input('fields', '');
|
|
$relations = Request::input('relations', '');
|
|
|
|
$relations = !empty($relations) ? explode(',', $relations) : [];
|
|
$fields = !empty($fields) ? explode(',', $fields) : [];
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer
|
|
(
|
|
$mediaUpload, $serializeType)
|
|
->serialize
|
|
(
|
|
Request::input('expand', ''),
|
|
$fields,
|
|
$relations
|
|
)
|
|
);
|
|
}
|
|
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 LaravelRequest $request
|
|
* @param $summit_id
|
|
* @param $presentation_id
|
|
* @param $media_upload_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function updatePresentationMediaUpload(LaravelRequest $request, $summit_id, $presentation_id, $media_upload_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
if (is_null($current_member)) return $this->error403();
|
|
$serializeType = SerializerRegistry::SerializerType_Private;
|
|
|
|
if(!$current_member->isAdmin()){
|
|
$serializeType = SerializerRegistry::SerializerType_Public;
|
|
// check if we could edit presentation
|
|
$presentation = $summit->getEvent($presentation_id);
|
|
if(is_null($presentation) || !$presentation instanceof Presentation)
|
|
return $this->error404();
|
|
if(!$current_member->hasSpeaker() || !$presentation->canEdit($current_member->getSpeaker()))
|
|
return $this->error403();
|
|
}
|
|
|
|
|
|
$mediaUpload = $this->presentation_service->updateMediaUploadFrom
|
|
(
|
|
$request,
|
|
$summit,
|
|
intval($presentation_id),
|
|
intval($media_upload_id)
|
|
);
|
|
|
|
$fields = Request::input('fields', '');
|
|
$relations = Request::input('relations', '');
|
|
|
|
$relations = !empty($relations) ? explode(',', $relations) : [];
|
|
$fields = !empty($fields) ? explode(',', $fields) : [];
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer
|
|
(
|
|
$mediaUpload, $serializeType)
|
|
->serialize
|
|
(
|
|
Request::input('expand', ''),
|
|
$fields,
|
|
$relations
|
|
)
|
|
);
|
|
}
|
|
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 $presentation_id
|
|
* @param $media_upload_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function deletePresentationMediaUpload($summit_id, $presentation_id, $media_upload_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$this->presentation_service->deleteMediaUpload($summit, intval($presentation_id), intval($media_upload_id));
|
|
|
|
return $this->deleted();
|
|
}
|
|
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);
|
|
}
|
|
}
|
|
|
|
} |