public function actionDeletepost($cid = null, $fid = null, $tid = null, $pid = null)
    {
        $post = Post::verify($cid, $fid, $tid, $pid);
        if (empty($post)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        if ($post->thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $post->thread])) {
            $this->info(Yii::t('podium/flash', 'This thread is locked.'));
            return $this->redirect([
                'forum/thread',
                'cid' => $post->forum->category->id,
                'fid' => $post->forum->id,
                'id' => $post->thread->id,
                'slug' => $post->thread->slug
            ]);
        }

        if (!User::can(Rbac::PERM_DELETE_OWN_POST, ['post' => $post]) && !User::can(Rbac::PERM_DELETE_POST, ['item' => $post])) {
            $this->error(Yii::t('podium/flash', 'Sorry! You do not have the required permission to perform this action.'));
            return $this->redirect(['forum/index']);
        }

        $postData = Yii::$app->request->post('post');
        if ($postData) {
            if ($postData != $post->id) {
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while deleting the post.'));
            } else {
                if ($post->podiumDelete()) {
                    $this->success(Yii::t('podium/flash', 'Post has been deleted.'));
                    if (Thread::find()->where(['id' => $post->thread->id])->exists()) {
                        return $this->redirect([
                            'forum/forum',
                            'cid' => $post->forum->category->id,
                            'id' => $post->forum->id,
                            'slug' => $post->forum->slug
                        ]);
                    }
                    return $this->redirect([
                        'forum/thread',
                        'cid' => $post->forum->category->id,
                        'fid' => $post->forum->id,
                        'id' => $post->thread->id,
                        'slug' => $post->thread->slug
                    ]);
                }
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while deleting the post.'));
            }
        }
        return $this->render('deletepost', ['model' => $post]);
    }
public function actionDeletepost($cid = null, $fid = null, $tid = null, $pid = null)
    {
        $post = Post::verify($cid, $fid, $tid, $pid);
        if (empty($post)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        if ($post->thread->locked == 1 && !User::can(Rbac::PERM_UPDATE_THREAD, ['item' => $post->thread])) {
            $this->info(Yii::t('podium/flash', 'This thread is locked.'));
            return $this->redirect([
                'forum/thread',
                'cid' => $post->forum->category->id,
                'fid' => $post->forum->id,
                'id' => $post->thread->id,
                'slug' => $post->thread->slug
            ]);
        }

        if (!User::can(Rbac::PERM_DELETE_OWN_POST, ['post' => $post]) && !User::can(Rbac::PERM_DELETE_POST, ['item' => $post])) {
            $this->error(Yii::t('podium/flash', 'Sorry! You do not have the required permission to perform this action.'));
            return $this->redirect(['forum/index']);
        }

        $postData = Yii::$app->request->post('post');
        if ($postData) {
            if ($postData != $post->id) {
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while deleting the post.'));
            } else {
                if ($post->podiumDelete()) {
                    $this->success(Yii::t('podium/flash', 'Post has been deleted.'));
                    if (Thread::find()->where(['id' => $post->thread->id])->exists()) {
                        return $this->redirect([
                            'forum/forum',
                            'cid' => $post->forum->category->id,
                            'id' => $post->forum->id,
                            'slug' => $post->forum->slug
                        ]);
                    }
                    return $this->redirect([
                        'forum/thread',
                        'cid' => $post->forum->category->id,
                        'fid' => $post->forum->id,
                        'id' => $post->thread->id,
                        'slug' => $post->thread->slug
                    ]);
                }
                $this->error(Yii::t('podium/flash', 'Sorry! There was an error while deleting the post.'));
            }
        }
        return $this->render('deletepost', ['model' => $post]);
    }
public function actionDeletepost ( $ cid = null , $ fid = null , $ tid = null , $ pid = null ) { $ post = Post :: verify ( $ cid , $ fid , $ tid , $ pid ) ; if ( empty ( $ post ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find the post you are looking for.' ) ) ; return $ this -> redirect ( [ 'forum/index' ] ) ; } if ( $ post -> thread -> locked == 1 && ! User :: can ( Rbac :: PERM_UPDATE_THREAD , [ 'item' => $ post -> thread ] ) ) { $ this -> info ( Yii :: t ( 'podium/flash' , 'This thread is locked.' ) ) ; return $ this -> redirect ( [ 'forum/thread' , 'cid' => $ post -> forum -> category -> id , 'fid' => $ post -> forum -> id , 'id' => $ post -> thread -> id , 'slug' => $ post -> thread -> slug ] ) ; } if ( ! User :: can ( Rbac :: PERM_DELETE_OWN_POST , [ 'post' => $ post ] ) && ! User :: can ( Rbac :: PERM_DELETE_POST , [ 'item' => $ post ] ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! You do not have the required permission to perform this action.' ) ) ; return $ this -> redirect ( [ 'forum/index' ] ) ; } $ postData = Yii :: $ app -> request -> post ( 'post' ) ; if ( $ postData ) { if ( $ postData != $ post -> id ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was an error while deleting the post.' ) ) ; } else { if ( $ post -> podiumDelete ( ) ) { $ this -> success ( Yii :: t ( 'podium/flash' , 'Post has been deleted.' ) ) ; if ( Thread :: find ( ) -> where ( [ 'id' => $ post -> thread -> id ] ) -> exists ( ) ) { return $ this -> redirect ( [ 'forum/forum' , 'cid' => $ post -> forum -> category -> id , 'id' => $ post -> forum -> id , 'slug' => $ post -> forum -> slug ] ) ; } return $ this -> redirect ( [ 'forum/thread' , 'cid' => $ post -> forum -> category -> id , 'fid' => $ post -> forum -> id , 'id' => $ post -> thread -> id , 'slug' => $ post -> thread -> slug ] ) ; } $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was an error while deleting the post.' ) ) ; } } return $ this -> render ( 'deletepost' , [ 'model' => $ post ] ) ; }
Deleting the post of given category ID, forum ID, thread ID and ID.
@param int $cid category ID
@param int $fid forum ID
@param int $tid thread ID
@param int $pid post ID
@return string|Response
Deleting the post of given category ID forum ID thread ID and ID .