public function search($forumId = null, $filters = null)
    {
        $query = static::find();
        if ($forumId) {
            $query->where(['forum_id' => (int)$forumId]);
        }
        if (!empty($filters)) {
            $loggedId = User::loggedId();
            if (!empty($filters['pin']) && $filters['pin'] == 1) {
                $query->andWhere(['pinned' => 1]);
            }
            if (!empty($filters['lock']) && $filters['lock'] == 1) {
                $query->andWhere(['locked' => 1]);
            }
            if (!empty($filters['hot']) && $filters['hot'] == 1) {
                $query->andWhere(['>=', 'posts', Podium::getInstance()->podiumConfig->get('hot_minimum')]);
            }
            if (!empty($filters['new']) && $filters['new'] == 1 && !Podium::getInstance()->user->isGuest) {
                $query->joinWith(['threadView tvn' => function ($q) use ($loggedId) {
                    $q->onCondition(['tvn.user_id' => $loggedId]);
                    $q->andWhere(['or',
                            new Expression('tvn.new_last_seen < new_post_at'),
                            ['tvn.new_last_seen' => null]
                        ]);
                }], false);
            }
            if (!empty($filters['edit']) && $filters['edit'] == 1 && !Podium::getInstance()->user->isGuest) {
                $query->joinWith(['threadView tve' => function ($q) use ($loggedId) {
                    $q->onCondition(['tve.user_id' => $loggedId]);
                    $q->andWhere(['or',
                            new Expression('tve.edited_last_seen < edited_post_at'),
                            ['tve.edited_last_seen' => null]
                        ]);
                }], false);
            }
        }

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => false,
        ]);
        $dataProvider->sort->defaultOrder = [
            'pinned' => SORT_DESC,
            'updated_at' => SORT_DESC,
            'id' => SORT_ASC
        ];

        return $dataProvider;
    }
public function search($forumId = null, $filters = null)
    {
        $query = static::find();
        if ($forumId) {
            $query->where(['forum_id' => (int)$forumId]);
        }
        if (!empty($filters)) {
            $loggedId = User::loggedId();
            if (!empty($filters['pin']) && $filters['pin'] == 1) {
                $query->andWhere(['pinned' => 1]);
            }
            if (!empty($filters['lock']) && $filters['lock'] == 1) {
                $query->andWhere(['locked' => 1]);
            }
            if (!empty($filters['hot']) && $filters['hot'] == 1) {
                $query->andWhere(['>=', 'posts', Podium::getInstance()->podiumConfig->get('hot_minimum')]);
            }
            if (!empty($filters['new']) && $filters['new'] == 1 && !Podium::getInstance()->user->isGuest) {
                $query->joinWith(['threadView tvn' => function ($q) use ($loggedId) {
                    $q->onCondition(['tvn.user_id' => $loggedId]);
                    $q->andWhere(['or',
                            new Expression('tvn.new_last_seen < new_post_at'),
                            ['tvn.new_last_seen' => null]
                        ]);
                }], false);
            }
            if (!empty($filters['edit']) && $filters['edit'] == 1 && !Podium::getInstance()->user->isGuest) {
                $query->joinWith(['threadView tve' => function ($q) use ($loggedId) {
                    $q->onCondition(['tve.user_id' => $loggedId]);
                    $q->andWhere(['or',
                            new Expression('tve.edited_last_seen < edited_post_at'),
                            ['tve.edited_last_seen' => null]
                        ]);
                }], false);
            }
        }

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => false,
        ]);
        $dataProvider->sort->defaultOrder = [
            'pinned' => SORT_DESC,
            'updated_at' => SORT_DESC,
            'id' => SORT_ASC
        ];

        return $dataProvider;
    }
public function search ( $ forumId = null , $ filters = null ) { $ query = static :: find ( ) ; if ( $ forumId ) { $ query -> where ( [ 'forum_id' => ( int ) $ forumId ] ) ; } if ( ! empty ( $ filters ) ) { $ loggedId = User :: loggedId ( ) ; if ( ! empty ( $ filters [ 'pin' ] ) && $ filters [ 'pin' ] == 1 ) { $ query -> andWhere ( [ 'pinned' => 1 ] ) ; } if ( ! empty ( $ filters [ 'lock' ] ) && $ filters [ 'lock' ] == 1 ) { $ query -> andWhere ( [ 'locked' => 1 ] ) ; } if ( ! empty ( $ filters [ 'hot' ] ) && $ filters [ 'hot' ] == 1 ) { $ query -> andWhere ( [ '>=' , 'posts' , Podium :: getInstance ( ) -> podiumConfig -> get ( 'hot_minimum' ) ] ) ; } if ( ! empty ( $ filters [ 'new' ] ) && $ filters [ 'new' ] == 1 && ! Podium :: getInstance ( ) -> user -> isGuest ) { $ query -> joinWith ( [ 'threadView tvn' => function ( $ q ) use ( $ loggedId ) { $ q -> onCondition ( [ 'tvn.user_id' => $ loggedId ] ) ; $ q -> andWhere ( [ 'or' , new Expression ( 'tvn.new_last_seen < new_post_at' ) , [ 'tvn.new_last_seen' => null ] ] ) ; } ] , false ) ; } if ( ! empty ( $ filters [ 'edit' ] ) && $ filters [ 'edit' ] == 1 && ! Podium :: getInstance ( ) -> user -> isGuest ) { $ query -> joinWith ( [ 'threadView tve' => function ( $ q ) use ( $ loggedId ) { $ q -> onCondition ( [ 'tve.user_id' => $ loggedId ] ) ; $ q -> andWhere ( [ 'or' , new Expression ( 'tve.edited_last_seen < edited_post_at' ) , [ 'tve.edited_last_seen' => null ] ] ) ; } ] , false ) ; } } $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'pagination' => false , ] ) ; $ dataProvider -> sort -> defaultOrder = [ 'pinned' => SORT_DESC , 'updated_at' => SORT_DESC , 'id' => SORT_ASC ] ; return $ dataProvider ; }
Searches for thread.
@param int $forumId
@return ActiveDataProvider
Searches for thread .