From 8412aeb1337c4060a77af7c94441ca8cbc6bb4ad Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Fri, 12 Feb 2010 19:05:44 -0800 Subject: For consistency, use straight Kohana_404_Exception instead of the event system. --- modules/gallery/controllers/albums.php | 2 +- modules/gallery/controllers/items.php | 2 +- modules/gallery/controllers/movies.php | 2 +- modules/gallery/controllers/photos.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index 1cc3b1ec..036dade0 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -26,7 +26,7 @@ class Albums_Controller extends Items_Controller { if (!is_object($album)) { // show() must be public because we route to it in url::parse_url(), so make // sure that we're actually receiving an object - Event::run('system.404'); + throw new Kohana_404_Exception(); } access::required("view", $album); diff --git a/modules/gallery/controllers/items.php b/modules/gallery/controllers/items.php index 0bd47b2d..f261e3a9 100644 --- a/modules/gallery/controllers/items.php +++ b/modules/gallery/controllers/items.php @@ -21,7 +21,7 @@ class Items_Controller extends Controller { public function __call($function, $args) { $item = ORM::factory("item", (int)$function); if (!$item->loaded()) { - Event::run('system.404'); + throw new Kohana_404_Exception(); } // Redirect to the more specific resource type, since it will render diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 1dbcb481..78a56e81 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -22,7 +22,7 @@ class Movies_Controller extends Items_Controller { if (!is_object($movie)) { // show() must be public because we route to it in url::parse_url(), so make // sure that we're actually receiving an object - Event::run('system.404'); + throw new Kohana_404_Exception(); } access::required("view", $movie); diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 2a77aea4..f2d47eec 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -22,7 +22,7 @@ class Photos_Controller extends Items_Controller { if (!is_object($photo)) { // show() must be public because we route to it in url::parse_url(), so make // sure that we're actually receiving an object - Event::run('system.404'); + throw new Kohana_404_Exception(); } access::required("view", $photo); -- cgit v1.2.3 From 0f66db51efc427482aaf3b575fff84f015a3a2ab Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sat, 13 Feb 2010 18:03:46 -0800 Subject: Change JavaScript reauthentication check to check via XHR. Benefit: Getting the real deadline this way, not interfering with an ongoing maintenance task. --- modules/gallery/controllers/admin.php | 21 +++++++++++++++++++++ modules/gallery/helpers/gallery_theme.php | 17 +++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php index 7706e9fc..838c2b50 100644 --- a/modules/gallery/controllers/admin.php +++ b/modules/gallery/controllers/admin.php @@ -29,6 +29,9 @@ class Admin_Controller extends Controller { } public function __call($controller_name, $args) { + if (Input::instance()->get("reauth_check")) { + return self::_reauth_check(); + } if (auth::must_reauth_for_admin_area()) { return self::_prompt_for_reauth($controller_name, $args); } @@ -54,6 +57,24 @@ class Admin_Controller extends Controller { call_user_func_array(array(new $controller_name, $method), $args); } + private static function _reauth_check() { + $session = Session::instance(); + $last_active_auth = $session->get("active_auth_timestamp", 0); + $last_admin_area_activity = $session->get("admin_area_activity_timestamp", 0); + $admin_area_timeout = module::get_var("gallery", "admin_area_timeout"); + + $time_remaining = max($last_active_auth, $last_admin_area_activity) + + $admin_area_timeout - time(); + + $result = new stdClass(); + $result->result = "success"; + if ($time_remaining < 30) { + $result->location = url::abs_site(""); + } + + print json_encode($result); + } + private static function _prompt_for_reauth($controller_name, $args) { if (request::method() == "get" && !request::is_ajax()) { // Avoid anti-phishing protection by passing the url as session variable. diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 9ffeb911..ec650e1c 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -92,13 +92,18 @@ class gallery_theme_Core { } // Redirect to the root album when the admin session expires. - $redirect_url = url::abs_site(""); - $admin_area_timeout = 1000 * module::get_var("gallery", "admin_area_timeout"); $admin_session_redirect_check = ''; + var adminReauthCheck = function() { + $.ajax({url: "' . url::site("admin?reauth_check=1") . '", + dataType: "json", + success: function(data){ + if ("location" in data) { + document.location = data.location; + } + }}); + }; + setInterval("adminReauthCheck();", 60 * 1000); + '; print $admin_session_redirect_check; if ($session->get("l10n_mode", false)) { -- cgit v1.2.3 From 409121942590e12692eaf4e6e9e8b71bfe5ed60c Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Sun, 14 Feb 2010 19:26:34 -0800 Subject: Fix for ticket #491: Make user and group names translatable. Also fixed a UI bug: No longer showing the edit user buttons to admins in the profile view (to be consistent with the requirements in the controller). --- modules/gallery/controllers/user_profile.php | 5 +++-- modules/gallery/helpers/gallery_event.php | 3 +++ modules/gallery/views/permissions_form.html.php | 2 +- modules/user/helpers/user_installer.php | 8 ++++---- modules/user/models/user.php | 2 +- modules/user/views/admin_users.html.php | 2 +- modules/user/views/admin_users_group.html.php | 6 +++--- 7 files changed, 16 insertions(+), 12 deletions(-) (limited to 'modules/gallery/controllers') diff --git a/modules/gallery/controllers/user_profile.php b/modules/gallery/controllers/user_profile.php index 327d2ff1..05373466 100644 --- a/modules/gallery/controllers/user_profile.php +++ b/modules/gallery/controllers/user_profile.php @@ -23,7 +23,8 @@ class User_Profile_Controller extends Controller { $user = identity::lookup_user($id); $active_user = identity::active_user(); $is_current_active = $active_user->id == $id; - $display_all = $active_user->admin || ($is_current_active && !$active_user->guest); + $can_edit = $is_current_active && !$active_user->guest; + $display_all = $active_user->admin || $can_edit; $v = new Theme_View("page.html", "other", "profile"); $v->page_title = t("%name Profile", array("name" => $user->display_name())); @@ -32,7 +33,7 @@ class User_Profile_Controller extends Controller { // @todo modify user_home to supply a link to their album, $v->content->user = $user; $v->content->not_current = !$is_current_active; - $v->content->editable = identity::is_writable() && $display_all; + $v->content->editable = identity::is_writable() && $can_edit; $event_data = (object)array("user" => $user, "display_all" => $display_all, "content" => array()); module::event("show_user_profile", $event_data); diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index faf1c0c6..3f77bc42 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -423,6 +423,9 @@ class gallery_event_Core { if ($field == "locale") { $value = locales::display_name($value); } + if ($field == "full_name") { + $value = t($value); + } $v->user_profile_data[(string) $label] = $value; } } diff --git a/modules/gallery/views/permissions_form.html.php b/modules/gallery/views/permissions_form.html.php index f1714119..b486acb7 100644 --- a/modules/gallery/views/permissions_form.html.php +++ b/modules/gallery/views/permissions_form.html.php @@ -5,7 +5,7 @@ - name) ?> + name)) ?> diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php index 729f087a..c57ad010 100644 --- a/modules/user/helpers/user_installer.php +++ b/modules/user/helpers/user_installer.php @@ -98,25 +98,25 @@ class user_installer { DEFAULT CHARSET=utf8;"); $everybody = ORM::factory("group"); - $everybody->name = "Everybody"; + $everybody->name = t("Everybody", array("locale" => "root")); $everybody->special = true; $everybody->save(); $registered = ORM::factory("group"); - $registered->name = "Registered Users"; + $registered->name = t("Registered Users", array("locale" => "root")); $registered->special = true; $registered->save(); $guest = ORM::factory("user"); $guest->name = "guest"; - $guest->full_name = "Guest User"; + $guest->full_name = t("Guest User", array("locale" => "root")); $guest->password = ""; $guest->guest = true; $guest->save(); $admin = ORM::factory("user"); $admin->name = "admin"; - $admin->full_name = "Gallery Administrator"; + $admin->full_name = t("Gallery Administrator", array("locale" => "root")); $admin->password = "admin"; $admin->email = "unknown@unknown.com"; $admin->admin = true; diff --git a/modules/user/models/user.php b/modules/user/models/user.php index 4404ee63..aa752203 100644 --- a/modules/user/models/user.php +++ b/modules/user/models/user.php @@ -113,7 +113,7 @@ class User_Model extends ORM implements User_Definition { * @return string */ public function display_name() { - return empty($this->full_name) ? $this->name : $this->full_name; + return empty($this->full_name) ? $this->name : t($this->full_name); } /** diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php index 270a7207..69d97547 100644 --- a/modules/user/views/admin_users.html.php +++ b/modules/user/views/admin_users.html.php @@ -78,7 +78,7 @@ name) ?> - full_name) ?> + full_name)) ?> email) ?> diff --git a/modules/user/views/admin_users_group.html.php b/modules/user/views/admin_users_group.html.php index 6c6c341e..8317d393 100644 --- a/modules/user/views/admin_users_group.html.php +++ b/modules/user/views/admin_users_group.html.php @@ -1,9 +1,9 @@

- name) ?> + name)) ?> special): ?> id") ?>" - title=" $group->name))->for_html_attr() ?>" + title=" t(html::clean($group->name))))->for_html_attr() ?>" class="g-dialog-link g-button g-right"> @@ -22,7 +22,7 @@ $user->name, "group" => $group->name))->for_html_attr() ?>"> + array("user" => $user->name, "group" => t(html::clean($group->name))))->for_html_attr() ?>"> -- cgit v1.2.3