Example #1
0
 function itThrowAnExceptionIfUserIsNotValid()
 {
     $group_id = 300;
     $ugroup_id = 200;
     $ugroup = new UGroup(array('group_id' => $group_id, 'ugroup_id' => $ugroup_id));
     $this->expectException();
     $user = anAnonymousUser()->build();
     $ugroup->addUser($user);
 }
 /**
  * Add user to a User Group
  * 
  * * Error codes:
  *   * 3000, Invalid project id
  *   * 3201, Permission denied: need to be project admin
  *   * 3203, Invalid user id
  *   * 3301, User Group doesn't exist
  * 
  * @param String  $sessionKey The project admin session hash
  * @param Integer $groupId    The Project id where the User Group is defined
  * @param Integer $ugroupId   The User Group where the user should be added
  * @param Integer $userId     The user id to add
  * 
  * @return Boolean 
  */
 public function addUserToUGroup($sessionKey, $groupId, $ugroupId, $userId)
 {
     $this->getProjectIfUserIsAdmin($groupId, $sessionKey);
     if ($user = $this->userManager->getUserById($userId)) {
         try {
             $ugroup = new UGroup(array('ugroup_id' => $ugroupId, 'group_id' => $groupId));
             $ugroup->addUser($user);
         } catch (Exception $e) {
             throw new SoapFault((string) $e->getCode(), $e->getMessage());
         }
         $this->feedbackToSoapFault();
         return true;
     } else {
         throw new SoapFault('3203', "Invalid user id {$userId}");
     }
 }