public function PageLoad() { if (!$this->validator->IsValid()) { return; } $userId = $this->page->GetUserId(); $scheduleId = $this->page->GetScheduleId(); $resourceId = $this->page->GetResourceId(); $accessoryIds = $this->page->GetAccessoryIds(); $resourceGroupId = $this->page->GetResourceGroupId(); $weekAgo = Date::Now()->AddDays(-7); $nextYear = Date::Now()->AddDays(365); $sid = null; $rid = null; $uid = null; $aid = null; $resourceIds = array(); $reservations = array(); $res = array(); $summaryFormat = Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION_LABELS, ConfigKeys::RESERVATION_LABELS_ICS_SUMMARY); $reservationUserLevel = ReservationUserLevel::OWNER; if (!empty($scheduleId)) { $schedule = $this->subscriptionService->GetSchedule($scheduleId); $sid = $schedule->GetId(); } if (!empty($resourceId)) { $resource = $this->subscriptionService->GetResource($resourceId); $rid = $resource->GetId(); } if (!empty($accessoryIds)) { ## No transformation is implemented. It is assumed the accessoryIds is provided as AccessoryName ## filter is defined by LIKE "PATTERN%" $aid = $accessoryIds; } if (!empty($userId)) { $user = $this->subscriptionService->GetUser($userId); $uid = $user->Id(); $reservationUserLevel = ReservationUserLevel::ALL; $summaryFormat = Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION_LABELS, ConfigKeys::RESERVATION_LABELS_MY_ICS_SUMMARY); } if (!empty($resourceGroupId)) { $resourceIds = $this->subscriptionService->GetResourcesInGroup($resourceGroupId); } if (!empty($uid) || !empty($sid) || !empty($rid) || !empty($resourceIds)) { $res = $this->reservationViewRepository->GetReservationList($weekAgo, $nextYear, $uid, $reservationUserLevel, $sid, $rid); } elseif (!empty($aid)) { throw new Exception('need to give an accessory a public id, allow subscriptions'); $res = $this->reservationViewRepository->GetAccessoryReservationList($weekAgo, $nextYear, $accessoryIds); } Log::Debug('Loading calendar subscription for userId %s, scheduleId %s, resourceId %s. Found %s reservations.', $userId, $scheduleId, $resourceId, count($res)); $session = ServiceLocator::GetServer()->GetUserSession(); foreach ($res as $r) { if (empty($resourceIds) || in_array($r->ResourceId, $resourceIds)) { $reservations[] = new iCalendarReservationView($r, $session, $this->privacyFilter, $summaryFormat); } } $this->page->SetReservations($reservations); }
public function testCannotSeeReservationDetailsIfConfiguredOff() { $referenceNumber = 'ref'; $reservationResult = new ReservationView(); $this->validator->expects($this->atLeastOnce())->method('IsValid')->will($this->returnValue(true)); $this->page->expects($this->once())->method('GetReferenceNumber')->will($this->returnValue($referenceNumber)); $this->repo->expects($this->once())->method('GetReservationForEditing')->with($this->equalTo($referenceNumber))->will($this->returnValue($reservationResult)); $this->page->expects($this->once())->method('SetReservations')->with($this->arrayHasKey(0)); $this->presenter->PageLoad($this->fakeUser); }
public function setup() { parent::setup(); $this->repo = $this->getMock('IReservationViewRepository'); $this->page = $this->getMock('ICalendarSubscriptionPage'); $this->validator = $this->getMock('ICalendarExportValidator'); $this->service = $this->getMock('ICalendarSubscriptionService'); $this->privacyFilter = new FakePrivacyFilter(); $this->validator->expects($this->atLeastOnce())->method('IsValid')->will($this->returnValue(true)); $this->presenter = new CalendarSubscriptionPresenter($this->page, $this->repo, $this->validator, $this->service, $this->privacyFilter); }
public function PageLoad(UserSession $currentUser) { if (!$this->validator->IsValid()) { return; } $referenceNumber = $this->page->GetReferenceNumber(); $reservations = array(); if (!empty($referenceNumber)) { $res = $this->reservationViewRepository->GetReservationForEditing($referenceNumber); $reservations = array(new iCalendarReservationView($res, $currentUser, $this->privacyFilter)); } $this->page->SetReservations($reservations); }
public function PageLoad() { if (!$this->validator->IsValid()) { return; } $userId = $this->page->GetUserId(); $scheduleId = $this->page->GetScheduleId(); $resourceId = $this->page->GetResourceId(); $accessoryIds = $this->page->GetAccessoryIds(); $weekAgo = Date::Now()->AddDays(-7); $nextYear = Date::Now()->AddDays(365); $sid = null; $rid = null; $uid = null; $aid = null; $reservations = array(); $res = array(); if (!empty($scheduleId)) { $schedule = $this->subscriptionService->GetSchedule($scheduleId); $sid = $schedule->GetId(); } if (!empty($resourceId)) { $resource = $this->subscriptionService->GetResource($resourceId); $rid = $resource->GetId(); } if (!empty($accessoryIds)) { ## No transformation is implemented. It is assumed the accessoryIds is provided as AccessoryName ## filter is defined by LIKE "PATTERN%" $aid = $accessoryIds; } if (!empty($userId)) { $user = $this->subscriptionService->GetUser($userId); $uid = $user->Id(); } if (!empty($uid) || !empty($sid) || !empty($rid)) { $res = $this->reservationViewRepository->GetReservationList($weekAgo, $nextYear, $uid, null, $sid, $rid); } elseif (!empty($aid)) { throw new Exception('need to give an accessory a public id, allow subscriptions'); $res = $this->reservationViewRepository->GetAccessoryReservationList($weekAgo, $nextYear, $accessoryIds); } Log::Debug('Loading calendar subscription for userId %s, scheduleId %s, resourceId %s. Found %s reservations.', $userId, $scheduleId, $resourceId, count($res)); foreach ($res as $r) { $reservations[] = new iCalendarReservationView($r, ServiceLocator::GetServer()->GetUserSession(), $this->privacyFilter); } $this->page->SetReservations($reservations); }