diff options
| author | Tim Almdal <tnalmdal@shaw.ca> | 2009-10-22 13:09:20 -0700 | 
|---|---|---|
| committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-10-22 13:11:03 -0700 | 
| commit | 3c936d661a088fb43b47eb5b208958180e8f65eb (patch) | |
| tree | 1a117dc1bfe54bec44f664cbd7c5f8c93aa5e993 /modules/gallery/controllers | |
| parent | 4cb9ec1d6d37b49ebafc68d0a94d794a1acb8b28 (diff) | |
Change the name of identity library from Identity to IdentityProvider. Create a helper class called identity to simplify call the Identity Provider. Move the contents of MY_Session.php to the new helper class and remove the MY_Session class
Diffstat (limited to 'modules/gallery/controllers')
| -rw-r--r-- | modules/gallery/controllers/admin.php | 2 | ||||
| -rw-r--r-- | modules/gallery/controllers/admin_identity.php | 10 | ||||
| -rw-r--r-- | modules/gallery/controllers/albums.php | 4 | ||||
| -rw-r--r-- | modules/gallery/controllers/l10n_client.php | 4 | ||||
| -rw-r--r-- | modules/gallery/controllers/login.php | 8 | ||||
| -rw-r--r-- | modules/gallery/controllers/logout.php | 2 | ||||
| -rw-r--r-- | modules/gallery/controllers/permissions.php | 6 | ||||
| -rw-r--r-- | modules/gallery/controllers/upgrader.php | 4 | ||||
| -rw-r--r-- | modules/gallery/controllers/welcome_message.php | 4 | 
9 files changed, 22 insertions, 22 deletions
| diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php index 24eebe7d..98cac557 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 (!(Session::active_user()->admin)) { +    if (!(identity::active_user()->admin)) {        access::forbidden();      } diff --git a/modules/gallery/controllers/admin_identity.php b/modules/gallery/controllers/admin_identity.php index 9d756a5c..d06132ff 100644 --- a/modules/gallery/controllers/admin_identity.php +++ b/modules/gallery/controllers/admin_identity.php @@ -21,7 +21,7 @@ class Admin_Identity_Controller extends Admin_Controller {    public function index() {      $view = new Admin_View("admin.html");      $view->content = new View("admin_identity.html"); -    $view->content->available = Identity::providers(); +    $view->content->available = identity::providers();      $view->content->active = module::get_var("gallery", "identity_provider", "user");      print $view;    } @@ -39,7 +39,7 @@ class Admin_Identity_Controller extends Admin_Controller {      access::verify_csrf();      $active_provider = module::get_var("gallery", "identity_provider", "user"); -    $providers = Identity::providers(); +    $providers = identity::providers();      $new_provider = $this->input->post("provider"); @@ -47,13 +47,13 @@ class Admin_Identity_Controller extends Admin_Controller {        module::event("pre_identity_change", $active_provider, $new_provider); -      Identity::deactivate(); +      identity::deactivate();        // Switch authentication        module::set_var("gallery", "identity_provider", $new_provider); -      Identity::reset(); +      identity::reset(); -      Identity::activate(); +      identity::activate();        // @todo this type of collation is questionable from an i18n perspective        message::success(t("Changed to %description", diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index fabf67ce..24ceb0c9 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -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"), -        Session::active_user()->id, +        identity::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"), -        Session::active_user()->id); +        identity::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 2ab73102..6db67d3b 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 (!Session::active_user()->admin) { +    if (!identity::active_user()->admin) {        access::forbidden();      } @@ -85,7 +85,7 @@ class L10n_Client_Controller extends Controller {    public function toggle_l10n_mode() {      access::verify_csrf(); -    if (!Session::active_user()->admin) { +    if (!identity::active_user()->admin) {        access::forbidden();      } diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php index 4c83d647..86e2b0a4 100644 --- a/modules/gallery/controllers/login.php +++ b/modules/gallery/controllers/login.php @@ -58,8 +58,8 @@ class Login_Controller extends Controller {      $form = login::get_login_form($url);      $valid = $form->validate();      if ($valid) { -      $user = Identity::lookup_user_by_name($form->login->inputs["name"]->value); -      if (empty($user) || !Identity::is_correct_password($user, $form->login->password->value)) { +      $user = identity::lookup_user_by_name($form->login->inputs["name"]->value); +      if (empty($user) || !identity::is_correct_password($user, $form->login->password->value)) {          log::warning(            "user",            t("Failed login for %name", @@ -70,12 +70,12 @@ class Login_Controller extends Controller {      }      if ($valid) { -      if (Identity::is_writable()) { +      if (identity::is_writable()) {          $user->login_count += 1;          $user->last_login = time();          $user->save();        } -      Session::set_active_user($user); +      identity::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 058860fa..1b0364fd 100644 --- a/modules/gallery/controllers/logout.php +++ b/modules/gallery/controllers/logout.php @@ -19,7 +19,7 @@   */  class Logout_Controller extends Controller {    public function index() { -    $user = Session::active_user(); +    $user = identity::active_user();      if (!$user->guest) {        try {          Session::instance()->destroy(); diff --git a/modules/gallery/controllers/permissions.php b/modules/gallery/controllers/permissions.php index 58c5b816..99943fbb 100644 --- a/modules/gallery/controllers/permissions.php +++ b/modules/gallery/controllers/permissions.php @@ -51,7 +51,7 @@ class Permissions_Controller extends Controller {    function change($command, $group_id, $perm_id, $item_id) {      access::verify_csrf(); -    $group = Identity::lookup_group($group_id); +    $group = identity::lookup_group($group_id);      $perm = ORM::factory("permission", $perm_id);      $item = ORM::factory("item", $item_id);      access::required("view", $item); @@ -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(Session::active_user(), "edit", $item)) { +        if (!access::user_can(identity::active_user(), "edit", $item)) {            access::allow($group, $perm->name, $item);          }        } @@ -84,7 +84,7 @@ class Permissions_Controller extends Controller {    private function _get_form($item) {      $view = new View("permissions_form.html");      $view->item = $item; -    $view->groups = Identity::groups(); +    $view->groups = identity::groups();      $view->permissions = ORM::factory("permission")->find_all();      return $view;    } diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php index e0c5d340..1aa607ef 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 = Session::active_user()->admin || $session->get("can_upgrade"); +    $view->can_upgrade = identity::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 (!Session::active_user()->admin && !Session::instance()->get("can_upgrade", false)) { +    } else if (!identity::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 cfdc3976..af0d6997 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 (!Session::active_user()->admin) { +    if (!identity::active_user()->admin) {        url::redirect(item::root()->abs_url());      }      $v = new View("welcome_message.html"); -    $v->user = Session::active_user(); +    $v->user = identity::active_user();      print $v;    }  } | 
