コード例 #1
0
ファイル: BoardSearch.php プロジェクト: liasica/yiiforum
 public function search($params)
 {
     $query = Board::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'threads' => $this->threads, 'posts' => $this->posts]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Allows the current user to select the active board from his/her board options
  */
 public function actionSelect()
 {
     $userBoardId = explode(',', User::findOne(Yii::$app->getUser()->id)->board_id);
     $userBoards = new ActiveDataProvider(['query' => Board::find()->where(['id' => $userBoardId])]);
     $boardCount = $userBoards->getTotalCount();
     if ($boardCount == 0) {
         // No Boards, log user out
         Yii::$app->user->logout();
         return $this->render('noBoard');
     } elseif ($boardCount == 1) {
         // Only one board for user, activate it automatically
         $activeBoardId = $userBoards->getModels()[0]->id;
         $this->redirect(['activate', 'id' => $activeBoardId]);
     } else {
         // USer must select which board to activate
         return $this->render('select', ['userBoards' => $userBoards]);
     }
 }
コード例 #3
0
 /**
  * Lists all Board models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Board::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
コード例 #4
0
ファイル: Board.php プロジェクト: liasica/yiiforum
 public static function createCache()
 {
     $newLine = "\r\n";
     $content = '<?php' . $newLine;
     $channels = Board::find()->all();
     foreach ($channels as $row) {
         $id = $row['id'];
         $content .= '$cachedBoards[' . $row['id'] . ']=[' . $newLine;
         $content .= Board::getCacheItem('id', $row, true);
         $content .= Board::getCacheItem('parent_id', $row, true);
         $parentIds = Board::getParentIds($id);
         $content .= Board::getCacheItemValue('parent_ids', implode(',', $parentIds));
         $content .= Board::getCacheItem('name', $row);
         $content .= Board::getCacheItem('icon', $row);
         $content .= Board::getCacheItem('description', $row);
         $content .= Board::getCacheItem('rule', $row);
         $content .= Board::getCacheItem('columns', $row, true);
         $content .= Board::getCacheItem('sort_num', $row, true);
         $content .= Board::getCacheItem('redirect_url', $row);
         $content .= Board::getCacheItem('target', $row);
         $content .= Board::getCacheItemValue('level', count($parentIds) - 1, true);
         $content .= "];" . $newLine;
     }
     $dataRoot = \Yii::getAlias('@data');
     TFileHelper::writeFile([$dataRoot, 'cache', 'cachedBoards.php'], $content);
 }