Пример #1
0
 /**
  * Reporting the post of given category ID, forum ID, thread ID, own ID and slug.
  * @param integer $cid category's ID
  * @param integer $fid forum's ID
  * @param integer $tid thread's ID
  * @param integer $pid post's ID
  * @return string|\yii\web\Response
  */
 public function actionReport($cid = null, $fid = null, $tid = null, $pid = null)
 {
     if (Yii::$app->user->isGuest) {
         $this->warning(Yii::t('podium/flash', 'Please sign in to report the post.'));
         return $this->redirect(['account/login']);
     }
     $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(['default/index']);
     }
     if ($post->author_id == User::loggedId()) {
         $this->info(Yii::t('podium/flash', 'You can not report your own post. Please contact the administrator or moderators if you have got any concerns regarding your post.'));
         return $this->redirect(['default/thread', 'cid' => $post->forum->category->id, 'fid' => $post->forum->id, 'id' => $post->thread->id, 'slug' => $post->thread->slug]);
     }
     $model = new Message();
     $model->scenario = 'report';
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->podiumReport($post)) {
             $this->success(Yii::t('podium/flash', 'Thank you for your report. The moderation team will take a look at this post.'));
             return $this->redirect(['default/thread', 'cid' => $post->forum->category->id, 'fid' => $post->forum->id, 'id' => $post->thread->id, 'slug' => $post->thread->slug]);
         } else {
             $this->error(Yii::t('podium/flash', 'Sorry! There was an error while notifying the moderation team. Contact administrator about this problem.'));
         }
     }
     return $this->render('report', ['model' => $model, 'post' => $post]);
 }