/** * @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); } }
/** * @static * @param ReservationItemView $reservation * @return string */ public static function Create(ReservationItemView $reservation) { $f = new SlotLabelFactory(); return $f->Format($reservation); }
/** * @param SlotLabelFactory|null $factory * @return string */ public function Label($factory = null) { if (empty($factory)) { return SlotLabelFactory::Create($this->_reservation); } return $factory->Format($this->_reservation); }
/** * @static * @param array|ReservationItemView[] $reservations * @param array|ResourceDto[] $resources * @param UserSession $userSession * @param bool $groupSeriesByResource * @return array|CalendarReservation[] */ public static function FromScheduleReservationList($reservations, $resources, UserSession $userSession, $groupSeriesByResource = false) { $knownSeries = array(); $factory = new SlotLabelFactory($userSession); $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; } if ($groupSeriesByResource) { if (array_key_exists($reservation->SeriesId, $knownSeries)) { continue; } $knownSeries[$reservation->SeriesId] = true; } $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 = $factory->Format($reservation, Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION_LABELS, ConfigKeys::RESERVATION_LABELS_RESOURCE_CALENDAR)); $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 FormatReservationDescription(iCalendarReservationView $reservation, UserSession $user) { $factory = new SlotLabelFactory($user); return $factory->Format($reservation->ReservationItemView, Configuration::Instance()->GetSectionKey(ConfigSection::RESERVATION_LABELS, ConfigKeys::RESERVATION_LABELS_RSS_DESCRIPTION)); }