Some cleanups/rewrites here and there:
[mailer.git] / inc / extensions / ext-user.php
index 8a4d75b468905dfc2fbd704672c5815c30930154..344cb3258906753f11307c0d574465fc987a0211 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 04/29/2004 *
- * ================                             Last change: 10/29/2004 *
+ * Mailer v0.2.1-FINAL                                Start: 04/29/2004 *
+ * ===================                          Last change: 10/29/2004 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : ext-user.php                                     *
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -42,112 +41,112 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Version number
-setThisExtensionVersion('0.3.5');
+setThisExtensionVersion('0.3.7');
 
 // Version history array (add more with , '0.1.0' and so on)
-setExtensionVersionHistory(array('0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5'));
+setExtensionVersionHistory(array('0.0', '0.1.0', '0.1.1', '0.1.2', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', '0.1.9', '0.2.0', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7'));
 
 // Keep this extension always active!
 setExtensionAlwaysActive('Y');
 
 switch (getExtensionMode()) {
        case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_cats`");
+               addDropTableSql('user_cats');
                addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_cats` (
-  `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
-  `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `cat_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
-PRIMARY KEY  (`id`),
+`id` BIGINT(22) NOT NULL AUTO_INCREMENT,
+`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`cat_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
+PRIMARY KEY (`id`),
 INDEX (`userid`),
 INDEX (`cat_id`)
-) TYPE={?_TABLE_TYPE?}");
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci");
 
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_data`");
+               addDropTableSql('user_data');
                addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_data` (
-  `userid` BIGINT(22) NOT NULL AUTO_INCREMENT,
-  `surname` VARCHAR(255) NOT NULL DEFAULT '',
-  `family` VARCHAR(255) NOT NULL DEFAULT '',
-  `street_nr` VARCHAR(255) NOT NULL DEFAULT '',
-  `country` VARCHAR(4) NOT NULL DEFAULT '',
-  `zip` VARCHAR(6) NOT NULL DEFAULT '',
-  `city` VARCHAR(255) NOT NULL DEFAULT '',
-  `email` VARCHAR(255) NOT NULL DEFAULT '',
-  `birth_day` CHAR(2) NOT NULL DEFAULT '01',
-  `birth_month` CHAR(2) NOT NULL DEFAULT '01',
-  `birth_year` VARCHAR(4) NOT NULL DEFAULT '1970',
-  `password` VARCHAR(255) NOT NULL DEFAULT '',
-  `max_mails` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `receive_mails` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `refid` BIGINT(22) NOT NULL DEFAULT 0,
-  `status` ENUM('UNCONFIRMED','CONFIRMED','LOCKED') NOT NULL DEFAULT 'UNCONFIRMED',
-  `user_hash` VARCHAR(255) NULL DEFAULT NULL,
-  `REMOTE_ADDR` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
-  `last_online` VARCHAR(10) NOT NULL DEFAULT 0,
-  `last_module` VARCHAR(255) NOT NULL DEFAULT '',
-  `ref_clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `total_logins` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `gender` ENUM('M','F') NOT NULL DEFAULT 'M',
-  `used_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-  `emails_sent` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `joined` VARCHAR(10) NOT NULL DEFAULT 0,
-  `last_update` VARCHAR(10) NOT NULL DEFAULT 0,
-  `last_profile_sent` VARCHAR(10) NOT NULL DEFAULT 0,
-  `notified` ENUM('Y','N') NOT NULL DEFAULT 'N',
-  `ref_payout` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
-  `last_login` VARCHAR(10) NOT NULL DEFAULT 0,
-  `login_failures` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `last_failure` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
-PRIMARY KEY  (`userid`),
+`userid` BIGINT(22) NOT NULL AUTO_INCREMENT,
+`surname` VARCHAR(255) NOT NULL DEFAULT '',
+`family` VARCHAR(255) NOT NULL DEFAULT '',
+`street_nr` VARCHAR(255) NOT NULL DEFAULT '',
+`country` VARCHAR(4) NOT NULL DEFAULT '',
+`zip` VARCHAR(6) NOT NULL DEFAULT '',
+`city` VARCHAR(255) NOT NULL DEFAULT '',
+`email` VARCHAR(255) NOT NULL DEFAULT '',
+`birth_day` CHAR(2) NOT NULL DEFAULT '01',
+`birth_month` CHAR(2) NOT NULL DEFAULT '01',
+`birth_year` VARCHAR(4) NOT NULL DEFAULT '1970',
+`password` VARCHAR(255) NOT NULL DEFAULT '',
+`max_mails` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`receive_mails` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`refid` BIGINT(22) NOT NULL DEFAULT 0,
+`status` ENUM('UNCONFIRMED','CONFIRMED','LOCKED') NOT NULL DEFAULT 'UNCONFIRMED',
+`user_hash` VARCHAR(255) NULL DEFAULT NULL,
+`REMOTE_ADDR` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
+`last_online` VARCHAR(10) NOT NULL DEFAULT 0,
+`last_module` VARCHAR(255) NOT NULL DEFAULT '',
+`ref_clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`total_logins` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`gender` ENUM('M','F') NOT NULL DEFAULT 'M',
+`used_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+`emails_sent` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`joined` VARCHAR(10) NOT NULL DEFAULT 0,
+`last_update` VARCHAR(10) NOT NULL DEFAULT 0,
+`last_profile_sent` VARCHAR(10) NOT NULL DEFAULT 0,
+`notified` ENUM('Y','N') NOT NULL DEFAULT 'N',
+`ref_payout` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
+`last_login` VARCHAR(10) NOT NULL DEFAULT 0,
+`login_failures` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`last_failure` TIMESTAMP NULL DEFAULT NULL,
+PRIMARY KEY (`userid`),
 UNIQUE (`user_hash`),
 INDEX (`refid`),
 INDEX `status_mails` (`status`,`max_mails`)
-) TYPE={?_TABLE_TYPE?}");
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci");
 
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_points`");
+               addDropTableSql('user_points');
                addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_points` (
-  `id` BIGINT(22) NOT NULL AUTO_INCREMENT,
-  `userid` BIGINT(22) NOT NULL DEFAULT 0,
-  `ref_depth` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
-  `points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-  `locked_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
-PRIMARY KEY  (`id`),
+`id` BIGINT(22) NOT NULL AUTO_INCREMENT,
+`userid` BIGINT(22) NOT NULL DEFAULT 0,
+`ref_depth` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
+`points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+`locked_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
+PRIMARY KEY (`id`),
 INDEX (`userid`)
-) TYPE={?_TABLE_TYPE?}");
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci");
 
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_links`");
+               addDropTableSql('user_links');
                addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_links` (
-  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-  `stats_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `link_type` ENUM('NORMAL') NOT NULL DEFAULT 'NORMAL',
-PRIMARY KEY  (`id`),
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`stats_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`link_type` ENUM('NORMAL') NOT NULL DEFAULT 'NORMAL',
+PRIMARY KEY (`id`),
 INDEX (`userid`),
 INDEX (`stats_id`)
-) TYPE={?_TABLE_TYPE?}");
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci");
 
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_stats`");
+               addDropTableSql('user_stats');
                addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_stats` (
-  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
-  `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `cat_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `payment_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `subject` VARCHAR(200) NOT NULL DEFAULT '',
-  `url` TINYTEXT NOT NULL,
-  `max_rec` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp_ordered` VARCHAR(10) NOT NULL DEFAULT '',
-  `pool_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
-  `timestamp_sstart` VARCHAR(10) NOT NULL DEFAULT '',
-  `timestamp_send` VARCHAR(10) NOT NULL DEFAULT '',
-  `is_stats` ENUM('Y','N') NOT NULL DEFAULT 'N',
-PRIMARY KEY  (`id`),
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`cat_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`payment_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`subject` VARCHAR(200) NOT NULL DEFAULT '',
+`url` TINYTEXT NOT NULL,
+`max_rec` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`timestamp_ordered` VARCHAR(10) NOT NULL DEFAULT '',
+`pool_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`timestamp_sstart` VARCHAR(10) NOT NULL DEFAULT '',
+`timestamp_send` VARCHAR(10) NOT NULL DEFAULT '',
+`is_stats` ENUM('Y','N') NOT NULL DEFAULT 'N',
+PRIMARY KEY (`id`),
 INDEX (`userid`),
 INDEX (`cat_id`),
 INDEX (`payment_id`),
 INDEX (`pool_id`)
-) TYPE={?_TABLE_TYPE?}");
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci");
 
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_stats_data`");
+               addDropTableSql('user_stats_data');
                addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_stats_data` (
 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
@@ -157,7 +156,7 @@ INDEX (`pool_id`)
 PRIMARY KEY (`id`),
 INDEX (`userid`),
 INDEX (`stats_type`)
-) TYPE={?_TABLE_TYPE?} COMMENT='Member statistics data'");
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Member statistics data'");
 
                // Admin menu
                addAdminMenuSql('user',NULL,'Mitglieder-Management','Mitglieder freischalten, sperren, Accounts editieren, Neuanmeldungen verwalten, {OPEN_CONFIG}POINTS{CLOSE_CONFIG} gutschreiben und abziehen und und und...',3);
@@ -174,14 +173,14 @@ INDEX (`stats_type`)
 
        case 'remove': // Do stuff when removing extension
                // SQL commands to run
+               addDropTableSql('user_del');
+               addDropTableSql('user_cats');
+               addDropTableSql('user_data');
+               addDropTableSql('user_points');
+               addDropTableSql('user_links');
+               addDropTableSql('user_stats');
+               addDropTableSql('user_stats_data');
                addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('config_user','user_contct','list_user_del') OR `action`='user'");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_del`");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_cats`");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_data`");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_points`");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_links`");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_stats`");
-               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_stats_data`");
                break;
 
        case 'activate': // Do stuff when admin activates this extension
