summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-10-16 10:06:58 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-10-16 10:06:58 -0700
commit78ee4193b70329c8e0929efd18c22324dd2ad8e0 (patch)
tree900c686f12934fdf168ebe214afc1cb414bf4683 /modules/gallery/helpers
parentbc241e44c2e4d10ac19ccc32a40c90426672d963 (diff)
Remove all non Identity API methods from Identity.php. Created an MY_Session class to provide the user state changes in the session and a login.php helper that has the login form.
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/access.php2
-rw-r--r--modules/gallery/helpers/gallery.php2
-rw-r--r--modules/gallery/helpers/gallery_event.php6
-rw-r--r--modules/gallery/helpers/gallery_theme.php2
-rw-r--r--modules/gallery/helpers/item.php4
-rw-r--r--modules/gallery/helpers/locales.php2
-rw-r--r--modules/gallery/helpers/log.php2
-rw-r--r--modules/gallery/helpers/login.php31
-rw-r--r--modules/gallery/helpers/movie.php2
-rw-r--r--modules/gallery/helpers/photo.php2
-rw-r--r--modules/gallery/helpers/site_status.php2
-rw-r--r--modules/gallery/helpers/task.php2
12 files changed, 45 insertions, 14 deletions
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index 0e0e749e..21f4de81 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -79,7 +79,7 @@ class access_Core {
* @return boolean
*/
static function can($perm_name, $item) {
- return self::user_can(Identity::active(), $perm_name, $item);
+ return self::user_can(Session::active_user(), $perm_name, $item);
}
/**
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index e1fa2a7c..18bb2609 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -27,7 +27,7 @@ class gallery_Core {
static function maintenance_mode() {
$maintenance_mode = Kohana::config("core.maintenance_mode", false, false);
- if (Router::$controller != "login" && !empty($maintenance_mode) && !Identity::active()->admin) {
+ if (Router::$controller != "login" && !empty($maintenance_mode) && !Session::active_user()->admin) {
Router::$controller = "maintenance";
Router::$controller_path = MODPATH . "gallery/controllers/maintenance.php";
Router::$method = "index";
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index abead9e3..a6aa0657 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -24,10 +24,10 @@ class gallery_event_Core {
*/
static function gallery_ready() {
// Call Identity::instance() now to force the load of the user interface classes.
- // Identity::load_user will attempt to load the active user from the session and needs
+ // Session::load_user will attempt to load the active user from the session and needs
// the user definition class, which can't be reached by Kohana's heiracrchical lookup.
Identity::instance();
- Identity::load_user();
+ Session::load_user();
locales::set_request_locale();
}
@@ -139,7 +139,7 @@ class gallery_event_Core {
}
}
- if (Identity::active()->admin) {
+ if (Session::active_user()->admin) {
$menu->append($admin_menu = Menu::factory("submenu")
->id("admin_menu")
->label(t("Admin")));
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index cc46a88a..d21cb124 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -54,7 +54,7 @@ class gallery_theme_Core {
static function header_top($theme) {
if ($theme->page_type != "login") {
$view = new View("login.html");
- $view->user = Identity::active();
+ $view->user = Session::active_user();
return $view->render();
}
}
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index bce83bb3..3d36a324 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -158,8 +158,8 @@ class item_Core {
*/
static function viewable($model) {
$view_restrictions = array();
- if (!Identity::active()->admin) {
- foreach (Identity::group_ids_for_active_user() as $id) {
+ if (!Session::active_user()->admin) {
+ foreach (Session::group_ids_for_active_user() as $id) {
// Separate the first restriction from the rest to make it easier for us to formulate
// our where clause below
if (empty($view_restrictions)) {
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index 2dfc7f21..f80fce03 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -141,7 +141,7 @@ class locales_Core {
$locale = self::cookie_locale();
// 2. Check the user's preference
if (!$locale) {
- $locale = Identity::active()->locale;
+ $locale = Session::active_user()->locale;
}
// 3. Check the browser's / OS' preference
if (!$locale) {
diff --git a/modules/gallery/helpers/log.php b/modules/gallery/helpers/log.php
index 512723dd..d1b34e3a 100644
--- a/modules/gallery/helpers/log.php
+++ b/modules/gallery/helpers/log.php
@@ -80,7 +80,7 @@ class log_Core {
$log->url = substr(url::abs_current(true), 0, 255);
$log->referer = request::referrer(null);
$log->timestamp = time();
- $log->user_id = Identity::active()->id;
+ $log->user_id = Session::active_user()->id;
$log->save();
}
diff --git a/modules/gallery/helpers/login.php b/modules/gallery/helpers/login.php
new file mode 100644
index 00000000..d44153ad
--- /dev/null
+++ b/modules/gallery/helpers/login.php
@@ -0,0 +1,31 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class login_Core {
+ static function get_login_form($url) {
+ $form = new Forge($url, "", "post", array("id" => "g-login-form"));
+ $form->set_attr('class', "g-narrow");
+ $group = $form->group("login")->label(t("Login"));
+ $group->input("name")->label(t("Username"))->id("g-username")->class(null);
+ $group->password("password")->label(t("Password"))->id("g-password")->class(null);
+ $group->inputs["name"]->error_messages("invalid_login", t("Invalid name or password"));
+ $group->submit("")->value(t("Login"));
+ return $form;
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php
index bc0efa01..9541f20e 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -77,7 +77,7 @@ class movie_Core {
$movie->title = $title;
$movie->description = $description;
$movie->name = $name;
- $movie->owner_id = $owner_id ? $owner_id : Identity::active()->id;
+ $movie->owner_id = $owner_id ? $owner_id : Session::active_user()->id;
$movie->width = $movie_info[0];
$movie->height = $movie_info[1];
$movie->mime_type = strtolower($pi["extension"]) == "mp4" ? "video/mp4" : "video/x-flv";
diff --git a/modules/gallery/helpers/photo.php b/modules/gallery/helpers/photo.php
index ad23e322..203862cd 100644
--- a/modules/gallery/helpers/photo.php
+++ b/modules/gallery/helpers/photo.php
@@ -76,7 +76,7 @@ class photo_Core {
$photo->title = $title;
$photo->description = $description;
$photo->name = $name;
- $photo->owner_id = $owner_id ? $owner_id : Identity::active()->id;
+ $photo->owner_id = $owner_id ? $owner_id : Session::active_user()->id;
$photo->width = $image_info[0];
$photo->height = $image_info[1];
$photo->mime_type = empty($image_info['mime']) ? "application/unknown" : $image_info['mime'];
diff --git a/modules/gallery/helpers/site_status.php b/modules/gallery/helpers/site_status.php
index 3f7ff19d..06b29fda 100644
--- a/modules/gallery/helpers/site_status.php
+++ b/modules/gallery/helpers/site_status.php
@@ -95,7 +95,7 @@ class site_status_Core {
* @return html text
*/
static function get() {
- if (!Identity::active()->admin) {
+ if (!Session::active_user()->admin) {
return;
}
$buf = array();
diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php
index 4735c36c..f84fd10e 100644
--- a/modules/gallery/helpers/task.php
+++ b/modules/gallery/helpers/task.php
@@ -42,7 +42,7 @@ class task_Core {
$task->percent_complete = 0;
$task->status = "";
$task->state = "started";
- $task->owner_id = Identity::active()->id;
+ $task->owner_id = Session::active_user()->id;
$task->context = serialize($context);
$task->save();