public function GetResourceGroups($scheduleId, UserSession $user) { $filter = new CompositeResourceFilter(); $filter->Add(new ResourcePermissionFilter($this->_permissionService, $user)); $filter->Add(new ResourceStatusFilter($this->_userRepository, $user)); $groups = $this->_resourceRepository->GetResourceGroups($scheduleId, $filter); return $groups; }
public function FilterResources($resources, IResourceRepository $resourceRepository, IAttributeService $attributeService) { $resourceIds = array(); if (!$this->HasFilter()) { foreach ($resources as $resource) { $resourceIds[] = $resource->GetId(); } return $resourceIds; } $groupResourceIds = array(); if (!empty($this->GroupId) && empty($this->ResourceId)) { $groups = $resourceRepository->GetResourceGroups($this->ScheduleId); $groupResourceIds = $groups->GetResourceIds($this->GroupId); } $resourceAttributeValues = null; if (!empty($this->ResourceAttributes)) { $resourceAttributeValues = $attributeService->GetAttributes(CustomAttributeCategory::RESOURCE, null); } $resourceTypeAttributeValues = null; if (!empty($this->ResourceTypeAttributes)) { $resourceTypeAttributeValues = $attributeService->GetAttributes(CustomAttributeCategory::RESOURCE_TYPE, null); } $resourceIds = array(); foreach ($resources as $resource) { $resourceIds[] = $resource->GetId(); if (!empty($this->ResourceId) && $resource->GetId() != $this->ResourceId) { array_pop($resourceIds); continue; } if (!empty($this->GroupId) && !in_array($resource->GetId(), $groupResourceIds)) { array_pop($resourceIds); continue; } if (!empty($this->MinCapacity) && $resource->GetMaxParticipants() < $this->MinCapacity) { array_pop($resourceIds); continue; } if (!empty($this->ResourceTypeId) && $resource->GetResourceTypeId() != $this->ResourceTypeId) { array_pop($resourceIds); continue; } $resourceAttributesPass = true; if (!empty($this->ResourceAttributes)) { $values = $resourceAttributeValues->GetAttributes($resource->GetId()); /** var @attribute AttributeValue */ foreach ($this->ResourceAttributes as $attribute) { $value = $this->GetAttribute($values, $attribute->AttributeId); if (!$this->AttributeValueMatches($attribute, $value)) { $resourceAttributesPass = false; break; } } } if (!$resourceAttributesPass) { array_pop($resourceIds); continue; } $resourceTypeAttributesPass = true; if (!empty($this->ResourceTypeAttributes)) { if (!$resource->HasResourceType()) { array_pop($resourceIds); // there's a filter but this resource doesn't have a resource type continue; } $values = $resourceTypeAttributeValues->GetAttributes($resource->GetResourceTypeId()); /** var @attribute AttributeValue */ foreach ($this->ResourceTypeAttributes as $attribute) { $value = $this->GetAttribute($values, $attribute->AttributeId); if (!$this->AttributeValueMatches($attribute, $value)) { $resourceTypeAttributesPass = false; break; } } } if (!$resourceTypeAttributesPass) { array_pop($resourceIds); continue; } } return $resourceIds; }
public function PageLoad() { $this->page->BindResourceGroups($this->resourceRepository->GetResourceGroups()); $this->page->BindResources($this->resourceRepository->GetResourceList()); }
public function GetResourcesInGroup($publicResourceGroupId) { if (!array_key_exists($publicResourceGroupId, $this->cache)) { $group = $this->resourceRepository->LoadResourceGroupByPublicId($publicResourceGroupId); if ($group == null) { return array(); } $groups = $this->resourceRepository->GetResourceGroups(); $this->cache[$publicResourceGroupId] = $groups->GetResourceIds($group->id); } return $this->cache[$publicResourceGroupId]; }