2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 06/19/2004 *
4 * =================== Last change: 12/26/2004 *
6 * -------------------------------------------------------------------- *
7 * File : ext-rallye.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Referral rallye *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Referral Rallyes starten *
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.3.7');
46 // Version history array (add more with , '0.0.1' and so on)
47 setExtensionVersionHistory(array('0.0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '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'));
49 switch (getExtensionMode()) {
50 case 'register': // Do stuff when installation is running
51 // SQL commands to run
52 addDropTableSql('rallye_data');
53 addCreateTableSql('rallye_data', "
54 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
55 `admin_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
56 `title` VARCHAR(255) NOT NULL DEFAULT '',
57 `descr` LONGTEXT NOT NULL,
58 `template` VARCHAR(255) NOT NULL DEFAULT '',
59 `start_time` VARCHAR(10) NOT NULL DEFAULT 0,
60 `end_time` VARCHAR(10) NOT NULL DEFAULT 0,
61 `auto_add_new_user` ENUM('Y','N') NOT NULL DEFAULT 'Y',
62 `is_active` ENUM('Y','N') NOT NULL DEFAULT 'N',
63 `send_notify` ENUM('Y','N') NOT NULL DEFAULT 'Y',
64 `notified` ENUM('Y','N') NOT NULL DEFAULT 'N',
69 addDropTableSql('rallye_prices');
70 addCreateTableSql('rallye_prices', "
71 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
72 `rallye_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
73 `price_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
74 `points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
75 `info` LONGTEXT NOT NULL,
78 'Prices data for a rallye');
80 addDropTableSql('rallye_users');
81 addCreateTableSql('rallye_users', "
82 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
83 `rallye_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
84 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
85 `refs` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
89 'Rallye->user connection table');
92 addAdminMenuSql('rallye', NULL, 'Rallye-Management','Richten Sie neue Ref-Rallyes ein, die zeitgesteuert anfangen und aufhöhren. Dabei wird alles weitere automatisch geregelt.',9);
93 addAdminMenuSql('rallye','add_rallye','Neue Rallye hinzufügen','Neue Ref-Rallye hinzufügen.',1);
94 // @TODO Fix config_rallye_prices to list_rallye_prices
95 addAdminMenuSql('rallye','config_rallye_prices','Preise einrichten','Richten Sie Preise zu den Rallyes ein.',2);
96 addAdminMenuSql('rallye','list_rallyes','Rallyes verwalten','Alle bestehenden Ref-Rallyes auflisten, bearbeiten, stoppen, löschen usw.',3);
99 addGuestMenuSql('main', 'rallyes', 'Ref-Rallyes', 9);
102 addMemberMenuSql('main', 'rallyes', 'Ref-Rallyes', 9);
105 case 'remove': // Do stuff when removing extension
107 addDropTableSql('rallye_data');
108 addDropTableSql('rallye_prices');
109 addDropTableSql('rallye_users');
112 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='rallye'");
113 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `what`='rallyes' LIMIT 1");
114 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='rallyes' LIMIT 1");
116 // Remove points_data entry
117 unregisterExtensionPointsData('rallye_winner');
120 unregisterFilter(__FILE__, __LINE__, 'extra_autopurge', 'RALLYE_EXTRA_AUTOPURGE', TRUE, isExtensionDryRun());
121 unregisterFilter(__FILE__, __LINE__, 'init', 'RALLYE_NOTIFY_USERS', TRUE, isExtensionDryRun());
122 unregisterFilter(__FILE__, __LINE__, 'add_rallye_notify_sqls', 'ADD_RALLYE_SQL_COLUMNS', TRUE, isExtensionDryRun());
125 case 'activate': // Do stuff when admin activates this extension
126 // SQL commands to run
127 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y',`locked`='N' WHERE `what`='rallyes' LIMIT 1");
128 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='rallyes' LIMIT 1");
131 case 'deactivate': // Do stuff when admin deactivates this extension
132 // SQL commands to run
133 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='N',`locked`='Y' WHERE `what`='rallyes' LIMIT 1");
134 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N',`locked`='Y' WHERE `what`='rallyes' LIMIT 1");
137 case 'update': // Update an extension
138 switch (getCurrentExtensionVersion()) {
139 case '0.0.1': // SQL queries for v0.0.1
140 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_rallye_data` ADD `expired` ENUM('Y','N') NOT NULL DEFAULT 'N'");
142 // Update notes (these will be set as task text!)
143 setExtensionUpdateNotes("Ablaufen der Rallyes intergriert.");
146 case '0.0.2': // SQL queries for v0.0.2
147 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_rallye_users` ADD `curr_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
149 // Update notes (these will be set as task text!)
150 setExtensionUpdateNotes("Aktueller {?POINTS?}-Stand wird beachtet.");
153 case '0.0.6': // SQL queries for v0.0.6
154 // Update notes (these will be set as task text!)
155 setExtensionUpdateNotes("Fehler <span class=\"notice\">Unknown column 'd.useid' in 'on clause'</span> behoben.");
158 case '0.0.7': // SQL queries for v0.0.7
159 // Update notes (these will be set as task text!)
160 setExtensionUpdateNotes("Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.");
163 case '0.0.8': // SQL queries for v0.0.8
164 // Update notes (these will be set as task text!)
165 setExtensionUpdateNotes("Fehler <u>Template nicht gefunden</u> behoben und Admin-Formulare ausgelagert");
168 case '0.0.9': // SQL queries for v0.0.9
169 // Update notes (these will be set as task text!)
170 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist. Und der vorherige Fehler <u>Template nicht gefunden</u> ist endlich beseitigt.");
173 case '0.1.0': // SQL queries for v0.2.1
174 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_rallye_users` CHANGE `curr_points` `curr_points` FLOAT(23,5) UNSIGNED NOT NULL DEFAULT 0.00000");
176 // Update notes (these will be set as task text!)
177 setExtensionUpdateNotes("5 Nachkommastellen implementiert.");
180 case '0.1.1': // SQL queries for v0.1.1
181 // Update notes (these will be set as task text!)
182 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
185 case '0.1.2': // SQL queries for v0.1.2
186 // Update notes (these will be set as task text!)
187 setExtensionUpdateNotes("Problem mit Speicherung der Einstellungen beseitigt.");
190 case '0.1.3': // SQL queries for v0.1.3
191 // Update notes (these will be set as task text!)
192 setExtensionUpdateNotes("Anzeigefehler im Gast-/Mitgliedsbereich behoben.");
195 case '0.1.4': // SQL queries for v0.1.4
196 // Update notes (these will be set as task text!)
197 setExtensionUpdateNotes("Admin-Mails korregiert.");
200 case '0.1.5': // SQL queries for v0.1.5
201 // Update notes (these will be set as task text!)
202 setExtensionUpdateNotes("Menüpunkte im Gast-/Mitgliedsbereich können nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
205 case '0.1.6': // SQL queries for v0.1.6
206 // Update notes (these will be set as task text!)
207 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> überflüssige HTML-Tags entfernt.");
210 case '0.1.7': // SQL queries for v0.1.7
211 // Update notes (these will be set as task text!)
212 setExtensionUpdateNotes("Aktivierte bzw. abgelaufene Rallyes werden nur ausserhalb des CSS-Modus geladen (wenn also nicht css.php aufgerufen wurde)");
215 case '0.1.8': // SQL queries for v0.1.8
216 // Update notes (these will be set as task text!)
217 setExtensionUpdateNotes("Weitere Templates vom Admin-Bereich ausgelagert und Referral-Anazahl in der Mail zur Rallye-Ankündigung repariert.");
220 case '0.1.9': // SQL queries for v0.1.9
221 // Update notes (these will be set as task text!)
222 setExtensionUpdateNotes("Funktion <u>generateUserProfileLink()</u> mit Verlinkung auf Referral-Liste implementiert.");
225 case '0.2.0': // SQL queries for v0.2.0
226 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_rallye_data` ADD `min_users` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
227 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_rallye_data` ADD `min_prices` BIGINT(20) UNSIGNED NOT NULL DEFAULT 3");
229 // Update notes (these will be set as task text!)
230 setExtensionUpdateNotes("Ablaufen der Rallyes intergriert. Bauen Sie in Ihr Template <strong>templates/de/emails/member/member_rallye_notify.tpl</strong> folgende zwei Zeilen ein:<br />
232 <li>$DATA[min_users]</li>
233 <li>$DATA[min_prices]</li>
235 Zudem sollten Sie mindestens folgende Templates (in <strong>templates/".getLanguage()."/html/guest/</strong> !) aktualisieren:<br />
237 <li><strong>guest_rallye_footer.tpl</strong></li>
238 <li><strong>guest_rallye_header.tpl</strong></li>
242 case '0.2.1': // SQL queries for v0.2.1
243 // Update notes (these will be set as task text!)
244 setExtensionUpdateNotes("Wörter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.");
247 case '0.2.2': // SQL queries for v0.2.2
248 // Update notes (these will be set as task text!)
249 setExtensionUpdateNotes("Links wegen <strong>what=admins_contct</strong> geändert.");
252 case '0.2.3': // SQL queries for v0.2.3
253 // Update notes (these will be set as task text!)
254 setExtensionUpdateNotes("HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.");
257 case '0.2.4': // SQL queries for v0.2.4
258 // Update notes (these will be set as task text!)
259 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
262 case '0.2.5': // SQL queries for v0.2.5
263 // Update notes (these will be set as task text!)
264 setExtensionUpdateNotes("Menüpunkt "Rallyes verwalten" repariert.");
267 case '0.2.6': // SQL queries for v0.2.6
268 // Update notes (these will be set as task text!)
269 setExtensionUpdateNotes("Automatisches Starten von Referral-Rallyes repariert.");
272 case '0.2.7': // SQL queries for v0.2.7
273 // Update notes (these will be set as task text!)
274 setExtensionUpdateNotes("Fatalen Fehler beseitigt.");
277 case '0.2.8': // SQL queries for v0.2.8
278 // Update notes (these will be set as task text!)
280 setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
283 case '0.2.9': // SQL queries for v0.2.9
284 // Update notes (these will be set as task text!)
285 setExtensionUpdateNotes("Sicherheitsupdate für die Include-Befehle.");
288 case '0.3.0': // SQL queries for v0.3.0
289 // Update notes (these will be set as task text!)
290 setExtensionUpdateNotes("if-Anweisungen auf Funktion <strong>empty()</strong> umgestellt.");
293 case '0.3.1': // SQL queries for v0.3.1
294 // Update notes (these will be set as task text!)
295 setExtensionUpdateNotes("Erweiterung für automatisch generierte Admin-Kontaktlinks geändert.");
298 case '0.3.2': // SQL queries for v0.3.2
299 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='rals',`title`='Referral-Rallye',`sort`=1 WHERE `what`='rallyes' LIMIT 1");
301 // Update notes (these will be set as task text!)
302 setExtensionUpdateNotes("Mitgliedsmenü komplett umgebaut.");
305 case '0.3.3': // SQL queries for v0.3.3
306 // Update notes (these will be set as task text!)
307 setExtensionUpdateNotes("Rallyes werden nun nur dann automatisch beseitigt, wenn die Erweiterung <strong>autopurge</strong> installiert und aktiviert ist.");
310 case '0.3.4': // SQL queries for v0.3.4
311 // Update notes (these will be set as task text!)
312 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
315 case '0.3.5': // SQL queries for 0.3.5
316 // This update depends on ext-sql_patches
317 addExtensionDependency('sql_patches');
320 registerFilter(__FILE__, __LINE__, 'extra_autopurge', 'RALLYE_EXTRA_AUTOPURGE', FALSE, TRUE, isExtensionDryRun());
322 // Update notes (these will be set as task text!)
323 setExtensionUpdateNotes("Filter hinzugefügt und ist von <strong>sql_patches</strong> abhängig.");
326 case '0.3.6': // SQL queries for v0.3.6
327 // Register points data
328 registerExtensionPointsData('rallye_winner', 'points', 'LOCKED', 'DIRECT');
330 // This depends on ext-sql_patches
331 addExtensionDependency('sql_patches');
334 setExtensionUpdateNotes("Gewinn aus der Referral-Rallye wird nun über die Tabelle <strong>{OPEN_CONFIG}_MYSQL_PREFIX{CLOSE_CONFIG}_points_data</strong> verwaltet.");
337 case '0.3.7': // SQL queries for v0.3.7
339 registerFilter(__FILE__, __LINE__, 'init', 'RALLYE_NOTIFY_USERS', FALSE, TRUE, isExtensionDryRun());
340 registerFilter(__FILE__, __LINE__, 'add_rallye_notify_sqls', 'ADD_RALLYE_SQL_COLUMNS', FALSE, TRUE, isExtensionDryRun());
343 setExtensionUpdateNotes("Weitere Filter hinzugefügt.");
348 case 'modify': // When the extension got modified
351 case 'test': // For testing purposes
354 case 'init': // Do stuff when extension is initialized
357 default: // Unknown extension mode
358 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));