public function searchUserByLogin($username, $parentGroupId = null)
    {
        try {
            $user = $this->userService->loadUserByLogin($username);
        } catch (ApiExceptions\NotFoundException $e) {
            return null;
        }

        if ($user && $parentGroupId) {
            $userGroups = $this->userService->loadUserGroupsOfUser($user);

            foreach ($userGroups as $userGroup) {
                if ($userGroup->getVersionInfo()->getContentInfo()->id == $parentGroupId) {
                    return $user;
                }
            }
            // user not found in $parentGroupId
            return null;
        }

        return $user;
    }
public function searchUserByLogin($username, $parentGroupId = null)
    {
        try {
            $user = $this->userService->loadUserByLogin($username);
        } catch (ApiExceptions\NotFoundException $e) {
            return null;
        }

        if ($user && $parentGroupId) {
            $userGroups = $this->userService->loadUserGroupsOfUser($user);

            foreach ($userGroups as $userGroup) {
                if ($userGroup->getVersionInfo()->getContentInfo()->id == $parentGroupId) {
                    return $user;
                }
            }
            // user not found in $parentGroupId
            return null;
        }

        return $user;
    }
public function searchUserByLogin ( $ username , $ parentGroupId = null ) { try { $ user = $ this -> userService -> loadUserByLogin ( $ username ) ; } catch ( ApiExceptions \ NotFoundException $ e ) { return null ; } if ( $ user && $ parentGroupId ) { $ userGroups = $ this -> userService -> loadUserGroupsOfUser ( $ user ) ; foreach ( $ userGroups as $ userGroup ) { if ( $ userGroup -> getVersionInfo ( ) -> getContentInfo ( ) -> id == $ parentGroupId ) { return $ user ; } } // user not found in $parentGroupId return null ; } return $ user ; }
Search User with given username, optionally at given location.

@param string $username name of User to search for
@param string $parentGroupLocationId where to search, in User Group tree

@return User found
Search User with given username optionally at given location .