/** * @param ReservationItemView $res * @param UserSession $currentUser * @param IPrivacyFilter $privacyFilter * @param string|null $summaryFormat */ public function __construct($res, UserSession $currentUser, IPrivacyFilter $privacyFilter, $summaryFormat = null) { if ($summaryFormat == null) { $summaryFormat = Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION_LABELS, ConfigKeys::RESERVATION_LABELS_ICS_SUMMARY); } $factory = new SlotLabelFactory($currentUser); $this->ReservationItemView = $res; $canViewUser = $privacyFilter->CanViewUser($currentUser, $res, $res->UserId); $canViewDetails = $privacyFilter->CanViewDetails($currentUser, $res, $res->UserId); $privateNotice = 'Private'; $this->DateCreated = $res->CreatedDate; $this->DateEnd = $res->EndDate; $this->DateStart = $res->StartDate; $this->Description = $canViewDetails ? $res->Description : $privateNotice; $fullName = new FullName($res->OwnerFirstName, $res->OwnerLastName); $this->Organizer = $canViewUser ? $fullName->__toString() : $privateNotice; $this->OrganizerEmail = $canViewUser ? $res->OwnerEmailAddress : $privateNotice; $this->RecurRule = $this->CreateRecurRule($res); $this->ReferenceNumber = $res->ReferenceNumber; $this->Summary = $canViewDetails ? $factory->Format($res, $summaryFormat) : $privateNotice; $this->ReservationUrl = sprintf("%s/%s?%s=%s", Configuration::Instance()->GetScriptUrl(), Pages::RESERVATION, QueryStringKeys::REFERENCE_NUMBER, $res->ReferenceNumber); $this->Location = $res->ResourceName; $this->StartReminder = $res->StartReminder; $this->EndReminder = $res->EndReminder; if ($res->UserId == $currentUser->UserId) { $this->OrganizerEmail = str_replace('@', '-noreply@', $res->OwnerEmailAddress); } }
/** * @param IRestServer $server * @param array|ReservationItemView[] $reservations * @param IPrivacyFilter $privacyFilter * @param Date $minDate * @param Date $maxDate */ public function __construct(IRestServer $server, $reservations, IPrivacyFilter $privacyFilter, Date $minDate, Date $maxDate) { $user = $server->GetSession(); foreach ($reservations as $reservation) { $showUser = $privacyFilter->CanViewUser($user, null, $reservation->UserId); $showDetails = $privacyFilter->CanViewDetails($user, null, $reservation->UserId); $this->reservations[] = new ReservationItemResponse($reservation, $server, $showUser, $showDetails); $this->startDateTime = $minDate->ToIso(); $this->endDateTime = $maxDate->ToIso(); } }
/** * @param IRestServer $server * @param ReservationView $reservation * @param IPrivacyFilter $privacyFilter * @param array|CustomAttribute[] $attributes */ public function __construct(IRestServer $server, ReservationView $reservation, IPrivacyFilter $privacyFilter, $attributes = array()) { $this->owner = ReservationUserResponse::Masked(); $canViewUser = $privacyFilter->CanViewUser($server->GetSession(), $reservation); $canViewDetails = $privacyFilter->CanViewDetails($server->GetSession(), $reservation); $this->referenceNumber = $reservation->ReferenceNumber; $this->startDateTime = $reservation->StartDate->ToTimezone($server->GetSession()->Timezone)->ToIso(); $this->endDateTime = $reservation->EndDate->ToTimezone($server->GetSession()->Timezone)->ToIso(); $this->requiresApproval = $reservation->RequiresApproval(); $this->isRecurring = $reservation->IsRecurring(); $repeatTerminationDate = $reservation->RepeatTerminationDate != null ? $reservation->RepeatTerminationDate->ToIso() : null; $this->recurrenceRule = new RecurrenceRequestResponse($reservation->RepeatType, $reservation->RepeatInterval, $reservation->RepeatMonthlyType, $reservation->RepeatWeekdays, $repeatTerminationDate); $this->resourceId = $reservation->ResourceId; $this->scheduleId = $reservation->ScheduleId; $this->AddService($server, WebServices::GetSchedule, array(WebServiceParams::ScheduleId => $reservation->ScheduleId)); foreach ($reservation->Resources as $resource) { $this->resources[] = new ResourceItemResponse($server, $resource->Id(), $resource->GetName()); } foreach ($reservation->Accessories as $accessory) { $this->accessories[] = new ReservationAccessoryResponse($server, $accessory->AccessoryId, $accessory->Name, $accessory->QuantityReserved, $accessory->QuantityAvailable); } if ($canViewDetails) { $this->title = $reservation->Title; $this->description = $reservation->Description; foreach ($attributes as $attribute) { $this->customAttributes[] = new CustomAttributeResponse($server, $attribute->Id(), $attribute->Label(), $reservation->GetAttributeValue($attribute->Id())); } foreach ($reservation->Attachments as $attachment) { $this->attachments[] = new AttachmentResponse($server, $attachment->FileId(), $attachment->FileName(), $reservation->ReferenceNumber); } } if ($canViewUser) { $this->owner = new ReservationUserResponse($server, $reservation->OwnerId, $reservation->OwnerFirstName, $reservation->OwnerLastName, $reservation->OwnerEmailAddress); foreach ($reservation->Participants as $participant) { $this->participants[] = new ReservationUserResponse($server, $participant->UserId, $participant->FirstName, $participant->LastName, $participant->Email); } foreach ($reservation->Invitees as $invitee) { $this->invitees[] = new ReservationUserResponse($server, $invitee->UserId, $invitee->FirstName, $invitee->LastName, $invitee->Email); } } if ($reservation->StartReminder != null) { $this->startReminder = new ReminderRequestResponse($reservation->StartReminder->GetValue(), $reservation->StartReminder->GetInterval()); } if ($reservation->EndReminder != null) { $this->endReminder = new ReminderRequestResponse($reservation->EndReminder->GetValue(), $reservation->EndReminder->GetInterval()); } $this->allowParticipation = $reservation->AllowParticipation; if ($reservation->RequiresApproval()) { $this->AddService($server, WebServices::ApproveReservation, array(WebServiceParams::ReferenceNumber => $reservation->ReferenceNumber)); } }
public function Bind(IReservationComponentInitializer $initializer) { $this->page->SetAdditionalResources($this->reservationView->AdditionalResourceIds); $this->page->SetTitle($this->reservationView->Title); $this->page->SetDescription($this->reservationView->Description); $this->page->SetReferenceNumber($this->reservationView->ReferenceNumber); $this->page->SetReservationId($this->reservationView->ReservationId); $this->page->SetIsRecurring($this->reservationView->IsRecurring()); $this->page->SetRepeatType($this->reservationView->RepeatType); $this->page->SetRepeatInterval($this->reservationView->RepeatInterval); $this->page->SetRepeatMonthlyType($this->reservationView->RepeatMonthlyType); if ($this->reservationView->RepeatTerminationDate != null) { $this->page->SetRepeatTerminationDate($this->reservationView->RepeatTerminationDate->ToTimezone($initializer->GetTimezone())); } $this->page->SetRepeatWeekdays($this->reservationView->RepeatWeekdays); $participants = $this->reservationView->Participants; $invitees = $this->reservationView->Invitees; $this->page->SetParticipants($participants); $this->page->SetInvitees($invitees); $this->page->SetAllowParticipantsToJoin($this->reservationView->AllowParticipation); $this->page->SetAccessories($this->reservationView->Accessories); $currentUser = $initializer->CurrentUser(); $this->page->SetCurrentUserParticipating($this->IsCurrentUserParticipating($currentUser->UserId)); $this->page->SetCurrentUserInvited($this->IsCurrentUserInvited($currentUser->UserId)); $canBeEdited = $this->reservationAuthorization->CanEdit($this->reservationView, $currentUser); $this->page->SetIsEditable($canBeEdited); $this->page->SetIsApprovable($this->reservationAuthorization->CanApprove($this->reservationView, $currentUser)); $this->page->SetAttachments($this->reservationView->Attachments); $showUser = $this->privacyFilter->CanViewUser($initializer->CurrentUser(), $this->reservationView); $showDetails = $this->privacyFilter->CanViewDetails($initializer->CurrentUser(), $this->reservationView); $initializer->ShowUserDetails($showUser); $initializer->ShowReservationDetails($showDetails); if (!empty($this->reservationView->StartReminder)) { $this->page->SetStartReminder($this->reservationView->StartReminder->GetValue(), $this->reservationView->StartReminder->GetInterval()); } if (!empty($this->reservationView->EndReminder)) { $this->page->SetEndReminder($this->reservationView->EndReminder->GetValue(), $this->reservationView->EndReminder->GetInterval()); } }
/** * @static * @param array|ReservationItemView[] $reservations * @param array|ResourceDto[] $resources * @param UserSession $userSession * @param IPrivacyFilter $privacyFilter * @return array|CalendarReservation[] */ public static function FromScheduleReservationList($reservations, $resources, UserSession $userSession, IPrivacyFilter $privacyFilter) { $resourceMap = array(); /** @var $resource ResourceDto */ foreach ($resources as $resource) { $resourceMap[$resource->GetResourceId()] = $resource->GetName(); } $res = array(); foreach ($reservations as $reservation) { if (!array_key_exists($reservation->ResourceId, $resourceMap)) { continue; } $timezone = $userSession->Timezone; $start = $reservation->StartDate->ToTimezone($timezone); $end = $reservation->EndDate->ToTimezone($timezone); $referenceNumber = $reservation->ReferenceNumber; $cr = new CalendarReservation($start, $end, $resourceMap[$reservation->ResourceId], $referenceNumber); $cr->Title = $reservation->Title; $cr->OwnerName = new FullName($reservation->FirstName, $reservation->LastName); $cr->OwnerFirst = $reservation->FirstName; $cr->OwnerLast = $reservation->LastName; $cr->DisplayTitle = 'Private'; if ($privacyFilter->CanViewUser($userSession, null, $reservation->UserId)) { $cr->DisplayTitle = $cr->OwnerName; } if ($privacyFilter->CanViewDetails($userSession, null, $reservation->UserId)) { $cr->DisplayTitle .= ' ' . $reservation->Title; } $color = $reservation->UserPreferences->Get(UserPreferences::RESERVATION_COLOR); if (!empty($color)) { $cr->Color = "#{$color}"; $cr->TextColor = new ContrastingColor($color); } $cr->Class = self::GetClass($reservation); $res[] = $cr; } return $res; }
public function __construct(IRestServer $server, IReservationSlot $slot, IPrivacyFilter $privacyFilter) { $user = $server->GetSession(); $slotLabelFactory = $user->IsAdmin ? new AdminSlotLabelFactory() : new SlotLabelFactory($user); $this->slotSpan = $slot->PeriodSpan(); $this->isReserved = $slot->IsReserved(); $this->label = $slot->Label($slotLabelFactory); $this->isReservable = $slot->IsReservable(); $this->color = $slot->Color(); $this->startDateTime = $slot->BeginDate()->ToIso(); $this->endDateTime = $slot->EndDate()->ToIso(); if ($slot->IsReserved()) { /** @var ReservationSlot $slot */ $reservation = $slot->Reservation(); $showUser = $privacyFilter->CanViewUser($user, null, $reservation->UserId); $showDetails = $privacyFilter->CanViewDetails($user, null, $reservation->UserId); $this->reservation = new ReservationItemResponse($reservation, $server, $showUser, $showDetails); } }