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())
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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