Updated Summit Event
added fields * updated_by_id * created_by_id added resource context facade binded to singleton instance Change-Id: I0b6a467f581e93648f70fdd7b6f982809e13cd01 Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
b375702c67
commit
3983531390
24
app/Facades/ResourceServerContext.php
Normal file
24
app/Facades/ResourceServerContext.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php namespace App\Facades;
|
||||
/**
|
||||
* Copyright 2021 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 Illuminate\Support\Facades\Facade;
|
||||
use models\oauth2\IResourceServerContext;
|
||||
/**
|
||||
* @see IResourceServerContext
|
||||
* Class ResourceServerContext
|
||||
* @package App\Facades
|
||||
*/
|
||||
class ResourceServerContext extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor() { return 'resource_server_context'; }
|
||||
}
|
@ -347,7 +347,7 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
'attendees_expected_learnt',
|
||||
];
|
||||
|
||||
$presentation = $this->presentation_service->submitPresentation($summit, $current_member, HTMLCleaner::cleanData($data, $fields));
|
||||
$presentation = $this->presentation_service->submitPresentation($summit, HTMLCleaner::cleanData($data, $fields));
|
||||
|
||||
return $this->created(SerializerRegistry::getInstance()->getSerializer($presentation)->serialize(Request::input('expand', '')));
|
||||
}
|
||||
@ -418,10 +418,10 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
'attendees_expected_learnt',
|
||||
];
|
||||
|
||||
$presentation = $this->presentation_service->updatePresentationSubmission(
|
||||
$presentation = $this->presentation_service->updatePresentationSubmission
|
||||
(
|
||||
$summit,
|
||||
$presentation_id,
|
||||
$current_member,
|
||||
HTMLCleaner::cleanData($data, $fields)
|
||||
);
|
||||
|
||||
@ -461,8 +461,7 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$presentation = $this->presentation_service->completePresentationSubmission
|
||||
(
|
||||
$summit,
|
||||
$presentation_id,
|
||||
$current_member
|
||||
$presentation_id
|
||||
);
|
||||
|
||||
return $this->updated(SerializerRegistry::getInstance()->getSerializer($presentation)->serialize(Request::input('expand', '')));
|
||||
@ -498,7 +497,7 @@ final class OAuth2PresentationApiController extends OAuth2ProtectedController
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
if (is_null($current_member)) return $this->error403();
|
||||
|
||||
$this->presentation_service->deletePresentation($summit, $current_member, $presentation_id);
|
||||
$this->presentation_service->deletePresentation($summit, $presentation_id);
|
||||
|
||||
return $this->deleted();
|
||||
|
||||
|
@ -433,6 +433,8 @@ final class OAuth2SummitEventsApiController extends OAuth2ProtectedController
|
||||
if(!Request::isJson()) return $this->error400();
|
||||
$data = Input::json();
|
||||
|
||||
$current_member = $this->resource_server_context->getCurrentUser();
|
||||
|
||||
$rules = [
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'required|string|max:1100',
|
||||
@ -571,7 +573,7 @@ final class OAuth2SummitEventsApiController extends OAuth2ProtectedController
|
||||
'social_summary',
|
||||
];
|
||||
|
||||
$event = $this->service->updateEvent($summit, $event_id, HTMLCleaner::cleanData($data->all(), $fields), $current_member);
|
||||
$event = $this->service->updateEvent($summit, $event_id, HTMLCleaner::cleanData($data->all(), $fields));
|
||||
|
||||
return $this->ok(SerializerRegistry::getInstance()->getSerializer($event)->serialize());
|
||||
|
||||
|
@ -79,7 +79,7 @@ final class OAuth2SummitPresentationActionApiController
|
||||
if (!$authz)
|
||||
return $this->error403();
|
||||
|
||||
$action = $this->service->updateAction($summit, intval($selection_plan_id), intval($presentation_id), intval($action_id),$member, true );
|
||||
$action = $this->service->updateAction($summit, intval($selection_plan_id), intval($presentation_id), intval($action_id), true );
|
||||
return $this->updated(SerializerRegistry::getInstance()->getSerializer($action)->serialize(Input::get('expand', '')));
|
||||
|
||||
} catch (ValidationException $ex) {
|
||||
@ -116,7 +116,7 @@ final class OAuth2SummitPresentationActionApiController
|
||||
if (!$authz)
|
||||
return $this->error403();
|
||||
|
||||
$action = $this->service->updateAction($summit, intval($selection_plan_id), intval($presentation_id), intval($action_id), $member, false );
|
||||
$action = $this->service->updateAction($summit, intval($selection_plan_id), intval($presentation_id), intval($action_id), false );
|
||||
|
||||
return $this->updated(SerializerRegistry::getInstance()->getSerializer($action)->serialize(Input::get('expand', '')));
|
||||
} catch (ValidationException $ex) {
|
||||
|
@ -383,7 +383,15 @@ final class OAuth2SummitSelectionPlansApiController extends OAuth2ProtectedContr
|
||||
},
|
||||
function () {
|
||||
return [
|
||||
'track'
|
||||
'id',
|
||||
'title',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'created',
|
||||
'track',
|
||||
'location',
|
||||
'trackchairsel',
|
||||
'last_edited',
|
||||
];
|
||||
},
|
||||
function ($filter) use ($summit, $selection_plan_id) {
|
||||
@ -496,7 +504,15 @@ final class OAuth2SummitSelectionPlansApiController extends OAuth2ProtectedContr
|
||||
},
|
||||
function () {
|
||||
return [
|
||||
'track'
|
||||
'id',
|
||||
'title',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'created',
|
||||
'track',
|
||||
'location',
|
||||
'trackchairsel',
|
||||
'last_edited',
|
||||
];
|
||||
},
|
||||
function ($filter) use ($summit, $selection_plan_id) {
|
||||
|
@ -303,7 +303,7 @@ final class SerializerRegistry
|
||||
|
||||
// orders
|
||||
|
||||
$this->registry['SummitOrder'] =[
|
||||
$this->registry['SummitOrder'] = [
|
||||
self::SerializerType_Public => SummitOrderBaseSerializer::class,
|
||||
ISummitOrderSerializerTypes::CheckOutType => SummitOrderBaseSerializer::class,
|
||||
ISummitOrderSerializerTypes::ReservationType => SummitOrderReservationSerializer::class,
|
||||
|
@ -58,6 +58,18 @@ class PresentationSerializer extends SummitEventSerializer
|
||||
'actions',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getMediaUploadsSerializerType(){
|
||||
$serializerType = SerializerRegistry::SerializerType_Public;
|
||||
$currentUser = $this->resource_server_context->getCurrentUser();
|
||||
if(!is_null($currentUser) && $currentUser->isAdmin()){
|
||||
$serializerType = SerializerRegistry::SerializerType_Private;
|
||||
}
|
||||
return $serializerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $expand
|
||||
* @param array $fields
|
||||
@ -217,14 +229,12 @@ class PresentationSerializer extends SummitEventSerializer
|
||||
break;
|
||||
case 'media_uploads':{
|
||||
$media_uploads = [];
|
||||
$serializerType = SerializerRegistry::SerializerType_Public;
|
||||
$currentUser = $this->resource_server_context->getCurrentUser();
|
||||
if(!is_null($currentUser) && $currentUser->isAdmin()){
|
||||
$serializerType = SerializerRegistry::SerializerType_Private;
|
||||
}
|
||||
|
||||
foreach ($presentation->getMediaUploads() as $mediaUpload) {
|
||||
$media_uploads[] = SerializerRegistry::getInstance()->getSerializer($mediaUpload, $serializerType)->serialize(AbstractSerializer::filterExpandByPrefix($expand, $relation));
|
||||
$media_uploads[] = SerializerRegistry::getInstance()->getSerializer
|
||||
(
|
||||
$mediaUpload, $this->getMediaUploadsSerializerType()
|
||||
)->serialize(AbstractSerializer::filterExpandByPrefix($expand, $relation));
|
||||
}
|
||||
|
||||
$values['media_uploads'] = $media_uploads;
|
||||
|
@ -58,6 +58,13 @@ class TrackChairPresentationSerializer extends AdminPresentationSerializer
|
||||
'category_changes_requests',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getMediaUploadsSerializerType(){
|
||||
return SerializerRegistry::SerializerType_Private;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $expand
|
||||
* @param array $fields
|
||||
|
@ -12,6 +12,7 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Facades\ResourceServerContext;
|
||||
use Libs\ModelSerializers\AbstractSerializer;
|
||||
use models\summit\SummitEvent;
|
||||
|
||||
@ -50,6 +51,8 @@ class SummitEventSerializer extends SilverStripeSerializer
|
||||
'ImageUrl' => 'image:json_url',
|
||||
"StreamThumbnailUrl" => "stream_thumbnail:json_url",
|
||||
'Level' => 'level',
|
||||
'CreatedById' => 'created_by_id:json_int',
|
||||
'UpdatedById' => 'updated_by_id:json_int',
|
||||
];
|
||||
|
||||
protected static $allowed_fields = [
|
||||
@ -83,6 +86,8 @@ class SummitEventSerializer extends SilverStripeSerializer
|
||||
'image',
|
||||
'stream_thumbnail',
|
||||
'level',
|
||||
'created_by_id',
|
||||
'updated_by_id',
|
||||
];
|
||||
|
||||
protected static $allowed_relations = [
|
||||
@ -141,7 +146,7 @@ class SummitEventSerializer extends SilverStripeSerializer
|
||||
$values['current_attendance'] = $attendance;
|
||||
}
|
||||
|
||||
if ($event->hasAccess($this->resource_server_context->getCurrentUser())) {
|
||||
if ($event->hasAccess(ResourceServerContext::getCurrentUser())) {
|
||||
$values['streaming_url'] = $event->getStreamingUrl();
|
||||
$values['etherpad_link'] = $event->getEtherpadLink();
|
||||
}
|
||||
@ -215,6 +220,22 @@ class SummitEventSerializer extends SilverStripeSerializer
|
||||
$values['tags'] = $tags;
|
||||
}
|
||||
break;
|
||||
case 'created_by':
|
||||
{
|
||||
if(!$event->hasCreatedBy())
|
||||
break;
|
||||
unset($values['created_by_id']);
|
||||
$values['created_by'] = SerializerRegistry::getInstance()->getSerializer($event->getCreatedBy())->serialize(AbstractSerializer::filterExpandByPrefix($expand, $relation));
|
||||
}
|
||||
break;
|
||||
case 'updated_by':
|
||||
{
|
||||
if(!$event->hasUpdatedBy())
|
||||
break;
|
||||
unset($values['updated_by_id']);
|
||||
$values['updated_by'] = SerializerRegistry::getInstance()->getSerializer($event->getUpdatedBy())->serialize(AbstractSerializer::filterExpandByPrefix($expand, $relation));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,13 +130,6 @@ class Presentation extends SummitEvent
|
||||
*/
|
||||
protected $moderator;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinColumn(name="CreatorID", referencedColumnName="ID", onDelete="SET NULL")
|
||||
* @var Member
|
||||
*/
|
||||
protected $creator;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="App\Models\Foundation\Summit\SelectionPlan", inversedBy="presentations", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinColumn(name="SelectionPlanID", referencedColumnName="ID")
|
||||
@ -854,19 +847,21 @@ class Presentation extends SummitEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return Member
|
||||
*/
|
||||
public function getCreator()
|
||||
{
|
||||
return $this->creator;
|
||||
return $this->created_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated moved to created by attribute
|
||||
* @param Member $creator
|
||||
*/
|
||||
public function setCreator(Member $creator)
|
||||
{
|
||||
$this->creator = $creator;
|
||||
$this->created_by = $creator;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -957,13 +952,14 @@ class Presentation extends SummitEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return int
|
||||
*/
|
||||
public function getCreatorId()
|
||||
{
|
||||
try {
|
||||
if (is_null($this->creator)) return 0;
|
||||
return $this->creator->getId();
|
||||
if (is_null($this->created_by)) return 0;
|
||||
return $this->created_by->getId();
|
||||
} catch (\Exception $ex) {
|
||||
return 0;
|
||||
}
|
||||
@ -975,7 +971,7 @@ class Presentation extends SummitEvent
|
||||
*/
|
||||
public function canEdit(PresentationSpeaker $speaker)
|
||||
{
|
||||
if ($this->getCreatorId() == $speaker->getMemberId()) return true;
|
||||
if ($this->getCreatedById() == $speaker->getMemberId()) return true;
|
||||
if ($this->getModeratorId() == $speaker->getId()) return true;
|
||||
if ($this->isSpeaker($speaker)) return true;
|
||||
return false;
|
||||
|
@ -30,8 +30,8 @@ use DateTime;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Cocur\Slugify\Slugify;
|
||||
use models\utils\One2ManyPropertyTrait;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitEventRepository")
|
||||
* @ORM\AssociationOverrides({
|
||||
@ -55,6 +55,18 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
class SummitEvent extends SilverstripeBaseModel
|
||||
{
|
||||
use One2ManyPropertyTrait;
|
||||
|
||||
protected $getIdMappings = [
|
||||
'getCreatedById' => 'created_by',
|
||||
'getUpdatedById' => 'updated_by',
|
||||
];
|
||||
|
||||
protected $hasPropertyMappings = [
|
||||
'hasCreatedBy' => 'created_by',
|
||||
'hasUpdatedBy' => 'updated_by',
|
||||
];
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Title", type="string")
|
||||
* @var string
|
||||
@ -248,19 +260,32 @@ class SummitEvent extends SilverstripeBaseModel
|
||||
/**
|
||||
* @var PreRemoveEventArgs
|
||||
*/
|
||||
private $pre_remove_events;
|
||||
protected $pre_remove_events;
|
||||
/**
|
||||
* @var PreUpdateEventArgs
|
||||
*/
|
||||
private $pre_update_args;
|
||||
|
||||
protected $pre_update_args;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\File", cascade={"persist"})
|
||||
* @ORM\JoinColumn(name="ImageID", referencedColumnName="ID")
|
||||
* @var File
|
||||
*/
|
||||
private $image;
|
||||
protected $image;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinColumn(name="CreatedByID", referencedColumnName="ID", onDelete="SET NULL")
|
||||
* @var Member
|
||||
*/
|
||||
protected $created_by = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinColumn(name="UpdatedByID", referencedColumnName="ID", onDelete="SET NULL")
|
||||
* @var Member
|
||||
*/
|
||||
protected $updated_by = null;
|
||||
|
||||
/**
|
||||
* SummitEvent constructor.
|
||||
@ -1310,4 +1335,38 @@ class SummitEvent extends SilverstripeBaseModel
|
||||
$this->level = $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Member
|
||||
*/
|
||||
public function getCreatedBy(): ?Member
|
||||
{
|
||||
return $this->created_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member $created_by
|
||||
*/
|
||||
public function setCreatedBy(Member $created_by): void
|
||||
{
|
||||
$this->created_by = $created_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Member
|
||||
*/
|
||||
public function getUpdatedBy(): ?Member
|
||||
{
|
||||
return $this->updated_by;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member $updated_by
|
||||
*/
|
||||
public function setUpdatedBy(Member $updated_by): void
|
||||
{
|
||||
$this->updated_by = $updated_by;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -20,6 +20,8 @@ use Illuminate\Support\Facades\Validator;
|
||||
use libs\utils\ICacheService;
|
||||
use models\main\ChatTeamPermission;
|
||||
use models\main\PushNotificationMessagePriority;
|
||||
use models\oauth2\IResourceServerContext;
|
||||
use models\oauth2\ResourceServerContext;
|
||||
use Sokil\IsoCodes\IsoCodesFactory;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
/**
|
||||
@ -541,7 +543,14 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
App::singleton('models\\oauth2\\IResourceServerContext', 'models\\oauth2\\ResourceServerContext');
|
||||
|
||||
App::singleton(IResourceServerContext::class, ResourceServerContext::class);
|
||||
|
||||
App::bind('resource_server_context',function($app){
|
||||
// bind facade accesor with singleton instance
|
||||
return $app->make(IResourceServerContext::class);
|
||||
});
|
||||
|
||||
App::singleton('App\Models\ResourceServer\IAccessTokenService', 'App\Models\ResourceServer\AccessTokenService');
|
||||
App::singleton('App\Models\ResourceServer\IApi', 'models\\resource_server\\Api');
|
||||
App::singleton('App\Models\ResourceServer\IApiEndpoint', 'models\\resource_server\\ApiEndpoint');
|
||||
|
@ -111,6 +111,8 @@ final class DoctrineSummitEventRepository
|
||||
'published' => 'e.published',
|
||||
'start_date' => 'e.start_date:datetime_epoch',
|
||||
'end_date' => 'e.end_date:datetime_epoch',
|
||||
'created' => 'e.created:datetime_epoch',
|
||||
'last_edited' => 'e.last_edited:datetime_epoch',
|
||||
'tags' => new DoctrineLeftJoinFilterMapping
|
||||
(
|
||||
'e.tags',
|
||||
@ -283,7 +285,8 @@ final class DoctrineSummitEventRepository
|
||||
'created' => 'e.created',
|
||||
'track' => 'cc.title',
|
||||
'location' => 'l.name',
|
||||
'trackchairsel' => 'ssp.order'
|
||||
'trackchairsel' => 'ssp.order',
|
||||
'last_edited' => 'e.last_edited',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -52,45 +52,41 @@ interface IPresentationService
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param Member $member
|
||||
* @param array $data
|
||||
* @return Presentation
|
||||
* @throws ValidationException
|
||||
* @throws EntityNotFoundException
|
||||
*/
|
||||
public function submitPresentation(Summit $summit, Member $member, array $data);
|
||||
public function submitPresentation(Summit $summit, array $data);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $presentation_id
|
||||
* @param Member $member
|
||||
* @param array $data
|
||||
* @return Presentation
|
||||
* @throws ValidationException
|
||||
* @throws EntityNotFoundException
|
||||
*/
|
||||
public function updatePresentationSubmission(Summit $summit, $presentation_id, Member $member, array $data);
|
||||
public function updatePresentationSubmission(Summit $summit, $presentation_id, array $data);
|
||||
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $presentation_id
|
||||
* @param Member $member
|
||||
* @return Presentation
|
||||
* @throws ValidationException
|
||||
* @throws EntityNotFoundException
|
||||
*/
|
||||
public function completePresentationSubmission(Summit $summit, $presentation_id, Member $member);
|
||||
public function completePresentationSubmission(Summit $summit, $presentation_id);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param Member $member
|
||||
* @param int $presentation_id
|
||||
* @return void
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function deletePresentation(Summit $summit, Member $member, $presentation_id);
|
||||
public function deletePresentation(Summit $summit, $presentation_id);
|
||||
|
||||
/**
|
||||
* @param LaravelRequest $request
|
||||
|
@ -28,7 +28,6 @@ interface ISummitPresentationActionService
|
||||
* @param int $selection_plan_id
|
||||
* @param int $presentation_id
|
||||
* @param int $action_id
|
||||
* @param Member $performer
|
||||
* @param bool $isCompleted
|
||||
* @return PresentationAction|null
|
||||
* @throws EntityNotFoundException
|
||||
@ -40,7 +39,6 @@ interface ISummitPresentationActionService
|
||||
int $selection_plan_id,
|
||||
int $presentation_id,
|
||||
int $action_id,
|
||||
Member $performer,
|
||||
bool $isCompleted
|
||||
):?PresentationAction;
|
||||
}
|
@ -44,10 +44,9 @@ interface ISummitService
|
||||
* @param Summit $summit
|
||||
* @param int $event_id
|
||||
* @param array $data
|
||||
* @param null|Member $current_member
|
||||
* @return SummitEvent
|
||||
*/
|
||||
public function updateEvent(Summit $summit, $event_id, array $data, Member $current_member = null);
|
||||
public function updateEvent(Summit $summit, $event_id, array $data);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
|
@ -13,6 +13,7 @@
|
||||
**/
|
||||
use App\Events\PresentationMaterialDeleted;
|
||||
use App\Events\PresentationMaterialUpdated;
|
||||
use App\Facades\ResourceServerContext;
|
||||
use App\Http\Utils\FileSizeUtil;
|
||||
use App\Http\Utils\FileUploadInfo;
|
||||
use App\Http\Utils\IFileUploader;
|
||||
@ -131,7 +132,6 @@ final class PresentationService
|
||||
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
|
||||
if (is_null($presentation))
|
||||
throw new EntityNotFoundException('presentation not found!');
|
||||
|
||||
@ -242,17 +242,17 @@ final class PresentationService
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param Member $member
|
||||
* @param array $data
|
||||
* @return Presentation
|
||||
* @throws ValidationException
|
||||
* @throws EntityNotFoundException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function submitPresentation(Summit $summit, Member $member, array $data)
|
||||
public function submitPresentation(Summit $summit, array $data)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($summit, $member, $data) {
|
||||
return $this->tx_service->transaction(function () use ($summit, $data) {
|
||||
|
||||
$member = ResourceServerContext::getCurrentUser(false);
|
||||
$current_selection_plan = $summit->getCurrentSelectionPlanByStatus(SelectionPlan::STATUS_SUBMISSION);
|
||||
|
||||
if (is_null($current_selection_plan))
|
||||
@ -300,9 +300,12 @@ final class PresentationService
|
||||
['limit' => $limit]));
|
||||
|
||||
$presentation = new Presentation();
|
||||
$presentation->setCreator($member);
|
||||
//$presentation->setCreator($member);
|
||||
$presentation->setSelectionPlan($current_selection_plan);
|
||||
|
||||
$presentation->setCreatedBy(ResourceServerContext::getCurrentUser(false));
|
||||
$presentation->setUpdatedBy(ResourceServerContext::getCurrentUser(false));
|
||||
|
||||
$summit->addEvent($presentation);
|
||||
if(!$presentation->isCompleted())
|
||||
$presentation->setProgress(Presentation::PHASE_SUMMARY);
|
||||
@ -324,15 +327,16 @@ final class PresentationService
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $presentation_id
|
||||
* @param Member $member
|
||||
* @param array $data
|
||||
* @return Presentation
|
||||
* @throws ValidationException
|
||||
* @throws EntityNotFoundException
|
||||
*/
|
||||
public function updatePresentationSubmission(Summit $summit, $presentation_id, Member $member, array $data)
|
||||
public function updatePresentationSubmission(Summit $summit, $presentation_id, array $data)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($summit, $presentation_id, $member, $data) {
|
||||
return $this->tx_service->transaction(function () use ($summit, $presentation_id, $data) {
|
||||
|
||||
$member = ResourceServerContext::getCurrentUser(false);
|
||||
|
||||
$current_selection_plan = $summit->getCurrentSelectionPlanByStatus(SelectionPlan::STATUS_SUBMISSION);
|
||||
$current_speaker = $this->speaker_repository->getByMember($member);
|
||||
@ -374,6 +378,8 @@ final class PresentationService
|
||||
['presentation_id' => $presentation_id]
|
||||
));
|
||||
|
||||
$presentation->setUpdatedBy(ResourceServerContext::getCurrentUser(false));
|
||||
|
||||
return $this->saveOrUpdatePresentation
|
||||
(
|
||||
$summit,
|
||||
@ -557,15 +563,16 @@ final class PresentationService
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param Member $member
|
||||
* @param int $presentation_id
|
||||
* @throws ValidationException
|
||||
* @throws EntityNotFoundException
|
||||
* @return void
|
||||
*/
|
||||
public function deletePresentation(Summit $summit, Member $member, $presentation_id)
|
||||
public function deletePresentation(Summit $summit, $presentation_id)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($summit, $member, $presentation_id) {
|
||||
return $this->tx_service->transaction(function () use ($summit, $presentation_id) {
|
||||
|
||||
$member = ResourceServerContext::getCurrentUser(false);
|
||||
|
||||
$current_speaker = $this->speaker_repository->getByMember($member);
|
||||
if (is_null($current_speaker))
|
||||
@ -592,17 +599,19 @@ final class PresentationService
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $presentation_id
|
||||
* @param Member $member
|
||||
* @return Presentation
|
||||
* @throws ValidationException
|
||||
* @throws EntityNotFoundException
|
||||
*/
|
||||
public function completePresentationSubmission(Summit $summit, $presentation_id, Member $member)
|
||||
public function completePresentationSubmission(Summit $summit, $presentation_id)
|
||||
{
|
||||
return $this->tx_service->transaction(function () use ($summit, $member, $presentation_id) {
|
||||
return $this->tx_service->transaction(function () use ($summit, $presentation_id) {
|
||||
|
||||
$member = ResourceServerContext::getCurrentUser(false);
|
||||
|
||||
$current_selection_plan = $summit->getCurrentSelectionPlanByStatus(SelectionPlan::STATUS_SUBMISSION);
|
||||
$current_speaker = $this->speaker_repository->getByMember($member);
|
||||
|
||||
if (is_null($current_speaker))
|
||||
throw new EntityNotFoundException(sprintf("member %s does not has a speaker profile", $member->getId()));
|
||||
|
||||
@ -638,7 +647,6 @@ final class PresentationService
|
||||
$presentation_id
|
||||
));
|
||||
|
||||
|
||||
if (!$presentation->fulfilSpeakersConditions()) {
|
||||
throw new ValidationException
|
||||
(
|
||||
@ -672,6 +680,8 @@ final class PresentationService
|
||||
|
||||
PresentationCreatorNotificationEmail::dispatch($presentation);
|
||||
|
||||
$presentation->setUpdatedBy($member);
|
||||
|
||||
return $presentation;
|
||||
});
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Facades\ResourceServerContext;
|
||||
use App\Services\Model\AbstractService;
|
||||
use App\Services\Model\ISummitPresentationActionService;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
@ -29,10 +31,11 @@ implements ISummitPresentationActionService
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function updateAction(Summit $summit, int $selection_plan_id, int $presentation_id, int $action_id, Member $performer, bool $isCompleted): ?PresentationAction
|
||||
public function updateAction(Summit $summit, int $selection_plan_id, int $presentation_id, int $action_id, bool $isCompleted): ?PresentationAction
|
||||
{
|
||||
return $this->tx_service->transaction(function() use($summit, $selection_plan_id, $presentation_id, $action_id, $performer, $isCompleted){
|
||||
return $this->tx_service->transaction(function() use($summit, $selection_plan_id, $presentation_id, $action_id, $isCompleted){
|
||||
|
||||
$performer = ResourceServerContext::getCurrentUser(false);
|
||||
$selection_plan = $summit->getSelectionPlanById($selection_plan_id);
|
||||
if(is_null($selection_plan))
|
||||
throw new EntityNotFoundException(sprintf("Selection Plan %s not found.", $selection_plan_id));
|
||||
@ -57,6 +60,8 @@ implements ISummitPresentationActionService
|
||||
// emit notification
|
||||
$presentation->addTrackChairComment($performer, $message, true);
|
||||
|
||||
$presentation->setUpdatedBy($performer);
|
||||
|
||||
return $action;
|
||||
});
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Facades\ResourceServerContext;
|
||||
use League\Csv\Reader;
|
||||
use App\Events\MyFavoritesAdd;
|
||||
use App\Events\MyFavoritesRemove;
|
||||
@ -602,22 +604,23 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
* @param Summit $summit
|
||||
* @param array $data
|
||||
* @return SummitEvent
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function addEvent(Summit $summit, array $data)
|
||||
{
|
||||
return $this->saveOrUpdateEvent($summit, $data);
|
||||
return $this->saveOrUpdateEvent($summit, $data, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $event_id
|
||||
* @param array $data
|
||||
* @param null|Member $current_member
|
||||
* @return SummitEvent
|
||||
*/
|
||||
public function updateEvent(Summit $summit, $event_id, array $data, Member $current_member = null)
|
||||
public function updateEvent(Summit $summit, $event_id, array $data)
|
||||
{
|
||||
return $this->saveOrUpdateEvent($summit, $data, $event_id, $current_member);
|
||||
return $this->saveOrUpdateEvent($summit, $data, $event_id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -700,10 +703,12 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
* @throws ValidationException
|
||||
* @throws Exception
|
||||
*/
|
||||
private function saveOrUpdateEvent(Summit $summit, array $data, $event_id = null, Member $current_member = null)
|
||||
private function saveOrUpdateEvent(Summit $summit, array $data, $event_id = null)
|
||||
{
|
||||
|
||||
return $this->tx_service->transaction(function () use ($summit, $data, $event_id, $current_member) {
|
||||
return $this->tx_service->transaction(function () use ($summit, $data, $event_id) {
|
||||
|
||||
$current_member = ResourceServerContext::getCurrentUser(false);
|
||||
|
||||
if (!is_null($current_member) && !$this->permissions_manager->canEditFields($current_member, 'SummitEvent', $data)) {
|
||||
throw new ValidationException(sprintf("user %s cant set requested summit event fields", $current_member->getEmail()));
|
||||
@ -763,8 +768,12 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
|
||||
|
||||
// new event
|
||||
if (is_null($event))
|
||||
if (is_null($event)) {
|
||||
$event = SummitEventFactory::build($event_type, $summit);
|
||||
$event->setCreatedBy($current_member);
|
||||
}
|
||||
|
||||
$event->setUpdatedBy($current_member);
|
||||
|
||||
// main data
|
||||
|
||||
@ -1005,7 +1014,7 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
|
||||
$event = $this->event_repository->getById($event_id);
|
||||
|
||||
if (is_null($event))
|
||||
if (is_null($event) || !$event instanceof SummitEvent)
|
||||
throw new EntityNotFoundException(sprintf("event id %s does not exists!", $event_id));
|
||||
|
||||
if (is_null($event->getType()))
|
||||
@ -1042,6 +1051,7 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
$this->validateBlackOutTimesAndTimes($event);
|
||||
$event->unPublish();
|
||||
$event->publish();
|
||||
$event->setUpdatedBy(ResourceServerContext::getCurrentUser(false));
|
||||
$this->event_repository->add($event);
|
||||
return $event;
|
||||
});
|
||||
@ -1122,6 +1132,8 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
|
||||
$event->unPublish();
|
||||
|
||||
$event->setUpdatedBy(ResourceServerContext::getCurrentUser(false));
|
||||
|
||||
return $event;
|
||||
});
|
||||
}
|
||||
@ -1934,6 +1946,8 @@ final class SummitService extends AbstractService implements ISummitService
|
||||
$eventClone->setCategory($event->getCategory());
|
||||
$eventClone->setEtherpadLink($event->getEtherpadLink());
|
||||
$eventClone->setStreamingUrl($event->getStreamingUrl());
|
||||
$eventClone->setCreatedBy(ResourceServerContext::getCurrentUser(false));
|
||||
$eventClone->setUpdatedBy(ResourceServerContext::getCurrentUser(false));
|
||||
|
||||
if ($event->hasRSVPTemplate()) {
|
||||
$eventClone->setRSVPTemplate($event->getRSVPTemplate());
|
||||
|
@ -216,6 +216,7 @@ return [
|
||||
'Doctrine' => LaravelDoctrine\ORM\Facades\Doctrine::class,
|
||||
'Encryption' => services\utils\Facades\Encryption::class,
|
||||
'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class,
|
||||
'ResourceServerContext' => \App\Facades\ResourceServerContext::class,
|
||||
],
|
||||
|
||||
'app_name' => env('APP_NAME', 'Open Infrastructure Summit'),
|
||||
|
60
database/migrations/model/Version20210405144636.php
Normal file
60
database/migrations/model/Version20210405144636.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php namespace Database\Migrations\Model;
|
||||
/**
|
||||
* Copyright 2019 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 Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema as Schema;
|
||||
use LaravelDoctrine\Migrations\Schema\Builder;
|
||||
use LaravelDoctrine\Migrations\Schema\Table;
|
||||
/**
|
||||
* Class Version20210405144636
|
||||
* @package Database\Migrations\Model
|
||||
*/
|
||||
final class Version20210405144636 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema):void
|
||||
{
|
||||
$builder = new Builder($schema);
|
||||
|
||||
if($schema->hasTable("SummitEvent")) {
|
||||
$builder->table('SummitEvent', function (Table $table) {
|
||||
|
||||
// FK
|
||||
$table->integer("CreatedByID", false, false)->setNotnull(false)->setDefault('NULL');
|
||||
$table->index("CreatedByID", "CreatedByID");
|
||||
$table->foreign("Member", "CreatedByID", "ID", ["onDelete" => "SET NULL"]);
|
||||
|
||||
$table->integer("UpdatedByID", false, false)->setNotnull(false)->setDefault('NULL');
|
||||
$table->index("UpdatedByID", "UpdatedByID");
|
||||
$table->foreign("Member", "UpdatedByID", "ID", ["onDelete" => "SET NULL"]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema):void
|
||||
{
|
||||
$builder = new Builder($schema);
|
||||
if($schema->hasTable("SummitEvent")) {
|
||||
$builder->table('SummitEvent', function (Table $table) {
|
||||
// FK
|
||||
$table->dropColumn("CreatedByID");
|
||||
$table->dropColumn("UpdatedByID");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
44
database/migrations/model/Version20210406124904.php
Normal file
44
database/migrations/model/Version20210406124904.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php namespace Database\Migrations\Model;
|
||||
/**
|
||||
* Copyright 2019 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 Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema as Schema;
|
||||
|
||||
/**
|
||||
* Class Version20210406124904
|
||||
* @package Database\Migrations\Model
|
||||
*/
|
||||
final class Version20210406124904 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema):void
|
||||
{
|
||||
$sql = <<<SQL
|
||||
UPDATE SummitEvent,Presentation
|
||||
SET SummitEvent.CreatedByID = Presentation.CreatorID
|
||||
WHERE SummitEvent.ID = Presentation.ID;
|
||||
SQL;
|
||||
$this->addSql($sql);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema):void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
45
database/migrations/model/Version20210406125358.php
Normal file
45
database/migrations/model/Version20210406125358.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php namespace Database\Migrations\Model;
|
||||
/**
|
||||
* Copyright 2019 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 Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema as Schema;
|
||||
use LaravelDoctrine\Migrations\Schema\Builder;
|
||||
use LaravelDoctrine\Migrations\Schema\Table;
|
||||
/**
|
||||
* Class Version20210406125358
|
||||
* @package Database\Migrations\Model
|
||||
*/
|
||||
final class Version20210406125358 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema):void
|
||||
{
|
||||
$builder = new Builder($schema);
|
||||
if($schema->hasTable("Presentation")) {
|
||||
$builder->table('Presentation', function (Table $table) {
|
||||
// FK
|
||||
$table->dropColumn("CreatorID");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema):void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user