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); } }
public function GetFunction(IReservationSlot $slot, $accessAllowed = false) { if ($slot->IsReserved()) { if ($this->IsMyReservation($slot)) { return 'displayMyReserved'; } elseif ($this->AmIParticipating($slot)) { return 'displayMyParticipating'; } else { return 'displayReserved'; } } else { if (!$accessAllowed) { return 'displayRestricted'; } else { if ($slot->IsPastDate(Date::Now()) && !$this->UserHasAdminRights()) { return 'displayPastTime'; } else { if ($slot->IsReservable()) { return 'displayReservable'; } else { return 'displayUnreservable'; } } } } return null; }
public function GetFunction(IReservationSlot $slot, $accessAllowed = false) { if ($slot->IsReserved()) { if ($this->IsMyReservation($slot)) { return 'displayMyReserved'; } elseif ($this->AmIParticipating($slot)) { return 'displayMyParticipating'; } else { if ($this->IsMyPending($slot)) { return 'displayMyReserved'; } elseif ((!$this->IsMyTrainingType($slot) || !$this->IsMyTrainingLevel($slot) || $this->IsFull($slot) || !$this->HaveCredit() && $this->Registered() || $this->AmIprivate()) && !$this->UserHasAdminRights()) { return 'displayRestricted'; } else { return 'displayReserved'; } } } else { if (!$accessAllowed) { return 'displayRestricted'; } else { if ($slot->IsPastDate(Date::Now()) && !$this->UserHasAdminRights()) { return 'displayPastTime'; } else { if ($slot->IsReservable() && ($this->UserHasAdminRights() || $this->AmIprivate())) { return 'displayReservable'; } else { return 'displayUnreservable'; } } } } return null; }