Esempio n. 1
0
 public function actionRemove($params)
 {
     $view = $this->ajaxView('comment');
     $view->state = 'failed';
     if ($params['id']) {
         $comment = new Model_Comment($this->getStorage(), $params['id']);
         $this->canPerform($view->comment->getArticle(), 'edit');
         if ($view instanceof View_Html) {
             $view->redir('Admin_Article', 'edit', array('id' => $comment->article));
         }
         if ($comment->isLoaded()) {
             $view->state = 'removed';
             $view->id = $comment->getId();
             try {
                 //$comment->remove();
                 Model_Trashcan::put($comment);
             } catch (Exception $e) {
                 $view->state = 'failed';
                 $view->error = $e->getMessage();
             }
         } else {
             $view->error = 'Comment not found.';
         }
     } else {
         $view->error = 'Comment ID is not set.';
     }
     return $view;
 }