2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 04/29/2004 *
4 * =================== Last change: 10/29/2004 *
6 * -------------------------------------------------------------------- *
7 * File : ext-user.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Swapped out user management *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Ausgelagertes Mitglieder-Management *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2012 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
44 setThisExtensionVersion('0.5.3');
46 // Version history array (add more with , '0.0.1' and so on)
47 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', '0.4.5', '0.4.6', '0.4.7', '0.4.8', '0.4.9', '0.5.0', '0.5.1', '0.5.2', '0.5.3'));
49 // Keep this extension always active!
50 setExtensionAlwaysActive('Y');
52 switch (getExtensionMode()) {
53 case 'register': // Do stuff when installation is running
54 addDropTableSql('user_cats');
55 addCreateTableSql('user_cats', "
56 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
57 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
58 `cat_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
62 'User->category connection data');
64 addDropTableSql('user_data');
65 addCreateTableSql('user_data', "
66 `userid` BIGINT(20) NOT NULL AUTO_INCREMENT,
67 `surname` VARCHAR(255) NOT NULL DEFAULT '',
68 `family` VARCHAR(255) NOT NULL DEFAULT '',
69 `street_nr` VARCHAR(255) NOT NULL DEFAULT '',
70 `country` VARCHAR(4) NOT NULL DEFAULT '',
71 `zip` VARCHAR(6) NOT NULL DEFAULT '',
72 `city` VARCHAR(255) NOT NULL DEFAULT '',
73 `email` VARCHAR(255) NOT NULL DEFAULT '',
74 `birth_day` CHAR(2) NOT NULL DEFAULT '01',
75 `birth_month` CHAR(2) NOT NULL DEFAULT '01',
76 `birth_year` VARCHAR(4) NOT NULL DEFAULT '1970',
77 `password` VARCHAR(255) NOT NULL DEFAULT '',
78 `max_mails` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
79 `receive_mails` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
80 `refid` BIGINT(20) NOT NULL DEFAULT 0,
81 `status` ENUM('UNCONFIRMED','CONFIRMED','LOCKED') NOT NULL DEFAULT 'UNCONFIRMED',
82 `user_hash` VARCHAR(255) NULL DEFAULT NULL,
83 `REMOTE_ADDR` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
84 `last_online` VARCHAR(10) NOT NULL DEFAULT 0,
85 `last_module` VARCHAR(255) NULL DEFAULT NULL,
86 `ref_clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
87 `total_logins` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
88 `gender` ENUM('M','F') NOT NULL DEFAULT 'M',
89 `used_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
90 `emails_sent` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
91 `joined` VARCHAR(10) NOT NULL DEFAULT 0,
92 `last_update` VARCHAR(10) NOT NULL DEFAULT 0,
93 `last_profile_sent` VARCHAR(10) NOT NULL DEFAULT 0,
94 `notified` ENUM('Y','N') NOT NULL DEFAULT 'N',
95 `ref_payout` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
96 `last_login` VARCHAR(10) NOT NULL DEFAULT 0,
97 `login_failures` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
98 `last_failure` TIMESTAMP NULL DEFAULT NULL,
99 PRIMARY KEY (`userid`),
100 UNIQUE INDEX (`user_hash`),
102 INDEX `status_mails` (`status`,`max_mails`)",
105 addDropTableSql('user_points');
106 addCreateTableSql('user_points', "
107 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
108 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
109 `ref_depth` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
110 `points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
111 `locked_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
114 'User points (no used points)');
116 addDropTableSql('user_links');
117 addCreateTableSql('user_links', "
118 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
119 `stats_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
120 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
121 `link_type` VARCHAR(255) NOT NULL DEFAULT 'NORMAL',
125 'Unconfirmed mails per user');
127 addDropTableSql('user_stats');
128 addCreateTableSql('user_stats', "
129 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
130 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
131 `cat_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
132 `payment_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
133 `subject` VARCHAR(255) NOT NULL DEFAULT '',
134 `url` TINYTEXT NOT NULL,
135 `max_rec` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
136 `clicks` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
137 `timestamp_ordered` VARCHAR(10) NOT NULL DEFAULT '',
138 `pool_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
139 `timestamp_sstart` VARCHAR(10) NOT NULL DEFAULT '',
140 `timestamp_send` VARCHAR(10) NOT NULL DEFAULT '',
141 `is_stats` ENUM('Y','N') NOT NULL DEFAULT 'N',
145 INDEX (`payment_id`),
147 'Mail statistics per user order');
149 addDropTableSql('user_stats_data');
150 addCreateTableSql('user_stats_data', "
151 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
152 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
153 `stats_type` VARCHAR(255) NOT NULL DEFAULT 'unknown',
154 `stats_data` VARCHAR(255) NOT NULL DEFAULT '',
155 `inserted` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
158 INDEX (`stats_type`)",
159 'Member statistics data');
162 addAdminMenuSql('user', NULL, 'Mitglieder-Management', 'Mitglieder freischalten, sperren, Accounts editieren, Neuanmeldungen verwalten, {OPEN_CONFIG}POINTS{CLOSE_CONFIG} gutschreiben und abziehen und und und...', 3);
163 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);
164 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);
165 addAdminMenuSql('user', 'list_user', 'Mitglieder 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);
166 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);
167 addAdminMenuSql('user', 'edit_user', 'Account editieren', 'Daten eines Mitglieder-Accountes ändern.', 6);
168 addAdminMenuSql('user', 'list_refs', 'Referrals anzeigen', 'Mit diesem Menüpunkt können Sie die generierten Referrals eines Mitgliedes auflisten.', 7);
169 addAdminMenuSql('user', 'list_links', 'Unbestätigte Mails', 'Mit diesem Menüpunkt können Sie die vom Mitglied nicht bestätigten Mails anzeigen.', 8);
170 addAdminMenuSql('user', 'list_cats', 'Kategorien anzeigen', 'Listet die ausgewählten Kategorien eines Mitgliedes auf.', 9);
173 case 'remove': // Do stuff when removing extension
174 // SQL commands to run
175 addDropTableSql('user_del');
176 addDropTableSql('user_cats');
177 addDropTableSql('user_data');
178 addDropTableSql('user_points');
179 addDropTableSql('user_links');
180 addDropTableSql('user_refs');
181 addDropTableSql('user_stats');
182 addDropTableSql('user_stats_data');
183 addDropTableSql('user_subids');
184 addDropTableSql('subid_log');
185 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what` IN('config_user','user_contct','list_user_del') OR `action`='user'");
186 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what` IN ('subids')");
188 // Register new filters for gathering points
189 unregisterFilter(__FILE__, __LINE__, 'get_total_points', 'USER_POINTS', true, isExtensionDryRun());
190 unregisterFilter(__FILE__, __LINE__, 'get_own_points', 'USER_POINTS', true, isExtensionDryRun());
191 unregisterFilter(__FILE__, __LINE__, 'get_locked_points', 'LOCKED_USER_POINTS', true, isExtensionDryRun());
192 unregisterFilter(__FILE__, __LINE__, 'get_all_point_columns', 'GET_ALL_USER_POINTS_COLUMN_NAMES', true, isExtensionDryRun());
193 unregisterFilter(__FILE__, __LINE__, 'user_exclusion_sql', 'TESTER_USER_EXCLUSION_SQL', true, isExtensionDryRun());
194 unregisterFilter(__FILE__, __LINE__, 'user_inclusion_sql', 'TESTER_USER_INCLUSION_SQL', true, isExtensionDryRun());
195 unregisterFilter(__FILE__, __LINE__, 'pre_user_registration', 'TESTER_USER_REGISTRATION_ADD_SQL_COLUMNS', true, isExtensionDryRun());
196 unregisterFilter(__FILE__, __LINE__, 'convert_user_data_columns', 'ADD_USER_DATA_CONVERT_SQL_COLUMNS', true, isExtensionDryRun());
197 unregisterFilter(__FILE__, __LINE__, 'post_refid_validation', 'HANDLE_USER_SUBID', true, isExtensionDryRun());
198 unregisterFilter(__FILE__, __LINE__, 'pre_user_registration', 'SUBID_USER_REGISTRATION_ADD_SQL_COLUMNS', true, isExtensionDryRun());
201 case 'activate': // Do stuff when admin activates this extension
202 // SQL commands to run
206 case 'deactivate': // Do stuff when admin deactivates this extension
207 // SQL commands to run
211 case 'update': // Update an extension
212 switch (getCurrentExtensionVersion()) {
213 case '0.1.0': // SQL queries for v0.1
214 addConfigAddSql('user_limit', 'INT(7) UNSIGNED NOT NULL DEFAULT 20');
216 // Update notes (these will be set as task text!)
217 setExtensionUpdateNotes("Seitenweises Anzeigen der User-Liste ist nun möglich.");
220 case '0.1.1': // SQL queries for v0.1.1
221 // This update depends on ext-sql_patches update!
222 addExtensionDependency('sql_patches');
224 // Update notes (these will be set as task text!)
225 setExtensionUpdateNotes("Ungültiges Update.");
228 case '0.1.2': // SQL queries for v0.1.2
229 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `mails_confirmed` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
231 // Update notes (these will be set as task text!)
232 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.");
235 case '0.1.3': // SQL queries for v0.1.3
236 // Update notes (these will be set as task text!)
237 setExtensionUpdateNotes("Den Pfad <span class=\"bad\">Sie sind hier</span> im Menüpunkt <u>Online-Liste</u> erweitert.");
240 case '0.1.4': // SQL queries for v0.1.4
241 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `emails_received` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
243 // Update notes (these will be set as task text!)
244 setExtensionUpdateNotes("Anzahl empfangener Mails wird angezeigt. <big>Diese Anzeige kann fehlerhaft sein, wenn Sie bereits Mitglieder in Ihrem {?mt_word?} haben sollen!</big>");
247 case '0.1.5': // SQL queries for v0.1.5
248 // Update notes (these will be set as task text!)
249 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
252 case '0.1.6': // SQL queries for v0.1.6
253 // Update notes (these will be set as task text!)
254 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
257 case '0.1.7': // SQL queries for v0.1.7
258 // Update notes (these will be set as task text!)
259 setExtensionUpdateNotes("Erweiterung bleibt wegen integrierten Schalters immer aktiv.");
262 case '0.1.8': // SQL queries for v0.1.8
263 // Update notes (these will be set as task text!)
264 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> überflüssige HTML-Tags entfernt.");
267 case '0.1.9': // SQL queries for v0.1.9
268 // Update notes (these will be set as task text!)
269 setExtensionUpdateNotes("Link zum Mitgliedsprofil in Funktion <u>generateUserProfileLink()</u> ausgelagert.");
272 case '0.2.0': // SQL queries for v0.2.0
273 // Update notes (these will be set as task text!)
274 setExtensionUpdateNotes("User-Liste ausgelagert in Templates und überbreite Zeile in 2er-Zeile umgewandelt.");
277 case '0.2.1': // SQL queries for v0.2.1
278 addConfigAddSql('user_alpha', 'TINYINT(3) UNSIGNED NOT NULL DEFAULT 10');
279 addAdminMenuSql('setup','config_user','Mitgliederliste','Anzahl Mitglieder pro Seite, Anzahl Buchstaben pro Zeile usw.', 8);
281 // Update notes (these will be set as task text!)
282 setExtensionUpdateNotes("User-Liste ist konfigurierbar: Anzahl Mitglieder pro Seite und Anzahl Buchstaben pro Zeile; Template-Fehler beseitigt.");
285 case '0.2.2': // SQL queries for v0.2.2
286 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `gender` `gender` ENUM('M','F','C') NOT NULL DEFAULT 'M'");
288 // Update notes (these will be set as task text!)
289 setExtensionUpdateNotes("Anrede "Firma" hinzugefügt.");
292 case '0.2.3': // SQL queries for v0.2.3
293 // Update notes (these will be set as task text!)
294 setExtensionUpdateNotes("Datumsformat festgelegt auf ausführlich.");
297 case '0.2.4': // SQL queries for v0.2.4
298 // Update notes (these will be set as task text!)
299 setExtensionUpdateNotes("Wörter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.");
302 case '0.2.5': // SQL queries for v0.2.5
303 // Update notes (these will be set as task text!)
304 setExtensionUpdateNotes("SQL-Anweisungen abgesichert.");
307 case '0.2.6': // SQL queries for v0.2.6
308 // Update notes (these will be set as task text!)
309 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
312 case '0.2.7': // SQL queries for v0.2.7
313 // Update notes (these will be set as task text!)
314 setExtensionUpdateNotes("Sicherheitsupdate für die Include-Befehle.");
317 case '0.2.8': // SQL queries for v0.2.8
318 // Update notes (these will be set as task text!)
319 setExtensionUpdateNotes("if-Anweisungen auf Funktion <strong>empty()</strong> umgestellt.");
322 case '0.2.9': // SQL queries for v0.2.9
323 addAdminMenuSql('user','user_contct','Mitglied kontaktieren','Kontaktieren Sie hier Ihre Mitglieder ganz direkt über ein Webformular. Sie brauchen somit kein EMail-Programm mehr starten!', 8);
325 // Update notes (these will be set as task text!)
326 setExtensionUpdateNotes("Admin-Kontaktformular hinzugefügt.");
329 case '0.3.0': // SQL queries for v0.3.0
330 // Update notes (these will be set as task text!)
331 setExtensionUpdateNotes("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.<br />Diverse Fixes für <span class=\"bad\">0.2.1-Beta1</span> Release.");
334 case '0.3.1': // SQL queries for v0.3.1
335 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title` = 'Mitglieder-Management' WHERE `action`='user' AND (`what`='' OR `what` IS NULL) LIMIT 1");
337 // Update notes (these will be set as task text!)
338 setExtensionUpdateNotes("Verwaltung auf Management umgestellt");
341 case '0.3.2': // SQL queries for v0.3.2
342 // Update notes (these will be set as task text!)
343 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ätigten Mails gefixt.");
346 case '0.3.3': // SQL queries for v0.3.3
347 // Update notes (these will be set as task text!)
348 setExtensionUpdateNotes("Mitglieder sind nun per Formular kontaktierbar (es wird eine EMail versendet), gesperrte und bestätigte Mitglieder-Accounts sind seperat oder gemeinsam auflistbar (seperat nur mit der Erweiterung <span class=\"bad\">task</span>!)");
351 case '0.3.4': // SQL queries for v0.3.4
352 addConfigAddSql('select_user_zero_refid', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
353 addConfigAddSql('user_min_confirmed', 'SMALLINT(5) UNSIGNED NOT NULL DEFAULT 10');
354 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `rand_confirmed` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
356 // Update notes (these will be set as task text!)
357 setExtensionUpdateNotes("Mitglieder werden per Zufall als Referral-Id ausgewählt, die eine Mindestanzahl an bestätigten Mails haben, wenn die Ref-Id 0 ist.");
360 case '0.3.5': // SQL queries for v0.3.5
361 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `lock_reason` TINYTEXT");
362 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `lock_timestamp` TIMESTAMP NULL DEFAULT NULL");
363 addConfigAddSql('user_delete_purge', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 30));
364 addAdminMenuSql('user', 'list_user_del', 'Löschungen auflisten', 'Listet die Löschungen von Usern auf.', 9);
365 addDropTableSql('user_del');
366 addCreateTableSql('user_del', "
367 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
368 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
369 `email` VARCHAR(255) NOT NULL DEFAULT '',
370 `surname` VARCHAR(255) NOT NULL DEFAULT '',
371 `family` VARCHAR(255) NOT NULL DEFAULT '',
372 `joined` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
373 `last_online` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
374 `del_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
375 `del_reason` TINYTEXT,
378 'List of deleted users');
380 // Update notes (these will be set as task text!)
381 setExtensionUpdateNotes("Der Sperrgrund wird nun mit abgespeichert und beim Löschen des Users mit ausgesendet.");
384 case '0.3.6': // SQL queries for v0.3.6
385 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` DROP INDEX `userid`');
386 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` ADD UNIQUE `userid_catid` (`userid`,`cat_id`)');
388 // Update notes (these will be set as task text!)
389 setExtensionUpdateNotes("Der Sperrgrund wird nun mit abgespeichert und beim Löschen des Users mit ausgesendet.");
392 case '0.3.7': // SQL queries for v0.3.7
393 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` CHANGE `id` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT');
394 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
395 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` CHANGE `cat_id` `cat_id` TINYINT(3) UNSIGNED NULL DEFAULT NULL');
396 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT');
397 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_del` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
398 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` CHANGE `stats_id` `stats_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
399 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
400 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
401 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` CHANGE `ref_depth` `ref_depth` TINYINT(3) UNSIGNED NULL DEFAULT NULL');
402 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
403 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `cat_id` `cat_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
404 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `payment_id` `payment_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
405 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `pool_id` `pool_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
406 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats_data` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
409 addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid` IS NULL OR `cat_id` IS NULL');
410 addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_del` WHERE `userid` IS NULL');
411 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_links` SET `stats_id`=NULL WHERE `stats_id`=0');
412 addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid` IS NULL');
413 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `ref_depth`=NULL WHERE `ref_depth`=0');
414 addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid` IS NULL');
415 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `cat_id`=NULL WHERE `cat_id`=0');
416 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `payment_id`=NULL WHERE `payment_id`=0');
417 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `pool_id`=NULL WHERE `pool_id`=0');
418 addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `userid` IS NULL');
420 // Update notes (these will be set as task text!)
421 setExtensionUpdateNotes("NULL ist wichtiger als 0 und UNSIGNED auch.");
424 case '0.3.8': // SQL queries for v0.3.8
425 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `last_failure` `last_failure` TIMESTAMP NULL DEFAULT NULL');
427 // Update notes (these will be set as task text!)
428 setExtensionUpdateNotes("Ausgangswert ist nicht mehr 0000-00-00 00:00:00, sondern einfach NULL.");
431 case '0.3.9': // SQL queries for v0.3.9
432 // Update notes (these will be set as task text!)
433 setExtensionUpdateNotes("Update verschoben nach ext-order (da es Werbeguthaben ist und nichts mit dem Mitglied selbst zu tun hat).");
436 case '0.4.0': // SQL queries for v0.4.0
437 // Register new filters for gathering points
438 registerFilter(__FILE__, __LINE__, 'get_total_points', 'USER_POINTS', false, true, isExtensionDryRun());
439 registerFilter(__FILE__, __LINE__, 'get_own_points', 'USER_POINTS', false, true, isExtensionDryRun());
441 // Update notes (these will be set as task text!)
442 setExtensionUpdateNotes("Filter registriert, die das eigene {?POINTS?}-Guthaben des Mitgliedes zurückliefern.");
445 case '0.4.1': // SQL queries for v0.4.1
446 // Add special fix include to fix filters
447 addIncludeToPool('extension', 'inc/fix_user_points.php');
449 // Update notes (these will be set as task text!)
450 setExtensionUpdateNotes("Das Mitgliederguthaben musste repariert werden, da für Referral-Ebene 0, noch NULL geschrieben wurde.");
453 case '0.4.2': // SQL queries for v0.4.2
454 // Add special fix include to fix filters
455 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='chk_regs' LIMIT 1");
457 // Update notes (these will be set as task text!)
458 setExtensionUpdateNotes("Überflüssiges Menü <strong>chk_regs</strong> entfernt, dies kann mit <strong>list_user</strong> übernommen werden.");
461 case '0.4.3': // SQL queries for v0.4.3
462 // Add special fix include to fix filters
463 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `refid` `refid` BIGINT(20) NULL DEFAULT NULL");
465 // Update notes (these will be set as task text!)
466 setExtensionUpdateNotes("Überflüssiges Menü <strong>chk_regs</strong> entfernt, dies kann mit <strong>list_user</strong> übernommen werden.");
469 case '0.4.4': // SQL queries for v0.4.4
470 addDropTableSql('user_refs');
471 addCreateTableSql('user_refs', "
472 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
473 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
474 `level` smallINT(6) UNSIGNED NOT NULL DEFAULT 0,
475 `refid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
477 UNIQUE `user_refid` (`userid`,`level`,`refid`),
482 // Load ext-refback's special include to regenerate the referral table
483 addIncludeToPool('extension', 'inc/fix_refsystem.php');
485 // Update notes (these will be set as task text!)
486 setExtensionUpdateNotes("Neues Tabellenlayout und verschoben von ext-refback.");
489 case '0.4.5': // SQL queries for v0.4.5
490 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` CHANGE `link_type` `link_type` VARCHAR(255) NOT NULL DEFAULT 'NORMAL'");
492 // Update notes (these will be set as task text!)
493 setExtensionUpdateNotes("Die Spalte <strong>link_type</strong> ist nun kein ENUM mehr, um weitere Mailtypen zu erlauben.");
496 case '0.4.6': // SQL queries for v0.4.6
497 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='{OPEN_CONFIG}POINTS{CLOSE_CONFIG} gutschreiben' WHERE `what` = 'add_points' LIMIT 1");
498 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='{OPEN_CONFIG}POINTS{CLOSE_CONFIG} abziehen' WHERE `what` = 'sub_points' LIMIT 1");
499 addAdminMenuSql('user','sub_points','{OPEN_CONFIG}POINTS{CLOSE_CONFIG} abziehen','Allen oder einem Mitglied {OPEN_CONFIG}POINTS{CLOSE_CONFIG} abziehen.', 8);
501 // This update depends on ext-menu update
502 addExtensionDependency('menu');
504 // Update notes (these will be set as task text!)
505 setExtensionUpdateNotes("Abzug von {?POINTS?} sollte nun dabei sein und Hinzufügen gefixt (war zu kurze Spalte).");
508 case '0.4.7': // SQL queries for v0.4.7
509 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `lock_timestamp` `lock_timestamp` TIMESTAMP NULL DEFAULT NULL');
510 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `lock_timestamp`=NULL WHERE `lock_timestamp`='0000-00-00 00:00:00'");
512 // Update notes (these will be set as task text!)
513 setExtensionUpdateNotes("0000-00-00 00:00:00 ist kein Standardwert mehr, NULL ist dies.");
516 case '0.4.8': // SQL queries for v0.4.8
517 // Update notes (these will be set as task text!)
518 setExtensionUpdateNotes("Dieses Update ist nicht mehr gültig.");
521 case '0.4.9': // SQL queries for v0.4.9
522 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `last_module` `last_what` VARCHAR(255) NULL DEFAULT NULL');
524 // Register filter locked points
525 registerFilter(__FILE__, __LINE__, 'get_locked_points', 'LOCKED_USER_POINTS', false, true, isExtensionDryRun());
527 // Register filter for all column names
528 registerFilter(__FILE__, __LINE__, 'get_all_point_columns', 'GET_ALL_USER_POINTS_COLUMN_NAMES', false, true, isExtensionDryRun());
530 // Update notes (these will be set as task text!)
531 setExtensionUpdateNotes("Die Spalte <strong>last_module</strong> ist nach <strong>last_what</strong> umbenannt und hat nun NULL als Ausgangswert und Filter für gesperrtes Guthaben hinzugefügt.");
534 case '0.5.0': // SQL queries for v0.5.0
535 // Prefix for all test accounts
536 addConfigAddSql('tester_user_maximum', 'INT(5) UNSIGNED ZEROFILL NOT NULL DEFAULT 00999');
537 addConfigAddSql('tester_user_gender', "ENUM('M','F') NOT NULL DEFAULT 'M'");
538 addConfigAddSql('tester_user_surname_prefix', "VARCHAR(255) NOT NULL DEFAULT 'tester_'");
539 addConfigAddSql('tester_user_family', "VARCHAR(255) NOT NULL DEFAULT 'Testbenutzer'");
540 addConfigAddSql('tester_user_street_nr', "VARCHAR(255) NOT NULL DEFAULT 'Teststraße 123'");
541 addConfigAddSql('tester_user_zip', 'INT(6) UNSIGNED NOT NULL DEFAULT 12345');
542 addConfigAddSql('tester_user_city', "VARCHAR(255) NOT NULL DEFAULT 'Teststadt'");
543 addConfigAddSql('tester_user_email', "VARCHAR(255) NOT NULL DEFAULT '{OPEN_CONFIG}WEBMASTER{CLOSE_CONFIG}'");
544 addConfigAddSql('tester_user_default_refid', 'BIGINT(20) NULL DEFAULT NULL');
545 addConfigAddSql('tester_user_password', "VARCHAR(255) NOT NULL DEFAULT ''");
546 addConfigAddSql('tester_user_check_cat', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
549 addAdminMenuSql('user', 'add_tester_user', 'Testbenutzer anlegen', 'Es können hier bis zu 100 Testbenutzer angelegt werden. Diese haben als Vornamen immer den Präfix <span class="data">{?tester_user_surname_prefix?}</span> und werden bei Null anfangend bis 99 hochgezält.', 1);
550 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='Mitglieder auflisten' WHERE `what`='list_user' LIMIT 1");
552 // Change 'zip' to INT(6)
553 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `zip` `zip` INT(6) NOT NULL DEFAULT 0');
555 // Register filter for WHERE/AND exclusion/inclusion statements
556 registerFilter(__FILE__, __LINE__, 'user_exclusion_sql', 'TESTER_USER_EXCLUSION_SQL', false, true, isExtensionDryRun());
557 registerFilter(__FILE__, __LINE__, 'user_inclusion_sql', 'TESTER_USER_INCLUSION_SQL', false, true, isExtensionDryRun());
559 // Update notes (these will be set as task text!)
560 setExtensionUpdateNotes("Es können nun Test-Benutzer angelegt werden. Noch müssen diese überall ausgeschlossen werden, damit die Mediadaten nicht unnötig verfälscht werden.");
563 case '0.5.1': // SQL queries for v0.5.1
565 registerFilter(__FILE__, __LINE__, 'pre_user_registration', 'TESTER_USER_REGISTRATION_ADD_SQL_COLUMNS', false, true, isExtensionDryRun());
567 // Update notes (these will be set as task text!)
568 setExtensionUpdateNotes("Filter zum Hinzufügen von SQL-Spalten für die Mitgliederanmeldung hinzugefügt.");
571 case '0.5.2': // SQL queries for v0.5.2
573 registerFilter(__FILE__, __LINE__, 'convert_user_data_columns', 'ADD_USER_DATA_CONVERT_SQL_COLUMNS', false, true, isExtensionDryRun());
575 // Update notes (these will be set as task text!)
576 setExtensionUpdateNotes("Filter zum Hinzufügen von SQL-Spalten für die Mitgliederanmeldung hinzugefügt.");
579 case '0.5.3': // SQL queries for v0.5.3
581 registerFilter(__FILE__, __LINE__, 'post_refid_validation', 'HANDLE_USER_SUBID', false, true, isExtensionDryRun());
582 registerFilter(__FILE__, __LINE__, 'pre_user_registration', 'SUBID_USER_REGISTRATION_ADD_SQL_COLUMNS', false, true, isExtensionDryRun());
585 addAdminMenuSql('user', 'list_user_subid', 'Sub-Ids', 'Listet alle pro vom Mitglied eingegebenen Sub-Ids und ermittelten Referral-URLs auf.', 7);
588 addMemberMenuSql('extras', 'subids', 'Sub-Id Tracking', 4);
590 // Add table for subids
591 addDropTableSql('user_subids');
592 addCreateTableSql('user_subids', "
593 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
594 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
595 `subid` VARCHAR(255) NOT NULL DEFAULT '',
596 `subid_added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
598 UNIQUE `user_subid` (`userid`, `subid`),
602 // Add table for subid logging
603 addDropTableSql('subid_log');
604 addCreateTableSql('subid_log', "
605 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
606 `refid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
607 `subid` VARCHAR(255) NOT NULL DEFAULT '',
608 `referral_url` TINYTEXT,
609 `remote_address` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
610 `entry_added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
616 // For saving used subid in user_data table
617 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `subid` VARCHAR(255) NULL DEFAULT NULL');
618 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD INDEX (`subid`)');
620 // Configuration entry for purging old subid logs (7 days default)
621 addConfigAddSql('user_subid_purge', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 7));
623 // Update notes (these will be set as task text!)
624 setExtensionUpdateNotes("Filter, Datenbanktabelle und Menüpunkte für SubId-Tracking hinzugefügt.");
629 case 'modify': // When the extension got modified
632 case 'test': // For testing purposes
635 case 'init': // Do stuff when extension is initialized
638 default: // Unknown extension mode
639 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));