Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
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()));
 }