diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-11-25 09:15:45 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-11-25 09:15:45 +0000 |
commit | 9bdf825a947ea4758b1f86100c05f62582edc0a6 (patch) | |
tree | 678755887df11f6bde2273c90cb9297bdfdd1232 /core/controllers | |
parent | b2af9ed47043ac43d33c9c19db4d29093e3ee600 (diff) |
Add a "Access" tab to the scaffolding and list users and groups.
Refactor welcome.php a little bit to make index() more readable.
Diffstat (limited to 'core/controllers')
-rw-r--r-- | core/controllers/welcome.php | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index c62ccbc8..6d0399dc 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -39,26 +39,10 @@ class Welcome_Controller extends Template_Controller { $this->template->deepest_photo = null; } - try { - $this->template->comment_count = ORM::factory("comment")->count_all(); - } catch (Exception $e) { - $this->template->comment_count = 0; - } - - try { - $this->template->tag_count = ORM::factory("tag")->count_all(); - $this->template->most_tagged = Database::instance() - ->select("item_id AS id", "COUNT(tag_id) AS count") - ->from("items_tags") - ->groupby("item_id") - ->orderby("count", "DESC") - ->limit(1) - ->get() - ->current(); - } catch (Exception $e) { - $this->template->tag_count = 0; - $this->template->most_tagged = 0; - } + $this->_load_user_info(); + $this->_load_group_info(); + $this->_load_comment_info(); + $this->_load_tag_info(); set_error_handler($old_handler); @@ -341,4 +325,45 @@ class Welcome_Controller extends Template_Controller { ksort($modules); return $modules; } + + private function _load_group_info() { + try { + $this->template->groups = ORM::factory("group")->find_all(); + } catch (Exception $e) { + $this->template->groups = array(); + } + } + + private function _load_user_info() { + try { + $this->template->users = ORM::factory("user")->find_all(); + } catch (Exception $e) { + $this->template->users = array(); + } + } + + private function _load_comment_info() { + try { + $this->template->comment_count = ORM::factory("comment")->count_all(); + } catch (Exception $e) { + $this->template->comment_count = 0; + } + } + + private function _load_tag_info() { + try { + $this->template->tag_count = ORM::factory("tag")->count_all(); + $this->template->most_tagged = Database::instance() + ->select("item_id AS id", "COUNT(tag_id) AS count") + ->from("items_tags") + ->groupby("item_id") + ->orderby("count", "DESC") + ->limit(1) + ->get() + ->current(); + } catch (Exception $e) { + $this->template->tag_count = 0; + $this->template->most_tagged = 0; + } + } } |