concrete/src/User/UserList.php
public function filterByInAnyGroup($groups, $inGroups = true)
    {
        $this->checkGroupJoin();
        $groupIDs = [];
        $orX = $this->getQueryObject()->expr()->orX();
        $app = Application::getFacadeApplication();
        /** @var $likeBuilder LikeBuilder */
        $likeBuilder = $app->make(LikeBuilder::class);
        $query = $this->getQueryObject()->getConnection()->createQueryBuilder();

        foreach ($groups as $group) {
            if ($group instanceof \Concrete\Core\User\Group\Group) {
                $orX->add($this->getQueryObject()->expr()->like('g.gPath', ':groupPathChild_'.$group->getGroupID()));
                $this->getQueryObject()->setParameter('groupPathChild_'.$group->getGroupID(), $likeBuilder->escapeForLike($group->getGroupPath()). '/%');

                $groupIDs[] = $group->getGroupID();
            }
        }
        if (is_array($groups) && count($groups) > 0) {
            $query->select('u.uID')->from('Users','u')
                ->leftJoin('u','UserGroups','ug','u.uID=ug.uID')
                ->leftJoin('ug', $query->getConnection()->getDatabasePlatform()->quoteSingleIdentifier('Groups'), 'g', 'ug.gID=g.gID');
            $orX->add($this->getQueryObject()->expr()->in('g.gID', $groupIDs));
            $query->where($orX)->andWhere($this->getQueryObject()->expr()->isNotNull('g.gID'));
            if ($inGroups) {
                $this->getQueryObject()->andWhere($this->getQueryObject()->expr()->in('u.uID', $query->getSQL()));
            } else {
                $this->getQueryObject()->andWhere($this->getQueryObject()->expr()->notIn('u.uID', $query->getSQL()));
                $this->getQueryObject()->setParameter('groupIDs',$groupIDs, \Concrete\Core\Database\Connection\Connection::PARAM_INT_ARRAY);
            }
        }



    }
public function filterByInAnyGroup($groups, $inGroups = true)
    {
        $this->checkGroupJoin();
        $groupIDs = [];
        $orX = $this->getQueryObject()->expr()->orX();
        $app = Application::getFacadeApplication();
        /** @var $likeBuilder LikeBuilder */
        $likeBuilder = $app->make(LikeBuilder::class);
        $query = $this->getQueryObject()->getConnection()->createQueryBuilder();

        foreach ($groups as $group) {
            if ($group instanceof \Concrete\Core\User\Group\Group) {
                $orX->add($this->getQueryObject()->expr()->like('g.gPath', ':groupPathChild_'.$group->getGroupID()));
                $this->getQueryObject()->setParameter('groupPathChild_'.$group->getGroupID(), $likeBuilder->escapeForLike($group->getGroupPath()). '/%');

                $groupIDs[] = $group->getGroupID();
            }
        }
        if (is_array($groups) && count($groups) > 0) {
            $query->select('u.uID')->from('Users','u')
                ->leftJoin('u','UserGroups','ug','u.uID=ug.uID')
                ->leftJoin('ug', $query->getConnection()->getDatabasePlatform()->quoteSingleIdentifier('Groups'), 'g', 'ug.gID=g.gID');
            $orX->add($this->getQueryObject()->expr()->in('g.gID', $groupIDs));
            $query->where($orX)->andWhere($this->getQueryObject()->expr()->isNotNull('g.gID'));
            if ($inGroups) {
                $this->getQueryObject()->andWhere($this->getQueryObject()->expr()->in('u.uID', $query->getSQL()));
            } else {
                $this->getQueryObject()->andWhere($this->getQueryObject()->expr()->notIn('u.uID', $query->getSQL()));
                $this->getQueryObject()->setParameter('groupIDs',$groupIDs, \Concrete\Core\Database\Connection\Connection::PARAM_INT_ARRAY);
            }
        }



    }
public function filterByInAnyGroup ( $ groups , $ inGroups = true ) { $ this -> checkGroupJoin ( ) ; $ groupIDs = [ ] ; $ orX = $ this -> getQueryObject ( ) -> expr ( ) -> orX ( ) ; $ app = Application :: getFacadeApplication ( ) ; /** @var $likeBuilder LikeBuilder */ $ likeBuilder = $ app -> make ( LikeBuilder :: class ) ; $ query = $ this -> getQueryObject ( ) -> getConnection ( ) -> createQueryBuilder ( ) ; foreach ( $ groups as $ group ) { if ( $ group instanceof \ Concrete \ Core \ User \ Group \ Group ) { $ orX -> add ( $ this -> getQueryObject ( ) -> expr ( ) -> like ( 'g.gPath' , ':groupPathChild_' . $ group -> getGroupID ( ) ) ) ; $ this -> getQueryObject ( ) -> setParameter ( 'groupPathChild_' . $ group -> getGroupID ( ) , $ likeBuilder -> escapeForLike ( $ group -> getGroupPath ( ) ) . '/%' ) ; $ groupIDs [ ] = $ group -> getGroupID ( ) ; } } if ( is_array ( $ groups ) && count ( $ groups ) > 0 ) { $ query -> select ( 'u.uID' ) -> from ( 'Users' , 'u' ) -> leftJoin ( 'u' , 'UserGroups' , 'ug' , 'u.uID=ug.uID' ) -> leftJoin ( 'ug' , $ query -> getConnection ( ) -> getDatabasePlatform ( ) -> quoteSingleIdentifier ( 'Groups' ) , 'g' , 'ug.gID=g.gID' ) ; $ orX -> add ( $ this -> getQueryObject ( ) -> expr ( ) -> in ( 'g.gID' , $ groupIDs ) ) ; $ query -> where ( $ orX ) -> andWhere ( $ this -> getQueryObject ( ) -> expr ( ) -> isNotNull ( 'g.gID' ) ) ; if ( $ inGroups ) { $ this -> getQueryObject ( ) -> andWhere ( $ this -> getQueryObject ( ) -> expr ( ) -> in ( 'u.uID' , $ query -> getSQL ( ) ) ) ; } else { $ this -> getQueryObject ( ) -> andWhere ( $ this -> getQueryObject ( ) -> expr ( ) -> notIn ( 'u.uID' , $ query -> getSQL ( ) ) ) ; $ this -> getQueryObject ( ) -> setParameter ( 'groupIDs' , $ groupIDs , \ Concrete \ Core \ Database \ Connection \ Connection :: PARAM_INT_ARRAY ) ; } } }
Filters the user list for only users within at least one of the provided groups.

@param \Concrete\Core\User\Group\Group[]|\Generator $groups
@param bool $inGroups Set to true to search users that are in at least in one of the specified groups, false to search users that aren't in any of the specified groups
Filters the user list for only users within at least one of the provided groups .