public function actionAdd($id = null)
    {
        if (!Yii::$app->request->isAjax) {
            return $this->redirect(['forum/index']);
        }

        $data = [
            'error' => 1,
            'msg' => Html::tag('span',
                Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign'])
                . ' ' . Yii::t('podium/view', 'Error while adding this subscription!'),
                ['class' => 'text-danger']
            ),
        ];

        if (Podium::getInstance()->user->isGuest) {
            $data['msg'] = Html::tag('span',
                Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign'])
                . ' ' . Yii::t('podium/view', 'Please sign in to subscribe to this thread'),
                ['class' => 'text-info']
            );
        }

        if (is_numeric($id) && $id > 0) {
            $subscription = Subscription::find()->where(['thread_id' => $id, 'user_id' => User::loggedId()])->limit(1)->one();
            if (!empty($subscription)) {
                $data['msg'] = Html::tag('span',
                    Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign'])
                    . ' ' . Yii::t('podium/view', 'You are already subscribed to this thread.'),
                    ['class' => 'text-info']
                );
            } else {
                if (Subscription::add((int)$id)) {
                    $data = [
                        'error' => 0,
                        'msg'   => Html::tag('span',
                            Html::tag('span', '', ['class' => 'glyphicon glyphicon-ok-circle'])
                            . ' ' . Yii::t('podium/view', 'You have subscribed to this thread!'),
                            ['class' => 'text-success']
                        ),
                    ];
                }
            }
        }
        return Json::encode($data);
    }
public function actionAdd($id = null)
    {
        if (!Yii::$app->request->isAjax) {
            return $this->redirect(['forum/index']);
        }

        $data = [
            'error' => 1,
            'msg' => Html::tag('span',
                Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign'])
                . ' ' . Yii::t('podium/view', 'Error while adding this subscription!'),
                ['class' => 'text-danger']
            ),
        ];

        if (Podium::getInstance()->user->isGuest) {
            $data['msg'] = Html::tag('span',
                Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign'])
                . ' ' . Yii::t('podium/view', 'Please sign in to subscribe to this thread'),
                ['class' => 'text-info']
            );
        }

        if (is_numeric($id) && $id > 0) {
            $subscription = Subscription::find()->where(['thread_id' => $id, 'user_id' => User::loggedId()])->limit(1)->one();
            if (!empty($subscription)) {
                $data['msg'] = Html::tag('span',
                    Html::tag('span', '', ['class' => 'glyphicon glyphicon-warning-sign'])
                    . ' ' . Yii::t('podium/view', 'You are already subscribed to this thread.'),
                    ['class' => 'text-info']
                );
            } else {
                if (Subscription::add((int)$id)) {
                    $data = [
                        'error' => 0,
                        'msg'   => Html::tag('span',
                            Html::tag('span', '', ['class' => 'glyphicon glyphicon-ok-circle'])
                            . ' ' . Yii::t('podium/view', 'You have subscribed to this thread!'),
                            ['class' => 'text-success']
                        ),
                    ];
                }
            }
        }
        return Json::encode($data);
    }
public function actionAdd ( $ id = null ) { if ( ! Yii :: $ app -> request -> isAjax ) { return $ this -> redirect ( [ 'forum/index' ] ) ; } $ data = [ 'error' => 1 , 'msg' => Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-warning-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , 'Error while adding this subscription!' ) , [ 'class' => 'text-danger' ] ) , ] ; if ( Podium :: getInstance ( ) -> user -> isGuest ) { $ data [ 'msg' ] = Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-warning-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , 'Please sign in to subscribe to this thread' ) , [ 'class' => 'text-info' ] ) ; } if ( is_numeric ( $ id ) && $ id > 0 ) { $ subscription = Subscription :: find ( ) -> where ( [ 'thread_id' => $ id , 'user_id' => User :: loggedId ( ) ] ) -> limit ( 1 ) -> one ( ) ; if ( ! empty ( $ subscription ) ) { $ data [ 'msg' ] = Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-warning-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , 'You are already subscribed to this thread.' ) , [ 'class' => 'text-info' ] ) ; } else { if ( Subscription :: add ( ( int ) $ id ) ) { $ data = [ 'error' => 0 , 'msg' => Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-ok-circle' ] ) . ' ' . Yii :: t ( 'podium/view' , 'You have subscribed to this thread!' ) , [ 'class' => 'text-success' ] ) , ] ; } } } return Json :: encode ( $ data ) ; }
Subscribing the thread of given ID.
@param int $id
@return Response
Subscribing the thread of given ID .