Updated Eventbrite permission model

moved schedule collection from attendee
to member, so in that way now is enough
to have an openstack membership in order
to create a schedule.

Change-Id: Ief54112960ccc7252cd57ca28238f39a448be323
This commit is contained in:
Sebastian Marcet 2017-07-11 19:53:17 -03:00
parent 5b6011dd91
commit d540167d7e
19 changed files with 895 additions and 546 deletions

View File

@ -1,6 +1,7 @@
<?php namespace App\Events;
use models\summit\SummitAttendee;
use models\main\Member;
use models\summit\Summit;
/**
* Class MyScheduleAdd
@ -10,23 +11,30 @@ class MyScheduleAdd extends SummitEventAction
{
/**
* @var SummitAttendee
* @var Member
*/
protected $attendee;
protected $member;
/**
* @var Summit
*/
protected $summit;
/**
* MyScheduleAdd constructor.
* @param SummitAttendee $attendee
* @param Member $member
* @param Summit $summit
* @param int $event_id
*/
function __construct(SummitAttendee $attendee, $event_id)
{
$this->attendee = $attendee;
public function __construct($member, $summit, $event_id){
$this->member = $member;
$this->summit = $summit;
parent::__construct($event_id);
}
/**
* @return SummitAttendee
*/
public function getAttendee(){ return $this->attendee;}
public function getMember(){ return $this->member; }
public function getSummit(){ return $this->summit;}
}

View File

