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 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); }