コード例 #1
0
ファイル: BbiiTopicRead.php プロジェクト: sourcetoad/bbii2
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * 
  * @param  [type] $params [description]
  * @return ActiveDataProvider The data provider that can return the models based on the search/filter conditions.
  */
 public function search($params = null)
 {
     $query = BbiiTopicRead::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->addCondition('data', $this->data, true);
     $this->addCondition('user_id', $this->user_id, true);
     return $dataProvider;
 }
コード例 #2
0
ファイル: ForumController.php プロジェクト: sourcetoad/bbii2
 public function isWatching($topic_id)
 {
     $object = new BbiiTopicRead();
     $model = BbiiTopicRead::find(\Yii::$app->user->identity->id);
     if ($model === null) {
         return false;
     }
     $object->unserialize($model->data);
     return $object->follows($topic_id);
 }
コード例 #3
0
ファイル: MemberController.php プロジェクト: sourcetoad/bbii2
 /**
  * [actionView description]
  *
  * @version  2.2.0
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function actionView($id = null)
 {
     $object = new BbiiTopicRead();
     $read = BbiiTopicRead::find($id);
     if (isset(\Yii::$app->request->get()['unwatch']) && ($this->isModerator() || $id == \Yii::$app->user->identity->id)) {
         if ($read !== null) {
             $object->unserialize($read->data);
             foreach (\Yii::$app->request->get()['unwatch'] as $topicId => $val) {
                 $object->unsetFollow($topicId);
             }
             $read->data = $object->serialize();
             $read->save();
         }
     }
     if (($this->isModerator() || $id == \Yii::$app->user->identity->id) && isset($read->data)) {
         if ($read === null) {
             $in = array(0);
         } else {
             $object->unserialize($read->data);
             $in = array_keys($object->getFollow());
         }
     } else {
         $in = array(0);
     }
     // @todo Need to figure out the Yii2 version of `'with' => 'forum',` for ADP - DJE : 2015-05-15
     $dataProvider = new ActiveDataProvider(['pagination' => false, 'query' => BbiiPost::find()->where(['approved' => 1, 'user_id' => \Yii::$app->user->identity->id])->orderBy('create_time DESC')->limit(10)]);
     // @todo Need to figure out the Yii2 version of `'with' => 'forum',` for ADP - DJE : 2015-05-15
     $topicProvider = new ActiveDataProvider(['pagination' => false, 'query' => BbiiTopic::find()->where(['id' => $in])->orderBy('id ASC')]);
     return $this->render('view', array('dataProvider' => $dataProvider, 'topicProvider' => $topicProvider, 'userData' => BbiiMember::find()->where(['id' => is_numeric($id) ? $id : \Yii::$app->request->get('id')])->one()));
 }