public function CanViewDetails(UserSession $currentUser, $reservationView = null, $ownerId = null) { $hideReservationDetails = ReservationDetailsFilter::HideReservationDetails(); if ($reservationView != null) { /** @var ReservationView $reservationView */ $hideReservationDetails = ReservationDetailsFilter::HideReservationDetails($reservationView->StartDate, $reservationView->EndDate); } return $this->CanView($hideReservationDetails, $currentUser, $ownerId, $reservationView); }
/** * @param ReservationItemView $reservation * @param string $format * @return string */ public function Format(ReservationItemView $reservation, $format = null) { $shouldHideUser = Configuration::Instance()->GetSectionKey(ConfigSection::PRIVACY, ConfigKeys::PRIVACY_HIDE_USER_DETAILS, new BooleanConverter()); $shouldHideDetails = ReservationDetailsFilter::HideReservationDetails($reservation->StartDate, $reservation->EndDate); if (($shouldHideUser || $shouldHideDetails) && (is_null($this->user) || $this->user->UserId != $reservation->UserId && !$this->user->IsAdminForGroup($reservation->OwnerGroupIds()))) { return ''; } if (empty($format)) { $format = Configuration::Instance()->GetSectionKey(ConfigSection::SCHEDULE, ConfigKeys::SCHEDULE_RESERVATION_LABEL); } if ($format == 'none' || empty($format)) { return ''; } $name = $this->GetFullName($reservation); $timezone = 'UTC'; $dateFormat = Resources::GetInstance()->GetDateFormat('res_popup'); if (!is_null($this->user)) { $timezone = $this->user->Timezone; } $label = $format; $label = str_replace('{name}', $name, $label); $label = str_replace('{title}', $reservation->Title, $label); $label = str_replace('{description}', $reservation->Description, $label); $label = str_replace('{email}', $reservation->OwnerEmailAddress, $label); $label = str_replace('{organization}', $reservation->OwnerOrganization, $label); $label = str_replace('{phone}', $reservation->OwnerPhone, $label); $label = str_replace('{position}', $reservation->OwnerPosition, $label); $label = str_replace('{startdate}', $reservation->StartDate->ToTimezone($timezone)->Format($dateFormat), $label); $label = str_replace('{enddate}', $reservation->EndDate->ToTimezone($timezone)->Format($dateFormat), $label); $label = str_replace('{resourcename}', $reservation->ResourceName, $label); $label = str_replace('{participants}', trim(implode(', ', $reservation->ParticipantNames)), $label); $label = str_replace('{invitees}', trim(implode(', ', $reservation->InviteeNames)), $label); $matches = array(); preg_match_all('/\\{(att\\d+?)\\}/', $format, $matches); $matches = $matches[0]; if (count($matches) > 0) { for ($m = 0; $m < count($matches); $m++) { $id = filter_var($matches[$m], FILTER_SANITIZE_NUMBER_INT); $value = $reservation->GetAttributeValue($id); $label = str_replace($matches[$m], $value, $label); } } if (BookedStringHelper::Contains($label, '{reservationAttributes}')) { $attributesLabel = new StringBuilder(); $attributes = $this->attributeRepository->GetByCategory(CustomAttributeCategory::RESERVATION); foreach ($attributes as $attribute) { $attributesLabel->Append($attribute->Label() . ': ' . $reservation->GetAttributeValue($attribute->Id()) . ', '); } $label = str_replace('{reservationAttributes}', rtrim($attributesLabel->ToString(), ', '), $label); } return $label; }
public function PageLoad() { $hideUserInfo = Configuration::Instance()->GetSectionKey(ConfigSection::PRIVACY, ConfigKeys::PRIVACY_HIDE_USER_DETAILS, new BooleanConverter()); $userSession = ServiceLocator::GetServer()->GetUserSession(); $tz = $userSession->Timezone; $reservation = $this->_reservationRepository->GetReservationForEditing($this->_page->GetReservationId()); if (!$reservation->IsDisplayable()) { return; } $hideReservationDetails = ReservationDetailsFilter::HideReservationDetails($reservation->StartDate, $reservation->EndDate); if ($hideReservationDetails || $hideUserInfo) { $canViewDetails = $this->_reservationAuthorization->CanViewDetails($reservation, ServiceLocator::GetServer()->GetUserSession()); $hideReservationDetails = !$canViewDetails && $hideReservationDetails; $hideUserInfo = !$canViewDetails && $hideUserInfo; } $this->_page->SetHideDetails($hideReservationDetails); $this->_page->SetHideUser($hideUserInfo); $startDate = $reservation->StartDate->ToTimezone($tz); $endDate = $reservation->EndDate->ToTimezone($tz); $this->_page->SetName($reservation->OwnerFirstName, $reservation->OwnerLastName); $this->_page->SetResources($reservation->Resources); $this->_page->SetParticipants($reservation->Participants); $this->_page->SetSummary($reservation->Description); $this->_page->SetTitle($reservation->Title); $this->_page->SetAccessories($reservation->Accessories); $this->_page->SetDates($startDate, $endDate); $attributeValues = $this->attributeService->GetReservationAttributes($userSession, $reservation); $this->_page->BindAttributes($attributeValues); }