File renamed to naming convention, ext-repair continued:
[mailer.git] / inc / extensions / ext-user.php
index 77be291ef18c6cf2a013c1735734832bde44b361..4a65c5d0c9719926e9de3797f0902b193a104537 100644 (file)
@@ -41,29 +41,29 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Version number
-setThisExtensionVersion('0.3.7');
+setThisExtensionVersion('0.4.4');
 
-// 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', '0.3.6', '0.3.7'));
+// Version history array (add more with , '0.0.1' and so on)
+setExtensionVersionHistory(array('0.0.0', '0.1.0', '0.1.1', '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', '0.3.8', '0.3.9', '0.4.0', '0.4.1', '0.4.2', '0.4.3', '0.4.4'));
 
 // Keep this extension always active!
 setExtensionAlwaysActive('Y');
 
 switch (getExtensionMode()) {
-       case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
+       case 'register': // Do stuff when installation is running
                addDropTableSql('user_cats');
-               addCreateTableSql('user_cats', "(
-`id` BIGINT(22) NOT NULL AUTO_INCREMENT,
+               addCreateTableSql('user_cats', "
+`id` BIGINT(20) 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`)
-) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'User->category connection data'");
+INDEX (`cat_id`)",
+                       'User->category connection data');
 
                addDropTableSql('user_data');
-               addCreateTableSql('user_data', "(
-`userid` BIGINT(22) NOT NULL AUTO_INCREMENT,
+               addCreateTableSql('user_data', "
+`userid` BIGINT(20) NOT NULL AUTO_INCREMENT,
 `surname` VARCHAR(255) NOT NULL DEFAULT '',
 `family` VARCHAR(255) NOT NULL DEFAULT '',
 `street_nr` VARCHAR(255) NOT NULL DEFAULT '',
@@ -77,7 +77,7 @@ INDEX (`cat_id`)
 `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,
+`refid` BIGINT(20) 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',
@@ -99,33 +99,33 @@ INDEX (`cat_id`)
 PRIMARY KEY (`userid`),
 UNIQUE (`user_hash`),
 INDEX (`refid`),
-INDEX `status_mails` (`status`,`max_mails`)
-) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Main user data'");
+INDEX `status_mails` (`status`, `max_mails`)",
+                       'Main user data');
 
                addDropTableSql('user_points');
-               addCreateTableSql('user_points', "(
-`id` BIGINT(22) NOT NULL AUTO_INCREMENT,
-`userid` BIGINT(22) NOT NULL DEFAULT 0,
+               addCreateTableSql('user_points', "
+`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
+`userid` BIGINT(20) 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`)
-) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'User points (no used points)'");
+INDEX (`userid`)",
+                       'User points (no used points)');
 
                addDropTableSql('user_links');
-               addCreateTableSql('user_links', "(
+               addCreateTableSql('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`),
 INDEX (`userid`),
-INDEX (`stats_id`)
-) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Unconfirmed mails per user'");
+INDEX (`stats_id`)",
+                       'Unconfirmed mails per user');
 
                addDropTableSql('user_stats');
-               addCreateTableSql('user_stats', "(
+               addCreateTableSql('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,
@@ -143,11 +143,11 @@ PRIMARY KEY (`id`),
 INDEX (`userid`),
 INDEX (`cat_id`),
 INDEX (`payment_id`),
-INDEX (`pool_id`)
-) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Mail statistics per user order'");
+INDEX (`pool_id`)",
+                       'Mail statistics per user order');
 
                addDropTableSql('user_stats_data');
