From 736d74d05f70be5b72e44eafe2cc8efae52b0af7 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 16 Mar 2009 04:33:45 +0000 Subject: Clean up the login, maintenance login and required-top-level-login code. We now have two clear and separate login approaches: login/ajax login/html Choose the one that's appropriate. Totally simplified the maintenance page to be separate from the theme and dead simple, and use login/html approach there. Totally simplified the top level login (login_page.html.php) to just be a login page, not the rest of the chrome on the page and use the login/ajax approach there. Don't use access::required in albums and then catch the exception, instead use access::can and check the return code. Improve the text for maintenance mode. --- core/controllers/albums.php | 11 +++++------ core/controllers/maintenance.php | 10 ++-------- 2 files changed, 7 insertions(+), 14 deletions(-) (limited to 'core/controllers') diff --git a/core/controllers/albums.php b/core/controllers/albums.php index 9811ba13..bcfdd8c2 100644 --- a/core/controllers/albums.php +++ b/core/controllers/albums.php @@ -23,13 +23,12 @@ class Albums_Controller extends Items_Controller { * @see REST_Controller::_show($resource) */ public function _show($album) { - try { - access::required("view", $album); - } catch (Exception $e) { + if (!access::can("view", $album)) { if ($album->id != 1) { - throw $e; + access::forbidden(); } else { - url::redirect("login/page"); + print new Theme_View("login_page.html"); + return; } } @@ -163,7 +162,7 @@ class Albums_Controller extends Items_Controller { $album->description = $form->edit_album->description->value; $album->sort_column = $form->edit_album->sort_order->column->value; $album->sort_order = $form->edit_album->sort_order->direction->value; - + $album->save(); module::event("item_updated", $orig, $album); diff --git a/core/controllers/maintenance.php b/core/controllers/maintenance.php index 908e90b5..32295a45 100644 --- a/core/controllers/maintenance.php +++ b/core/controllers/maintenance.php @@ -19,12 +19,6 @@ */ class Maintenance_Controller extends Controller { function index() { - $album = ORM::factory("item", 1); - $v = new Theme_View("maintenance.html", "reset"); - $v->title = t("%title Unavailable", array("title" => $album->title)); - $v->content = t("%title is currently unavailable as it is undergoing maintenance", - array("title" => $album->title)); - - print $v; - } + print new View("maintenance.html"); + } } \ No newline at end of file -- cgit v1.2.3