1
0

Refactor the identity provider installation in to a common helper method (change_provider) with an initialization callback.

This commit is contained in:
Tim Almdal 2010-01-22 12:09:46 -08:00
parent b8bce53b8f
commit b0270cf722

View File

@ -19,31 +19,18 @@
*/
class ldap_installer {
static function check_environment() {
return array();
$messages = array();
if (array_search("ldap", get_loaded_extensions()) === false) {
$messages["error"][] =
t("Cannot install LDAP identity provider as the PHP LDAP extension module is not enabled.");
} else {
$messages["warn"][] = IdentityProvider::confirmation_message();
}
return $messages;
}
static function install() {
$current_provider = module::get_var("gallery", "identity_provider");
if (!empty($current_provider)) {
module::uninstall($current_provider);
}
IdentityProvider::reset();
module::set_var("gallery", "identity_provider", "ldap");
module::set_version("ldap", 1);
$root = item::root();
$ldap_provider = IdentityProvider::instance();
foreach ($ldap_provider->groups() as $group) {
module::event("group_created", $group);
access::allow($group, "view", $root);
access::allow($group, "view_full", $root);
}
module::event("identity_provider_changed", $current_provider, "ldap");
auth::login($ldap_provider->admin_user());
Session::instance()->regenerate();
IdentityProvider::change_provider("ldap");
}
static function uninstall() {
@ -53,4 +40,14 @@ class ldap_installer {
module::event("group_deleted", $group);
}
}
static function initialize() {
module::set_version("ldap", 1);
$root = item::root();
foreach (IdentityProvider::instance()->groups() as $group) {
module::event("group_created", $group);
access::allow($group, "view", $root);
access::allow($group, "view_full", $root);
}
}
}