@ -72,85 +72,7 @@ final class OAuth2SummitAttendeesApiController extends OAuth2ProtectedController
/**
* Attendees endpoints
*/
/**
* @param $summit_id
* @return mixed
*/
/*public function getAttendees($summit_id)
{
try {
$values = Input::all();
$rules = array
(
'page' => 'integer|min:1',
'per_page' => 'required_with:page|integer|min:5|max:100',
);
$validation = Validator::make($values, $rules);
if ($validation->fails()) {
$messages = $validation->messages()->toArray();
return $this->error412($messages);
}
$summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
if (is_null($summit)) return $this->error404();
// default values
$page = 1;
$per_page = 5;
if (Input::has('page')) {
$page = intval(Input::get('page'));
$per_page = intval(Input::get('per_page'));
}
$filter = null;
if (Input::has('filter')) {
$filter = FilterParser::parse(Input::get('filter'), array
(
'first_name' => array('=@', '=='),
'last_name' => array('=@', '=='),
'email' => array('=@', '=='),
));
}
$order = null;
if (Input::has('order'))
{
$order = OrderParser::parse(Input::get('order'), array
(
'first_name',
'last_name',
));
}
list($total, $per_page, $current_page, $last_page, $items) = $summit->attendees($page, $per_page, $filter, $order);
return $this->ok
(
array
(
'total' => $total,
'per_page' => $per_page,
'current_page' => $current_page,
'last_page' => $last_page,
'data' => $items,
)
);
}
catch (Exception $ex)
{
Log::error($ex);
return $this->error500($ex);
}
}*/
/**
/**
* @param $summit_id
* @param $attendee_id
* @return mixed
@ -231,7 +153,7 @@ final class OAuth2SummitAttendeesApiController extends OAuth2ProtectedController
$attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
if (is_null($attendee)) return $this->error404();
$this->service->addEventToAttendeeSchedule($summit, $attendee, intval($event_id));
$this->service->addEventToMemberSchedule($summit, $attendee->getMember(), intval($event_id));
return $this->created();
}
@ -273,7 +195,7 @@ final class OAuth2SummitAttendeesApiController extends OAuth2ProtectedController
$attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
if (is_null($attendee)) return $this->error404();
$this->service->removeEventFromAttendeeSchedule($summit, $attendee, intval($event_id));
$this->service->removeEventFromMemberSchedule($summit, $attendee->getMember(), intval($event_id));
return $this->deleted();
@ -306,41 +228,6 @@ final class OAuth2SummitAttendeesApiController extends OAuth2ProtectedController
* @param $event_id
* @return mixed
*/
public function checkingAttendeeOnEvent($summit_id, $attendee_id, $event_id)
{
try {
$summit = SummitFinderStrategyFactory::build($this->repository)->find($summit_id);
if (is_null($summit)) return $this->error404();
$attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
if (is_null($attendee)) return $this->error404();
$this->service->checkInAttendeeOnEvent($summit, $attendee, intval($event_id));
return $this->updated();
}
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(\HTTP401UnauthorizedException $ex3)
{
Log::warning($ex3);
return $this->error401();
}
catch (Exception $ex) {
Log::error($ex);
return $this->error500($ex);
}
}
public function deleteEventRSVP($summit_id, $attendee_id, $event_id){
try {
@ -356,7 +243,7 @@ final class OAuth2SummitAttendeesApiController extends OAuth2ProtectedController
$attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
if (is_null($attendee)) return $this->error404();
$this->service->unRSVPEvent($summit, $attendee, $event_id);
$this->service->unRSVPEvent($summit, $attendee->getMember(), $event_id);
return $this->deleted();

View File

@ -100,10 +100,10 @@ final class OAuth2SummitMembersApiController extends OAuth2ProtectedController
if (is_null($current_member)) return $this->error404();
$favorites = array();
foreach ($current_member->getFavoritesSummitEvents() as $favorite_event)
foreach ($current_member->getFavoritesSummitEventsBySummit($summit) as $favorite_event)
{
if(!$summit->isEventOnSchedule($favorite_event->getId())) continue;
$favorites[] = SerializerRegistry::getInstance()->getSerializer($favorite_event)->serialize();
if(!$summit->isEventOnSchedule($favorite_event->getEvent()->getId())) continue;
$favorites[] = SerializerRegistry::getInstance()->getSerializer($favorite_event)->serialize(Request::input('expand', ''));
}
$response = new PagingResponse
@ -137,9 +137,14 @@ final class OAuth2SummitMembersApiController extends OAuth2ProtectedController
Log::error($ex);
return $this->error500($ex);
}
}
/**
* @param $summit_id
* @param $member_id
* @param $event_id
* @return mixed
*/
public function addEventToMemberFavorites($summit_id, $member_id, $event_id){
try {
@ -179,6 +184,12 @@ final class OAuth2SummitMembersApiController extends OAuth2ProtectedController
}
}
/**
* @param $summit_id
* @param $member_id
* @param $event_id
* @return mixed
*/
public function removeEventFromMemberFavorites($summit_id, $member_id, $event_id){
try {
@ -216,4 +227,201 @@ final class OAuth2SummitMembersApiController extends OAuth2ProtectedController
return $this->error500($ex);
}
}
/**
* @param $summit_id
* @param $member_id
* @return mixed
*/
public function getMemberScheduleSummitEvents($summit_id, $member_id){
try {
$summit = SummitFinderStrategyFactory::build($this->summit_repository)->find($summit_id);
if (is_null($summit)) return $this->error404();
$current_member_id = $this->resource_server_context->getCurrentUserExternalId();
if (is_null($current_member_id)) return $this->error403();
$current_member = $this->repository->getById($current_member_id);
if (is_null($current_member)) return $this->error404();
$schedule = array();
foreach ($current_member->getScheduleBySummit($summit) as $schedule_event)
{
if(!$summit->isEventOnSchedule($schedule_event->getEvent()->getId())) continue;
$schedule[] = SerializerRegistry::getInstance()->getSerializer($schedule_event)->serialize(Request::input('expand', ''));
}
$response = new PagingResponse
(
count($schedule),
count($schedule),
1,
1,
$schedule
);
return $this->ok($response->toArray($expand = Input::get('expand','')));
}
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(\HTTP401UnauthorizedException $ex3)
{
Log::warning($ex3);
return $this->error401();
}
catch (\Exception $ex)
{
Log::error($ex);
return $this->error500($ex);
}
}
/**
* @param $summit_id
* @param $member_id
* @param $event_id
* @return mixed
*/
public function addEventToMemberSchedule($summit_id, $member_id, $event_id)
{
try {
$summit = SummitFinderStrategyFactory::build($this->summit_repository)->find($summit_id);
if (is_null($summit)) return $this->error404();
$current_member_id = $this->resource_server_context->getCurrentUserExternalId();
if (is_null($current_member_id)) return $this->error403();
$current_member = $this->repository->getById($current_member_id);
if (is_null($current_member)) return $this->error404();
$this->summit_service->addEventToMemberSchedule($summit, $current_member, intval($event_id));
return $this->created();
}
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(\HTTP401UnauthorizedException $ex3)
{
Log::warning($ex3);
return $this->error401();
}
catch (\Exception $ex)
{
Log::error($ex);
return $this->error500($ex);
}
}
/**
* @param $summit_id
* @param $member_id
* @param $event_id
* @return mixed
*/
public function removeEventFromMemberSchedule($summit_id, $member_id, $event_id)
{
try {
$summit = SummitFinderStrategyFactory::build($this->summit_repository)->find($summit_id);
if (is_null($summit)) return $this->error404();
$current_member_id = $this->resource_server_context->getCurrentUserExternalId();
if (is_null($current_member_id)) return $this->error403();
$current_member = $this->repository->getById($current_member_id);
if (is_null($current_member)) return $this->error404();
$this->summit_service->removeEventFromMemberSchedule($summit, $current_member, intval($event_id));
return $this->deleted();
}
catch (ValidationException $ex1)
{
Log::warning($ex1);
return $this->error412(array( $ex1->getMessage()));
}
catch (EntityNotFoundException $ex2)
{
Log::warning($ex2);
return $this->error404(array('message' => $ex2->getMessage()));
}
catch(\HTTP401UnauthorizedException $ex3)
{
Log::warning($ex3);
return $this->error401();
}
catch (\Exception $ex)
{
Log::error($ex);
return $this->error500($ex);
}
}
/**
* @param $summit_id
* @param $member_id
* @param $event_id
* @return mixed
*/
public function deleteEventRSVP($summit_id, $member_id, $event_id){
try {
$summit = SummitFinderStrategyFactory::build($this->summit_repository)->find($summit_id);
if (is_null($summit)) return $this->error404();
$current_member_id = $this->resource_server_context->getCurrentUserExternalId();
if (is_null($current_member_id)) return $this->error403();
$current_member = $this->repository->getById($current_member_id);
if (is_null($current_member)) return $this->error404();
$event = $summit->getScheduleEvent(intval($event_id));
if (is_null($event)) {
return $this->error404();
}
$this->summit_service->unRSVPEvent($summit, $current_member, $event_id);
return $this->deleted();
}
catch (ValidationException $ex1)
{
Log::warning($ex1);
return $this->error412(array( $ex1->getMessage()));
}
catch (EntityNotFoundException $ex2)
{
Log::warning($ex2);
return $this->error404(array('message' => $ex2->getMessage()));
}
catch(\HTTP401UnauthorizedException $ex3)
{
Log::warning($ex3);
return $this->error401();
}
catch (Exception $ex) {
Log::error($ex);
return $this->error500($ex);
}
}
}

View File

