Caching of XML/email templates finished:
[mailer.git] / inc / extensions / ext-user.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 04/29/2004 *
4  * ===================                          Last change: 10/29/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-user.php                                     *
8  * -------------------------------------------------------------------- *
9  * Short description : Swapped out user management                      *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Ausgelagertes Mitglieder-Management              *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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                      *
21  *                                                                      *
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.                                  *
26  *                                                                      *
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.                         *
31  *                                                                      *
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,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Version number
44 setThisExtensionVersion('0.5.5');
45
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', '0.5.4', '0.5.5'));
48
49 // Keep this extension always active!
50 setExtensionAlwaysActive('Y');
51
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,
59 PRIMARY KEY (`id`),
60 INDEX (`userid`),
61 INDEX (`cat_id`)",
62                         'User->category connection data');
63
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`),
101 INDEX (`refid`),
102 INDEX `status_mails` (`status`,`max_mails`)",
103                         'Main user data');
104
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,
112 PRIMARY KEY (`id`),
113 INDEX (`userid`)",
114                         'User points (no used points)');
115
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',
122 PRIMARY KEY (`id`),
123 INDEX (`userid`),
124 INDEX (`stats_id`)",
125                         'Unconfirmed mails per user');
126
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',
142 PRIMARY KEY (`id`),
143 INDEX (`userid`),
144 INDEX (`cat_id`),
145 INDEX (`payment_id`),
146 INDEX (`pool_id`)",
147                         'Mail statistics per user order');
148
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,
156 PRIMARY KEY (`id`),
157 INDEX (`userid`),
158 INDEX (`stats_type`)",
159                         'Member statistics data');
160
161                 // Admin menu
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&ouml;schen', 'L&ouml;schen Sie hier Mitglied, die gegen die AGBs mehrmals verstossen haben. Bitte seien Sie nett zu Ihren Mitgliedern und l&ouml;schen Sie nicht gleich.', 1);
164                 addAdminMenuSql('user', 'lock_user', 'Mitglied sperren / entsperren', 'Sperren Sie Mitglied, die zu viele unbest&auml;tigte Mails haben oder gegen Ihre AGBs verstossen haben &uuml;ber diesen Men&uuml;punkt.', 3);
165                 addAdminMenuSql('user', 'list_user', 'Mitglieder auflisten', 'Listen Sie alle Mitglied oder eingeschr&auml;nkt nach Suchkritieren Ihre Userdatenbank auf. Sie k&ouml;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&ouml;nnen dazu auch einen Kommentar mitsenden.', 5);
167                 addAdminMenuSql('user', 'edit_user', 'Account editieren', 'Daten eines Mitglieder-Accountes &auml;ndern.', 6);
168                 addAdminMenuSql('user', 'list_refs', 'Referrals anzeigen', 'Mit diesem Men&uuml;punkt k&ouml;nnen Sie die generierten Referrals eines Mitgliedes auflisten.', 7);
169                 addAdminMenuSql('user', 'list_links', 'Unbest&auml;tigte Mails', 'Mit diesem Men&uuml;punkt k&ouml;nnen Sie die vom Mitglied nicht best&auml;tigten Mails anzeigen.', 8);
170                 addAdminMenuSql('user', 'list_cats', 'Kategorien anzeigen', 'Listet die ausgew&auml;hlten Kategorien eines Mitgliedes auf.', 9);
171                 break;
172
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')");
187
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());
199                 unregisterFilter(__FILE__, __LINE__, 'update_referral_data', 'GENERIC_UPDATE_USER_REFERRAL', true, isExtensionDryRun());
200                 unregisterFilter(__FILE__, __LINE__, 'update_referral_data', 'UPDATE_USER_SUBID', true, isExtensionDryRun());
201                 unregisterFilter(__FILE__, __LINE__, 'member_admin_actions', 'ADD_USER_SUBID_MEMBER_ACTION', true, isExtensionDryRun());
202                 break;
203
204         case 'activate': // Do stuff when admin activates this extension
205                 // SQL commands to run
206                 addExtensionSql('');
207                 break;
208
209         case 'deactivate': // Do stuff when admin deactivates this extension
210                 // SQL commands to run
211                 addExtensionSql('');
212                 break;
213
214         case 'update': // Update an extension
215                 switch (getCurrentExtensionVersion()) {
216                         case '0.1.0': // SQL queries for v0.1
217                                 addConfigAddSql('user_limit', 'INT(7) UNSIGNED NOT NULL DEFAULT 20');
218
219                                 // Update notes (these will be set as task text!)
220                                 setExtensionUpdateNotes("Seitenweises Anzeigen der User-Liste ist nun m&ouml;glich.");
221                                 break;
222
223                         case '0.1.1': // SQL queries for v0.1.1
224                                 // This update depends on ext-sql_patches update!
225                                 addExtensionDependency('sql_patches');
226
227                                 // Update notes (these will be set as task text!)
228                                 setExtensionUpdateNotes("Ung&uuml;ltiges Update.");
229                                 break;
230
231                         case '0.1.2': // SQL queries for v0.1.2
232                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `mails_confirmed` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
233
234                                 // Update notes (these will be set as task text!)
235                                 setExtensionUpdateNotes("Dem Mitglied wird nun angezeigt, wie viele Mails er best&auml;tigt hat. Alle vor dieser Version best. Mails werden leider nicht mehr ber&uuml;cksichtigt! Bitte teilen Sie dies Ihren Mitgliedern mit.");
236                                 break;
237
238                         case '0.1.3': // SQL queries for v0.1.3
239                                 // Update notes (these will be set as task text!)
240                                 setExtensionUpdateNotes("Den Pfad <span class=\"bad\">Sie sind hier</span> im Men&uuml;punkt <u>Online-Liste</u> erweitert.");
241                                 break;
242
243                         case '0.1.4': // SQL queries for v0.1.4
244                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `emails_received` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
245
246                                 // Update notes (these will be set as task text!)
247                                 setExtensionUpdateNotes("Anzahl empfangener Mails wird angezeigt. <big>Diese Anzeige kann fehlerhaft sein, wenn Sie bereits Mitglieder in Ihrem {?mt_word?} haben sollen!</big>");
248                                 break;
249
250                         case '0.1.5': // SQL queries for v0.1.5
251                                 // Update notes (these will be set as task text!)
252                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
253                                 break;
254
255                         case '0.1.6': // SQL queries for v0.1.6
256                                 // Update notes (these will be set as task text!)
257                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
258                                 break;
259
260                         case '0.1.7': // SQL queries for v0.1.7
261                                 // Update notes (these will be set as task text!)
262                                 setExtensionUpdateNotes("Erweiterung bleibt wegen integrierten Schalters immer aktiv.");
263                                 break;
264
265                         case '0.1.8': // SQL queries for v0.1.8
266                                 // Update notes (these will be set as task text!)
267                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
268                                 break;
269
270                         case '0.1.9': // SQL queries for v0.1.9
271                                 // Update notes (these will be set as task text!)
272                                 setExtensionUpdateNotes("Link zum Mitgliedsprofil in Funktion <u>generateUserProfileLink()</u> ausgelagert.");
273                                 break;
274
275                         case '0.2.0': // SQL queries for v0.2.0
276                                 // Update notes (these will be set as task text!)
277                                 setExtensionUpdateNotes("User-Liste ausgelagert in Templates und &uuml;berbreite Zeile in 2er-Zeile umgewandelt.");
278                                 break;
279
280                         case '0.2.1': // SQL queries for v0.2.1
281                                 addConfigAddSql('user_alpha', 'TINYINT(3) UNSIGNED NOT NULL DEFAULT 10');
282                                 addAdminMenuSql('setup','config_user','Mitgliederliste','Anzahl Mitglieder pro Seite, Anzahl Buchstaben pro Zeile usw.', 8);
283
284                                 // Update notes (these will be set as task text!)
285                                 setExtensionUpdateNotes("User-Liste ist konfigurierbar: Anzahl Mitglieder pro Seite und Anzahl Buchstaben pro Zeile; Template-Fehler beseitigt.");
286                                 break;
287
288                         case '0.2.2': // SQL queries for v0.2.2
289                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `gender` `gender` ENUM('M','F','C') NOT NULL DEFAULT 'M'");
290
291                                 // Update notes (these will be set as task text!)
292                                 setExtensionUpdateNotes("Anrede &quot;Firma&quot; hinzugef&uuml;gt.");
293                                 break;
294
295                         case '0.2.3': // SQL queries for v0.2.3
296                                 // Update notes (these will be set as task text!)
297                                 setExtensionUpdateNotes("Datumsformat festgelegt auf ausf&uuml;hrlich.");
298                                 break;
299
300                         case '0.2.4': // SQL queries for v0.2.4
301                                 // Update notes (these will be set as task text!)
302                                 setExtensionUpdateNotes("W&ouml;rter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.");
303                                 break;
304
305                         case '0.2.5': // SQL queries for v0.2.5
306                                 // Update notes (these will be set as task text!)
307                                 setExtensionUpdateNotes("SQL-Anweisungen abgesichert.");
308                                 break;
309
310                         case '0.2.6': // SQL queries for v0.2.6
311                                 // Update notes (these will be set as task text!)
312                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
313                                 break;
314
315                         case '0.2.7': // SQL queries for v0.2.7
316                                 // Update notes (these will be set as task text!)
317                                 setExtensionUpdateNotes("Sicherheitsupdate f&uuml;r die Include-Befehle.");
318                                 break;
319
320                         case '0.2.8': // SQL queries for v0.2.8
321                                 // Update notes (these will be set as task text!)
322                                 setExtensionUpdateNotes("if-Anweisungen auf Funktion <strong>empty()</strong> umgestellt.");
323                                 break;
324
325                         case '0.2.9': // SQL queries for v0.2.9
326                                 addAdminMenuSql('user','user_contct','Mitglied kontaktieren','Kontaktieren Sie hier Ihre Mitglieder ganz direkt &uuml;ber ein Webformular. Sie brauchen somit kein EMail-Programm mehr starten!', 8);
327
328                                 // Update notes (these will be set as task text!)
329                                 setExtensionUpdateNotes("Admin-Kontaktformular hinzugef&uuml;gt.");
330                                 break;
331
332                         case '0.3.0': // SQL queries for v0.3.0
333                                 // Update notes (these will be set as task text!)
334                                 setExtensionUpdateNotes("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.<br />Diverse Fixes f&uuml;r <span class=\"bad\">0.2.1-Beta1</span> Release.");
335                                 break;
336
337                         case '0.3.1': // SQL queries for v0.3.1
338                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title` = 'Mitglieder-Management' WHERE `action`='user' AND (`what`='' OR `what` IS NULL) LIMIT 1");
339
340                                 // Update notes (these will be set as task text!)
341                                 setExtensionUpdateNotes("Verwaltung auf Management umgestellt");
342                                 break;
343
344                         case '0.3.2': // SQL queries for v0.3.2
345                                 // Update notes (these will be set as task text!)
346                                 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.");
347                                 break;
348
349                         case '0.3.3': // SQL queries for v0.3.3
350                                 // Update notes (these will be set as task text!)
351                                 setExtensionUpdateNotes("Mitglieder sind nun per Formular kontaktierbar (es wird eine EMail versendet), gesperrte und best&auml;tigte Mitglieder-Accounts sind seperat oder gemeinsam auflistbar (seperat nur mit der Erweiterung <span class=\"bad\">task</span>!)");
352                                 break;
353
354                         case '0.3.4': // SQL queries for v0.3.4
355                                 addConfigAddSql('select_user_zero_refid', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
356                                 addConfigAddSql('user_min_confirmed', 'SMALLINT(5) UNSIGNED NOT NULL DEFAULT 10');
357                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `rand_confirmed` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
358
359                                 // Update notes (these will be set as task text!)
360                                 setExtensionUpdateNotes("Mitglieder werden per Zufall als Referral-Id ausgew&auml;hlt, die eine Mindestanzahl an best&auml;tigten Mails haben, wenn die Ref-Id 0 ist.");
361                                 break;
362
363                         case '0.3.5': // SQL queries for v0.3.5
364                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `lock_reason` TINYTEXT");
365                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `lock_timestamp` TIMESTAMP NULL DEFAULT NULL");
366                                 addConfigAddSql('user_delete_purge', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 30));
367                                 addAdminMenuSql('user', 'list_user_del', 'L&ouml;schungen auflisten', 'Listet die L&ouml;schungen von Usern auf.', 9);
368                                 addDropTableSql('user_del');
369                                 addCreateTableSql('user_del', "
370 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
371 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
372 `email` VARCHAR(255) NOT NULL DEFAULT '',
373 `surname` VARCHAR(255) NOT NULL DEFAULT '',
374 `family` VARCHAR(255) NOT NULL DEFAULT '',
375 `joined` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
376 `last_online` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
377 `del_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
378 `del_reason` TINYTEXT NOT NULL,
379 PRIMARY KEY (`id`),
380 INDEX (`userid`)",
381                                         'List of deleted users');
382
383                                 // Update notes (these will be set as task text!)
384                                 setExtensionUpdateNotes("Der Sperrgrund wird nun mit abgespeichert und beim L&ouml;schen des Users mit ausgesendet.");
385                                 break;
386
387                         case '0.3.6': // SQL queries for v0.3.6
388                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` DROP INDEX `userid`');
389                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` ADD UNIQUE `userid_catid` (`userid`,`cat_id`)');
390
391                                 // Update notes (these will be set as task text!)
392                                 setExtensionUpdateNotes("Der Sperrgrund wird nun mit abgespeichert und beim L&ouml;schen des Users mit ausgesendet.");
393                                 break;
394
395                         case '0.3.7': // SQL queries for v0.3.7
396                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` CHANGE `id` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT');
397                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
398                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_cats` CHANGE `cat_id` `cat_id` TINYINT(3) UNSIGNED NULL DEFAULT NULL');
399                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT');
400                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_del` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
401                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` CHANGE `stats_id` `stats_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
402                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
403                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
404                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` CHANGE `ref_depth` `ref_depth` TINYINT(3) UNSIGNED NULL DEFAULT NULL');
405                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
406                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `cat_id` `cat_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
407                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `payment_id` `payment_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
408                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats` CHANGE `pool_id` `pool_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
409                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_stats_data` CHANGE `userid` `userid` BIGINT(20) UNSIGNED NULL DEFAULT NULL');
410
411                                 // Cleanup SQLs
412                                 addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid` IS NULL OR `cat_id` IS NULL');
413                                 addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_del` WHERE `userid` IS NULL');
414                                 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_links` SET `stats_id`=NULL WHERE `stats_id`=0');
415                                 addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `userid` IS NULL');
416                                 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_points` SET `ref_depth`=NULL WHERE `ref_depth`=0');
417                                 addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid` IS NULL');
418                                 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `cat_id`=NULL WHERE `cat_id`=0');
419                                 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `payment_id`=NULL WHERE `payment_id`=0');
420                                 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `pool_id`=NULL WHERE `pool_id`=0');
421                                 addExtensionSql('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `userid` IS NULL');
422
423                                 // Update notes (these will be set as task text!)
424                                 setExtensionUpdateNotes("NULL ist wichtiger als 0 und UNSIGNED auch.");
425                                 break;
426
427                         case '0.3.8': // SQL queries for v0.3.8
428                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `last_failure` `last_failure` TIMESTAMP NULL DEFAULT NULL');
429
430                                 // Update notes (these will be set as task text!)
431                                 setExtensionUpdateNotes("Ausgangswert ist nicht mehr 0000-00-00 00:00:00, sondern einfach NULL.");
432                                 break;
433
434                         case '0.3.9': // SQL queries for v0.3.9
435                                 // Update notes (these will be set as task text!)
436                                 setExtensionUpdateNotes("Update verschoben nach ext-order (da es Werbeguthaben ist und nichts mit dem Mitglied selbst zu tun hat).");
437                                 break;
438
439                         case '0.4.0': // SQL queries for v0.4.0
440                                 // Register new filters for gathering points
441                                 registerFilter(__FILE__, __LINE__, 'get_total_points', 'USER_POINTS', false, true, isExtensionDryRun());
442                                 registerFilter(__FILE__, __LINE__, 'get_own_points', 'USER_POINTS', false, true, isExtensionDryRun());
443
444                                 // Update notes (these will be set as task text!)
445                                 setExtensionUpdateNotes("Filter registriert, die das eigene {?POINTS?}-Guthaben des Mitgliedes zur&uuml;ckliefern.");
446                                 break;
447
448                         case '0.4.1': // SQL queries for v0.4.1
449                                 // Add special fix include to fix filters
450                                 addIncludeToPool('extension', 'inc/fix_user_points.php');
451
452                                 // Update notes (these will be set as task text!)
453                                 setExtensionUpdateNotes("Das Mitgliederguthaben musste repariert werden, da f&uuml;r Referral-Ebene 0, noch NULL geschrieben wurde.");
454                                 break;
455
456                         case '0.4.2': // SQL queries for v0.4.2
457                                 // Add special fix include to fix filters
458                                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='chk_regs' LIMIT 1");
459
460                                 // Update notes (these will be set as task text!)
461                                 setExtensionUpdateNotes("&Uuml;berfl&uuml;ssiges Men&uuml; <strong>chk_regs</strong> entfernt, dies kann mit <strong>list_user</strong> &uuml;bernommen werden.");
462                                 break;
463
464                         case '0.4.3': // SQL queries for v0.4.3
465                                 // Add special fix include to fix filters
466                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `refid` `refid` BIGINT(20) NULL DEFAULT NULL");
467
468                                 // Update notes (these will be set as task text!)
469                                 setExtensionUpdateNotes("&Uuml;berfl&uuml;ssiges Men&uuml; <strong>chk_regs</strong> entfernt, dies kann mit <strong>list_user</strong> &uuml;bernommen werden.");
470                                 break;
471
472                         case '0.4.4': // SQL queries for v0.4.4
473                                 addDropTableSql('user_refs');
474                                 addCreateTableSql('user_refs', "
475 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
476 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
477 `level` smallINT(6) UNSIGNED NOT NULL DEFAULT 0,
478 `refid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
479 PRIMARY KEY (`id`),
480 UNIQUE `user_refid` (`userid`,`level`,`refid`),
481 INDEX (`level`),
482 INDEX (`refid`)",
483                                         'User referrals');
484
485                                 // Load ext-refback's special include to regenerate the referral table
486                                 addIncludeToPool('extension', 'inc/fix_refsystem.php');
487
488                                 // Update notes (these will be set as task text!)
489                                 setExtensionUpdateNotes("Neues Tabellenlayout und verschoben von ext-refback.");
490                                 break;
491
492                         case '0.4.5': // SQL queries for v0.4.5
493                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_links` CHANGE `link_type` `link_type` VARCHAR(255) NOT NULL DEFAULT 'NORMAL'");
494
495                                 // Update notes (these will be set as task text!)
496                                 setExtensionUpdateNotes("Die Spalte <strong>link_type</strong> ist nun kein ENUM mehr, um weitere Mailtypen zu erlauben.");
497                                 break;
498
499                         case '0.4.6': // SQL queries for v0.4.6
500                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='{OPEN_CONFIG}POINTS{CLOSE_CONFIG} gutschreiben' WHERE `what` = 'add_points' LIMIT 1");
501                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='{OPEN_CONFIG}POINTS{CLOSE_CONFIG} abziehen' WHERE `what` = 'sub_points' LIMIT 1");
502                                 addAdminMenuSql('user','sub_points','{OPEN_CONFIG}POINTS{CLOSE_CONFIG} abziehen','Allen oder einem Mitglied {OPEN_CONFIG}POINTS{CLOSE_CONFIG} abziehen.', 8);
503
504                                 // This update depends on ext-menu update
505                                 addExtensionDependency('menu');
506
507                                 // Update notes (these will be set as task text!)
508                                 setExtensionUpdateNotes("Abzug von {?POINTS?} sollte nun dabei sein und Hinzuf&uuml;gen gefixt (war zu kurze Spalte).");
509                                 break;
510
511                         case '0.4.7': // SQL queries for v0.4.7
512                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `lock_timestamp` `lock_timestamp` TIMESTAMP NULL DEFAULT NULL');
513                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `lock_timestamp`=NULL WHERE `lock_timestamp`='0000-00-00 00:00:00'");
514
515                                 // Update notes (these will be set as task text!)
516                                 setExtensionUpdateNotes("0000-00-00  00:00:00 ist kein Standardwert mehr, NULL ist dies.");
517                                 break;
518
519                         case '0.4.8': // SQL queries for v0.4.8
520                                 // Update notes (these will be set as task text!)
521                                 setExtensionUpdateNotes("Dieses Update ist nicht mehr g&uuml;ltig.");
522                                 break;
523
524                         case '0.4.9': // SQL queries for v0.4.9
525                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `last_module` `last_what` VARCHAR(255) NULL DEFAULT NULL');
526
527                                 // Register filter locked points
528                                 registerFilter(__FILE__, __LINE__, 'get_locked_points', 'LOCKED_USER_POINTS', false, true, isExtensionDryRun());
529
530                                 // Register filter for all column names
531                                 registerFilter(__FILE__, __LINE__, 'get_all_point_columns', 'GET_ALL_USER_POINTS_COLUMN_NAMES', false, true, isExtensionDryRun());
532
533                                 // Update notes (these will be set as task text!)
534                                 setExtensionUpdateNotes("Die Spalte <strong>last_module</strong> ist nach <strong>last_what</strong> umbenannt und hat nun NULL als Ausgangswert und Filter f&uuml;r gesperrtes Guthaben hinzugef&uuml;gt.");
535                                 break;
536
537                         case '0.5.0': // SQL queries for v0.5.0
538                                 // Prefix for all test accounts
539                                 addConfigAddSql('tester_user_maximum', 'INT(5) UNSIGNED ZEROFILL NOT NULL DEFAULT 00999');
540                                 addConfigAddSql('tester_user_gender', "ENUM('M','F') NOT NULL DEFAULT 'M'");
541                                 addConfigAddSql('tester_user_surname_prefix', "VARCHAR(255) NOT NULL DEFAULT 'tester_'");
542                                 addConfigAddSql('tester_user_family', "VARCHAR(255) NOT NULL DEFAULT 'Testbenutzer'");
543                                 addConfigAddSql('tester_user_street_nr', "VARCHAR(255) NOT NULL DEFAULT 'Teststra&szlig;e 123'");
544                                 addConfigAddSql('tester_user_zip', 'INT(6) UNSIGNED NOT NULL DEFAULT 12345');
545                                 addConfigAddSql('tester_user_city', "VARCHAR(255) NOT NULL DEFAULT 'Teststadt'");
546                                 addConfigAddSql('tester_user_email', "VARCHAR(255) NOT NULL DEFAULT '{OPEN_CONFIG}WEBMASTER{CLOSE_CONFIG}'");
547                                 addConfigAddSql('tester_user_default_refid', 'BIGINT(20) NULL DEFAULT NULL');
548                                 addConfigAddSql('tester_user_password', "VARCHAR(255) NOT NULL DEFAULT ''");
549                                 addConfigAddSql('tester_user_check_cat', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
550
551                                 // Admin menu
552                                 addAdminMenuSql('user', 'add_tester_user', 'Testbenutzer anlegen', 'Es k&ouml;nnen hier bis zu 100 Testbenutzer angelegt werden. Diese haben als Vornamen immer den Pr&auml;fix <span class="data">{?tester_user_surname_prefix?}</span> und werden bei Null anfangend bis 99 hochgez&auml;lt.', 1);
553                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='Mitglieder auflisten' WHERE `what`='list_user' LIMIT 1");
554
555                                 // Change 'zip' to INT(6)
556                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` CHANGE `zip` `zip` INT(6) NOT NULL DEFAULT 0');
557
558                                 // Register filter for WHERE/AND exclusion/inclusion statements
559                                 registerFilter(__FILE__, __LINE__, 'user_exclusion_sql', 'TESTER_USER_EXCLUSION_SQL', false, true, isExtensionDryRun());
560                                 registerFilter(__FILE__, __LINE__, 'user_inclusion_sql', 'TESTER_USER_INCLUSION_SQL', false, true, isExtensionDryRun());
561
562                                 // Update notes (these will be set as task text!)
563                                 setExtensionUpdateNotes("Es k&ouml;nnen nun Test-Benutzer angelegt werden. Noch m&uuml;ssen diese &uuml;berall ausgeschlossen werden, damit die Mediadaten nicht unn&ouml;tig verf&auml;lscht werden.");
564                                 break;
565
566                         case '0.5.1': // SQL queries for v0.5.1
567                                 // Register a filter
568                                 registerFilter(__FILE__, __LINE__, 'pre_user_registration', 'TESTER_USER_REGISTRATION_ADD_SQL_COLUMNS', false, true, isExtensionDryRun());
569
570                                 // Update notes (these will be set as task text!)
571                                 setExtensionUpdateNotes("Filter zum Hinzuf&uuml;gen von SQL-Spalten f&uuml;r die Mitgliederanmeldung hinzugef&uuml;gt.");
572                                 break;
573
574                         case '0.5.2': // SQL queries for v0.5.2
575                                 // Register a filter
576                                 registerFilter(__FILE__, __LINE__, 'convert_user_data_columns', 'ADD_USER_DATA_CONVERT_SQL_COLUMNS', false, true, isExtensionDryRun());
577
578                                 // Update notes (these will be set as task text!)
579                                 setExtensionUpdateNotes("Filter zum Hinzuf&uuml;gen von SQL-Spalten f&uuml;r die Mitgliederanmeldung hinzugef&uuml;gt.");
580                                 break;
581
582                         case '0.5.3': // SQL queries for v0.5.3
583                                 // Register filter
584                                 registerFilter(__FILE__, __LINE__, 'post_refid_validation', 'HANDLE_USER_SUBID', false, true, isExtensionDryRun());
585                                 registerFilter(__FILE__, __LINE__, 'pre_user_registration', 'SUBID_USER_REGISTRATION_ADD_SQL_COLUMNS', false, true, isExtensionDryRun());
586
587                                 // Admin menu
588                                 addAdminMenuSql('user', 'list_user_subid', 'Sub-Ids', 'Listet alle pro vom Mitglied eingegebenen Sub-Ids und ermittelten Referral-URLs auf.', 7);
589
590                                 // Member menu
591                                 addMemberMenuSql('extras', 'subids', 'Sub-Id Tracking', 4);
592
593                                 // Add table for subids
594                                 addDropTableSql('user_subids');
595                                 addCreateTableSql('user_subids', "
596 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
597 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
598 `subid` VARCHAR(255) NOT NULL DEFAULT '',
599 `subid_added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
600 PRIMARY KEY (`id`),
601 UNIQUE `user_subid` (`userid`, `subid`),
602 INDEX (`subid`)",
603                                         'User sub ids');
604
605                                 // Add table for subid logging
606                                 addDropTableSql('subid_log');
607                                 addCreateTableSql('subid_log', "
608 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
609 `refid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
610 `subid` VARCHAR(255) NOT NULL DEFAULT '',
611 `referral_url` TINYTEXT NOT NULL,
612 `remote_address` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
613 `entry_added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
614 PRIMARY KEY (`id`),
615 INDEX (`refid`),
616 INDEX (`subid`)",
617                                         'Sub id logging');
618
619                                 // For saving used subid in user_data table
620                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `subid` VARCHAR(255) NULL DEFAULT NULL');
621                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD INDEX (`subid`)');
622
623                                 // Configuration entry for purging old subid logs (7 days default)
624                                 addConfigAddSql('user_subid_purge', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 7));
625
626                                 // Update notes (these will be set as task text!)
627                                 setExtensionUpdateNotes("Filter, Datenbanktabelle und Men&uuml;punkte f&uuml;r SubId-Tracking hinzugef&uuml;gt.");
628                                 break;
629
630                         case '0.5.4': // SQL queries for v0.5.4
631                                 // Register filter
632                                 registerFilter(__FILE__, __LINE__, 'update_referral_data', 'GENERIC_UPDATE_USER_REFERRAL', false, true, isExtensionDryRun());
633                                 registerFilter(__FILE__, __LINE__, 'update_referral_data', 'UPDATE_USER_SUBID', false, true, isExtensionDryRun());
634
635                                 // Add user agent
636                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_subid_log` ADD `user_agent` TINYTEXT NOT NULL AFTER `remote_address`');
637
638                                 // Update notes (these will be set as task text!)
639                                 setExtensionUpdateNotes("Weitere Filter f&uuml;r Referral-Counter und Sub-Id hinzugef&uuml;gt.");
640                                 break;
641
642                         case '0.5.5': // SQL queries for v0.5.5
643                                 // Register filter
644                                 registerFilter(__FILE__, __LINE__, 'member_admin_actions', 'ADD_USER_SUBID_MEMBER_ACTION', false, true, isExtensionDryRun());
645
646                                 // Update notes (these will be set as task text!)
647                                 setExtensionUpdateNotes("Weiteren Filter f&uuml;r Mitglieder-Aktionen im Adminbereich hinzugef&uuml;gt.");
648                                 break;
649                 } // END - switch
650                 break;
651
652         case 'modify': // When the extension got modified
653                 break;
654
655         case 'test': // For testing purposes
656                 break;
657
658         case 'init': // Do stuff when extension is initialized
659                 break;
660
661         default: // Unknown extension mode
662                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
663                 break;
664 } // END - switch
665
666 // [EOF]
667 ?>