Exemple #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;
 }
Exemple #2
0
 public function actionRemove($params)
 {
     $view = $this->ajaxView();
     $view->state = "failed";
     if ($params["id"]) {
         $topic = new Model_Topic($this->getStorage(), $params["id"]);
         $view->id = $topic->getId();
         if ($view->id) {
             $this->canPerform($topic, "delete");
             if ($topic->parent) {
                 $this->canPerform($topic->getParent(), "edit");
             }
             $children = $topic->getDescendants();
             $view->state = "removed";
             try {
                 //foreach ($children as $child)
                 //{
                 //$child->remove();
                 //}
                 //$topic->remove();
                 Model_Trashcan::put($topic);
             } catch (Exception $e) {
                 $view->state = "failed";
                 $view->error = $e->getMessage();
             }
         } else {
             $view->error = "Topic not found.";
         }
     } else {
         $view->error = "Topic ID is not set.";
     }
     return $view;
 }
Exemple #3
0
 public function actionRemove($params)
 {
     $view = $this->ajaxView('article');
     $view->state = "failed";
     if ($params["id"]) {
         $article = new Model_Article($this->getStorage(), $params["id"]);
         $view->id = $article->getId();
         if ($view->id) {
             $this->canPerform($article, "delete");
             $this->canPerform($article->getTopic(), "edit");
             $view->state = "removed";
             try {
                 //$article->remove();
                 Model_Trashcan::put($article);
             } catch (Exception $e) {
                 $view->state = "failed";
                 $view->error = $e->getMessage();
             }
         } else {
             $view->error = "Article not found.";
         }
     } else {
         $view->error = "Article ID is not set.";
     }
     return $view;
 }