@ -219,6 +219,7 @@ Route::group([
Route::group(array('prefix' => 'members'), function () {
Route::group(array('prefix' => '{member_id}'), function () {
Route::get('', 'OAuth2SummitMembersApiController@getMyMember')->where('member_id', 'me');
// favorites
Route::group(array('prefix' => 'favorites'), function ()
{
Route::get('', 'OAuth2SummitMembersApiController@getMemberFavoritesSummitEvents')->where('member_id', 'me');
@ -228,6 +229,18 @@ Route::group([
Route::delete('', 'OAuth2SummitMembersApiController@removeEventFromMemberFavorites')->where('member_id', 'me');
});
});
// schedule
Route::group(array('prefix' => 'schedule'), function ()
{
Route::get('', 'OAuth2SummitMembersApiController@getMemberScheduleSummitEvents')->where('member_id', 'me');
Route::group(array('prefix' => '{event_id}'), function (){
Route::delete('/rsvp', 'OAuth2SummitMembersApiController@deleteEventRSVP')->where('member_id', 'me');
Route::post('', 'OAuth2SummitMembersApiController@addEventToMemberSchedule')->where('member_id', 'me');
Route::delete('', 'OAuth2SummitMembersApiController@removeEventFromMemberSchedule')->where('member_id', 'me');
});
});
});
});

View File

@ -25,6 +25,7 @@ final class OwnMemberSerializer extends AbstractMemberSerializer
'groups_events',
'favorite_summit_events',
'feedback',
'schedule_summit_events',
];
private static $expand_group_events = [
@ -90,6 +91,17 @@ final class OwnMemberSerializer extends AbstractMemberSerializer
$values['favorite_summit_events'] = $res;
}
if(in_array('schedule_summit_events', $relations) && !is_null($summit)){
$schedule = [];
foreach ($member->getScheduledEventsIds($summit) as $event_id){
$schedule[] = intval($event_id);
}
$values['schedule_summit_events'] = $schedule;
}
if (!empty($expand)) {
$exp_expand = explode(',', $expand);
foreach ($exp_expand as $relation) {
@ -125,13 +137,24 @@ final class OwnMemberSerializer extends AbstractMemberSerializer
if(!in_array('favorite_summit_events', $relations)) break;
if(is_null($summit)) break;
$favorites = [];
foreach ($member->getFavoritesSummitEvents($summit) as $events){
foreach ($member->getFavoritesSummitEventsBySummit($summit) as $events){
$favorites[] = SerializerRegistry::getInstance()
->getSerializer($events)
->serialize($expand);
}
$values['favorite_summit_events'] = $favorites;
}
case 'schedule_summit_events':{
if(!in_array('schedule_summit_events', $relations)) break;
if(is_null($summit)) break;
$schedule = [];
foreach ($member->getScheduleBySummit($summit) as $events){
$schedule[] = SerializerRegistry::getInstance()
->getSerializer($events)
->serialize($expand);
}
$values['schedule_summit_events'] = $schedule;
}
break;
}
}

View File

@ -75,7 +75,8 @@ final class SerializerRegistry
$this->registry['PresentationSpeaker'] = PresentationSpeakerSerializer::class;
$this->registry['SummitEventFeedback'] = SummitEventFeedbackSerializer::class;
$this->registry['SummitAttendee'] = SummitAttendeeSerializer::class;
$this->registry['SummitAttendeeSchedule'] = SummitAttendeeScheduleSerializer::class;
$this->registry['SummitMemberSchedule'] = SummitMemberScheduleSerializer::class;
$this->registry['SummitMemberFavorite'] = SummitMemberFavoriteSerializer::class;
$this->registry['SummitEntityEvent'] = SummitEntityEventSerializer::class;
$this->registry['SummitEventWithFile'] = SummitEventWithFileSerializer::class;

View File

@ -0,0 +1,40 @@
<?php namespace ModelSerializers;
/**
* Copyright 2017 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.
**/
/**
* Class SummitMemberFavoriteSerializer
* @package ModelSerializers
*/
final class SummitMemberFavoriteSerializer extends SilverStripeSerializer
{
protected static $array_mappings = array
(
);
public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array() )
{
$favorite = $this->object;
$values = SerializerRegistry::getInstance()->getSerializer($favorite->getEvent())->serialize
(
$expand,
$fields,
$relations,
$params
);
return $values;
}
}

View File

@ -1,6 +1,6 @@
<?php namespace ModelSerializers;
/**
* Copyright 2016 OpenStack Foundation
* Copyright 2017 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
@ -11,13 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use libs\utils\JsonUtils;
/**
* Class SummitAttendeeScheduleSerializer
* Class SummitMemberScheduleSerializer
* @package ModelSerializers
*/
class SummitAttendeeScheduleSerializer extends SilverStripeSerializer
final class SummitMemberScheduleSerializer extends SilverStripeSerializer
{
protected static $array_mappings = array
@ -37,7 +36,6 @@ class SummitAttendeeScheduleSerializer extends SilverStripeSerializer
$params
);
$values['is_checked_in'] = JsonUtils::toJsonBoolean($schedule->isIsCheckedIn());
return $values;
}
}

View File

