summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2010-01-22 12:09:11 -0800
committerTim Almdal <tnalmdal@shaw.ca>2010-01-22 12:09:11 -0800
commitae568b6182544b84067aa099eec494da477d083f (patch)
tree536eb4813e85ef4df06bc4c4166ccc116fc5bd3b /modules/gallery
parent603c3049a1ce7249c55ff8338fc3ea69323f0cb3 (diff)
Refactor the identity provider installation in to a common helper method (change_provider) with an initialization callback.
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/libraries/IdentityProvider.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php
index bcb3056a..f7be33e3 100644
--- a/modules/gallery/libraries/IdentityProvider.php
+++ b/modules/gallery/libraries/IdentityProvider.php
@@ -58,6 +58,35 @@ class IdentityProvider_Core {
}
/**
+ * Return a commen confirmation message
+ */
+ static function confirmation_message() {
+ return t("Are you sure you want to change your Identity Provider? " .
+ "Continuing will delete all existing users.");
+ }
+
+ static function change_provider($new_provider) {
+ $current_provider = module::get_var("gallery", "identity_provider");
+ if (!empty($current_provider)) {
+ module::uninstall($current_provider);
+ }
+
+ IdentityProvider::reset();
+ $provider = new IdentityProvider($new_provider);
+
+ module::set_var("gallery", "identity_provider", $new_provider);
+
+ if (method_exists("{$new_provider}_installer", "initialize")) {
+ call_user_func("{$new_provider}_installer::initialize");
+ }
+
+ module::event("identity_provider_changed", $current_provider, $new_provider);
+
+ auth::login($provider->admin_user());
+ Session::instance()->regenerate();
+ }
+
+ /**
* Loads the configured driver and validates it.
*
* @return void