From 9d584a528b8aa6b825a489ddf4bb9ecd50c54016 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 10 Jan 2009 07:55:16 +0000 Subject: Update the queue counts in the menu list whenever we approve/unapprove/spam a comment. --- modules/comment/controllers/admin_comments.php | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'modules/comment/controllers') diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php index 9d7e1222..a4b1a94c 100644 --- a/modules/comment/controllers/admin_comments.php +++ b/modules/comment/controllers/admin_comments.php @@ -19,24 +19,13 @@ */ class Admin_Comments_Controller extends Admin_Controller { - public function index() { - $this->queue("all"); - } - - public function queue($state) { + private function _get_base_view() { $view = new Admin_View("admin.html"); $view->content = new View("admin_comments.html"); - $view->content->all = $this->_query(array("published", "unpublished")); $view->content->published = $this->_query(array("published")); $view->content->unpublished = $this->_query(array("unpublished")); $view->content->spam = $this->_query(array("spam")); $view->content->menu = Menu::factory("root") - ->append(Menu::factory("link") - ->id("all") - ->label(t(array("one" => "All Comments ({{count}})", - "other" => "All Comments ({{count}})"), - array("count" => $view->content->all->count()))) - ->url(url::site("admin/comments/queue/all"))) ->append(Menu::factory("link") ->id("unpublished") ->label(t(array("one" => "Awaiting Moderation ({{count}})", @@ -55,13 +44,24 @@ class Admin_Comments_Controller extends Admin_Controller { "other" => "Spam ({{count}})"), array("count" => $view->content->spam->count()))) ->url(url::site("admin/comments/queue/spam"))); + return $view; + } - switch ($state) { - case "all": - $view->content->comments = $view->content->all; - $view->content->title = t("All Comments"); - break; + public function index() { + $this->queue("unpublished"); + } + + public function menu_labels($state) { + $view = $this->_get_base_view(); + print json_encode(array($view->content->menu->get("unpublished")->label, + $view->content->menu->get("published")->label, + $view->content->menu->get("spam")->label)); + } + public function queue($state) { + $view = $this->_get_base_view(); + + switch ($state) { case "published": $view->content->comments = $view->content->published; $view->content->title = t("Approved Comments"); -- cgit v1.2.3