/** * @name GetUser * @description Loads the requested user by Id * @response UserResponse * @param int $userId * @return void */ public function GetUser($userId) { $responseCode = RestResponse::OK_CODE; $hideUsers = Configuration::Instance()->GetSectionKey(ConfigSection::PRIVACY, ConfigKeys::PRIVACY_HIDE_USER_DETAILS, new BooleanConverter()); $userSession = $this->server->GetSession(); $repository = $this->repositoryFactory->Create($userSession); $user = $repository->LoadById($userId); $loadedUserId = $user->Id(); if (empty($loadedUserId)) { $this->server->WriteResponse(RestResponse::NotFound(), RestResponse::NOT_FOUND_CODE); return; } $attributes = $this->attributeService->GetAttributes(CustomAttributeCategory::USER, array($userId)); if ($userId == $userSession->UserId || !$hideUsers || $userSession->IsAdmin) { $response = new UserResponse($this->server, $user, $attributes); } else { $me = $repository->LoadById($userSession->UserId); if ($me->IsAdminFor($user)) { $response = new UserResponse($this->server, $user, $attributes); } else { $response = RestResponse::Unauthorized(); $responseCode = RestResponse::UNAUTHORIZED_CODE; } } $this->server->WriteResponse($response, $responseCode); }
public function PageLoad() { $types = $this->resourceRepository->GetResourceTypes(); $ids = array(); foreach ($types as $type) { $ids[] = $type->Id(); } $attributeList = $this->attributeService->GetAttributes(CustomAttributeCategory::RESOURCE_TYPE, $ids); $this->page->BindAttributeList($attributeList); $this->page->BindResourceTypes($types); }
/** * @name GetResource * @description Loads a specific resource by id * @param int $resourceId * @response ResourceResponse * @return void */ public function GetResource($resourceId) { $resource = $this->resourceRepository->LoadById($resourceId); $resourceId = $resource->GetResourceId(); if (empty($resourceId)) { $this->server->WriteResponse(RestResponse::NotFound(), RestResponse::NOT_FOUND_CODE); } else { $attributes = $this->attributeService->GetAttributes(CustomAttributeCategory::RESOURCE, array($resourceId)); $this->server->WriteResponse(new ResourceResponse($this->server, $resource, $attributes)); } }
public function PageLoad() { if ($this->page->GetUserId() != null) { $userList = $this->userRepository->GetList(1, 1, null, null, new SqlFilterEquals(ColumnNames::USER_ID, $this->page->GetUserId())); } else { $userList = $this->userRepository->GetList($this->page->GetPageNumber(), $this->page->GetPageSize(), null, null, null, $this->page->GetFilterStatusId()); } $this->page->BindUsers($userList->Results()); $this->page->BindPageInfo($userList->PageInfo()); $groups = $this->groupViewRepository->GetList(); $this->page->BindGroups($groups->Results()); $resources = array(); $user = $this->userRepository->LoadById(ServiceLocator::GetServer()->GetUserSession()->UserId); $allResources = $this->resourceRepository->GetResourceList(); foreach ($allResources as $resource) { if ($user->IsResourceAdminFor($resource)) { $resources[] = $resource; } } $this->page->BindResources($resources); $userIds = array(); /** @var $user UserItemView */ foreach ($userList->Results() as $user) { $userIds[] = $user->Id; } $attributeList = $this->attributeService->GetAttributes(CustomAttributeCategory::USER, $userIds); $this->page->BindAttributeList($attributeList); }
public function PageLoad() { $this->BounceIfNotAllowingRegistration(); $attributes = $this->attributeService->GetAttributes(CustomAttributeCategory::USER); $this->page->SetAttributes($attributes->GetAttributes()); $this->page->SetCaptchaImageUrl($this->captchaService->GetImageUrl()); $this->PopulateTimezones(); $this->PopulateHomepages(); }
public function PageLoad() { $userSession = ServiceLocator::GetServer()->GetUserSession(); Log::Debug('ProfilePresenter loading user %s', $userSession->UserId); $user = $this->userRepository->LoadById($userSession->UserId); $this->page->SetUsername($user->Username()); $this->page->SetFirstName($user->FirstName()); $this->page->SetLastName($user->LastName()); $this->page->SetEmail($user->EmailAddress()); $this->page->SetTimezone($user->Timezone()); $this->page->SetHomepage($user->Homepage()); $this->page->SetPhone($user->GetAttribute(UserAttribute::Phone)); $this->page->SetOrganization($user->GetAttribute(UserAttribute::Organization)); $this->page->SetPosition($user->GetAttribute(UserAttribute::Position)); $userId = $userSession->UserId; $attributes = $this->attributeService->GetAttributes(CustomAttributeCategory::USER, $userId); $this->page->SetAttributes($attributes->GetAttributes($userId)); $this->PopulateTimezones(); $this->PopulateHomepages(); }
public function PageLoad() { $resourceAttributes = $this->attributeService->GetByCategory(CustomAttributeCategory::RESOURCE); $filterValues = $this->page->GetFilterValues(); $results = $this->resourceRepository->GetList($this->page->GetPageNumber(), $this->page->GetPageSize(), null, null, $filterValues->AsFilter($resourceAttributes)); $resources = $results->Results(); $this->page->BindResources($resources); $this->page->BindPageInfo($results->PageInfo()); $schedules = $this->scheduleRepository->GetAll(); $scheduleList = array(); /* @var $schedule Schedule */ foreach ($schedules as $schedule) { $scheduleList[$schedule->GetId()] = $schedule->GetName(); } $this->page->BindSchedules($scheduleList); $this->page->AllSchedules($schedules); $resourceTypes = $this->resourceRepository->GetResourceTypes(); $resourceTypeList = array(); /* @var $resourceType ResourceType */ foreach ($resourceTypes as $resourceType) { $resourceTypeList[$resourceType->Id()] = $resourceType; } $this->page->BindResourceTypes($resourceTypeList); $statusReasons = $this->resourceRepository->GetStatusReasons(); $statusReasonList = array(); foreach ($statusReasons as $reason) { $statusReasonList[$reason->Id()] = $reason; } $this->page->BindResourceStatusReasons($statusReasonList); $groups = $this->groupRepository->GetGroupsByRole(RoleLevel::RESOURCE_ADMIN); $this->page->BindAdminGroups($groups); $resourceIds = array(); foreach ($resources as $resource) { $resourceIds[] = $resource->GetId(); } $attributeList = $this->attributeService->GetAttributes(CustomAttributeCategory::RESOURCE, $resourceIds); $this->page->BindAttributeList($attributeList); $this->InitializeFilter($filterValues, $resourceAttributes); }
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() { $resourceId = $this->page->GetResourceId(); $resource = $this->resourceRepository->LoadById($resourceId); $this->page->BindResource($resource); $attributeList = $this->attributeService->GetAttributes(CustomAttributeCategory::RESOURCE, $resourceId); $this->page->BindAttributes($attributeList->GetAttributes($resourceId)); if ($resource->HasResourceType()) { $resourceType = $this->resourceRepository->LoadResourceType($resource->GetResourceTypeId()); $attributeList = $this->attributeService->GetAttributes(CustomAttributeCategory::RESOURCE_TYPE, $resource->GetResourceTypeId()); $this->page->BindResourceType($resourceType, $attributeList->GetAttributes($resource->GetResourceTypeId())); } }