Example #1
0
 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);
 }
Example #2
0
 /**
  * [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()));
 }