Fixed erro on allow to see event logic
there were a null pointer exception when event hasnt an event type set Change-Id: Ie3fca917d74c764935ee1829d4a6e370f49858eb
This commit is contained in:
parent
68cab449dc
commit
36971f039f
@ -35,8 +35,6 @@ final class SummitGroupEventEntityEventInsertOrUpdateType extends SummitEventEnt
|
||||
if (!$published_old && !$published_current) return;
|
||||
$entity = $this->getEntity();
|
||||
|
||||
if (!$entity instanceof SummitGroupEvent) return;
|
||||
|
||||
$current_member = $this->process_ctx->getCurrentMember();
|
||||
|
||||
if (is_null($current_member)) return;
|
||||
|
@ -121,33 +121,6 @@ class SummitEventType extends SilverstripeBaseModel
|
||||
$this->blackout_times = $blackout_times;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param int $summit_id
|
||||
* @return bool
|
||||
*/
|
||||
static public function isPrivateType($type, $summit_id){
|
||||
$private_types = [ISummitEventType::GroupsEvents];
|
||||
return in_array($type, $private_types);
|
||||
|
||||
try{
|
||||
$sql = <<<SQL
|
||||
SELECT COUNT(DISTINCT(SummitEventType.ID))
|
||||
FROM SummitEventType
|
||||
WHERE SummitEventType.SummitID = :summit_id
|
||||
AND SummitEventType.Type = :$type
|
||||
SQL;
|
||||
$stmt = self::prepareRawSQLStatic($sql);
|
||||
$stmt->execute(['summit_id' => $summit->getId(), 'type' => $type]);
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return count($res) > 0 ;
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param string $type
|
||||
|
@ -30,7 +30,7 @@ final class SummitEventFactory
|
||||
if($type instanceof PresentationType)
|
||||
$event = new Presentation();
|
||||
|
||||
if(SummitEventType::isPrivateType($type->getType(), $summit->getId()))
|
||||
if($type->isPrivate())
|
||||
$event = new SummitGroupEvent();
|
||||
|
||||
if($type->isAllowsAttachment())
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php namespace models\summit;
|
||||
|
||||
/**
|
||||
* Copyright 2015 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -11,17 +12,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use Doctrine\ORM\Cache;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\main\Company;
|
||||
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;
|
||||
use DateTimeZone;
|
||||
use DateTime;
|
||||
use models\main\Company;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitRepository")
|
||||
@ -274,6 +274,7 @@ class Summit extends SilverstripeBaseModel
|
||||
{
|
||||
$this->dates_label = $dates_label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
@ -425,8 +426,7 @@ class Summit extends SilverstripeBaseModel
|
||||
{
|
||||
try {
|
||||
return $this->type;
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
} catch (\Exception $ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -442,11 +442,11 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getTypeId(){
|
||||
public function getTypeId()
|
||||
{
|
||||
try {
|
||||
return !is_null($this->type) ? $this->type->getId() : 0;
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
} catch (\Exception $ex) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -454,19 +454,24 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasType(){
|
||||
public function hasType()
|
||||
{
|
||||
return $this->getTypeId() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSummitExternalId(){ return $this->external_summit_id; }
|
||||
public function getSummitExternalId()
|
||||
{
|
||||
return $this->external_summit_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive(){
|
||||
public function isActive()
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
@ -516,7 +521,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param int $assistance_id
|
||||
* @return PresentationSpeakerSummitAssistanceConfirmationRequest|null
|
||||
*/
|
||||
public function getSpeakerAssistanceById($assistance_id){
|
||||
public function getSpeakerAssistanceById($assistance_id)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('id', intval($assistance_id)));
|
||||
$speaker_assistance = $this->speaker_assistances->matching($criteria)->first();
|
||||
@ -531,8 +537,7 @@ class Summit extends SilverstripeBaseModel
|
||||
{
|
||||
$summit_time_zone = $this->getTimeZone();
|
||||
|
||||
if(!is_null($summit_time_zone) && !empty($value))
|
||||
{
|
||||
if (!is_null($summit_time_zone) && !empty($value)) {
|
||||
$utc_timezone = new DateTimeZone("UTC");
|
||||
$timestamp = $value->format('Y-m-d H:i:s');
|
||||
$local_date = new DateTime($timestamp, $summit_time_zone);
|
||||
@ -544,7 +549,8 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return DateTimeZone|null
|
||||
*/
|
||||
public function getTimeZone(){
|
||||
public function getTimeZone()
|
||||
{
|
||||
$time_zone_id = $this->time_zone_id;
|
||||
if (empty($time_zone_id)) return null;
|
||||
$time_zone_list = timezone_identifiers_list();
|
||||
@ -554,6 +560,7 @@ class Summit extends SilverstripeBaseModel
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTime $value
|
||||
* @return null|DateTime
|
||||
@ -564,8 +571,7 @@ class Summit extends SilverstripeBaseModel
|
||||
if (empty($time_zone_id)) return $value;
|
||||
$time_zone_list = timezone_identifiers_list();
|
||||
|
||||
if(isset($time_zone_list[$time_zone_id]) && !empty($value))
|
||||
{
|
||||
if (isset($time_zone_list[$time_zone_id]) && !empty($value)) {
|
||||
$utc_timezone = new DateTimeZone("UTC");
|
||||
$time_zone_name = $time_zone_list[$time_zone_id];
|
||||
$summit_time_zone = new DateTimeZone($time_zone_name);
|
||||
@ -576,6 +582,7 @@ class Summit extends SilverstripeBaseModel
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
@ -595,7 +602,8 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @param SummitAbstractLocation $location
|
||||
*/
|
||||
public function addLocation(SummitAbstractLocation $location){
|
||||
public function addLocation(SummitAbstractLocation $location)
|
||||
{
|
||||
$this->locations->add($location);
|
||||
$location->setSummit($this);
|
||||
}
|
||||
@ -611,7 +619,8 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return SummitVenue[]
|
||||
*/
|
||||
public function getVenues(){
|
||||
public function getVenues()
|
||||
{
|
||||
return $this->locations->filter(function ($e) {
|
||||
return $e instanceof SummitVenue;
|
||||
});
|
||||
@ -620,7 +629,8 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return SummitHotel[]
|
||||
*/
|
||||
public function getHotels(){
|
||||
public function getHotels()
|
||||
{
|
||||
return $this->locations->filter(function ($e) {
|
||||
return $e instanceof SummitHotel;
|
||||
});
|
||||
@ -629,7 +639,8 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return SummitAirport[]
|
||||
*/
|
||||
public function getAirports(){
|
||||
public function getAirports()
|
||||
{
|
||||
return $this->locations->filter(function ($e) {
|
||||
return $e instanceof SummitAirport;
|
||||
});
|
||||
@ -638,7 +649,8 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return SummitExternalLocation[]
|
||||
*/
|
||||
public function getExternalLocations(){
|
||||
public function getExternalLocations()
|
||||
{
|
||||
return $this->locations->filter(function ($e) {
|
||||
return $e->getClassName() == 'SummitExternalLocation';
|
||||
});
|
||||
@ -647,14 +659,16 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getEvents(){
|
||||
public function getEvents()
|
||||
{
|
||||
return $this->events;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitEvent $event
|
||||
*/
|
||||
public function addEvent(SummitEvent $event){
|
||||
public function addEvent(SummitEvent $event)
|
||||
{
|
||||
$this->events->add($event);
|
||||
$event->setSummit($this);
|
||||
}
|
||||
@ -670,18 +684,19 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasLogo(){
|
||||
public function hasLogo()
|
||||
{
|
||||
return $this->getLogoId() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLogoId(){
|
||||
public function getLogoId()
|
||||
{
|
||||
try {
|
||||
return !is_null($this->logo) ? $this->logo->getId() : 0;
|
||||
}
|
||||
catch(\Exception $ex){
|
||||
} catch (\Exception $ex) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -722,7 +737,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEventType($type){
|
||||
public function hasEventType($type)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('type', $type));
|
||||
return $this->event_types->matching($criteria)->count() > 0;
|
||||
@ -732,7 +748,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param string $type
|
||||
* @return SummitEventType|null
|
||||
*/
|
||||
public function getEventTypeByType($type){
|
||||
public function getEventTypeByType($type)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('type', $type));
|
||||
$event_type = $this->event_types->matching($criteria)->first();
|
||||
@ -743,7 +760,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param int $wifi_connection_id
|
||||
* @return SummitWIFIConnection|null
|
||||
*/
|
||||
public function getWifiConnection($wifi_connection_id){
|
||||
public function getWifiConnection($wifi_connection_id)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('id', intval($wifi_connection_id)));
|
||||
$wifi_conn = $this->wifi_connections->matching($criteria)->first();
|
||||
@ -762,7 +780,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param int $ticket_type_id
|
||||
* @return SummitTicketType|null
|
||||
*/
|
||||
public function getTicketType($ticket_type_id){
|
||||
public function getTicketType($ticket_type_id)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('id', intval($ticket_type_id)));
|
||||
$ticket_type = $this->ticket_types->matching($criteria)->first();
|
||||
@ -773,7 +792,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param string $ticket_type_external_id
|
||||
* @return SummitTicketType|null
|
||||
*/
|
||||
public function getTicketTypeByExternalId($ticket_type_external_id){
|
||||
public function getTicketTypeByExternalId($ticket_type_external_id)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('external_id', $ticket_type_external_id));
|
||||
$ticket_type = $this->ticket_types->matching($criteria)->first();
|
||||
@ -797,24 +817,28 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param int $event_id
|
||||
* @return bool
|
||||
*/
|
||||
public function isEventOnSchedule($event_id){
|
||||
public function isEventOnSchedule($event_id)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('published', 1));
|
||||
$criteria->andWhere(Criteria::expr()->eq('id', intval($event_id)));
|
||||
return $this->events->matching($criteria)->count() > 0;
|
||||
}
|
||||
|
||||
public function getScheduleEvents(){
|
||||
public function getScheduleEvents()
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('published', 1));
|
||||
$criteria->orderBy(["start_date" => Criteria::ASC, "end_date" => Criteria::ASC]);
|
||||
return $this->events->matching($criteria);
|
||||
}
|
||||
|
||||
public function getPresentations(){
|
||||
public function getPresentations()
|
||||
{
|
||||
$query = $this->createQuery("SELECT p from models\summit\Presentation p JOIN p.summit s WHERE s.id = :summit_id");
|
||||
return $query->setParameter('summit_id', $this->getIdentifier())->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $event_id
|
||||
* @return null|SummitEvent
|
||||
@ -840,7 +864,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param PresentationCategory $track
|
||||
* @return $this
|
||||
*/
|
||||
public function addPresentationCategory(PresentationCategory $track){
|
||||
public function addPresentationCategory(PresentationCategory $track)
|
||||
{
|
||||
$this->presentation_categories->add($track);
|
||||
$track->setSummit($this);
|
||||
return $this;
|
||||
@ -850,7 +875,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param int $category_id
|
||||
* @return PresentationCategory
|
||||
*/
|
||||
public function getPresentationCategory($category_id){
|
||||
public function getPresentationCategory($category_id)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('id', intval($category_id)));
|
||||
$category = $this->presentation_categories->matching($criteria)->first();
|
||||
@ -861,7 +887,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param string $category_title
|
||||
* @return PresentationCategory
|
||||
*/
|
||||
public function getPresentationCategoryByTitle($category_title){
|
||||
public function getPresentationCategoryByTitle($category_title)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('title', intval($category_title)));
|
||||
$category = $this->presentation_categories->matching($criteria)->first();
|
||||
@ -872,7 +899,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param string $category_code
|
||||
* @return PresentationCategory
|
||||
*/
|
||||
public function getPresentationCategoryByCode($category_code){
|
||||
public function getPresentationCategoryByCode($category_code)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('code', trim($category_code)));
|
||||
$category = $this->presentation_categories->matching($criteria)->first();
|
||||
@ -923,7 +951,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param Member $member
|
||||
* @return SummitAttendee|null
|
||||
*/
|
||||
public function getAttendeeByMember(Member $member){
|
||||
public function getAttendeeByMember(Member $member)
|
||||
{
|
||||
return $this->getAttendeeByMemberId($member->getId());
|
||||
}
|
||||
|
||||
@ -981,7 +1010,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param bool $filter_published_events
|
||||
* @return \Doctrine\ORM\QueryBuilder
|
||||
*/
|
||||
private function buildSpeakersQuery($filter_published_events = true){
|
||||
private function buildSpeakersQuery($filter_published_events = true)
|
||||
{
|
||||
$query = $this->createQueryBuilder()
|
||||
->select('distinct ps')
|
||||
->from('models\summit\PresentationSpeaker', 'ps')
|
||||
@ -997,7 +1027,8 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return \Doctrine\ORM\QueryBuilder
|
||||
*/
|
||||
private function buildSpeakerSummitAttendanceQuery(){
|
||||
private function buildSpeakerSummitAttendanceQuery()
|
||||
{
|
||||
return $this->createQueryBuilder()
|
||||
->select('distinct ps')
|
||||
->from('models\summit\PresentationSpeaker', 'ps')
|
||||
@ -1010,7 +1041,8 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return PresentationSpeaker[]
|
||||
*/
|
||||
public function getSpeakers(){
|
||||
public function getSpeakers()
|
||||
{
|
||||
// moderators
|
||||
$moderators = $this->buildModeratorsQuery()->getQuery()->getResult();
|
||||
// get moderators ids to exclude from speakers
|
||||
@ -1036,7 +1068,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param Member $member
|
||||
* @return PresentationSpeaker|null
|
||||
*/
|
||||
public function getSpeakerByMember(Member $member){
|
||||
public function getSpeakerByMember(Member $member)
|
||||
{
|
||||
return $this->getSpeakerByMemberId($member->getId());
|
||||
}
|
||||
|
||||
@ -1045,7 +1078,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param bool $filter_published_events
|
||||
* @return PresentationSpeaker|null
|
||||
*/
|
||||
public function getSpeakerByMemberId($member_id, $filter_published_events = true){
|
||||
public function getSpeakerByMemberId($member_id, $filter_published_events = true)
|
||||
{
|
||||
// moderators
|
||||
$moderator = $this->buildModeratorsQuery($filter_published_events)
|
||||
->join('ps.member', 'mb')
|
||||
@ -1081,7 +1115,8 @@ class Summit extends SilverstripeBaseModel
|
||||
* @param bool $filter_published_events
|
||||
* @return PresentationSpeaker|null
|
||||
*/
|
||||
public function getSpeaker($speaker_id, $filter_published_events = true){
|
||||
public function getSpeaker($speaker_id, $filter_published_events = true)
|
||||
{
|
||||
// moderators
|
||||
$moderator = $this->buildModeratorsQuery($filter_published_events)
|
||||
->andWhere('ps.id = :speaker_id')
|
||||
@ -1112,7 +1147,8 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return Company[]
|
||||
*/
|
||||
public function getSponsors(){
|
||||
public function getSponsors()
|
||||
{
|
||||
$builder = $this->createQueryBuilder();
|
||||
return $builder
|
||||
->select('distinct c')
|
||||
@ -1126,7 +1162,8 @@ class Summit extends SilverstripeBaseModel
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMainPage(){
|
||||
public function getMainPage()
|
||||
{
|
||||
try {
|
||||
$sql = <<<SQL
|
||||
SELECT URLSegment FROM SiteTree
|
||||
@ -1138,8 +1175,7 @@ SQL;
|
||||
$stmt->execute(['summit_id' => $this->id]);
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return count($res) > 0 ? $res[0] : '';
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
}
|
||||
return '';
|
||||
@ -1148,7 +1184,8 @@ SQL;
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSchedulePage(){
|
||||
public function getSchedulePage()
|
||||
{
|
||||
try {
|
||||
$sql = <<<SQL
|
||||
SELECT URLSegment FROM SiteTree
|
||||
@ -1160,8 +1197,7 @@ SQL;
|
||||
$stmt->execute(['summit_id' => $this->id]);
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return count($res) > 0 ? $res[0] : '';
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
}
|
||||
return '';
|
||||
@ -1171,13 +1207,19 @@ SQL;
|
||||
* @param SummitEvent $summit_event
|
||||
* @param Member|null $member
|
||||
* @return bool
|
||||
* @throws ValidationException
|
||||
*/
|
||||
static public function allowToSee(SummitEvent $summit_event, Member $member = null)
|
||||
{
|
||||
|
||||
if (SummitEventType::isPrivateType($summit_event->getType()->getType(), $summit_event->getSummitId())) {
|
||||
if (is_null($member))
|
||||
return false;
|
||||
$event_type = $summit_event->getType();
|
||||
|
||||
if (is_null($event_type))
|
||||
throw new ValidationException(sprintf("event type is null for event id %s", $summit_event->getId()));
|
||||
|
||||
if (!$event_type->isPrivate()) return true;
|
||||
|
||||
if (is_null($member)) return false;
|
||||
|
||||
if ($member->isAdmin()) return true;
|
||||
|
||||
@ -1199,14 +1241,13 @@ SQL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Member $member
|
||||
* @return SummitGroupEvent[]
|
||||
*/
|
||||
public function getGroupEventsFor(Member $member){
|
||||
public function getGroupEventsFor(Member $member)
|
||||
{
|
||||
$builder = $this->createQueryBuilder()
|
||||
->select('distinct eg')
|
||||
->from('models\summit\SummitGroupEvent', 'eg')
|
||||
@ -1228,7 +1269,8 @@ SQL;
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSlug(){
|
||||
public function getSlug()
|
||||
{
|
||||
$res = "openstack-" . $this->name . '-';
|
||||
$res .= $this->begin_date->format('Y') . '-summit';
|
||||
$res = strtolower(preg_replace('/[^a-zA-Z0-9\-]/', '', $res));
|
||||
@ -1238,7 +1280,8 @@ SQL;
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPresentationVotesCount(){
|
||||
public function getPresentationVotesCount()
|
||||
{
|
||||
|
||||
|
||||
try {
|
||||
@ -1252,8 +1295,7 @@ SQL;
|
||||
$stmt->execute(['summit_id' => $this->id]);
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return count($res) > 0 ? $res[0] : 0;
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
}
|
||||
return 0;
|
||||
@ -1262,7 +1304,8 @@ SQL;
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPresentationVotersCount(){
|
||||
public function getPresentationVotersCount()
|
||||
{
|
||||
try {
|
||||
$sql = <<<SQL
|
||||
SELECT COUNT(DISTINCT(Vote.MemberID)) AS voter_count
|
||||
@ -1274,8 +1317,7 @@ SQL;
|
||||
$stmt->execute(['summit_id' => $this->id]);
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return count($res) > 0 ? $res[0] : 0;
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
}
|
||||
return 0;
|
||||
@ -1349,21 +1391,24 @@ SQL;
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAttendeesCount(){
|
||||
public function getAttendeesCount()
|
||||
{
|
||||
return $this->attendees->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSpeakersCount(){
|
||||
public function getSpeakersCount()
|
||||
{
|
||||
return count($this->getSpeakers());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPresentationsSubmittedCount(){
|
||||
public function getPresentationsSubmittedCount()
|
||||
{
|
||||
|
||||
try {
|
||||
$sql = <<<SQL
|
||||
@ -1376,8 +1421,7 @@ SQL;
|
||||
$stmt->execute(['summit_id' => $this->id, 'status' => Presentation::STATUS_RECEIVED]);
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return count($res) > 0 ? $res[0] : 0;
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
}
|
||||
return 0;
|
||||
@ -1386,7 +1430,8 @@ SQL;
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPublishedEventsCount(){
|
||||
public function getPublishedEventsCount()
|
||||
{
|
||||
try {
|
||||
$sql = <<<SQL
|
||||
SELECT COUNT(DISTINCT(SummitEvent.ID))
|
||||
@ -1397,8 +1442,7 @@ SQL;
|
||||
$stmt->execute(['summit_id' => $this->id]);
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return count($res) > 0 ? $res[0] : 0;
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
}
|
||||
return 0;
|
||||
@ -1410,7 +1454,8 @@ SQL;
|
||||
* @param strign $type
|
||||
* @return int
|
||||
*/
|
||||
public function getSpeakerAnnouncementEmailCount($type){
|
||||
public function getSpeakerAnnouncementEmailCount($type)
|
||||
{
|
||||
try {
|
||||
$sql = <<<SQL
|
||||
SELECT COUNT(DISTINCT(SpeakerAnnouncementSummitEmail.ID))
|
||||
@ -1421,8 +1466,7 @@ SQL;
|
||||
$stmt->execute(['summit_id' => $this->id, 'type' => $type]);
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return count($res) > 0 ? $res[0] : 0;
|
||||
}
|
||||
catch (\Exception $ex){
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
}
|
||||
return 0;
|
||||
@ -1431,49 +1475,56 @@ SQL;
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSpeakerAnnouncementEmailAcceptedCount(){
|
||||
public function getSpeakerAnnouncementEmailAcceptedCount()
|
||||
{
|
||||
return $this->getSpeakerAnnouncementEmailCount('ACCEPTED');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSpeakerAnnouncementEmailRejectedCount(){
|
||||
public function getSpeakerAnnouncementEmailRejectedCount()
|
||||
{
|
||||
return $this->getSpeakerAnnouncementEmailCount('REJECTED');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSpeakerAnnouncementEmailAlternateCount(){
|
||||
public function getSpeakerAnnouncementEmailAlternateCount()
|
||||
{
|
||||
return $this->getSpeakerAnnouncementEmailCount('ALTERNATE');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSpeakerAnnouncementEmailAcceptedAlternateCount(){
|
||||
public function getSpeakerAnnouncementEmailAcceptedAlternateCount()
|
||||
{
|
||||
return $this->getSpeakerAnnouncementEmailCount('ACCEPTED_ALTERNATE');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSpeakerAnnouncementEmailAcceptedRejectedCount(){
|
||||
public function getSpeakerAnnouncementEmailAcceptedRejectedCount()
|
||||
{
|
||||
return $this->getSpeakerAnnouncementEmailCount('ACCEPTED_REJECTED');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSpeakerAnnouncementEmailAlternateRejectedCount(){
|
||||
public function getSpeakerAnnouncementEmailAlternateRejectedCount()
|
||||
{
|
||||
return $this->getSpeakerAnnouncementEmailCount('ALTERNATE_REJECTED');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitRegistrationPromoCode $promo_code
|
||||
*/
|
||||
public function addPromoCode(SummitRegistrationPromoCode $promo_code){
|
||||
public function addPromoCode(SummitRegistrationPromoCode $promo_code)
|
||||
{
|
||||
$this->promo_codes->add($promo_code);
|
||||
$promo_code->setSummit($this);
|
||||
}
|
||||
@ -1482,7 +1533,8 @@ SQL;
|
||||
* @param string $code
|
||||
* @return SummitRegistrationPromoCode|null
|
||||
*/
|
||||
public function getPromoCodeByCode($code){
|
||||
public function getPromoCodeByCode($code)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('code', trim($code)));
|
||||
$promo_code = $this->promo_codes->matching($criteria)->first();
|
||||
@ -1493,7 +1545,8 @@ SQL;
|
||||
* @param int $promo_code_id
|
||||
* @return SummitRegistrationPromoCode|null
|
||||
*/
|
||||
public function getPromoCodeById($promo_code_id){
|
||||
public function getPromoCodeById($promo_code_id)
|
||||
{
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(Criteria::expr()->eq('id', $promo_code_id));
|
||||
$promo_code = $this->promo_codes->matching($criteria)->first();
|
||||
@ -1504,7 +1557,8 @@ SQL;
|
||||
* @param SummitRegistrationPromoCode $promo_code
|
||||
* @return $this
|
||||
*/
|
||||
public function removePromoCode(SummitRegistrationPromoCode $promo_code){
|
||||
public function removePromoCode(SummitRegistrationPromoCode $promo_code)
|
||||
{
|
||||
$this->promo_codes->removeElement($promo_code);
|
||||
$promo_code->setSummit(null);
|
||||
return $this;
|
||||
@ -1514,7 +1568,8 @@ SQL;
|
||||
* @param SummitEventType $event_type
|
||||
* @return $this
|
||||
*/
|
||||
public function removeEventType(SummitEventType $event_type){
|
||||
public function removeEventType(SummitEventType $event_type)
|
||||
{
|
||||
$this->event_types->removeElement($event_type);
|
||||
$event_type->setSummit(null);
|
||||
return $this;
|
||||
@ -1564,7 +1619,8 @@ SQL;
|
||||
* @param SummitEventType $event_type
|
||||
* @return $this
|
||||
*/
|
||||
public function addEventType(SummitEventType $event_type){
|
||||
public function addEventType(SummitEventType $event_type)
|
||||
{
|
||||
$this->event_types->add($event_type);
|
||||
$event_type->setSummit($this);
|
||||
return $this;
|
||||
|
@ -215,9 +215,11 @@ final class SummitService implements ISummitService
|
||||
$this->tx_service->transaction(function () use ($summit, $member, $event_id, $check_rsvp) {
|
||||
|
||||
$event = $summit->getScheduleEvent($event_id);
|
||||
|
||||
if (is_null($event)) {
|
||||
throw new EntityNotFoundException('event not found on summit!');
|
||||
}
|
||||
|
||||
if(!Summit::allowToSee($event, $member))
|
||||
throw new EntityNotFoundException('event not found on summit!');
|
||||
|
||||
@ -581,8 +583,8 @@ final class SummitService implements ISummitService
|
||||
return false;
|
||||
}
|
||||
|
||||
$old_is_private = SummitEventType::isPrivateType($old_event_type->getType(), $old_event_type->getSummitId());
|
||||
$new_is_private = SummitEventType::isPrivateType($event_type->getType(), $event_type->getSummitId());
|
||||
$old_is_private = $old_event_type->isPrivate();
|
||||
$new_is_private = $event_type->isPrivate();
|
||||
|
||||
if((!$old_is_private && $new_is_private) || ($old_is_private && !$new_is_private))
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user