예제 #1
0
 public function actionDel($id)
 {
     $model = new Comment();
     $cond = ['or', ['id' => $id], ['pid' => $id]];
     $model->deleteAll($cond);
     // Yii::$app->request->referrer;
     return $this->redirect(Yii::$app->request->referrer);
 }
예제 #2
0
 /**
  * Deletes an existing Comment model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $mode = $this->findModel($id);
     $post = Post::findOne($mode->post_id);
     $post->updateCounters(['comment_count' => -1]);
     $mode->delete();
     Comment::deleteAll('parent_id = ' . $id);
     return $this->redirect(['index']);
 }
예제 #3
0
 public function actionDelete($id)
 {
     if (Yii::$app->user->can('deleteComment')) {
         $noteId = $this->findComment($id)->note_id;
         Comment::deleteAll(['id' => CommentClosure::findChildrenIds($id)]);
         return $this->redirect(['note/view', 'id' => $noteId]);
     } else {
         throw new ForbiddenHttpException();
     }
 }
예제 #4
0
파일: Post.php 프로젝트: grutabow/Yii2Blog
 /**
  * This is invoked after the record is deleted.
  */
 public function afterDelete()
 {
     parent::afterDelete();
     Comment::deleteAll('post_id = :post_id', [':post_id' => $this->id]);
     Tag::updateFrequency($this->tags, '');
 }
예제 #5
0
파일: Post.php 프로젝트: rocketyang/dcms2
 public function afterDelete()
 {
     parent::afterDelete();
     $Comment = new Comment();
     $Comment->deleteAll(['post_id' => $this->id]);
     $tag = new Tag();
     $tag->updateFrequency($this->tags, '');
 }
예제 #6
0
 /**
  * Удаление определенной записи
  * @param  integer $id Идентификатор удаляемой записи
  * @return redirect
  */
 public function actionDelete($id)
 {
     //Определение текущего языка
     SiteController::locale();
     //Поиск задания по идентификатору
     $task = Task::findOne($id);
     //Удаление всех связанных с заданием комментариев
     $commentDeleted = Comment::deleteAll(["task_id" => $id]);
     if ($task->delete()) {
         Yii::$app->session->setFlash('success', Yii::t('msg/msg', 'Запись удалена'));
         return $this->redirect("/");
     } else {
         Yii::$app->session->setFlash('errors', $task->errors);
     }
 }
예제 #7
0
 /**
  * delete post
  *
  * @param $id
  * @throws Exception
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function actionDelete($id)
 {
     try {
         Yii::trace('Trace :' . __METHOD__, __METHOD__);
         $model = $this->findModel($id);
         Comment::deleteAll('post_id = ' . $id);
         if ($model->delete() === false) {
             throw new \Exception('Erreur durant la suppression');
         }
         $sidebarCacheName = isset(Yii::$app->params['cache']['sidebar']) ? Yii::$app->params['cache']['sidebar'] : null;
         if ($sidebarCacheName !== null) {
             Yii::$app->cache->delete($sidebarCacheName);
         }
         return $this->redirect(['/admin/index']);
     } catch (Exception $e) {
         Yii::error($e->getMessage(), __METHOD__);
         throw $e;
     }
 }
예제 #8
0
 /**
  * This is invoked after the record is deleted.
  */
 public function afterDelete()
 {
     parent::afterDelete();
     Comment::deleteAll(['post_id' => $this->id, 'classify_type' => strtolower($this->getClassName())]);
     Tag::updateFrequency($this->tags, '', strtolower($this->getClassName()));
 }