@@ -195,10 +194,9 @@ INDEX (`stats_type`)
                break;
 
        case 'update': // Update an extension
-               switch (getCurrentExtensionVersion())
-               {
+               switch (getCurrentExtensionVersion()) {
                        case '0.1.0': // SQL queries for v0.1
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `user_limit` INT(7) UNSIGNED NOT NULL DEFAULT 20");
+                               addConfigAddSql('user_limit', "INT(7) UNSIGNED NOT NULL DEFAULT 20");
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Seitenweises Anzeigen der User-Liste ist nun m&ouml;glich.");
@@ -206,7 +204,7 @@ INDEX (`stats_type`)
 
                        case '0.1.1': // SQL queries for v0.1.1
                                // This update depends on sql_patches update!
-                               addExtensionUpdateDependency('sql_patches');
+                               addExtensionDependency('sql_patches');
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Ung&uuml;ltiges Update.");
@@ -262,7 +260,7 @@ INDEX (`stats_type`)
                                break;
 
                        case '0.2.1': // SQL queries for v0.2.1
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `user_alpha` TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
+                               addConfigAddSql('user_alpha', "TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
                                addAdminMenuSql('setup','config_user','Mitgliederliste','Anzahl Mitglieder pro Seite, Anzahl Buchstaben pro Zeile usw.', 8);
 
                                // Update notes (these will be set as task text!)
@@ -327,7 +325,7 @@ INDEX (`stats_type`)
 
                        case '0.3.2': // SQL queries for v0.3.2
                                // Update notes (these will be set as task text!)
-                               setExtensionUpdateNotes("PHP-Hinweis in Userauflistung gefixt (trat bei fehlender nickname-Erweiterung auf) und Darstellungsfehler von <strong>0.00000</strong> unbest&auml;tigten Mails gefixt.");
+                               setExtensionUpdateNotes("PHP-Hinweis in Userauflistung gefixt (trat bei fehlender Erweiterung <span class=\"data\">ext-nickname</span> auf) und Darstellungsfehler von <strong>0.00000</strong> unbest&auml;tigten Mails gefixt.");
                                break;
 
                        case '0.3.3': // SQL queries for v0.3.3
@@ -336,20 +334,20 @@ INDEX (`stats_type`)
                                break;
 
                        case '0.3.4': // SQL queries for v0.3.4
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `select_user_zero_refid` ENUM('Y','N') NOT NULL DEFAULT 'Y'");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `user_min_confirmed` SMALLINT(5) UNSIGNED NOT NULL DEFAULT 10");
+                               addConfigAddSql('select_user_zero_refid', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
+                               addConfigAddSql('user_min_confirmed', "SMALLINT(5) UNSIGNED NOT NULL DEFAULT 10");
                                addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `rand_confirmed` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
 
                                // Update notes (these will be set as task text!)
-                               setExtensionUpdateNotes("Mitglieder werden per Zufall als Referal-ID ausgew&auml;hlt, die eine Mindestanzahl an best&auml;tigten Mails haben, wenn die Ref-Id 0 ist.");
+                               setExtensionUpdateNotes("Mitglieder werden per Zufall als Referal-Id ausgew&auml;hlt, die eine Mindestanzahl an best&auml;tigten Mails haben, wenn die Ref-Id 0 ist.");
                                break;
 
                        case '0.3.5': // SQL queries for v0.3.5
                                addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `lock_reason` TINYTEXT");
                                addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `lock_timestamp` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00'");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `user_delete_purge` BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('ONE_DAY') * 30)."");
-                               addAdminMenuSql('user','list_user_del','L&ouml;schungen auflisten','Listet die L&ouml;schungen von Usern auf.', 9);
-                               addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_del`");
+                               addConfigAddSql('user_delete_purge', "BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getOneDay() * 30)."");
+                               addAdminMenuSql('user', 'list_user_del', 'L&ouml;schungen auflisten', 'Listet die L&ouml;schungen von Usern auf.', 9);
+                               addDropTableSql('user_del');
                                addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_del` (
 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
@@ -362,27 +360,81 @@ INDEX (`stats_type`)
 `del_reason` TINYTEXT,
 INDEX (`userid`),
 PRIMARY KEY (`id`)
-) TYPE={?_TABLE_TYPE?} COMMENT='List of deleted users'");
+) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'List of deleted users'");
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Der Sperrgrund wird nun mit abgespeichert und beim L&ouml;schen des Users mit ausgesendet.");
                                break;
-               }
+
+                       case '0.3.6': // SQL queries for v0.3.6
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` DROP INDEX `userid`");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` ADD UNIQUE `userid_catid` ( `userid` , `cat_id` )");
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Der Sperrgrund wird nun mit abgespeichert und beim L&ouml;schen des Users mit ausgesendet.");
+                               break;
+
+                       case '0.3.7': // SQL queries for v0.3.7
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` CHANGE `id` `id` BIGINT( 22 ) UNSIGNED NOT NULL AUTO_INCREMENT");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` CHANGE `userid` `userid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` CHANGE `cat_id` `cat_id` TINYINT( 3 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `userid` `userid` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_del` CHANGE `userid` `userid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` CHANGE `stats_id` `stats_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` CHANGE `userid` `userid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` CHANGE `userid` `userid` BIGINT( 22 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` CHANGE `ref_depth` `ref_depth` TINYINT( 3 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_refs` CHANGE `userid` `userid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_refs` CHANGE `level` `level` SMALLINT( 6 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_refs` CHANGE `refid` `refid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `userid` `userid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `cat_id` `cat_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `payment_id` `payment_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `pool_id` `pool_id` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats_data` CHANGE `userid` `userid` BIGINT( 20 ) UNSIGNED NULL DEFAULT NULL");
+
+                               // Cleanup SQLs
+                               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid` IS NULL OR `cat_id` IS NULL");
+                               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_del` WHERE `userid` IS NULL");
+                               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_user_links` SET `stats_id`=NULL WHERE `stats_id`=0");
+                               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid` IS NULL");
+                               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `ref_depth`=NULL WHERE `ref_depth`=0");
+                               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid` IS NULL");
+                               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid` IS NULL OR `refid` IS NULL OR `level` IS NULL");
+                               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `cat_id`=NULL WHERE `cat_id`=0");
+                               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `payment_id`=NULL WHERE `payment_id`=0");
+                               addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `pool_id`=NULL WHERE `pool_id`=0");
+                               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `userid` IS NULL");
+
+                               // This update depends on ext-bonus
+                               addExtensionDependency('bonus');
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("NULL ist wichtiger als 0 und UNSIGNED auch.");
+                               break;
+
+                       case '0.3.7': // SQL queries for v0.3.7
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `last_failure` `last_failure` TIMESTAMP NULL DEFAULT NULL");
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Standardwert 0000-00-00 00:00:00 ist nun einfach NULL.");
+                               break;
+               } // END - switch
                break;
 
        case 'modify': // When the extension got modified
                break;
 
-       case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
+       case 'test': // For testing purposes
                break;
 
        case 'init': // Do stuff when extension is initialized
                break;
 
        default: // Unknown extension mode
-               DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));
+               logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
                break;
-}
+} // END - switch
 
 // [EOF]
 ?>