Beispiel #1
0
 /**
  * @name GetGroup
  * @description Loads a specific group by id
  * @response GroupResponse
  * @param int $groupId
  * @return void
  */
 public function GetGroup($groupId)
 {
     $group = $this->groupRepository->LoadById($groupId);
     if ($group != null) {
         $this->server->WriteResponse(new GroupResponse($this->server, $group));
     } else {
         $this->server->WriteResponse(RestResponse::NotFound(), RestResponse::NOT_FOUND_CODE);
     }
 }
Beispiel #2
0
 public function ChangeGroups($user, $groupIds)
 {
     if ($groupIds == null) {
         return;
     }
     $existingGroupIds = array();
     foreach ($user->Groups() as $group) {
         $existingGroupIds[] = $group->GroupId;
     }
     foreach ($groupIds as $targetGroupId) {
         if (!in_array($targetGroupId, $existingGroupIds)) {
             // add group
             $group = $this->groupRepository->LoadById($targetGroupId);
             $group->AddUser($user->Id());
             $this->groupRepository->Update($group);
         }
     }
     foreach ($existingGroupIds as $existingId) {
         if (!in_array($existingId, $groupIds)) {
             // remove user
             $group = $this->groupRepository->LoadById($existingId);
             $group->RemoveUser($user->Id());
             $this->groupRepository->Update($group);
         }
     }
 }
 public function AddUser()
 {
     $userId = $this->manageUsersService->AddUser($this->page->GetUserName(), $this->page->GetEmail(), $this->page->GetFirstName(), $this->page->GetLastName(), $this->page->GetPassword(), $this->page->GetTimezone(), Configuration::Instance()->GetKey(ConfigKeys::LANGUAGE), Pages::DEFAULT_HOMEPAGE_ID, array(), $this->GetAttributeValues());
     $groupId = $this->page->GetUserGroup();
     if (!empty($groupId)) {
         $group = $this->groupRepository->LoadById($groupId);
         $group->AddUser($userId);
         $this->groupRepository->Update($group);
     }
 }