-               addCreateTableSql('user_stats_data', "(
+               addCreateTableSql('user_stats_data', "
 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 `stats_type` VARCHAR(255) NOT NULL DEFAULT 'unknown',
@@ -155,13 +155,12 @@ INDEX (`pool_id`)
 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 PRIMARY KEY (`id`),
 INDEX (`userid`),
-INDEX (`stats_type`)
-) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'Member statistics data'");
+INDEX (`stats_type`)",
+                       '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);
                addAdminMenuSql('user','del_user','Mitglied löschen','Löschen Sie hier Mitglied, die gegen die AGBs mehrmals verstossen haben. Bitte seien Sie nett zu Ihren Mitgliedern und löschen Sie nicht gleich.',1);
-               addAdminMenuSql('user','chk_regs','Anmeldungen prüfen','Prüfen Sie hier neue Anmeldungen zu Ihrem System. Hier können Sie im Falle einer Fehler-Mail den Mitglied gleich wieder löschen!',2);
                addAdminMenuSql('user','lock_user','Mitglied sperren / entsperren','Sperren Sie Mitglied, die zu viele unbestätigte Mails haben oder gegen Ihre AGBs verstossen haben über diesen Menüpunkt.',3);
                addAdminMenuSql('user','list_user','Mitglied auflisten','Listen Sie alle Mitglied oder eingeschränkt nach Suchkritieren Ihre Userdatenbank auf. Sie könen per Klick auf die Usernummer sich Details zum Mitglied ansehen.',4);
                addAdminMenuSql('user','add_points','{OPEN_CONFIG}POINTS{CLOSE_CONFIG} gutschreiben','Buchen Sie einem Mitglied direkt {OPEN_CONFIG}POINTS{CLOSE_CONFIG} auf. Sie können dazu auch einen Kommentar mitsenden.',5);
@@ -181,6 +180,10 @@ INDEX (`stats_type`)
                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'");
+
+               // Register new filters for gathering points
+               unregisterFilter(__FUNCTION__, __LINE__, 'get_total_points', 'USER_POINTS', true, isExtensionDryRun());
+               unregisterFilter(__FUNCTION__, __LINE__, 'get_own_points', 'USER_POINTS', true, isExtensionDryRun());
                break;
 
        case 'activate': // Do stuff when admin activates this extension
@@ -196,7 +199,7 @@ INDEX (`stats_type`)
        case 'update': // Update an extension
                switch (getCurrentExtensionVersion()) {
                        case '0.1.0': // SQL queries for v0.1
-                               addConfigAddSql('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öglich.");
@@ -211,7 +214,7 @@ INDEX (`stats_type`)
                                break;
 
                        case '0.1.2': // SQL queries for v0.1.2
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `mails_confirmed` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
+                               addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `mails_confirmed` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Dem Mitglied wird nun angezeigt, wie viele Mails er bestätigt hat. Alle vor dieser Version best. Mails werden leider nicht mehr berücksichtigt! Bitte teilen Sie dies Ihren Mitgliedern mit.");
@@ -223,7 +226,7 @@ INDEX (`stats_type`)
                                break;
 
                        case '0.1.4': // SQL queries for v0.1.4
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `emails_received` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
+                               addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `emails_received` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Anzahl empfangener Mails wird angezeigt. <big>Diese Anzeige kann fehlerhaft sein, wenn Sie bereits Mitglieder in Ihrem {?mt_word?} haben sollen!</big>");
@@ -260,7 +263,7 @@ INDEX (`stats_type`)
                                break;
 
                        case '0.2.1': // SQL queries for v0.2.1
-                               addConfigAddSql('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!)
@@ -335,8 +338,8 @@ INDEX (`stats_type`)
 
                        case '0.3.4': // SQL queries for v0.3.4
                                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");
+                               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.");
@@ -345,10 +348,10 @@ INDEX (`stats_type`)
                        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'");
-                               addConfigAddSql('user_delete_purge', "BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getOneDay() * 30)."");
+                               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');
-                               addCreateTableSql('user_del', "(
+                               addCreateTableSql('user_del', "
 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 `email` VARCHAR(255) NOT NULL DEFAULT '',
@@ -358,67 +361,119 @@ INDEX (`stats_type`)
 `last_online` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
 `del_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 `del_reason` TINYTEXT,
-INDEX (`userid`),
-PRIMARY KEY (`id`)
-) ENGINE = {?_TABLE_TYPE?} CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT = 'List of deleted users'");
+PRIMARY KEY (`id`),
+INDEX (`userid`)",
+                                       '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` )");
+                               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");
+                               addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` CHANGE `id` `id` BIGINT(20) 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(20) 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_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');
+                               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('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');
 
                                // 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");
+                       case '0.3.8': // SQL queries for v0.3.8
+                               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("Ausgangswert ist nicht mehr 0000-00-00 00:00:00, sondern einfach NULL.");
                                break;
+
+                       case '0.3.9': // SQL queries for v0.3.9
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Update verschoben nach ext-order (da es Werbeguthaben ist und nichts mit dem Mitglied selbst zu tun hat).");
+                               break;
+
+                       case '0.4.0': // SQL queries for v0.4.0
+                               // Register new filters for gathering points
+                               registerFilter('get_total_points', 'USER_POINTS', false, true, isExtensionDryRun());
+                               registerFilter('get_own_points', 'USER_POINTS', false, true, isExtensionDryRun());
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Filter registriert, die das eigene {?POINTS?}-Guthaben des Mitgliedes zur&uuml;ckliefern.");
+                               break;
+
+                       case '0.4.1': // SQL queries for v0.4.1
+                               // Add special fix include to fix filters
+                               addIncludeToPool('extension', 'inc/fix_user_points.php');
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Das Mitgliederguthaben musste repariert werden, da f&uuml;r Referal-Ebene 0, noch NULL geschrieben wurde.");
+                               break;
+
+                       case '0.4.2': // SQL queries for v0.4.2
+                               // Add special fix include to fix filters
+                               addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='chk_regs' LIMIT 1");
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("&Uuml;berfl&uuml;ssiges Men&uuml; <strong>chk_regs</strong> entfernt, dies kann mit <strong>list_user</strong> &uuml;bernommen werden.");
+                               break;
+
+                       case '0.4.3': // SQL queries for v0.4.3
+                               // Add special fix include to fix filters
+                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `refid` `refid` BIGINT(20) NULL DEFAULT NULL");
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("&Uuml;berfl&uuml;ssiges Men&uuml; <strong>chk_regs</strong> entfernt, dies kann mit <strong>list_user</strong> &uuml;bernommen werden.");
+                               break;
+
+                       case '0.4.4': // SQL queries for v0.4.4
+                               // SQL commands to run
+                               addDropTableSql('user_refs');
+                               addCreateTableSql('user_refs', "
+`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
+`userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+`level` smallINT(6) UNSIGNED NOT NULL DEFAULT 0,
+`refid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
+PRIMARY KEY (`id`),
+UNIQUE `user_refid` (`userid`, `level`, `refid`),
+INDEX (`level`),
+INDEX (`refid`)",
+                                       'User referals');
+
+                               // Update notes (these will be set as task text!)
+                               setExtensionUpdateNotes("Neues Tabellenlayout und verschoben von ext-refback.");
+
+                               // Load ext-refback's special include to regenerate the referal table
+                               addIncludeToPool('extension', 'inc/fix_refsystem.php');
+                               break;
                } // END - switch
                break;