@ -15,7 +15,11 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use models\exceptions\ValidationException;
use models\summit\RSVP;
use models\summit\Summit;
use models\summit\SummitEvent;
use models\summit\SummitEventFeedback;
@ -37,13 +41,27 @@ class Member extends SilverstripeBaseModel
public function __construct()
{
parent::__construct();
$this->feedback = new ArrayCollection();
$this->groups = new ArrayCollection();
$this->affiliations = new ArrayCollection();
$this->team_memberships = new ArrayCollection();
$this->favorites_summit_events = new ArrayCollection();
$this->feedback = new ArrayCollection();
$this->groups = new ArrayCollection();
$this->affiliations = new ArrayCollection();
$this->team_memberships = new ArrayCollection();
$this->favorites = new ArrayCollection();
$this->schedule = new ArrayCollection();
$this->rsvp = new ArrayCollection();
}
/**
* @ORM\OneToMany(targetEntity="SummitMemberSchedule", mappedBy="member", cascade={"persist"}, orphanRemoval=true)
* @var SummitMemberSchedule[]
*/
private $schedule;
/**
* @ORM\OneToMany(targetEntity="models\summit\RSVP", mappedBy="owner", cascade={"persist"})
* @var RSVP[]
*/
protected $rsvp;
/**
* @return Affiliation[]
*/
@ -134,26 +152,23 @@ class Member extends SilverstripeBaseModel
*/
public function getFavoritesSummitEvents()
{
return $this->favorites_summit_events;
return $this->favorites;
}
/**
* @param SummitEvent[] $favorites_summit_events
* @param SummitMemberFavorite[] $favorites
*/
public function setFavoritesSummitEvents($favorites_summit_events)
public function setFavoritesSummitEvents($favorites)
{
$this->favorites_summit_events = $favorites_summit_events;
$this->favorites = $favorites;
}
/**
* @ORM\ManyToMany(targetEntity="models\summit\SummitEvent")
* @ORM\JoinTable(name="Member_FavoriteSummitEvents",
* joinColumns={@ORM\JoinColumn(name="MemberID", referencedColumnName="ID")},
* inverseJoinColumns={@ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")}
* )
* @var SummitEvent[]
* @ORM\OneToMany(targetEntity="SummitMemberFavorite", mappedBy="member", cascade={"persist"}, orphanRemoval=true)
* @var SummitMemberFavorite[]
*/
private $favorites_summit_events;
private $favorites;
/**
* @return string
@ -561,7 +576,12 @@ class Member extends SilverstripeBaseModel
(
sprintf('Event %s is not published', $event->getId())
);
$this->favorites_summit_events->add($event);
$favorite = new SummitMemberFavorite();
$favorite->setMember($this);
$favorite->setEvent($event);
$this->favorites->add($favorite);
}
/**
@ -591,30 +611,228 @@ SQL;
*/
public function removeFavoriteSummitEvent(SummitEvent $event)
{
if (!$this->isOnFavorite($event)) {
$favorite = $this->getFavoriteByEvent($event);
if(is_null($favorite))
throw new ValidationException
(
sprintf('Event %s does not belongs to member %s favorites.', $event->getId(), $this->getId())
sprintf('Event %s does not belongs to member %s favorite.', $event->getId(), $this->getId())
);
}
$this->favorites_summit_events->removeElement($event);
$this->schedule->removeElement($favorite);
$favorite->clearOwner();
}
/**
* @param Summit $summit
* @return int[]
*/
public function getFavoritesEventsIds()
public function getFavoritesEventsIds(Summit $summit)
{
$sql = <<<SQL
SELECT SummitEventID
FROM Member_FavoriteSummitEvents
INNER JOIN SummitEvent ON SummitEvent.ID = Member_FavoriteSummitEvents.SummitEventID
WHERE MemberID = :member_id AND SummitEvent.Published = 1
WHERE MemberID = :member_id AND SummitEvent.Published = 1 AND SummitEvent.SummitID = :summit_id
SQL;
$stmt = $this->prepareRawSQL($sql);
$stmt->execute(['member_id' => $this->getId()]);
$stmt->execute(
[
'member_id' => $this->getId(),
'summit_id' => $summit->getId(),
]
);
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
}
/**
* @param SummitEvent $event
* @throws ValidationException
*/
public function add2Schedule(SummitEvent $event)
{
if($this->isOnSchedule($event))
throw new ValidationException
(
sprintf('Event %s already belongs to member %s schedule.', $event->getId(), $this->getId())
);
if(!$event->isPublished())
throw new ValidationException
(
sprintf('Event %s is not published', $event->getId())
);
$schedule = new SummitMemberSchedule();
$schedule->setMember($this);
$schedule->setEvent($event);
$this->schedule->add($schedule);
}
public function removeFromSchedule(SummitEvent $event)
{
$schedule = $this->getScheduleByEvent($event);
if(is_null($schedule))
throw new ValidationException
(
sprintf('Event %s does not belongs to member %s schedule.', $event->getId(), $this->getId())
);
$this->schedule->removeElement($schedule);
$schedule->clearOwner();
}
/**
* @param SummitEvent $event
* @return bool
*/
public function isOnSchedule(SummitEvent $event)
{
$sql = <<<SQL
SELECT COUNT(SummitEventID) AS QTY
FROM Member_Schedule
WHERE MemberID = :member_id AND SummitEventID = :event_id
SQL;
$stmt = $this->prepareRawSQL($sql);
$stmt->execute([
'member_id' => $this->getId(),
'event_id' => $event->getId()
]);
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
return count($res) > 0 ? intval($res[0]) > 0 : false;
}
/**
* @param SummitEvent $event
* @return null| SummitMemberSchedule
*/
public function getScheduleByEvent(SummitEvent $event){
try {
$query = $this->createQuery("SELECT s from models\main\SummitMemberSchedule s
JOIN s.member a
JOIN s.event e
WHERE a.id = :member_id and e.id = :event_id
");
return $query
->setParameter('member_id', $this->getIdentifier())
->setParameter('event_id', $event->getIdentifier())
->getSingleResult();
}
catch(NoResultException $ex1){
return null;
}
catch(NonUniqueResultException $ex2){
// should never happen
return null;
}
}
/**
* @param SummitEvent $event
* @return SummitMemberFavorite|null
*/
public function getFavoriteByEvent(SummitEvent $event){
try {
$query = $this->createQuery("SELECT f from models\main\SummitMemberFavorite f
JOIN f.member a
JOIN f.event e
WHERE a.id = :member_id and e.id = :event_id
");
return $query
->setParameter('member_id', $this->getIdentifier())
->setParameter('event_id', $event->getIdentifier())
->getSingleResult();
}
catch(NoResultException $ex1){
return null;
}
catch(NonUniqueResultException $ex2){
// should never happen
return null;
}
}
/**
* @return SummitMemberSchedule[]
*/
public function getSchedule(){
return $this->schedule;
}
/**
* @param Summit $summit
* @return int[]
*/
public function getScheduledEventsIds(Summit $summit){
$sql = <<<SQL
SELECT SummitEventID
FROM Member_Schedule
INNER JOIN SummitEvent ON SummitEvent.ID = Member_Schedule.SummitEventID
WHERE MemberID = :member_id AND SummitEvent.Published = 1 AND SummitEvent.SummitID = :summit_id
SQL;
$stmt = $this->prepareRawSQL($sql);
$stmt->execute(
[
'member_id' => $this->getId(),
'summit_id' => $summit->getId(),
]
);
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
}
/**
* @param int $event_id
* @return null|RSVP
*/
public function getRsvpByEvent($event_id){
$builder = $this->createQueryBuilder();
$rsvp = $builder
->select('r')
->from('models\summit\RSVP','r')
->join('r.owner','o')
->join('r.event','e')
->where('o.id = :owner_id and e.id = :event_id')
->setParameter('owner_id', $this->getId())
->setParameter('event_id', intval($event_id))
->getQuery()->getResult();
return count($rsvp) > 0 ? $rsvp[0] : null;
}
/**
* @param Summit $summit
* @return SummitMemberSchedule[]
*/
public function getScheduleBySummit(Summit $summit){
$query = $this->createQuery("SELECT s from models\main\SummitMemberSchedule s
JOIN s.member m
JOIN s.event e
JOIN e.summit su WHERE su.id = :summit_id and m.id = :member_id ");
return $query
->setParameter('member_id', $this->getId())
->setParameter('summit_id', $summit->getId())
->getResult();
}
/**
* @param Summit $summit
* @return SummitMemberFavorite[]
*/
public function getFavoritesSummitEventsBySummit(Summit $summit)
{
$query = $this->createQuery("SELECT f from models\main\SummitMemberFavorite f
JOIN f.member m
JOIN f.event e
JOIN e.summit su WHERE su.id = :summit_id and m.id = :member_id ");
return $query
->setParameter('member_id', $this->getId())
->setParameter('summit_id', $summit->getId())
->getResult();
}
}

View File

@ -0,0 +1,101 @@
<?php namespace models\main;
/**
* Copyright 2017 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\SummitEvent;
use models\utils\IEntity;
/**
* @ORM\Entity
* @ORM\Table(name="Member_FavoriteSummitEvents")
* Class SummitMemberSchedule
* @package models\main
*/
class SummitMemberFavorite
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(name="ID", type="integer", unique=true, nullable=false)
*/
private $id;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return Member
*/
public function getMember()
{
return $this->member;
}
/**
* @param Member $member
*/
public function setMember($member)
{
$this->member = $member;
}
public function clearOwner(){
$this->member = null;
$this->event = null;
}
/**
* @return SummitEvent
*/
public function getEvent()
{
return $this->event;
}
/**
* @param SummitEvent $event
*/
public function setEvent($event)
{
$this->event = $event;
}
/**
* @return int
*/
public function getIdentifier()
{
return $this->id;
}
/**
* @ORM\ManyToOne(targetEntity="Member", inversedBy="schedule")
* @ORM\JoinColumn(name="MemberID", referencedColumnName="ID", nullable=true )
* @var Member
*/
private $member;
/**
* @ORM\ManyToOne(targetEntity="models\summit\SummitEvent")
* @ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")
* @var SummitEvent
*/
private $event;
}

View File

@ -0,0 +1,102 @@
<?php namespace models\main;
/**
* Copyright 2017 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\SummitEvent;
use models\utils\IEntity;
/**
* @ORM\Entity
* @ORM\Table(name="Member_Schedule")
* Class SummitMemberSchedule
* @package models\main
*/
class SummitMemberSchedule implements IEntity
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(name="ID", type="integer", unique=true, nullable=false)
*/
private $id;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return Member
*/
public function getMember()
{
return $this->member;
}
/**
* @param Member $member
*/
public function setMember($member)
{
$this->member = $member;
}
public function clearOwner(){
$this->member = null;
$this->event = null;
}
/**
* @return SummitEvent
*/
public function getEvent()
{
return $this->event;
}
/**
* @param SummitEvent $event
*/
public function setEvent($event)
{
$this->event = $event;
}
/**
* @return int
*/
public function getIdentifier()
{
return $this->id;
}
/**
* @ORM\ManyToOne(targetEntity="Member", inversedBy="schedule")
* @ORM\JoinColumn(name="MemberID", referencedColumnName="ID", nullable=true )
* @var Member
*/
private $member;
/**
* @ORM\ManyToOne(targetEntity="models\summit\SummitEvent")
* @ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")
* @var SummitEvent
*/
private $event;
}

View File

@ -18,6 +18,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\NoResultException;
use models\exceptions\ValidationException;
use models\main\Member;
use models\main\SummitMemberSchedule;
use models\utils\SilverstripeBaseModel;
/**
@ -78,12 +79,6 @@ class SummitAttendee extends SilverstripeBaseModel
$this->share_contact_info = $share_contact_info;
}
/**
* @ORM\OneToMany(targetEntity="SummitAttendeeSchedule", mappedBy="attendee", cascade={"persist"}, orphanRemoval=true)
* @var SummitAttendeeSchedule[]
*/
private $schedule;
/**
* @ORM\ManyToOne(targetEntity="models\main\Member")
* @ORM\JoinColumn(name="MemberID", referencedColumnName="ID")
@ -145,22 +140,6 @@ class SummitAttendee extends SilverstripeBaseModel
$this->member = $member;
}
/**
* @return RSVP[]
*/
public function getRsvp()
{
return $this->rsvp;
}
/**
* @param RSVP[] $rsvp
*/
public function setRsvp($rsvp)
{
$this->rsvp = $rsvp;
}
use SummitOwned;
public function __construct()
@ -168,9 +147,7 @@ class SummitAttendee extends SilverstripeBaseModel
parent::__construct();
$this->share_contact_info = false;
$this->summit_hall_checked_in = false;
$this->schedule = new ArrayCollection();
$this->tickets = new ArrayCollection();
$this->rsvp = new ArrayCollection();
}
/**
@ -187,152 +164,65 @@ class SummitAttendee extends SilverstripeBaseModel
/**
* @param SummitEvent $event
* @throws ValidationException
* @deprecated use Member::add2Schedule instead
*/
public function add2Schedule(SummitEvent $event)
{
if($this->isOnSchedule($event))
throw new ValidationException
(
sprintf('Event %s already belongs to attendee %s schedule.', $event->getId(), $this->getId())
);
if(!$event->isPublished())
throw new ValidationException
(
sprintf('Event %s is not published', $event->getId())
);
$schedule = new SummitAttendeeSchedule;
$schedule->setAttendee($this);
$schedule->setEvent($event);
$schedule->setIsCheckedIn(false);
$this->schedule->add($schedule);
$this->member->add2Schedule($event);
}
/**
* @param SummitEvent $event
* @throws ValidationException
* @deprecated use Member::removeFromSchedule instead
*/
public function removeFromSchedule(SummitEvent $event)
{
$schedule = $this->getScheduleByEvent($event);
if(is_null($schedule))
throw new ValidationException
(
sprintf('Event %s does not belongs to attendee %s schedule.', $event->getId(), $this->getId())
);
$this->schedule->removeElement($schedule);
$schedule->clearAttendee();
$this->member->removeFromSchedule($event);
}
/**
* @param SummitEvent $event
* @return bool
* @deprecated use Member::isOnSchedule instead
*/
public function isOnSchedule(SummitEvent $event)
{
$sql = <<<SQL
SELECT COUNT(SummitEventID) AS QTY
FROM SummitAttendee_Schedule
WHERE SummitAttendeeID = :attendee_id AND SummitEventID = :event_id
SQL;
$stmt = $this->prepareRawSQL($sql);
$stmt->execute([
'attendee_id' => $this->getId(),
'event_id' => $event->getId()
]);
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
return count($res) > 0 ? intval($res[0]) > 0 : false;
return $this->member->isOnSchedule($event);
}
/**
* @param SummitEvent $event
* @return null| SummitAttendeeSchedule
* @return null| SummitMemberSchedule
* @deprecated use Member::getScheduleByEvent instead
*/
public function getScheduleByEvent(SummitEvent $event){
try {
$query = $this->createQuery("SELECT s from models\summit\SummitAttendeeSchedule s
JOIN s.attendee a
JOIN s.event e
WHERE a.id = :attendee_id and e.id = :event_id
");
return $query
->setParameter('attendee_id', $this->getIdentifier())
->setParameter('event_id', $event->getIdentifier())
->getSingleResult();
}
catch(NoResultException $ex1){
return null;
}
catch(NonUniqueResultException $ex2){
// should never happen
return null;
}
return $this->member->getScheduleByEvent($event);
}
/**
* @param SummitEvent $event
* @throws ValidationException
*/
public function checkIn(SummitEvent $event)
{
$schedule = $this->getScheduleByEvent($event);
if(is_null($schedule))
throw new ValidationException(sprintf('Event %s does not belongs to attendee %s schedule.', $event->ID, $this->ID));
$schedule->setIsCheckedIn(true);
}
/**
* @return SummitAttendeeSchedule[]
* @return SummitMemberSchedule[]
* @deprecated use Member::getScheduleBySummit instead
*/
public function getSchedule(){
return $this->schedule;
return $this->member->getScheduleBySummit($this->summit);
}
/**
* @return int[]
* @deprecated use Member::getScheduledEventsIds instead
*/
public function getScheduledEventsIds(){
$sql = <<<SQL
SELECT SummitEventID
FROM SummitAttendee_Schedule
INNER JOIN SummitEvent ON SummitEvent.ID = SummitAttendee_Schedule.SummitEventID
WHERE SummitAttendeeID = :attendee_id AND SummitEvent.Published = 1
SQL;
$stmt = $this->prepareRawSQL($sql);
$stmt->execute(['attendee_id' => $this->getId()]);
return $stmt->fetchAll(\PDO::FETCH_COLUMN);
return $this->member->getScheduledEventsIds($this->summit);
}
/**
* @ORM\OneToMany(targetEntity="models\summit\RSVP", mappedBy="owner", cascade={"persist"})
* @var RSVP[]
*/
protected $rsvp;
/**
* @param int $event_id
* @return null|RSVP
* @deprecated use Member::getRsvpByEvent instead
*/
public function getRsvpByEvent($event_id){
$builder = $this->createQueryBuilder();
$rsvp = $builder
->select('r')
->from('models\summit\RSVP','r')
->join('r.owner','o')
->join('r.event','e')
->where('o.id = :owner_id and e.id = :event_id')
->setParameter('owner_id', $this->getId())
->setParameter('event_id', intval($event_id))
->getQuery()->getResult();
return count($rsvp) > 0 ? $rsvp[0] : null;
return $this->member->getRsvpByEvent($event_id);
}
}

