Merge "Added endpoint to send speaker announcement email"
This commit is contained in:
commit
aeaee56d9a
|
@ -473,7 +473,7 @@ final class OAuth2SummitPromoCodesApiController extends OAuth2ProtectedControlle
|
|||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
$mail_request = $this->promo_code_service->sendPromoCodeMail($summit, $promo_code_id);
|
||||
return $this->ok($mail_request->getId());
|
||||
return $this->created($mail_request->getId());
|
||||
} catch (ValidationException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error412(array($ex1->getMessage()));
|
||||
|
|
|
@ -386,7 +386,31 @@ final class OAuth2SummitSpeakersAssistanceApiController extends OAuth2ProtectedC
|
|||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $assistance_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function sendSpeakerSummitAssistanceAnnouncementMail($summit_id, $assistance_id){
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
$mail_request = $this->service->sendSpeakerSummitAssistanceAnnouncementMail($summit, $assistance_id);
|
||||
return $this->created($mail_request->getId());
|
||||
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -223,6 +223,7 @@ Route::group([
|
|||
Route::get('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitSpeakersAssistanceApiController@getSpeakerSummitAssistanceBySummit']);
|
||||
Route::delete('',[ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitSpeakersAssistanceApiController@deleteSpeakerSummitAssistance']);
|
||||
Route::put('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitSpeakersAssistanceApiController@updateSpeakerSummitAssistance']);
|
||||
Route::post('mail', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitSpeakersAssistanceApiController@sendSpeakerSummitAssistanceAnnouncementMail']);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ use DateTime;
|
|||
* @ORM\DiscriminatorColumn(name="ClassName", type="string")
|
||||
* @ORM\DiscriminatorMap({"EmailCreationRequest" = "EmailCreationRequest",
|
||||
* "SpeakerCreationEmailCreationRequest" = "SpeakerCreationEmailCreationRequest",
|
||||
* "MemberPromoCodeEmailCreationRequest"= "MemberPromoCodeEmailCreationRequest"})
|
||||
* "MemberPromoCodeEmailCreationRequest"= "MemberPromoCodeEmailCreationRequest",
|
||||
* "SpeakerSelectionAnnouncementEmailCreationRequest" = "SpeakerSelectionAnnouncementEmailCreationRequest"})
|
||||
* Class EmailCreationRequest
|
||||
* @package models\main
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
<?php namespace models\main;
|
||||
/**
|
||||
* Copyright 2018 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\ORM\Mapping AS ORM;
|
||||
use models\summit\PresentationSpeaker;
|
||||
use models\summit\SpeakerAnnouncementSummitEmail;
|
||||
use models\summit\SummitOwned;
|
||||
use models\summit\SummitRegistrationPromoCode;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="SpeakerSelectionAnnouncementEmailCreationRequest")
|
||||
* Class SpeakerSelectionAnnouncementEmailCreationRequest
|
||||
* @package models\main
|
||||
*/
|
||||
final class SpeakerSelectionAnnouncementEmailCreationRequest
|
||||
extends EmailCreationRequest
|
||||
{
|
||||
|
||||
use SummitOwned;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Type", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="SpeakerRole", type="string")
|
||||
* @var string
|
||||
*/
|
||||
protected $speaker_role;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\PresentationSpeaker")
|
||||
* @ORM\JoinColumn(name="SpeakerID", referencedColumnName="ID")
|
||||
* @var PresentationSpeaker
|
||||
*/
|
||||
protected $speaker;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\SummitRegistrationPromoCode")
|
||||
* @ORM\JoinColumn(name="PromoCodeID", referencedColumnName="ID")
|
||||
* @var SummitRegistrationPromoCode
|
||||
*/
|
||||
protected $promo_code;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSpeakerRole()
|
||||
{
|
||||
return $this->speaker_role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $speaker_role
|
||||
*/
|
||||
public function setSpeakerRole($speaker_role)
|
||||
{
|
||||
$this->speaker_role = $speaker_role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationSpeaker
|
||||
*/
|
||||
public function getSpeaker()
|
||||
{
|
||||
return $this->speaker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationSpeaker $speaker
|
||||
*/
|
||||
public function setSpeaker($speaker)
|
||||
{
|
||||
$this->speaker = $speaker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SummitRegistrationPromoCode
|
||||
*/
|
||||
public function getPromoCode()
|
||||
{
|
||||
return $this->promo_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitRegistrationPromoCode $promo_code
|
||||
*/
|
||||
public function setPromoCode($promo_code)
|
||||
{
|
||||
$this->promo_code = $promo_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $valid_types = [
|
||||
SpeakerAnnouncementSummitEmail::TypeAccepted,
|
||||
SpeakerAnnouncementSummitEmail::TypeAcceptedAlternate,
|
||||
SpeakerAnnouncementSummitEmail::TypeAcceptedRejected,
|
||||
SpeakerAnnouncementSummitEmail::TypeAlternate,
|
||||
SpeakerAnnouncementSummitEmail::TypeAlternateRejected,
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public static function isValidType($type){
|
||||
return in_array($type, self::$valid_types);
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use models\exceptions\ValidationException;
|
||||
|
||||
/**
|
||||
* Class Presentation
|
||||
|
@ -24,6 +25,12 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||
*/
|
||||
class Presentation extends SummitEvent
|
||||
{
|
||||
/**
|
||||
* SELECTION STATUS (TRACK CHAIRS LIST)
|
||||
*/
|
||||
const SelectionStatus_Accepted = 'accepted';
|
||||
const SelectionStatus_Unaccepted = 'unaccepted';
|
||||
const SelectionStatus_Alternate = 'alternate';
|
||||
|
||||
/**
|
||||
* Defines the phase that a presentation has been created, but
|
||||
|
@ -482,4 +489,43 @@ class Presentation extends SummitEvent
|
|||
{
|
||||
$this->feature_cloud = $feature_cloud;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function getSelectionStatus()
|
||||
{
|
||||
|
||||
$session_sel = $this->createQuery("SELECT sp from models\summit\SummitSelectedPresentation sp
|
||||
JOIN sp.list l
|
||||
JOIN sp.presentation p
|
||||
WHERE p.id = :presentation_id
|
||||
AND sp.collection = :collection
|
||||
AND l.list_type = :list_type
|
||||
AND l.list_class = :list_class")
|
||||
->setParameter('presentation_id' , $this->id)
|
||||
->setParameter('collection', SummitSelectedPresentation::CollectionSelected)
|
||||
->setParameter('list_type', SummitSelectedPresentationList::Group)
|
||||
->setParameter('list_class', SummitSelectedPresentationList::Session)->getResult();
|
||||
|
||||
// Error out if a talk has more than one selection
|
||||
if (count($session_sel) > 1) {
|
||||
throw new ValidationException('presentation has more than 1 (one) selection.');
|
||||
}
|
||||
|
||||
$selection = null;
|
||||
if (count($session_sel) == 1) {
|
||||
$selection = $session_sel[0];
|
||||
}
|
||||
|
||||
if (!$selection) {
|
||||
return Presentation::SelectionStatus_Unaccepted;
|
||||
}
|
||||
if ($selection->getOrder() <= $this->getCategory()->getSessionCount()) {
|
||||
return Presentation::SelectionStatus_Accepted;
|
||||
}
|
||||
|
||||
return Presentation::SelectionStatus_Alternate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php namespace models\summit;
|
||||
|
||||
/**
|
||||
* Copyright 2015 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -12,15 +11,16 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* Class PresentationCategoryGroup
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="PresentationCategoryGroup")
|
||||
* @ORM\InheritanceType("JOINED")
|
||||
* @ORM\DiscriminatorColumn(name="ClassName", type="string")
|
||||
* @ORM\DiscriminatorMap({"PresentationCategoryGroup" = "PresentationCategoryGroup", "PrivatePresentationCategoryGroup" = "PrivatePresentationCategoryGroup"})
|
||||
* @package models\summit
|
||||
*/
|
||||
class PresentationCategoryGroup extends SilverstripeBaseModel
|
||||
|
@ -30,19 +30,19 @@ class PresentationCategoryGroup extends SilverstripeBaseModel
|
|||
* @ORM\Column(name="Name", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Color", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $color;
|
||||
protected $color;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Description", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $description;
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
|
@ -110,8 +110,6 @@ class PresentationCategoryGroup extends SilverstripeBaseModel
|
|||
return $this->summit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -126,7 +124,7 @@ class PresentationCategoryGroup extends SilverstripeBaseModel
|
|||
* )
|
||||
* @var PresentationCategory[]
|
||||
*/
|
||||
private $categories;
|
||||
protected $categories;
|
||||
|
||||
/**
|
||||
* @return PresentationCategory[]
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
<?php namespace models\summit;
|
||||
/**
|
||||
* Copyright 2018 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 models\main\Group;
|
||||
use models\summit\PresentationCategoryGroup;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
/**
|
||||
* Class PrivatePresentationCategoryGroup
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="PrivatePresentationCategoryGroup")
|
||||
* @package models\summit
|
||||
*/
|
||||
class PrivatePresentationCategoryGroup extends PresentationCategoryGroup
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(name="SubmissionBeginDate", type="datetime")
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $submission_begin_date;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="SubmissionEndDate", type="datetime")
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $submission_end_date;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="MaxSubmissionAllowedPerUser", type="integer")
|
||||
* @var int
|
||||
*/
|
||||
protected $max_submission_allowed_per_user;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="models\main\Group", inversedBy="groups")
|
||||
* @ORM\JoinTable(name="PrivatePresentationCategoryGroup_AllowedGroups",
|
||||
* joinColumns={@ORM\JoinColumn(name="PrivatePresentationCategoryGroupID", referencedColumnName="ID")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="GroupID", referencedColumnName="ID")}
|
||||
* )
|
||||
* @var Group[]
|
||||
*/
|
||||
protected $allowed_groups;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSubmissionOpen()
|
||||
{
|
||||
|
||||
if (empty($this->submission_begin_date) || empty($this->submission_end_date))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$start_date = new DateTime($this->submission_begin_date->getTimestamp(), new DateTimeZone('UTC'));
|
||||
$end_date = new DateTime($this->submission_end_date->getTimestamp(), new DateTimeZone('UTC'));
|
||||
$now = new DateTime('now', new DateTimeZone('UTC'));
|
||||
|
||||
return ($now >= $start_date && $now <= $end_date);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php namespace models\summit\factories;
|
||||
use models\summit\PresentationSpeaker;
|
||||
use models\summit\SpeakerAnnouncementSummitEmail;
|
||||
use models\summit\Summit;
|
||||
|
||||
/**
|
||||
* Copyright 2018 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.
|
||||
**/
|
||||
|
||||
final class SpeakerSelectionAnnouncementEmailTypeFactory
|
||||
{
|
||||
|
||||
public static function build(Summit $summit, PresentationSpeaker $speaker, $role = PresentationSpeaker::RoleSpeaker)
|
||||
{
|
||||
$has_published = $speaker->hasPublishedRegularPresentations($summit, $role, true, $summit->getExcludedCategoriesForAcceptedPresentations()) ||
|
||||
$speaker->hasPublishedLightningPresentations($summit, $role, true, $summit->getExcludedCategoriesForAcceptedPresentations());
|
||||
$has_rejected = $speaker->hasRejectedPresentations($summit, $role, true, $summit->getExcludedCategoriesForRejectedPresentations());
|
||||
$has_alternate = $speaker->hasAlternatePresentations($summit, $role, true, $summit->getExcludedCategoriesForAcceptedPresentations());
|
||||
|
||||
if($has_published && !$has_rejected && !$has_alternate)
|
||||
return SpeakerAnnouncementSummitEmail::TypeAccepted;
|
||||
|
||||
if(!$has_published && !$has_rejected && $has_alternate)
|
||||
return SpeakerAnnouncementSummitEmail::TypeAlternate;
|
||||
|
||||
if(!$has_published && $has_rejected && !$has_alternate)
|
||||
return SpeakerAnnouncementSummitEmail::TypeRejected;
|
||||
|
||||
if($has_published && !$has_rejected && $has_alternate)
|
||||
return SpeakerAnnouncementSummitEmail::TypeAcceptedAlternate;
|
||||
|
||||
if($has_published && $has_rejected && !$has_alternate)
|
||||
return SpeakerAnnouncementSummitEmail::TypeAcceptedRejected;
|
||||
|
||||
if(!$has_published && $has_rejected && $has_alternate)
|
||||
return SpeakerAnnouncementSummitEmail::TypeAcceptedRejected;
|
||||
|
||||
if($has_published && $has_rejected && $has_alternate)
|
||||
return SpeakerAnnouncementSummitEmail::TypeAcceptedAlternate;
|
||||
|
||||
return SpeakerAnnouncementSummitEmail::TypeNone;
|
||||
}
|
||||
}
|
|
@ -20,6 +20,9 @@ use Doctrine\ORM\Mapping AS ORM;
|
|||
*/
|
||||
class SpeakerSummitRegistrationPromoCode extends SummitRegistrationPromoCode
|
||||
{
|
||||
const TypeAccepted = 'ACCEPTED';
|
||||
const TypeAlternate = 'ALTERNATE';
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Type", type="string")
|
||||
* @var string
|
||||
|
|
|
@ -46,4 +46,11 @@ interface ISpeakerSummitRegistrationPromoCodeRepository
|
|||
* @return SpeakerSummitRegistrationPromoCode
|
||||
*/
|
||||
public function getAssignedCode($code, Summit $summit);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param string $type
|
||||
* @return SpeakerSummitRegistrationPromoCode
|
||||
*/
|
||||
public function getNextAvailableByType(Summit $summit, $type);
|
||||
}
|
|
@ -35,6 +35,15 @@ use Doctrine\Common\Collections\Criteria;
|
|||
class PresentationSpeaker extends SilverstripeBaseModel
|
||||
{
|
||||
|
||||
const AnnouncementEmailAccepted = 'ACCEPTED';
|
||||
const AnnouncementEmailRejected = 'REJECTED';
|
||||
const AnnouncementEmailAlternate = 'ALTERNATE';
|
||||
const AnnouncementEmailAcceptedAlternate = 'ACCEPTED_ALTERNATE';
|
||||
const AnnouncementEmailAcceptedRejected = 'ACCEPTED_REJECTED';
|
||||
const AnnouncementEmailAlternateRejected = 'ALTERNATE_REJECTED';
|
||||
const RoleSpeaker = 'SPEAKER';
|
||||
const RoleModerator = 'MODERATOR';
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="FirstName", type="string")
|
||||
*/
|
||||
|
@ -194,6 +203,12 @@ class PresentationSpeaker extends SilverstripeBaseModel
|
|||
*/
|
||||
protected $active_involvements;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="SpeakerAnnouncementSummitEmail", mappedBy="speaker", cascade={"persist"}, orphanRemoval=true)
|
||||
* @var SpeakerAnnouncementSummitEmail[]
|
||||
*/
|
||||
private $announcement_summit_emails;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -293,21 +308,22 @@ class PresentationSpeaker extends SilverstripeBaseModel
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->available_for_bureau = false;
|
||||
$this->willing_to_present_video = false;
|
||||
$this->willing_to_travel = false;
|
||||
$this->funded_travel = false;
|
||||
$this->org_has_cloud = false;
|
||||
$this->presentations = new ArrayCollection;
|
||||
$this->moderated_presentations = new ArrayCollection;
|
||||
$this->summit_assistances = new ArrayCollection;
|
||||
$this->promo_codes = new ArrayCollection;
|
||||
$this->areas_of_expertise = new ArrayCollection;
|
||||
$this->other_presentation_links = new ArrayCollection;
|
||||
$this->travel_preferences = new ArrayCollection;
|
||||
$this->languages = new ArrayCollection;
|
||||
$this->organizational_roles = new ArrayCollection;
|
||||
$this->active_involvements = new ArrayCollection;
|
||||
$this->available_for_bureau = false;
|
||||
$this->willing_to_present_video = false;
|
||||
$this->willing_to_travel = false;
|
||||
$this->funded_travel = false;
|
||||
$this->org_has_cloud = false;
|
||||
$this->presentations = new ArrayCollection;
|
||||
$this->moderated_presentations = new ArrayCollection;
|
||||
$this->summit_assistances = new ArrayCollection;
|
||||
$this->promo_codes = new ArrayCollection;
|
||||
$this->areas_of_expertise = new ArrayCollection;
|
||||
$this->other_presentation_links = new ArrayCollection;
|
||||
$this->travel_preferences = new ArrayCollection;
|
||||
$this->languages = new ArrayCollection;
|
||||
$this->organizational_roles = new ArrayCollection;
|
||||
$this->active_involvements = new ArrayCollection;
|
||||
$this->announcement_summit_emails = new ArrayCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -377,6 +393,414 @@ class PresentationSpeaker extends SilverstripeBaseModel
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param string $role
|
||||
* @param bool $include_sub_roles
|
||||
* @param array $excluded_tracks
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPublishedRegularPresentations
|
||||
(
|
||||
Summit $summit,
|
||||
$role = PresentationSpeaker::RoleSpeaker,
|
||||
$include_sub_roles = false,
|
||||
array $excluded_tracks = []
|
||||
)
|
||||
{
|
||||
return count($this->getPublishedRegularPresentations($summit, $role, $include_sub_roles, $excluded_tracks)) > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param string $role
|
||||
* @param bool $include_sub_roles
|
||||
* @param array $excluded_tracks
|
||||
* @return array
|
||||
*/
|
||||
public function getPublishedRegularPresentations
|
||||
(
|
||||
Summit $summit,
|
||||
$role = PresentationSpeaker::RoleSpeaker,
|
||||
$include_sub_roles = false,
|
||||
array $excluded_tracks = []
|
||||
)
|
||||
{
|
||||
$list = $this->getPublishedPresentationsByType
|
||||
(
|
||||
$summit,
|
||||
$role,
|
||||
[IPresentationType::Keynotes, IPresentationType::Panel, IPresentationType::Presentation],
|
||||
true,
|
||||
$excluded_tracks
|
||||
);
|
||||
|
||||
if($include_sub_roles && $role == PresentationSpeaker::RoleModerator){
|
||||
$presentations = $this->getPublishedPresentationsByType
|
||||
(
|
||||
$summit,
|
||||
PresentationSpeaker::RoleSpeaker,
|
||||
[IPresentationType::Keynotes, IPresentationType::Panel, IPresentationType::Presentation],
|
||||
true,
|
||||
$excluded_tracks
|
||||
);
|
||||
if($presentations) {
|
||||
foreach ($presentations as $speaker_presentation)
|
||||
$list[] = $speaker_presentation;
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param string $role
|
||||
* @param bool $include_sub_roles
|
||||
* @param array $excluded_tracks
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPublishedLightningPresentations
|
||||
(
|
||||
Summit $summit,
|
||||
$role = PresentationSpeaker::RoleSpeaker,
|
||||
$include_sub_roles = false,
|
||||
array $excluded_tracks = []
|
||||
)
|
||||
{
|
||||
return count($this->getPublishedLightningPresentations
|
||||
(
|
||||
$summit,
|
||||
$role,
|
||||
$include_sub_roles,
|
||||
$excluded_tracks
|
||||
))> 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param string $role
|
||||
* @param bool $include_sub_roles
|
||||
* @param array $excluded_tracks
|
||||
* @return array
|
||||
*/
|
||||
public function getPublishedLightningPresentations
|
||||
(
|
||||
Summit $summit,
|
||||
$role = PresentationSpeaker::RoleSpeaker,
|
||||
$include_sub_roles = false,
|
||||
array $excluded_tracks = []
|
||||
)
|
||||
{
|
||||
$list = $this->getPublishedPresentationsByType($summit, $role, [IPresentationType::LightingTalks], true , $excluded_tracks);
|
||||
|
||||
if($include_sub_roles && $role == PresentationSpeaker::RoleModerator){
|
||||
$presentations = $this->getPublishedPresentationsByType($summit, PresentationSpeaker::RoleSpeaker, [IPresentationType::LightingTalks], true, $excluded_tracks) ;
|
||||
if($presentations) {
|
||||
foreach ($presentations as $speaker_presentation) {
|
||||
$list[] = $speaker_presentation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param string $role
|
||||
* @param bool $include_sub_roles
|
||||
* @param array $excluded_tracks
|
||||
* @param bool $published_ones
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAlternatePresentations
|
||||
(
|
||||
Summit $summit,
|
||||
$role = PresentationSpeaker::RoleSpeaker,
|
||||
$include_sub_roles = false,
|
||||
array $excluded_tracks = [],
|
||||
$published_ones = false
|
||||
)
|
||||
{
|
||||
return count($this->getAlternatePresentations($summit, $role, $include_sub_roles, $excluded_tracks, $published_ones)) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param string $role
|
||||
* @param bool $include_sub_roles
|
||||
* @param array $excluded_tracks
|
||||
* @param bool $published_ones
|
||||
* @return array
|
||||
*/
|
||||
public function getAlternatePresentations
|
||||
(
|
||||
Summit $summit,
|
||||
$role = PresentationSpeaker::RoleSpeaker,
|
||||
$include_sub_roles = false,
|
||||
array $excluded_tracks = [],
|
||||
$published_ones = false
|
||||
)
|
||||
{
|
||||
$alternate_presentations = [];
|
||||
|
||||
$exclude_category_dql = '';
|
||||
if(count($excluded_tracks) > 0){
|
||||
$exclude_category_dql = ' AND p.category NOT IN (:exclude_tracks)';
|
||||
}
|
||||
|
||||
if($role == PresentationSpeaker::RoleSpeaker) {
|
||||
$query = $this->createQuery("SELECT p from models\summit\Presentation p
|
||||
JOIN p.summit s
|
||||
JOIN p.speakers sp
|
||||
WHERE s.id = :summit_id
|
||||
AND p.published = :published
|
||||
AND sp.id = :speaker_id".$exclude_category_dql);
|
||||
}
|
||||
else{
|
||||
$query = $this->createQuery("SELECT p from models\summit\Presentation p
|
||||
JOIN p.summit s
|
||||
JOIN p.moderator m
|
||||
WHERE s.id = :summit_id
|
||||
AND p.published = :published
|
||||
AND m.id = :speaker_id".$exclude_category_dql);
|
||||
}
|
||||
|
||||
$query
|
||||
->setParameter('summit_id', $summit->getId())
|
||||
->setParameter('speaker_id', $this->id)
|
||||
->setParameter('published', $published_ones ? 1 : 0);
|
||||
|
||||
if(count($excluded_tracks) > 0){
|
||||
$query->setParameter('exclude_tracks', $excluded_tracks);
|
||||
}
|
||||
|
||||
$presentations = $query->getResult();
|
||||
|
||||
foreach ($presentations as $p) {
|
||||
if ($p->getSelectionStatus() == Presentation::SelectionStatus_Alternate) {
|
||||
$alternate_presentations[] = $p;
|
||||
}
|
||||
}
|
||||
|
||||
// if role is moderator, add also the ones that belongs to role speaker ( if $include_sub_roles is true)
|
||||
if($include_sub_roles && $role == PresentationSpeaker::RoleModerator){
|
||||
$presentations = $this->getAlternatePresentations($summit,PresentationSpeaker::RoleSpeaker, $include_sub_roles, $excluded_tracks);
|
||||
if($presentations) {
|
||||
foreach ($presentations as $speaker_presentation)
|
||||
$alternate_presentations[] = $speaker_presentation;
|
||||
}
|
||||
}
|
||||
|
||||
return $alternate_presentations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit,
|
||||
* @param string $role
|
||||
* @param bool $include_sub_roles
|
||||
* @param array $excluded_tracks
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRejectedPresentations
|
||||
(
|
||||
Summit $summit,
|
||||
$role = PresentationSpeaker::RoleSpeaker,
|
||||
$include_sub_roles = false,
|
||||
array $excluded_tracks = []
|
||||
)
|
||||
{
|
||||
return count($this->getRejectedPresentations($summit, $role, $include_sub_roles, $excluded_tracks)) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit,
|
||||
* @param string $role
|
||||
* @param bool $include_sub_roles
|
||||
* @param array $excluded_tracks
|
||||
* @return array
|
||||
*/
|
||||
public function getRejectedPresentations
|
||||
(
|
||||
Summit $summit,
|
||||
$role = PresentationSpeaker::RoleSpeaker,
|
||||
$include_sub_roles = false,
|
||||
array $excluded_tracks = []
|
||||
){
|
||||
$list = $this->getUnacceptedPresentations($summit, $role, true, $excluded_tracks);
|
||||
if($include_sub_roles && $role == PresentationSpeaker::RoleModerator){
|
||||
$presentations = $this->getUnacceptedPresentations($summit, PresentationSpeaker::RoleSpeaker, true, $excluded_tracks);
|
||||
if($presentations) {
|
||||
foreach ($presentations as $speaker_presentation) {
|
||||
$list[] = $speaker_presentation;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit,
|
||||
* @param string $role
|
||||
* @param bool $exclude_privates_tracks
|
||||
* @param array $excluded_tracks
|
||||
* @return array
|
||||
*/
|
||||
public function getUnacceptedPresentations
|
||||
(
|
||||
Summit $summit,
|
||||
$role = PresentationSpeaker::RoleSpeaker,
|
||||
$exclude_privates_tracks = true,
|
||||
array $excluded_tracks = []
|
||||
)
|
||||
{
|
||||
$unaccepted_presentations = [];
|
||||
$private_tracks = [];
|
||||
|
||||
if($exclude_privates_tracks){
|
||||
$private_track_groups = $this->createQuery("SELECT pg from models\summit\PrivatePresentationCategoryGroup pg
|
||||
JOIN pg.summit s
|
||||
WHERE s.id = :summit_id")
|
||||
->setParameter('summit_id', $summit->getId())
|
||||
->getResult();
|
||||
|
||||
foreach($private_track_groups as $private_track_group){
|
||||
$current_private_tracks = $private_track_group->getCategories();
|
||||
if(count($current_private_tracks) == 0) continue;
|
||||
$private_tracks = array_merge($private_tracks, array_values($current_private_tracks));
|
||||
}
|
||||
}
|
||||
|
||||
if(count($private_tracks) > 0) {
|
||||
$excluded_tracks = array_merge($excluded_tracks, $private_tracks);
|
||||
}
|
||||
|
||||
$exclude_category_dql = '';
|
||||
if(count($excluded_tracks) > 0){
|
||||
$exclude_category_dql = ' AND p.category NOT IN (:exclude_tracks)';
|
||||
}
|
||||
|
||||
if($role == PresentationSpeaker::RoleSpeaker) {
|
||||
$query = $this->createQuery("SELECT p from models\summit\Presentation p
|
||||
JOIN p.summit s
|
||||
JOIN p.speakers sp
|
||||
WHERE s.id = :summit_id
|
||||
AND p.published = 0
|
||||
AND sp.id = :speaker_id".$exclude_category_dql);
|
||||
}
|
||||
else{
|
||||
$query = $this->createQuery("SELECT p from models\summit\Presentation p
|
||||
JOIN p.summit s
|
||||
JOIN p.moderator m
|
||||
WHERE s.id = :summit_id
|
||||
AND p.published = 0
|
||||
AND m.id = :speaker_id".$exclude_category_dql);
|
||||
}
|
||||
|
||||
$query
|
||||
->setParameter('summit_id', $summit->getId())
|
||||
->setParameter('speaker_id', $this->id);
|
||||
|
||||
if(count($excluded_tracks) > 0){
|
||||
$query->setParameter('exclude_tracks', $excluded_tracks);
|
||||
}
|
||||
$presentations = $query->getResult();
|
||||
|
||||
foreach ($presentations as $p) {
|
||||
if ($p->getSelectionStatus() == Presentation::SelectionStatus_Unaccepted) {
|
||||
$unaccepted_presentations[] = $p;
|
||||
}
|
||||
}
|
||||
|
||||
return $unaccepted_presentations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param string $role
|
||||
* @param array $types_slugs
|
||||
* @param bool $exclude_privates_tracks
|
||||
* @param array $excluded_tracks
|
||||
* @return array
|
||||
*/
|
||||
public function getPublishedPresentationsByType
|
||||
(
|
||||
Summit $summit,
|
||||
$role = PresentationSpeaker::RoleSpeaker,
|
||||
array $types_slugs = [IPresentationType::Keynotes, IPresentationType::Panel, IPresentationType::Presentation, IPresentationType::LightingTalks],
|
||||
$exclude_privates_tracks = true,
|
||||
array $excluded_tracks = []
|
||||
)
|
||||
{
|
||||
$query = $this->createQuery("SELECT pt from models\summit\PresentationType pt JOIN pt.summit s
|
||||
WHERE s.id = :summit_id and pt.type IN (:types) ");
|
||||
$types = $query
|
||||
->setParameter('summit_id', $summit->getIdentifier())
|
||||
->setParameter('types', $types_slugs)
|
||||
->getResult();
|
||||
|
||||
if(count($types) == 0 ) return [];
|
||||
|
||||
$private_tracks = [];
|
||||
$exclude_privates_tracks = boolval($exclude_privates_tracks);
|
||||
|
||||
if($exclude_privates_tracks){
|
||||
|
||||
$query = $this->createQuery("SELECT ppcg from models\summit\PrivatePresentationCategoryGroup ppcg JOIN ppcg.summit s
|
||||
WHERE s.id = :summit_id");
|
||||
$private_track_groups = $query
|
||||
->setParameter('summit_id', $summit->getIdentifier())
|
||||
->getResult();
|
||||
|
||||
foreach($private_track_groups as $private_track_group){
|
||||
$current_private_tracks = $private_track_group->getCategories();
|
||||
if($current_private_tracks->count() == 0) continue;
|
||||
$private_tracks = array_merge($private_tracks, array_values($current_private_tracks));
|
||||
}
|
||||
}
|
||||
|
||||
if(count($private_tracks) > 0) {
|
||||
$excluded_tracks = array_merge($excluded_tracks, $private_tracks);
|
||||
}
|
||||
|
||||
$exclude_category_dql = '';
|
||||
if(count($excluded_tracks) > 0){
|
||||
$exclude_category_dql = ' and p.category NOT IN (:exclude_tracks)';
|
||||
}
|
||||
|
||||
if($role == PresentationSpeaker::RoleSpeaker) {
|
||||
$query = $this->createQuery("SELECT p from models\summit\Presentation p
|
||||
JOIN p.summit s
|
||||
JOIN p.speakers sp
|
||||
WHERE s.id = :summit_id
|
||||
and sp.id = :speaker_id
|
||||
and p.published = 1 and p.type IN (:types)".$exclude_category_dql);
|
||||
}
|
||||
else{
|
||||
$query = $this->createQuery("SELECT p from models\summit\Presentation p
|
||||
JOIN p.summit s
|
||||
JOIN p.moderator m
|
||||
WHERE s.id = :summit_id
|
||||
and m.id = :speaker_id
|
||||
and p.published = 1 and p.type IN (:types)".$exclude_category_dql);
|
||||
}
|
||||
|
||||
$query
|
||||
->setParameter('summit_id', $summit->getId())
|
||||
->setParameter('types', $types)
|
||||
->setParameter('speaker_id', $this->id);
|
||||
|
||||
if(count($excluded_tracks) > 0){
|
||||
$query->setParameter('exclude_tracks', $excluded_tracks);
|
||||
}
|
||||
|
||||
return $query->getResult();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param null|int $summit_id
|
||||
* @param bool|true $published_ones
|
||||
|
@ -1029,4 +1453,44 @@ SQL;
|
|||
$presentation->setModerator($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @return bool
|
||||
*/
|
||||
public function isModeratorFor(Summit $summit){
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('summit', $summit));
|
||||
return $this->moderated_presentations->matching($criteria)->count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @return bool
|
||||
*/
|
||||
public function announcementEmailAlreadySent(Summit $summit)
|
||||
{
|
||||
$email_type = $this->getAnnouncementEmailTypeSent($summit);
|
||||
return !is_null($email_type) && $email_type !== SpeakerAnnouncementSummitEmail::TypeNone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAnnouncementEmailTypeSent(Summit $summit)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
|
||||
$criteria
|
||||
->where(Criteria::expr()->eq('summit', $summit))
|
||||
->andWhere(Criteria::expr()->notIn('type', [
|
||||
SpeakerAnnouncementSummitEmail::TypeCreateMembership,
|
||||
SpeakerAnnouncementSummitEmail::TypeSecondBreakoutRegister,
|
||||
SpeakerAnnouncementSummitEmail::TypeSecondBreakoutReminder,
|
||||
]));
|
||||
|
||||
$email = $this->announcement_summit_emails->matching($criteria)->first();
|
||||
|
||||
return $email ? $email->getType() : null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
<?php namespace models\summit;
|
||||
/**
|
||||
* Copyright 2018 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\ORM\Mapping AS ORM;
|
||||
use models\summit\PresentationSpeaker;
|
||||
use models\summit\SummitOwned;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
use DateTime;
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="SpeakerAnnouncementSummitEmail")
|
||||
* Class SpeakerAnnouncementSummitEmail
|
||||
* @package models\summit
|
||||
*/
|
||||
class SpeakerAnnouncementSummitEmail extends SilverstripeBaseModel
|
||||
{
|
||||
|
||||
const TypeAccepted = 'ACCEPTED';
|
||||
const TypeRejected = 'REJECTED';
|
||||
const TypeAlternate = 'ALTERNATE';
|
||||
const TypeAcceptedAlternate = 'ACCEPTED_ALTERNATE';
|
||||
const TypeAcceptedRejected = 'ACCEPTED_REJECTED';
|
||||
const TypeAlternateRejected = 'ALTERNATE_REJECTED';
|
||||
const TypeSecondBreakoutReminder = 'SECOND_BREAKOUT_REMINDER';
|
||||
const TypeSecondBreakoutRegister = 'SECOND_BREAKOUT_REGISTER';
|
||||
const TypeCreateMembership = 'CREATE_MEMBERSHIP';
|
||||
const TypeNone = 'NONE';
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="AnnouncementEmailTypeSent", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="AnnouncementEmailSentDate", type="datetime")
|
||||
* @var DateTime
|
||||
*/
|
||||
private $send_date;
|
||||
|
||||
Use SummitOwned;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\summit\PresentationSpeaker")
|
||||
* @ORM\JoinColumn(name="SpeakerID", referencedColumnName="ID")
|
||||
* @var PresentationSpeaker
|
||||
*/
|
||||
protected $speaker;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getSendDate()
|
||||
{
|
||||
return $this->send_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $send_date
|
||||
*/
|
||||
public function setSendDate(DateTime $send_date)
|
||||
{
|
||||
$this->send_date = $send_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationSpeaker
|
||||
*/
|
||||
public function getSpeaker()
|
||||
{
|
||||
return $this->speaker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PresentationSpeaker $speaker
|
||||
*/
|
||||
public function setSpeaker($speaker)
|
||||
{
|
||||
$this->speaker = $speaker;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@ use Doctrine\ORM\Mapping AS ORM;
|
|||
use Doctrine\ORM\Cache;
|
||||
use models\main\File;
|
||||
use models\main\Member;
|
||||
use models\main\Tag;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
@ -145,7 +146,6 @@ class Summit extends SilverstripeBaseModel
|
|||
*/
|
||||
private $time_zone_id;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="SummitAbstractLocation", mappedBy="summit", cascade={"persist"})
|
||||
*/
|
||||
|
@ -208,6 +208,57 @@ class Summit extends SilverstripeBaseModel
|
|||
* @ORM\OneToMany(targetEntity="models\summit\SummitTicketType", mappedBy="summit", cascade={"persist"})
|
||||
*/
|
||||
private $ticket_types;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="models\summit\PresentationCategory")
|
||||
* @ORM\JoinTable(name="Summit_ExcludedCategoriesForAcceptedPresentations",
|
||||
* joinColumns={@ORM\JoinColumn(name="SummitID", referencedColumnName="ID")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="PresentationCategoryID", referencedColumnName="ID")}
|
||||
* )
|
||||
* @var PresentationCategory[]
|
||||
*/
|
||||
private $excluded_categories_for_accepted_presentations;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="models\summit\PresentationCategory")
|
||||
* @ORM\JoinTable(name="Summit_ExcludedCategoriesForAlternatePresentations",
|
||||
* joinColumns={@ORM\JoinColumn(name="SummitID", referencedColumnName="ID")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="PresentationCategoryID", referencedColumnName="ID")}
|
||||
* )
|
||||
* @var PresentationCategory[]
|
||||
*/
|
||||
private $excluded_categories_for_alternate_presentations;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="models\summit\PresentationCategory")
|
||||
* @ORM\JoinTable(name="Summit_ExcludedCategoriesForRejectedPresentations",
|
||||
* joinColumns={@ORM\JoinColumn(name="SummitID", referencedColumnName="ID")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="PresentationCategoryID", referencedColumnName="ID")}
|
||||
* )
|
||||
* @var PresentationCategory[]
|
||||
*/
|
||||
private $excluded_categories_for_rejected_presentations;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="models\summit\PresentationCategory")
|
||||
* @ORM\JoinTable(name="Summit_ExcludedTracksForUploadPresentationSlideDeck",
|
||||
* joinColumns={@ORM\JoinColumn(name="SummitID", referencedColumnName="ID")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="PresentationCategoryID", referencedColumnName="ID")}
|
||||
* )
|
||||
* @var PresentationCategory[]
|
||||
*/
|
||||
private $excluded_categories_for_upload_slide_decks;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="models\main\Tag")
|
||||
* @ORM\JoinTable(name="Summit_CategoryDefaultTags",
|
||||
* joinColumns={@ORM\JoinColumn(name="SummitID", referencedColumnName="ID")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="TagID", referencedColumnName="ID")}
|
||||
* )
|
||||
* @var Tag[]
|
||||
*/
|
||||
private $category_default_tags;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -443,17 +494,22 @@ class Summit extends SilverstripeBaseModel
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->locations = new ArrayCollection();
|
||||
$this->events = new ArrayCollection();
|
||||
$this->event_types = new ArrayCollection();
|
||||
$this->ticket_types = new ArrayCollection();
|
||||
$this->presentation_categories = new ArrayCollection();
|
||||
$this->category_groups = new ArrayCollection();
|
||||
$this->attendees = new ArrayCollection();
|
||||
$this->entity_events = new ArrayCollection();
|
||||
$this->wifi_connections = new ArrayCollection();
|
||||
$this->promo_codes = new ArrayCollection();
|
||||
$this->speaker_assistances = new ArrayCollection();
|
||||
$this->locations = new ArrayCollection;
|
||||
$this->events = new ArrayCollection;
|
||||
$this->event_types = new ArrayCollection;
|
||||
$this->ticket_types = new ArrayCollection;
|
||||
$this->presentation_categories = new ArrayCollection;
|
||||
$this->category_groups = new ArrayCollection;
|
||||
$this->attendees = new ArrayCollection;
|
||||
$this->entity_events = new ArrayCollection;
|
||||
$this->wifi_connections = new ArrayCollection;
|
||||
$this->promo_codes = new ArrayCollection;
|
||||
$this->speaker_assistances = new ArrayCollection;
|
||||
$this->excluded_categories_for_accepted_presentations = new ArrayCollection;
|
||||
$this->excluded_categories_for_alternate_presentations = new ArrayCollection;
|
||||
$this->excluded_categories_for_rejected_presentations = new ArrayCollection;
|
||||
$this->excluded_categories_for_upload_slide_decks = new ArrayCollection;
|
||||
$this->category_default_tags = new ArrayCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1401,4 +1457,44 @@ SQL;
|
|||
$promo_code->setSummit(null);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationCategory[]
|
||||
*/
|
||||
public function getExcludedCategoriesForAcceptedPresentations()
|
||||
{
|
||||
return $this->excluded_categories_for_accepted_presentations->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationCategory[]
|
||||
*/
|
||||
public function getExcludedCategoriesForAlternatePresentations()
|
||||
{
|
||||
return $this->excluded_categories_for_alternate_presentations->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationCategory[]
|
||||
*/
|
||||
public function getExcludedCategoriesForRejectedPresentations()
|
||||
{
|
||||
return $this->excluded_categories_for_rejected_presentations->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationCategory[]
|
||||
*/
|
||||
public function getExcludedCategoriesForUploadSlideDecks()
|
||||
{
|
||||
return $this->excluded_categories_for_upload_slide_decks->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Tag[]
|
||||
*/
|
||||
public function getCategoryDefaultTags()
|
||||
{
|
||||
return $this->category_default_tags->toArray();
|
||||
}
|
||||
}
|
|
@ -104,4 +104,25 @@ final class DoctrineSpeakerSummitRegistrationPromoCodeRepository
|
|||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param string $type
|
||||
* @return SpeakerSummitRegistrationPromoCode
|
||||
*/
|
||||
public function getNextAvailableByType(Summit $summit, $type)
|
||||
{
|
||||
return $this->getEntityManager()
|
||||
->createQueryBuilder()
|
||||
->select("c")
|
||||
->from(SpeakerSummitRegistrationPromoCode::class, "c")
|
||||
->where("c.speaker is null")
|
||||
->andWhere("c.summit = :summit")
|
||||
->andWhere("c.type = :type")
|
||||
->setParameter("summit", $summit)
|
||||
->setParameter("type", trim($type))
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@
|
|||
**/
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\main\EmailCreationRequest;
|
||||
use models\main\File;
|
||||
use models\summit\PresentationSpeaker;
|
||||
use models\summit\PresentationSpeakerSummitAssistanceConfirmationRequest;
|
||||
|
@ -119,4 +120,14 @@ interface ISpeakerService
|
|||
* @return void
|
||||
*/
|
||||
public function deleteSpeakerAssistance(Summit $summit, $assistance_id);
|
||||
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $assistance_id
|
||||
* @return EmailCreationRequest
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function sendSpeakerSummitAssistanceAnnouncementMail(Summit $summit, $assistance_id);
|
||||
}
|
|
@ -17,12 +17,15 @@ use Illuminate\Http\UploadedFile;
|
|||
use libs\utils\ITransactionService;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\main\EmailCreationRequest;
|
||||
use models\main\File;
|
||||
use models\main\IEmailCreationRequestRepository;
|
||||
use models\main\IFolderRepository;
|
||||
use models\main\IMemberRepository;
|
||||
use models\main\MemberPromoCodeEmailCreationRequest;
|
||||
use models\main\SpeakerCreationEmailCreationRequest;
|
||||
use models\main\SpeakerSelectionAnnouncementEmailCreationRequest;
|
||||
use models\summit\factories\SpeakerSelectionAnnouncementEmailTypeFactory;
|
||||
use models\summit\ISpeakerRegistrationRequestRepository;
|
||||
use models\summit\ISpeakerRepository;
|
||||
use models\summit\ISpeakerSummitRegistrationPromoCodeRepository;
|
||||
|
@ -795,4 +798,159 @@ final class SpeakerService implements ISpeakerService
|
|||
$this->speakers_assistance_repository->delete($assistance);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param int $assistance_id
|
||||
* @return EmailCreationRequest
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function sendSpeakerSummitAssistanceAnnouncementMail(Summit $summit, $assistance_id)
|
||||
{
|
||||
return $this->tx_service->transaction(function() use($summit, $assistance_id){
|
||||
|
||||
$speaker_assistance = $summit->getSpeakerAssistanceById($assistance_id);
|
||||
|
||||
if(is_null($speaker_assistance))
|
||||
throw new EntityNotFoundException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'not_found_errors.send_speaker_summit_assistance_announcement_mail_not_found_assistance',
|
||||
[
|
||||
'summit_id' => $summit->getId(),
|
||||
'assistance_id' => $assistance_id
|
||||
]
|
||||
)
|
||||
);
|
||||
$speaker = $speaker_assistance->getSpeaker();
|
||||
|
||||
$role = $speaker->isModeratorFor($summit) ?
|
||||
PresentationSpeaker::RoleModerator : PresentationSpeaker::RoleSpeaker;
|
||||
|
||||
/*
|
||||
if($speaker->announcementEmailAlreadySent($summit))
|
||||
throw new ValidationException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'validation_errors.send_speaker_summit_assistance_announcement_mail_email_already_sent',
|
||||
[
|
||||
'summit_id' => $summit->getId(),
|
||||
'speaker_id' => $speaker->getId()
|
||||
]
|
||||
)
|
||||
);
|
||||
*/
|
||||
|
||||
$promo_code = $speaker->getPromoCodeFor($summit);
|
||||
|
||||
if(is_null($promo_code)){
|
||||
// try to get a new one
|
||||
$has_published =
|
||||
$speaker->hasPublishedRegularPresentations($summit, $role, true, $summit->getExcludedCategoriesForAcceptedPresentations()) ||
|
||||
$speaker->hasPublishedLightningPresentations($summit, $role, true, $summit->getExcludedCategoriesForAcceptedPresentations());
|
||||
$has_alternate = $speaker->hasAlternatePresentations($summit, $role, true, $summit->getExcludedCategoriesForAlternatePresentations());
|
||||
|
||||
if ($has_published) //get approved code
|
||||
{
|
||||
$promo_code = $this->registration_code_repository->getNextAvailableByType
|
||||
(
|
||||
$summit,
|
||||
SpeakerSummitRegistrationPromoCode::TypeAccepted
|
||||
);
|
||||
if (is_null($promo_code))
|
||||
throw new ValidationException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'validation_errors.send_speaker_summit_assistance_announcement_mail_run_out_promo_code',
|
||||
[
|
||||
'summit_id' => $summit->getId(),
|
||||
'speaker_id' => $speaker->getId(),
|
||||
'type' => SpeakerSummitRegistrationPromoCode::TypeAccepted
|
||||
]
|
||||
)
|
||||
);
|
||||
$speaker->addPromoCode($promo_code);
|
||||
}
|
||||
else if ($has_alternate) // get alternate code
|
||||
{
|
||||
$promo_code = $this->registration_code_repository->getNextAvailableByType
|
||||
(
|
||||
$summit,
|
||||
SpeakerSummitRegistrationPromoCode::TypeAlternate
|
||||
);
|
||||
if (is_null($promo_code))
|
||||
throw new ValidationException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'validation_errors.send_speaker_summit_assistance_announcement_mail_run_out_promo_code',
|
||||
[
|
||||
'summit_id' => $summit->getId(),
|
||||
'speaker_id' => $speaker->getId(),
|
||||
'type' => SpeakerSummitRegistrationPromoCode::TypeAccepted
|
||||
]
|
||||
)
|
||||
|
||||
);
|
||||
$speaker->addPromoCode($promo_code);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($promo_code))
|
||||
throw new ValidationException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'validation_errors.send_speaker_summit_assistance_promo_code_not_set',
|
||||
[
|
||||
'summit_id' => $summit->getId(),
|
||||
'speaker_id' => $speaker->getId(),
|
||||
]
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
$type = SpeakerSelectionAnnouncementEmailTypeFactory::build($summit, $speaker, $role);
|
||||
|
||||
if($promo_code->isRedeemed())
|
||||
throw new ValidationException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'validation_errors.send_speaker_summit_assistance_announcement_mail_code_already_redeemed',
|
||||
[
|
||||
'promo_code' => $promo_code->getCode()
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
if(!SpeakerSelectionAnnouncementEmailCreationRequest::isValidType($type))
|
||||
throw new ValidationException
|
||||
(
|
||||
trans
|
||||
(
|
||||
'validation_errors.send_speaker_summit_assistance_announcement_mail_invalid_mail_type',
|
||||
[
|
||||
'mail_type' => $type
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
// create email request
|
||||
$email_request = new SpeakerSelectionAnnouncementEmailCreationRequest();
|
||||
$email_request->setPromoCode($promo_code);
|
||||
$email_request->setSummit($summit);
|
||||
$email_request->setSpeaker($speaker);
|
||||
$email_request->setType($type);
|
||||
$email_request->setSpeakerRole($role);
|
||||
$this->email_creation_request_repository->add($email_request);
|
||||
$promo_code->setEmailSent(true);
|
||||
return $email_request;
|
||||
|
||||
});
|
||||
}
|
||||
}
|
|
@ -803,6 +803,15 @@ class ApiEndpointsSeeder extends Seeder
|
|||
sprintf(SummitScopes::WriteSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'send-speaker-assistance-mail',
|
||||
'route' => '/api/v1/summits/{id}/speakers-assistances/{assistance_id}/mail',
|
||||
'http_method' => 'POST',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::WriteSummitSpeakerAssistanceData, $current_realm),
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
* limitations under the License.
|
||||
**/
|
||||
return [
|
||||
'promo_code_delete_code_not_found' => 'promo code id :promo_code_id does not belongs to summit id :summit_id.',
|
||||
'promo_code_email_code_not_found' => 'promo code id :promo_code_id does not belongs to summit id :summit_id.',
|
||||
'add_speaker_assistance_speaker_not_found' => 'speaker id :speaker_id not found',
|
||||
'promo_code_delete_code_not_found' => 'promo code id :promo_code_id does not belongs to summit id :summit_id.',
|
||||
'promo_code_email_code_not_found' => 'promo code id :promo_code_id does not belongs to summit id :summit_id.',
|
||||
'add_speaker_assistance_speaker_not_found' => 'speaker id :speaker_id not found',
|
||||
'send_speaker_summit_assistance_announcement_mail_not_found_assistance' => 'summit speaker assistance :assistance_id not found for summit id :summit_id',
|
||||
];
|
|
@ -21,4 +21,9 @@ return [
|
|||
'add_speaker_assistance_speaker_already_has_assistance' => 'speaker id :speaker_id already has an assistance for summit id :summit_id',
|
||||
'add_speaker_assistance_speaker_is_not_on_summit' => 'speaker id :speaker_id is not related to summit id :summit_id ( is not assigned as speaker of any published presentations nor its assigned as moderator)',
|
||||
'speaker_assistance_does_not_belongs_to_summit' => 'summit assistance :assistance_id does not belongs to summit :summit_id',
|
||||
'send_speaker_summit_assistance_announcement_mail_email_already_sent' => 'speaker announcement email was already sent for speaker :speaker_id on summit :summit_id',
|
||||
'send_speaker_summit_assistance_announcement_mail_run_out_promo_code' => 'can not get any promo code for speaker :speaker_id , run out of :type promo codes for summit :summit_id',
|
||||
'send_speaker_summit_assistance_announcement_mail_code_already_redeemed' => 'promo code :promo_code already redeemed.',
|
||||
'send_speaker_summit_assistance_announcement_mail_invalid_mail_type' => 'mail type :mail_type is not valid.',
|
||||
'send_speaker_summit_assistance_promo_code_not_set' => 'speaker :speaker_id has not set a promo code for summit :summit_id, please set one manually.',
|
||||
];
|
|
@ -155,4 +155,43 @@ final class DoctrineTest extends TestCase
|
|||
$member = $speaker->getMember();
|
||||
$id = $member->getId();
|
||||
}
|
||||
|
||||
public function testGetSpeakerPublishedRegularPresentations($speaker_id = 1759){
|
||||
$repo1 = EntityManager::getRepository(\models\summit\PresentationSpeaker::class);
|
||||
$repo2 = EntityManager::getRepository(\models\summit\Summit::class);
|
||||
$summit = $repo2->getById(23);
|
||||
$speaker = $repo1->getById($speaker_id);
|
||||
|
||||
$this->assertTrue($speaker->hasPublishedRegularPresentations($summit));
|
||||
|
||||
$presentations = $speaker->getPublishedRegularPresentations($summit);
|
||||
|
||||
$this->assertTrue(count($presentations) > 0);
|
||||
}
|
||||
|
||||
public function testGetSpeakerAlternatePresentations($speaker_id = 70){
|
||||
$repo1 = EntityManager::getRepository(\models\summit\PresentationSpeaker::class);
|
||||
$repo2 = EntityManager::getRepository(\models\summit\Summit::class);
|
||||
$summit = $repo2->getById(23);
|
||||
$speaker = $repo1->getById($speaker_id);
|
||||
|
||||
$this->assertTrue($speaker->hasAlternatePresentations($summit));
|
||||
|
||||
$presentations = $speaker->getAlternatePresentations($summit);
|
||||
|
||||
$this->assertTrue(count($presentations) > 0);
|
||||
}
|
||||
|
||||
public function testGetSpeakerRejectedPresentations($speaker_id = 70){
|
||||
$repo1 = EntityManager::getRepository(\models\summit\PresentationSpeaker::class);
|
||||
$repo2 = EntityManager::getRepository(\models\summit\Summit::class);
|
||||
$summit = $repo2->getById(23);
|
||||
$speaker = $repo1->getById($speaker_id);
|
||||
|
||||
$this->assertTrue($speaker->hasRejectedPresentations($summit));
|
||||
|
||||
$presentations = $speaker->getRejectedPresentations($summit);
|
||||
|
||||
$this->assertTrue(count($presentations) > 0);
|
||||
}
|
||||
}
|
|
@ -278,4 +278,31 @@ final class OAuth2SpeakersAssistancesApiTest extends ProtectedApiTest
|
|||
return $assistance;
|
||||
}
|
||||
|
||||
public function testSendAnnouncementEmail($summit_id = 23, $assistance_id = 3541){
|
||||
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
'assistance_id' => $assistance_id
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"POST",
|
||||
"OAuth2SummitSpeakersAssistanceApiController@sendSpeakerSummitAssistanceAnnouncementMail",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers
|
||||
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(201);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue