summaryrefslogtreecommitdiff
path: root/modules/gallery/libraries/IdentityProvider.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-01-23 16:29:10 -0800
committerBharat Mediratta <bharat@menalto.com>2010-01-23 16:29:10 -0800
commitfecac4a8596a69088270e48a90868e845fc8f4ca (patch)
treea4683906d481d1091e218c9b6662a1997cb11086 /modules/gallery/libraries/IdentityProvider.php
parent8849594aa17768f564e45370a62f01e440570dcf (diff)
parent3b16d0662b8a4b06f4be72165c858a1231e9bd67 (diff)
Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev
Conflicts: modules/gallery/tests/xss_data.txt
Diffstat (limited to 'modules/gallery/libraries/IdentityProvider.php')
-rw-r--r--modules/gallery/libraries/IdentityProvider.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php
index 30d4efa4..79151154 100644
--- a/modules/gallery/libraries/IdentityProvider.php
+++ b/modules/gallery/libraries/IdentityProvider.php
@@ -58,6 +58,51 @@ 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);
+ }
+
+ try {
+ 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();
+ } catch (Exception $e) {
+ // Make sure new provider is not in the database
+ module::uninstall($new_provider);
+
+ // Lets reset to the current provider so that the gallery installation is still
+ // working.
+ module::set_var("gallery", "identity_provider", null);
+ IdentityProvider::change_provider($current_provider);
+ module::activate($current_provider);
+ message::error(
+ t("Error attempting to enable \"%new_provider\" identity provider, " .
+ "reverted to \"%old_provider\" identity provider",
+ array("new_provider" => $new_provider, "old_provider" => $current_provider)));
+ throw $e;
+ }
+ }
+
+ /**
* Loads the configured driver and validates it.
*
* @return void