summaryrefslogtreecommitdiff
path: root/modules/user
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/user
parent603c3049a1ce7249c55ff8338fc3ea69323f0cb3 (diff)
Refactor the identity provider installation in to a common helper method (change_provider) with an initialization callback.
Diffstat (limited to 'modules/user')
-rw-r--r--modules/user/helpers/user_installer.php68
1 files changed, 32 insertions, 36 deletions
diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php
index dd21c93c..3882f5f2 100644
--- a/modules/user/helpers/user_installer.php
+++ b/modules/user/helpers/user_installer.php
@@ -18,15 +18,40 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class user_installer {
+ static function check_environment() {
+ return array("warn" => array(IdentityProvider::confirmation_message()));
+ }
+
static function install() {
- $db = Database::instance();
- $current_provider = module::get_var("gallery", "identity_provider");
- if (!empty($current_provider)) {
- module::uninstall($current_provider);
+ IdentityProvider::change_provider("user");
+ }
+
+ static function upgrade($version) {
+ if ($version == 1) {
+ module::set_var("user", "mininum_password_length", 5);
+
+ module::set_version("user", $version = 2);
+ }
+ }
+
+ static function uninstall() {
+ // Delete all users and groups so that we give other modules an opportunity to clean up
+ foreach (ORM::factory("user")->find_all() as $user) {
+ $user->delete();
+ }
+
+ foreach (ORM::factory("group")->find_all() as $group) {
+ $group->delete();
}
- IdentityProvider::reset();
- module::set_var("gallery", "identity_provider", "user");
+ $db = Database::instance();
+ $db->query("DROP TABLE IF EXISTS {users};");
+ $db->query("DROP TABLE IF EXISTS {groups};");
+ $db->query("DROP TABLE IF EXISTS {groups_users};");
+ }
+
+ static function initialize() {
+ $db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {users} (
`id` int(9) NOT NULL auto_increment,
`name` varchar(32) NOT NULL,
@@ -84,36 +109,7 @@ class user_installer {
access::allow($registered, "view", $root);
access::allow($registered, "view_full", $root);
- module::set_var("user", "mininum_password_length", 5);
-
module::set_version("user", 2);
- module::event("identity_provider_changed", $current_provider, "user");
-
- auth::login(IdentityProvider::instance()->admin_user());
- Session::instance()->regenerate();
- }
-
- static function upgrade($version) {
- if ($version == 1) {
- module::set_var("user", "mininum_password_length", 5);
-
- module::set_version("user", $version = 2);
- }
- }
-
- static function uninstall() {
- // Delete all users and groups so that we give other modules an opportunity to clean up
- foreach (ORM::factory("user")->find_all() as $user) {
- $user->delete();
- }
-
- foreach (ORM::factory("group")->find_all() as $group) {
- $group->delete();
- }
-
- $db = Database::instance();
- $db->query("DROP TABLE IF EXISTS {users};");
- $db->query("DROP TABLE IF EXISTS {groups};");
- $db->query("DROP TABLE IF EXISTS {groups_users};");
+ module::set_var("user", "mininum_password_length", 5);
}
} \ No newline at end of file