View File

@ -1,166 +0,0 @@
<?php namespace models\summit;
/**
* Copyright 2016 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Doctrine\ORM\Mapping AS ORM;
use models\utils\IEntity;
/**
* @ORM\Entity
* @ORM\Table(name="SummitAttendee_Schedule")
* Class SummitAttendeeSchedule
* @package models\summit
*/
class SummitAttendeeSchedule implements IEntity
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(name="ID", type="integer", unique=true, nullable=false)
*/
private $id;
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return SummitAttendee
*/
public function getAttendee()
{
return $this->attendee;
}
/**
* @param SummitAttendee $attendee
*/
public function setAttendee($attendee)
{
$this->attendee = $attendee;
}
public function clearAttendee(){
$this->attendee = null;
$this->event = null;
}
/**
* @return SummitEvent
*/
public function getEvent()
{
return $this->event;
}
/**
* @param SummitEvent $event
*/
public function setEvent($event)
{
$this->event = $event;
}
/**
* @return boolean
*/
public function isIsCheckedIn()
{
return $this->is_checked_in;
}
/**
* @param boolean $is_checked_in
*/
public function setIsCheckedIn($is_checked_in)
{
$this->is_checked_in = $is_checked_in;
}
/**
* @return string
*/
public function getGoogleCalendarEventId()
{
return $this->google_calendar_event_id;
}
/**
* @param string $google_calendar_event_id
*/
public function setGoogleCalendarEventId($google_calendar_event_id)
{
$this->google_calendar_event_id = $google_calendar_event_id;
}
/**
* @return string
*/
public function getAppleCalendarEventId()
{
return $this->apple_calendar_event_id;
}
/**
* @param string $apple_calendar_event_id
*/
public function setAppleCalendarEventId($apple_calendar_event_id)
{
$this->apple_calendar_event_id = $apple_calendar_event_id;
}
/**
* @return int
*/
public function getIdentifier()
{
return $this->id;
}
/**
* @ORM\ManyToOne(targetEntity="SummitAttendee", inversedBy="schedule")
* @ORM\JoinColumn(name="SummitAttendeeID", referencedColumnName="ID", nullable=true )
* @var SummitAttendee
*/
private $attendee;
/**
* @ORM\ManyToOne(targetEntity="SummitEvent")
* @ORM\JoinColumn(name="SummitEventID", referencedColumnName="ID")
* @var SummitEvent
*/
private $event;
/**
* @ORM\Column(name="IsCheckedIn", type="boolean")
* @var bool
*/
private $is_checked_in;
/**
* @ORM\Column(name="GoogleCalEventId", type="integer")
* @var string
*/
private $google_calendar_event_id;
/**
* @ORM\Column(name="AppleCalEventId", type="boolean")
* @var string
*/
private $apple_calendar_event_id;
}

