diff options
Diffstat (limited to 'modules/gallery/controllers')
-rw-r--r-- | modules/gallery/controllers/admin.php | 2 | ||||
-rw-r--r-- | modules/gallery/controllers/albums.php | 6 | ||||
-rw-r--r-- | modules/gallery/controllers/l10n_client.php | 4 | ||||
-rw-r--r-- | modules/gallery/controllers/login.php | 13 | ||||
-rw-r--r-- | modules/gallery/controllers/logout.php | 13 | ||||
-rw-r--r-- | modules/gallery/controllers/permissions.php | 2 | ||||
-rw-r--r-- | modules/gallery/controllers/upgrader.php | 4 | ||||
-rw-r--r-- | modules/gallery/controllers/welcome_message.php | 4 |
8 files changed, 29 insertions, 19 deletions
diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php index 8a4181a6..24eebe7d 100644 --- a/modules/gallery/controllers/admin.php +++ b/modules/gallery/controllers/admin.php @@ -21,7 +21,7 @@ class Admin_Controller extends Controller { private $theme; public function __construct($theme=null) { - if (!(Identity::active()->admin)) { + if (!(Session::active_user()->admin)) { access::forbidden(); } diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index fdf06ec0..055ff22b 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -29,7 +29,7 @@ class Albums_Controller extends Items_Controller { $view = new Theme_View("page.html", "login"); $view->page_title = t("Log in to Gallery"); $view->content = new View("login_ajax.html"); - $view->content->form = Identity::get_login_form("login/auth_html"); + $view->content->form = login::get_login_form("login/auth_html"); print $view; return; } else { @@ -111,7 +111,7 @@ class Albums_Controller extends Items_Controller { $this->input->post("name"), $this->input->post("title", $this->input->post("name")), $this->input->post("description"), - Identity::active()->id, + Session::active_user()->id, $this->input->post("slug")); log::success("content", "Created an album", @@ -146,7 +146,7 @@ class Albums_Controller extends Items_Controller { $_FILES["file"]["name"], $this->input->post("title", $this->input->post("name")), $this->input->post("description"), - Identity::active()->id); + Session::active_user()->id); log::success("content", "Added a photo", html::anchor("photos/$photo->id", "view photo")); message::success(t("Added photo %photo_title", diff --git a/modules/gallery/controllers/l10n_client.php b/modules/gallery/controllers/l10n_client.php index b3929c5d..2ab73102 100644 --- a/modules/gallery/controllers/l10n_client.php +++ b/modules/gallery/controllers/l10n_client.php @@ -20,7 +20,7 @@ class L10n_Client_Controller extends Controller { public function save() { access::verify_csrf(); - if (!Identity::active()->admin) { + if (!Session::active_user()->admin) { access::forbidden(); } @@ -85,7 +85,7 @@ class L10n_Client_Controller extends Controller { public function toggle_l10n_mode() { access::verify_csrf(); - if (!Identity::active()->admin) { + if (!Session::active_user()->admin) { access::forbidden(); } diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php index c8b771ca..96a97a1d 100644 --- a/modules/gallery/controllers/login.php +++ b/modules/gallery/controllers/login.php @@ -21,7 +21,7 @@ class Login_Controller extends Controller { public function ajax() { $view = new View("login_ajax.html"); - $view->form = Identity::get_login_form("login/auth_ajax"); + $view->form = login::get_login_form("login/auth_ajax"); print $view; } @@ -40,7 +40,7 @@ class Login_Controller extends Controller { } public function html() { - print Identity::get_login_form("login/auth_html"); + print login::get_login_form("login/auth_html"); } public function auth_html() { @@ -54,7 +54,7 @@ class Login_Controller extends Controller { } } private function _auth($url) { - $form = Identity::get_login_form($url); + $form = login::get_login_form($url); $valid = $form->validate(); if ($valid) { $user = Identity::lookup_user_by_name($form->login->inputs["name"]->value); @@ -69,7 +69,12 @@ class Login_Controller extends Controller { } if ($valid) { - Identity::login($user); + if (Identity::is_writable()) { + $user->login_count += 1; + $user->last_login = time(); + $user->save(); + } + Session::set_active_user($user); log::info("user", t("User %name logged in", array("name" => $user->name))); } diff --git a/modules/gallery/controllers/logout.php b/modules/gallery/controllers/logout.php index 6841b870..058860fa 100644 --- a/modules/gallery/controllers/logout.php +++ b/modules/gallery/controllers/logout.php @@ -19,10 +19,15 @@ */ class Logout_Controller extends Controller { public function index() { - //access::verify_csrf(); - - $user = Identity::active(); - Identity::logout(); + $user = Session::active_user(); + if (!$user->guest) { + try { + Session::instance()->destroy(); + } catch (Exception $e) { + Kohana::log("error", $e); + } + module::event("user_logout", $user); + } log::info("user", t("User %name logged out", array("name" => $user->name)), html::anchor("user/$user->id", html::clean($user->name))); if ($continue_url = $this->input->get("continue")) { diff --git a/modules/gallery/controllers/permissions.php b/modules/gallery/controllers/permissions.php index 6b1e926f..7a06c3d3 100644 --- a/modules/gallery/controllers/permissions.php +++ b/modules/gallery/controllers/permissions.php @@ -74,7 +74,7 @@ class Permissions_Controller extends Controller { // If the active user just took away their own edit permissions, give it back. if ($perm->name == "edit") { - if (!access::user_can(Identity::active(), "edit", $item)) { + if (!access::user_can(Session::active_user(), "edit", $item)) { access::allow($group, $perm->name, $item); } } diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php index f6ca4c8a..e0c5d340 100644 --- a/modules/gallery/controllers/upgrader.php +++ b/modules/gallery/controllers/upgrader.php @@ -40,7 +40,7 @@ class Upgrader_Controller extends Controller { } $view = new View("upgrader.html"); - $view->can_upgrade = Identity::active()->admin || $session->get("can_upgrade"); + $view->can_upgrade = Session::active_user()->admin || $session->get("can_upgrade"); $view->upgrade_token = $upgrade_token; $view->available = module::available(); $view->done = ($available_upgrades == 0); @@ -52,7 +52,7 @@ class Upgrader_Controller extends Controller { // @todo this may screw up some module installers, but we don't have a better answer at // this time. $_SERVER["HTTP_HOST"] = "example.com"; - } else if (!Identity::active()->admin && !Session::instance()->get("can_upgrade", false)) { + } else if (!Session::active_user()->admin && !Session::instance()->get("can_upgrade", false)) { access::forbidden(); } diff --git a/modules/gallery/controllers/welcome_message.php b/modules/gallery/controllers/welcome_message.php index c093b67d..cfdc3976 100644 --- a/modules/gallery/controllers/welcome_message.php +++ b/modules/gallery/controllers/welcome_message.php @@ -19,12 +19,12 @@ */ class Welcome_Message_Controller extends Controller { public function index() { - if (!Identity::active()->admin) { + if (!Session::active_user()->admin) { url::redirect(item::root()->abs_url()); } $v = new View("welcome_message.html"); - $v->user = Identity::active(); + $v->user = Session::active_user(); print $v; } } |