コード例 #1
0
ファイル: ThreadController.php プロジェクト: luoche/iisns
 /**
  * Deletes an existing Thread model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     if ($model->user_id === Yii::$app->user->id || $model->board['user_id'] == Yii::$app->user->id) {
         $board_id = $model->board_id;
         Post::deleteAll(['thread_id' => $model->id]);
         $model->delete();
         Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Deleted successfully.'));
         return $this->redirect(['/forum/board/view', 'id' => $board_id]);
     } else {
         throw new ForbiddenHttpException('You are not allowed to perform this action.');
     }
 }
コード例 #2
0
ファイル: ThreadController.php プロジェクト: dutianbo/iisns
 /**
  * Deletes an existing Thread model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     if ($model->user_id === Yii::$app->user->id || $model->board['user_id'] == Yii::$app->user->id) {
         $board_id = $model->board_id;
         Post::deleteAll(['thread_id' => $model->id]);
         return $model->delete();
     } else {
         throw new ForbiddenHttpException('You are not allowed to perform this action.');
     }
 }