예제 #1
0
 /**
  * Remove user from group
  * 
  * @param Request $r
  */
 public static function apiRemoveUser(Request $r)
 {
     self::validateGroupAndOwner($r);
     $r["user"] = UserController::resolveUser($r["usernameOrEmail"]);
     try {
         $key = new GroupsUsers(array("group_id" => $r["group"]->group_id, "user_id" => $r["user"]->user_id));
         // Check user is actually in group
         $groups_user = GroupsUsersDAO::search($key);
         if (count($groups_user) === 0) {
             throw new InvalidParameterException("parameterNotFound", "User");
         }
         GroupsUsersDAO::delete($key);
         self::$log->info("Removed " . $r["user"]->username . " removed.");
     } catch (ApiException $ex) {
         throw $ex;
     } catch (Exception $ex) {
         throw new InvalidDatabaseOperationException($ex);
     }
     return array("status" => "ok");
 }
예제 #2
0
 /**
  * Remove user from group
  *
  * @param Request $r
  */
 public static function apiRemoveUser(Request $r)
 {
     self::validateGroupAndOwner($r);
     $r['user'] = UserController::resolveUser($r['usernameOrEmail']);
     try {
         $key = new GroupsUsers(array('group_id' => $r['group']->group_id, 'user_id' => $r['user']->user_id));
         // Check user is actually in group
         $groups_user = GroupsUsersDAO::search($key);
         if (count($groups_user) === 0) {
             throw new InvalidParameterException('parameterNotFound', 'User');
         }
         GroupsUsersDAO::delete($key);
         self::$log->info('Removed ' . $r['user']->username . ' removed.');
     } catch (ApiException $ex) {
         throw $ex;
     } catch (Exception $ex) {
         throw new InvalidDatabaseOperationException($ex);
     }
     return array('status' => 'ok');
 }