/** * Action for the members section of the directory * * @todo Dont pass lucene hits to view, build user array inside of action */ public function actionMembers() { $keyword = Yii::$app->request->get('keyword', ""); $page = (int) Yii::$app->request->get('page', 1); //$_GET['keyword'] = $keyword; // Fix for post var $searchResultSet = Yii::$app->search->find($keyword, ['model' => \humhub\modules\user\models\User::className(), 'page' => $page, 'pageSize' => Setting::Get('paginationSize')]); $pagination = new \yii\data\Pagination(['totalCount' => $searchResultSet->total, 'pageSize' => $searchResultSet->pageSize]); \yii\base\Event::on(Sidebar::className(), Sidebar::EVENT_INIT, function ($event) { $event->sender->addWidget(\humhub\modules\directory\widgets\NewMembers::className(), [], ['sortOrder' => 10]); $event->sender->addWidget(\humhub\modules\directory\widgets\MemberStatistics::className(), [], ['sortOrder' => 20]); }); return $this->render('members', array('keyword' => $keyword, 'users' => $searchResultSet->getResultInstances(), 'pagination' => $pagination)); }
/** * Action for the members section of the directory * * @todo Dont pass lucene hits to view, build user array inside of action */ public function actionMembers() { $keyword = Yii::$app->request->get('keyword', ""); $page = (int) Yii::$app->request->get('page', 1); $groupId = (int) Yii::$app->request->get('groupId', ""); $group = null; if ($groupId) { $group = \humhub\modules\user\models\Group::findOne(['id' => $groupId]); } $searchOptions = ['model' => \humhub\modules\user\models\User::className(), 'page' => $page, 'pageSize' => $this->module->pageSize]; if ($this->module->memberListSortField != "") { $searchOptions['sortField'] = $this->module->memberListSortField; } if ($group !== null) { $searchOptions['filters'] = ['groupId' => $group->id]; } $searchResultSet = Yii::$app->search->find($keyword, $searchOptions); $pagination = new \yii\data\Pagination(['totalCount' => $searchResultSet->total, 'pageSize' => $searchResultSet->pageSize]); \yii\base\Event::on(Sidebar::className(), Sidebar::EVENT_INIT, function ($event) { $event->sender->addWidget(\humhub\modules\directory\widgets\NewMembers::className(), [], ['sortOrder' => 10]); $event->sender->addWidget(\humhub\modules\directory\widgets\MemberStatistics::className(), [], ['sortOrder' => 20]); }); return $this->render('members', array('keyword' => $keyword, 'group' => $group, 'users' => $searchResultSet->getResultInstances(), 'pagination' => $pagination)); }