示例#1
0
文件: Comment.php 项目: kstep/pnut
 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;
 }
示例#2
0
文件: Topic.php 项目: kstep/pnut
 public function actionTrashcan($params)
 {
     Model_List_Db::setVisibility('');
     Model_Db::setVisibility('');
     $view = $this->htmlView("list_trashcan");
     $trashcan = new Model_Trashcan($this->getStorage());
     if ($_POST && isset($_POST['objects'])) {
         $mode = isset($_POST['restore']) ? 'restore' : (isset($_POST['cleanup']) ? 'cleanup' : '');
         if ($mode) {
             foreach ($_POST['objects'] as $oname => $idlist) {
                 $trashcan->{$mode}($oname, $idlist);
             }
         }
     }
     $olist = array();
     foreach (array('Статьи' => 'Article', 'Разделы' => 'Topic', 'Комментарии' => 'Comment') as $title => $oname) {
         $list = $trashcan->getList($oname);
         if (count($list)) {
             $olist[$title] = $list;
         }
         unset($list);
     }
     $view->trashcan = $olist;
     return $view;
 }
示例#3
0
文件: Article.php 项目: kstep/pnut
 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;
 }