View File

@ -13,6 +13,7 @@
* limitations under the License.
**/
use models\main\Member;
use models\utils\SilverstripeBaseModel;
use Doctrine\ORM\Mapping AS ORM;
use Doctrine\Common\Collections\ArrayCollection;
@ -33,9 +34,9 @@ class RSVP extends SilverstripeBaseModel
}
/**
* @ORM\ManyToOne(targetEntity="models\summit\SummitAttendee", inversedBy="rsvp", fetch="LAZY")
* @ORM\ManyToOne(targetEntity="models\main\Member", inversedBy="rsvp", fetch="LAZY")
* @ORM\JoinColumn(name="SubmittedByID", referencedColumnName="ID")
* @var SummitAttendee
* @var Member
*/
private $owner;
@ -56,7 +57,7 @@ class RSVP extends SilverstripeBaseModel
}
/**
* @return SummitAttendee
* @return Member
*/
public function getOwner()
{
@ -64,9 +65,9 @@ class RSVP extends SilverstripeBaseModel
}
/**
* @param SummitAttendee $owner
* @param Member $owner
*/
public function setOwner(SummitAttendee $owner){
public function setOwner(Member $owner){
$this->owner = $owner;
}

View File

@ -48,8 +48,8 @@ class EventServiceProvider extends ServiceProvider
$entity_event->setEntityClassName('MySchedule');
$entity_event->setEntityId($event->getEventId());
$entity_event->setType('INSERT');
$entity_event->setOwner($event->getAttendee()->getMember());
$entity_event->setSummit($event->getAttendee()->getSummit());
$entity_event->setOwner($event->getMember());
$entity_event->setSummit($event->getSummit());
$entity_event->setMetadata('');
$em = Registry::getManager('ss');
@ -78,8 +78,8 @@ class EventServiceProvider extends ServiceProvider
$entity_event->setEntityClassName('MySchedule');
$entity_event->setEntityId($event->getEventId());
$entity_event->setType('DELETE');
$entity_event->setOwner($event->getAttendee()->getMember());
$entity_event->setSummit($event->getAttendee()->getSummit());
$entity_event->setOwner($event->getMember());
$entity_event->setSummit($event->getSummit());
$entity_event->setMetadata('');
$em = Registry::getManager('ss');

View File

@ -67,29 +67,21 @@ interface ISummitService
/**
* @param Summit $summit
* @param SummitAttendee $attendee
* @param Member $member
* @param int $event_id
* @param bool $check_rsvp
* @return bool
*/
public function addEventToAttendeeSchedule(Summit $summit, SummitAttendee $attendee, $event_id, $check_rsvp = true);
public function addEventToMemberSchedule(Summit $summit, Member $member, $event_id, $check_rsvp = true);
/**
* @param Summit $summit
* @param SummitAttendee $attendee
* @param Member $member
* @param int $event_id
* @param bool $check_rsvp
* @return void
*/
public function removeEventFromAttendeeSchedule(Summit $summit, SummitAttendee $attendee, $event_id, $check_rsvp = true);
/**
* @param Summit $summit
* @param SummitAttendee $attendee
* @param $event_id
* @return void
*/
public function checkInAttendeeOnEvent(Summit $summit, SummitAttendee $attendee, $event_id);
public function removeEventFromMemberSchedule(Summit $summit, Member $member, $event_id, $check_rsvp = true);
/**
* @param Summit $summit
@ -147,12 +139,11 @@ interface ISummitService
*/
public function addEventToMemberFavorites(Summit $summit, Member $member, $event_id);
/**
* @param Summit $summit
* @param SummitAttendee $attendee
* @param Member $member
* @param $event_id
* @return bool
*/
public function unRSVPEvent(Summit $summit, SummitAttendee $attendee, $event_id);
public function unRSVPEvent(Summit $summit ,Member $member, $event_id);
}

