/**
  * @param IResource $resource
  * @return bool
  */
 public function ShouldInclude($resource)
 {
     if ($resource->GetStatusId() != ResourceStatus::AVAILABLE) {
         $user = $this->userRepository->LoadById($this->user->UserId);
         return $user->IsResourceAdminFor($resource);
     }
     return true;
 }
 private function PopulateTemplate()
 {
     $this->Set('UserName', $this->reservationOwner->FullName());
     $currentInstance = $this->reservationSeries->CurrentInstance();
     $this->Set('StartDate', $currentInstance->StartDate()->ToTimezone($this->timezone));
     $this->Set('EndDate', $currentInstance->EndDate()->ToTimezone($this->timezone));
     $this->Set('ResourceName', $this->resource->GetName());
     $this->Set('Title', $this->reservationSeries->Title());
     $this->Set('Description', $this->reservationSeries->Description());
     $repeatDates = array();
     foreach ($this->reservationSeries->Instances() as $repeated) {
         $repeatDates[] = $repeated->StartDate()->ToTimezone($this->timezone);
     }
     $this->Set('RequiresApproval', $this->reservationSeries->RequiresApproval());
     $this->Set('RepeatDates', $repeatDates);
     $this->Set('ReservationUrl', Pages::RESERVATION . "?" . QueryStringKeys::REFERENCE_NUMBER . '=' . $currentInstance->ReferenceNumber());
     $resourceNames = array();
     foreach ($this->reservationSeries->AllResources() as $resource) {
         $resourceNames[] = $resource->GetName();
     }
     $this->Set('ResourceNames', $resourceNames);
     $this->Set('Accessories', $this->reservationSeries->Accessories());
     $attributes = $this->attributeRepository->GetByCategory(CustomAttributeCategory::RESERVATION);
     $attributeValues = array();
     foreach ($attributes as $attribute) {
         $attributeValues[] = new Attribute($attribute, $this->reservationSeries->GetAttributeValue($attribute->Id()));
     }
     $this->Set('Attributes', $attributeValues);
 }
Exemple #3
0
 /**
  * @param IResource $resource
  * @return bool
  */
 public function IsResourceAdminFor(IResource $resource)
 {
     if ($this->isApplicationAdmin) {
         return true;
     }
     if ($this->isResourceAdmin || $this->isScheduleAdmin) {
         foreach ($this->groups as $group) {
             if ($group->GroupId == $resource->GetAdminGroupId() || $group->GroupId == $resource->GetScheduleAdminGroupId()) {
                 return true;
             }
         }
     }
     return false;
 }
Exemple #4
0
 public function IsResourceAdminFor(IResource $resource)
 {
     return $this->_IsResourceAdmin || in_array($resource->GetId(), $this->_ResourceAdminResourceIds);
 }