summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2010-02-10 08:53:39 -0800
committerTim Almdal <tnalmdal@shaw.ca>2010-02-10 08:53:39 -0800
commit8ef08d20883d9b9aa0b7560ce3bf6da8a6632149 (patch)
treed00e6302c95cfa0c7e0fec80805c4a2e1a33e768
parent17f0a1b10f3df250129188316c14b01f0e3b45f0 (diff)
Refactor the code to display the login page if the user does not have view
permission into the common auth::require_login() method.
-rw-r--r--modules/gallery/controllers/albums.php8
-rw-r--r--modules/gallery/controllers/movies.php7
-rw-r--r--modules/gallery/controllers/photos.php6
-rw-r--r--modules/gallery/helpers/auth.php13
4 files changed, 16 insertions, 18 deletions
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 1d369b95..e1985cfb 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -30,13 +30,7 @@ class Albums_Controller extends Items_Controller {
}
if (!access::can("view", $album)) {
- $view = new Theme_View("page.html", "other", "login");
- $view->page_title = t("Log in to Gallery");
- $view->content = new View("login_ajax.html");
- $view->content->form = auth::get_login_form("login/auth_html");
- // Avoid anti-phishing protection by passing the url as session variable.
- Session::instance()->set("continue_url", url::current(true));
- print $view;
+ print auth::require_login();
return;
}
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 9e882ef4..8041066e 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -26,12 +26,7 @@ class Movies_Controller extends Items_Controller {
}
if (!access::can("view", $movie)) {
- $view = new Theme_View("page.html", "other", "login");
- $view->page_title = t("Log in to Gallery");
- $view->content = new View("login_ajax.html");
- $view->content->form = auth::get_login_form("login/auth_html");
-
- print $view;
+ print auth::require_login();
return;
}
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 8beae207..778e9ae7 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -26,11 +26,7 @@ class Photos_Controller extends Items_Controller {
}
if (!access::can("view", $photo)) {
- $view = new Theme_View("page.html", "other", "login");
- $view->page_title = t("Log in to Gallery");
- $view->content = new View("login_ajax.html");
- $view->content->form = auth::get_login_form("login/auth_html");
- print $view;
+ print auth::require_login();
return;
}
diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php
index c3e9e6e9..f5454f85 100644
--- a/modules/gallery/helpers/auth.php
+++ b/modules/gallery/helpers/auth.php
@@ -130,4 +130,17 @@ class auth_Core {
$session->set("admin_area_activity_timestamp", time());
return false;
}
+
+ /**
+ * Redirect to the login page.
+ */
+ static function require_login() {
+ $view = new Theme_View("page.html", "other", "login");
+ $view->page_title = t("Log in to Gallery");
+ $view->content = new View("login_ajax.html");
+ $view->content->form = auth::get_login_form("login/auth_html");
+ // Avoid anti-phishing protection by passing the url as session variable.
+ Session::instance()->set("continue_url", url::current(true));
+ return $view;
+ }
} \ No newline at end of file