View File

@ -149,35 +149,35 @@ final class SummitService implements ISummitService
/**
* @param Summit $summit
* @param SummitAttendee $attendee
* @param Member $member
* @param int $event_id
* @param bool $check_rsvp
* @return void
* @throws EntityNotFoundException
* @throws ValidationException
*/
public function addEventToAttendeeSchedule(Summit $summit, SummitAttendee $attendee, $event_id, $check_rsvp = true)
public function addEventToMemberSchedule(Summit $summit, Member $member, $event_id, $check_rsvp = true)
{
try {
$this->tx_service->transaction(function () use ($summit, $attendee, $event_id, $check_rsvp) {
$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, $attendee->getMember()))
if(!Summit::allowToSee($event, $member))
throw new EntityNotFoundException('event not found on summit!');
if($check_rsvp && $event->hasRSVP() && !$event->getIssExternalRSVP())
throw new ValidationException("event has rsvp set on it!");
$attendee->add2Schedule($event);
$member->add2Schedule($event);
});
Event::fire(new MyScheduleAdd($attendee, $event_id));
Event::fire(new MyScheduleAdd($member ,$summit, $event_id));
}
catch (UniqueConstraintViolationException $ex){
throw new ValidationException
(
sprintf('Event %s already belongs to attendee %s schedule.', $event_id, $attendee->getId())
sprintf('Event %s already belongs to member %s schedule.', $event_id, $member->getId())
);
}
}
@ -210,36 +210,18 @@ final class SummitService implements ISummitService
}
}
/**
* @param Summit $summit
* @param SummitAttendee $attendee
* @param $event_id
* @return void
* @throws EntityNotFoundException
*/
public function checkInAttendeeOnEvent(Summit $summit, SummitAttendee $attendee, $event_id)
{
$this->tx_service->transaction(function () use ($summit, $attendee, $event_id) {
$event = $summit->getScheduleEvent($event_id);
if (is_null($event))
throw new EntityNotFoundException('event not found on summit!');
if(!Summit::allowToSee($event, $attendee->getMember()))
throw new EntityNotFoundException('event not found on summit!');
$attendee->checkIn($event);
});
}
/**
* @param Summit $summit
* @param SummitAttendee $attendee
* @param Member $member
* @param int $event_id
* @param boolean $check_rsvp
* @return void
* @throws \Exception
*/
public function removeEventFromAttendeeSchedule(Summit $summit, SummitAttendee $attendee, $event_id, $check_rsvp = true)
public function removeEventFromMemberSchedule(Summit $summit, Member $member, $event_id, $check_rsvp = true)
{
$this->tx_service->transaction(function () use ($summit, $attendee, $event_id, $check_rsvp) {
$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!');
@ -247,13 +229,12 @@ final class SummitService implements ISummitService
if($check_rsvp && $event->hasRSVP() && !$event->getIssExternalRSVP())
throw new ValidationException("event has rsvp set on it!");
$attendee->removeFromSchedule($event);
$member->removeFromSchedule($event);
});
Event::fire(new MyScheduleRemove($attendee, $event_id));
Event::fire(new MyScheduleRemove($member,$summit, $event_id));
}
/**
* @param Summit $summit
* @param Member $member
@ -944,30 +925,30 @@ final class SummitService implements ISummitService
/**
* @param Summit $summit
* @param SummitAttendee $attendee
* @param Member $member
* @param $event_id
* @return bool
*/
public function unRSVPEvent(Summit $summit, SummitAttendee $attendee, $event_id)
public function unRSVPEvent(Summit $summit, Member $member, $event_id)
{
return $this->tx_service->transaction(function () use ($summit, $attendee, $event_id) {
return $this->tx_service->transaction(function () use ($summit, $member, $event_id) {
$event = $summit->getScheduleEvent($event_id);
if (is_null($event)) {
throw new EntityNotFoundException('event not found on summit!');
}
if(!Summit::allowToSee($event, $attendee->getMember()))
if(!Summit::allowToSee($event, $member))
throw new EntityNotFoundException('event not found on summit!');
$rsvp = $attendee->getRsvpByEvent($event_id);
$rsvp = $member->getRsvpByEvent($event_id);
if(is_null($rsvp))
throw new ValidationException(sprintf("rsvp for event id %s does not exist for your attendee", $event_id));
throw new ValidationException(sprintf("rsvp for event id %s does not exist for your member", $event_id));
$this->rsvp_repository->delete($rsvp);
$this->removeEventFromAttendeeSchedule($summit, $attendee, $event_id ,false);
$this->removeEventFromAttendeeSchedule($summit, $member, $event_id ,false);
return true;
});

View File

@ -481,12 +481,36 @@ class ApiEndpointsSeeder extends Seeder
'http_method' => 'POST',
'scopes' => [sprintf('%s/me/summits/events/favorites/add', $current_realm)],
),
array(
'name' => 'delete-rsvp-member',
'route' => '/api/v1/summits/{id}/members/{member_id}/schedule/{event_id}/rsvp',
'http_method' => 'DELETE',
'scopes' => [sprintf('%s/summits/write', $current_realm)],
),
array(
'name' => 'remove-from-own-member-favorites',
'route' => '/api/v1/summits/{id}/members/{member_id}/favorites/{event_id}',
'http_method' => 'DELETE',
'scopes' => [sprintf('%s/me/summits/events/favorites/delete', $current_realm)],
),
array(
'name' => 'get-own-member-schedule',
'route' => '/api/v1/summits/{id}/members/{member_id}/schedule',
'http_method' => 'GET',
'scopes' => [sprintf('%s/me/read', $current_realm)],
),
array(
'name' => 'add-2-own-member-schedule',
'route' => '/api/v1/summits/{id}/members/{member_id}/schedule/{event_id}',
'http_method' => 'POST',
'scopes' => [sprintf('%s/summits/write', $current_realm)],
),
array(
'name' => 'remove-from-own-member-schedule',
'route' => '/api/v1/summits/{id}/members/{member_id}/schedule/{event_id}',
'http_method' => 'DELETE',
'scopes' => [sprintf('%s/summits/write', $current_realm)],
),
// notifications
array(
'name' => 'get-notifications',

View File

@ -245,7 +245,7 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
{
$params = array
(
'id' => 6,
'id' => 22,
'attendee_id' => 'me'
);
@ -266,7 +266,8 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
$this->assertTrue(!is_null($attendee));
}
public function testCurrentSummitMyAttendeeAddToSchedule($event_id = 16638, $summit_id = 7)
public function testCurrentSummitMyAttendeeAddToSchedule($event_id = 18845, $summit_id = 22)
{
$params = array
(
@ -289,30 +290,8 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
$this->assertResponseStatus(201);
}
public function testCurrentSummitMyAttendeeScheduleCheckIn()
{
$params = array
(
'id' => 6,
'attendee_id' => 'me',
'event_id' => 7202
);
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
$response = $this->action(
"PUT",
"OAuth2SummitAttendeesApiController@checkingAttendeeOnEvent",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(204);
}
public function testCurrentSummitMyAttendeeScheduleUnset($event_id = 16638, $summit_id = 7)
public function testCurrentSummitMyAttendeeScheduleUnset($event_id = 18845, $summit_id = 22)
{
//$this->testCurrentSummitMyAttendeeAddToSchedule($event_id, $summit_id);
$params = array
@ -336,7 +315,7 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
$this->assertResponseStatus(204);
}
public function testCurrentSummitMyAttendeeScheduleUnRSVP($event_id = 16638, $summit_id = 7)
public function testCurrentSummitMyAttendeeScheduleUnRSVP($event_id = 18639, $summit_id = 22)
{
//$this->testCurrentSummitMyAttendeeAddToSchedule($event_id, $summit_id);
$params = array
@ -2246,7 +2225,7 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
'expand' => 'attendee,speaker,feedback,groups,presentations',
'member_id' => 'me',
'id' => 7,
'id' => 22,
];
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
@ -2265,4 +2244,54 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
$member = json_decode($content);
$this->assertTrue(!is_null($member));
}
public function testCurrentSummitMyMemberFavorites()
{
$params = array
(
'id' => 22,
'member_id' => 'me',
'expand' => 'speakers',
);
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
$response = $this->action(
"GET",
"OAuth2SummitMembersApiController@getMemberFavoritesSummitEvents",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$favorites = json_decode($content);
$this->assertTrue(!is_null($favorites));
}
public function testCurrentSummitMyMemberScheduleUnRSVP($event_id = 18639, $summit_id = 22)
{
//$this->testCurrentSummitMyAttendeeAddToSchedule($event_id, $summit_id);
$params = array
(
'id' => $summit_id,
'member_id' => 'me',
'event_id' => $event_id
);
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
$response = $this->action(
"DELETE",
"OAuth2SummitMembersApiController@deleteEventRSVP",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(204);
}
}