Example #1
0
 function itConvertDynamicGroupIdToCorrespondingDatabaseFieldUpdateForRemove()
 {
     $this->assertEqual(UGroup::getRemoveFlagForUGroupId($GLOBALS['UGROUP_PROJECT_ADMIN']), "admin_flags = ''");
     $this->assertEqual(UGroup::getRemoveFlagForUGroupId($GLOBALS['UGROUP_FILE_MANAGER_ADMIN']), 'file_flags = 0');
     $this->assertEqual(UGroup::getRemoveFlagForUGroupId($GLOBALS['UGROUP_WIKI_ADMIN']), 'wiki_flags = 0');
     //$this->assertEqual(UGroup::getFieldForUGroupId($GLOBALS['UGROUP_DOCUMENT_TECH'], 'doc_flags = '));
     //$this->assertEqual(UGroup::getFieldForUGroupId($GLOBALS['UGROUP_DOCUMENT_ADMIN'], ''));
     $this->assertEqual(UGroup::getRemoveFlagForUGroupId(UGroup::FORUM_ADMIN), "forum_flags = 0");
     $this->assertEqual(UGroup::getRemoveFlagForUGroupId(UGroup::SVN_ADMIN), "svn_flags = 0");
     $this->assertEqual(UGroup::getRemoveFlagForUGroupId(UGroup::NEWS_ADMIN), "news_flags = 0");
     $this->assertEqual(UGroup::getRemoveFlagForUGroupId(UGroup::NEWS_EDITOR), "news_flags = 0");
 }
 /**
  * Remove User from 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 removed
  * @param Integer $userId     The user id to remove
  * 
  * @return Boolean 
  */
 public function removeUserFromUGroup($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->removeUser($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}");
     }
 }