Пример #1
0
 public function ChangePermissions()
 {
     $user = $this->userRepository->LoadById($this->page->GetUserId());
     $allowedResources = array();
     if (is_array($this->page->GetAllowedResourceIds())) {
         $allowedResources = $this->page->GetAllowedResourceIds();
     }
     $user->ChangePermissions($allowedResources);
     $this->userRepository->Update($user);
 }
Пример #2
0
 public function ChangePermissions()
 {
     $user = $this->userRepository->LoadById(ServiceLocator::GetServer()->GetUserSession()->UserId);
     $resources = $this->GetResourcesThatCurrentUserCanAdminister($user);
     $acceptableResourceIds = array();
     foreach ($resources as $resource) {
         $acceptableResourceIds[] = $resource->GetId();
     }
     $user = $this->userRepository->LoadById($this->page->GetUserId());
     $allowedResources = array();
     if (is_array($this->page->GetAllowedResourceIds())) {
         $allowedResources = $this->page->GetAllowedResourceIds();
     }
     $currentResources = $user->AllowedResourceIds();
     $toRemainUnchanged = array_diff($currentResources, $acceptableResourceIds);
     $user->ChangePermissions(array_merge($toRemainUnchanged, $allowedResources));
     $this->userRepository->Update($user);
 }