public function actionNewThread($cid = null, $fid = null)
    {
        if (!User::can(Rbac::PERM_CREATE_THREAD)) {
            $this->error(Yii::t('podium/flash', 'Sorry! You do not have the required permission to perform this action.'));
            return $this->redirect(['forum/index']);
        }

        $forum = Forum::find()->where(['id' => $fid, 'category_id' => $cid])->limit(1)->one();
        if (empty($forum)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the forum you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        $model = new Thread();
        $model->scenario = 'new';
        $model->subscribe = 1;
        $preview = false;
        $postData = Yii::$app->request->post();
        if ($model->load($postData)) {
            $model->posts = 0;
            $model->views = 0;
            $model->category_id = $forum->category->id;
            $model->forum_id = $forum->id;
            $model->author_id = User::loggedId();
            if ($model->validate()) {
                if (isset($postData['preview-button'])) {
                    $preview = true;
                } else {
                    if ($model->podiumNew()) {
                        $this->success(Yii::t('podium/flash', 'New thread has been created.'));
                        return $this->redirect([
                            'forum/thread',
                            'cid' => $forum->category->id,
                            'fid' => $forum->id,
                            'id' => $model->id,
                            'slug' => $model->slug
                        ]);
                    }
                    $this->error(Yii::t('podium/flash', 'Sorry! There was an error while creating the thread. Contact administrator about this problem.'));
                }
            }
        }
        return $this->render('new-thread', [
            'preview' => $preview,
            'model' => $model,
            'forum' => $forum,
        ]);
    }
public function actionNewThread($cid = null, $fid = null)
    {
        if (!User::can(Rbac::PERM_CREATE_THREAD)) {
            $this->error(Yii::t('podium/flash', 'Sorry! You do not have the required permission to perform this action.'));
            return $this->redirect(['forum/index']);
        }

        $forum = Forum::find()->where(['id' => $fid, 'category_id' => $cid])->limit(1)->one();
        if (empty($forum)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the forum you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        $model = new Thread();
        $model->scenario = 'new';
        $model->subscribe = 1;
        $preview = false;
        $postData = Yii::$app->request->post();
        if ($model->load($postData)) {
            $model->posts = 0;
            $model->views = 0;
            $model->category_id = $forum->category->id;
            $model->forum_id = $forum->id;
            $model->author_id = User::loggedId();
            if ($model->validate()) {
                if (isset($postData['preview-button'])) {
                    $preview = true;
                } else {
                    if ($model->podiumNew()) {
                        $this->success(Yii::t('podium/flash', 'New thread has been created.'));
                        return $this->redirect([
                            'forum/thread',
                            'cid' => $forum->category->id,
                            'fid' => $forum->id,
                            'id' => $model->id,
                            'slug' => $model->slug
                        ]);
                    }
                    $this->error(Yii::t('podium/flash', 'Sorry! There was an error while creating the thread. Contact administrator about this problem.'));
                }
            }
        }
        return $this->render('new-thread', [
            'preview' => $preview,
            'model' => $model,
            'forum' => $forum,
        ]);
    }
public function actionNewThread ( $ cid = null , $ fid = null ) { if ( ! User :: can ( Rbac :: PERM_CREATE_THREAD ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! You do not have the required permission to perform this action.' ) ) ; return $ this -> redirect ( [ 'forum/index' ] ) ; } $ forum = Forum :: find ( ) -> where ( [ 'id' => $ fid , 'category_id' => $ cid ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ forum ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find the forum you are looking for.' ) ) ; return $ this -> redirect ( [ 'forum/index' ] ) ; } $ model = new Thread ( ) ; $ model -> scenario = 'new' ; $ model -> subscribe = 1 ; $ preview = false ; $ postData = Yii :: $ app -> request -> post ( ) ; if ( $ model -> load ( $ postData ) ) { $ model -> posts = 0 ; $ model -> views = 0 ; $ model -> category_id = $ forum -> category -> id ; $ model -> forum_id = $ forum -> id ; $ model -> author_id = User :: loggedId ( ) ; if ( $ model -> validate ( ) ) { if ( isset ( $ postData [ 'preview-button' ] ) ) { $ preview = true ; } else { if ( $ model -> podiumNew ( ) ) { $ this -> success ( Yii :: t ( 'podium/flash' , 'New thread has been created.' ) ) ; return $ this -> redirect ( [ 'forum/thread' , 'cid' => $ forum -> category -> id , 'fid' => $ forum -> id , 'id' => $ model -> id , 'slug' => $ model -> slug ] ) ; } $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was an error while creating the thread. Contact administrator about this problem.' ) ) ; } } } return $ this -> render ( 'new-thread' , [ 'preview' => $ preview , 'model' => $ model , 'forum' => $ forum , ] ) ; }
Creating the thread of given category ID and forum ID.
@param int $cid category ID
@param int $fid forum ID
@return string|Response
Creating the thread of given category ID and forum ID .