Updated copyright notice as there are changes in this year
[mailer.git] / inc / extensions / ext-rallye.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/19/2004 *
4  * ===================                          Last change: 12/26/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-rallye.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : Referral rallye                                  *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Referral Rallyes starten                         *
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 - 2013 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.3.8');
45
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', '0.3.8'));
48
49 switch (getExtensionMode()) {
50         case 'setup': // 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',
65 PRIMARY KEY (`id`),
66 INDEX (`admin_id`)",
67                         'Main rallye data');
68
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,
76 PRIMARY KEY (`id`),
77 INDEX (`rallye_id`)",
78                         'Prices data for a rallye');
79
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,
86 PRIMARY KEY (`id`),
87 INDEX (`rallye_id`),
88 INDEX (`userid`)",
89                         'Rallye->user connection table');
90
91                 // Admin menu
92                 addAdminMenuSql('rallye', NULL, 'Rallye-Management','Richten Sie neue Ref-Rallyes ein, die zeitgesteuert anfangen und aufh&ouml;hren. Dabei wird alles weitere automatisch geregelt.',9);
93                 addAdminMenuSql('rallye','add_rallye','Neue Rallye hinzuf&uuml;gen','Neue Ref-Rallye hinzuf&uuml;gen.',1);
94                 addAdminMenuSql('rallye','list_rallye_prices','Preise einrichten','Richten Sie Preise zu den Rallyes ein.',2);
95                 addAdminMenuSql('rallye','list_rallyes','Rallyes verwalten','Alle bestehenden Ref-Rallyes auflisten, bearbeiten, stoppen, l&ouml;schen usw.',3);
96
97                 // Guest menu
98                 addGuestMenuSql('main', 'rallyes', 'Ref-Rallyes', 9);
99
100                 // Member menu
101                 addMemberMenuSql('main', 'rallyes', 'Ref-Rallyes', 9);
102                 break;
103
104         case 'remove': // Do stuff when removing extension
105                 // Drop tables
106                 addDropTableSql('rallye_data');
107                 addDropTableSql('rallye_prices');
108                 addDropTableSql('rallye_users');
109
110                 // Remove menus
111                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='rallye'");
112                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `what`='rallyes' LIMIT 1");
113                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='rallyes' LIMIT 1");
114
115                 // Remove points_data entry
116                 unregisterExtensionPointsData('rallye_winner');
117
118                 // Unregister filter
119                 unregisterFilter(__FILE__, __LINE__, 'extra_autopurge', 'RALLYE_EXTRA_AUTOPURGE', TRUE, isExtensionDryRun());
120                 unregisterFilter(__FILE__, __LINE__, 'init', 'RALLYE_NOTIFY_USERS', TRUE, isExtensionDryRun());
121                 unregisterFilter(__FILE__, __LINE__, 'add_rallye_notify_sqls', 'ADD_RALLYE_SQL_COLUMNS', TRUE, isExtensionDryRun());
122                 break;
123
124         case 'activate': // Do stuff when admin activates this extension
125                 // SQL commands to run
126                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y',`locked`='N' WHERE `what`='rallyes' LIMIT 1");
127                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='rallyes' LIMIT 1");
128                 break;
129
130         case 'deactivate': // Do stuff when admin deactivates this extension
131                 // SQL commands to run
132                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='N',`locked`='Y' WHERE `what`='rallyes' LIMIT 1");
133                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N',`locked`='Y' WHERE `what`='rallyes' LIMIT 1");
134                 break;
135
136         case 'update': // Update an extension
137                 switch (getCurrentExtensionVersion()) {
138                         case '0.0.1': // SQL queries for v0.0.1
139                                 addExtensionAddTableColumnSql('rallye_data', 'expired', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
140
141                                 // Update notes (these will be set as task text!)
142                                 setExtensionUpdateNotes("Ablaufen der Rallyes intergriert.");
143                                 break;
144
145                         case '0.0.2': // SQL queries for v0.0.2
146                                 addExtensionAddTableColumnSql('rallye_users', 'curr_points', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
147
148                                 // Update notes (these will be set as task text!)
149                                 setExtensionUpdateNotes("Aktueller {?POINTS?}-Stand wird beachtet.");
150                                 break;
151
152                         case '0.0.6': // SQL queries for v0.0.6
153                                 // Update notes (these will be set as task text!)
154                                 setExtensionUpdateNotes("Fehler <span class=\"notice\">Unknown column 'd.useid' in 'on clause'</span> behoben.");
155                                 break;
156
157                         case '0.0.7': // SQL queries for v0.0.7
158                                 // Update notes (these will be set as task text!)
159                                 setExtensionUpdateNotes("Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.");
160                                 break;
161
162                         case '0.0.8': // SQL queries for v0.0.8
163                                 // Update notes (these will be set as task text!)
164                                 setExtensionUpdateNotes("Fehler <u>Template nicht gefunden</u> behoben und Admin-Formulare ausgelagert");
165                                 break;
166
167                         case '0.0.9': // SQL queries for v0.0.9
168                                 // Update notes (these will be set as task text!)
169                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist. Und der vorherige Fehler <u>Template nicht gefunden</u> ist endlich beseitigt.");
170                                 break;
171
172                         case '0.1.0': // SQL queries for v0.2.1
173                                 addExtensionChangeTableColumnSql('rallye_users', 'curr_points', 'curr_points', 'FLOAT(23,5) UNSIGNED NOT NULL DEFAULT 0.00000');
174
175                                 // Update notes (these will be set as task text!)
176                                 setExtensionUpdateNotes("5 Nachkommastellen implementiert.");
177                                 break;
178
179                         case '0.1.1': // SQL queries for v0.1.1
180                                 // Update notes (these will be set as task text!)
181                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
182                                 break;
183
184                         case '0.1.2': // SQL queries for v0.1.2
185                                 // Update notes (these will be set as task text!)
186                                 setExtensionUpdateNotes("Problem mit Speicherung der Einstellungen beseitigt.");
187                                 break;
188
189                         case '0.1.3': // SQL queries for v0.1.3
190                                 // Update notes (these will be set as task text!)
191                                 setExtensionUpdateNotes("Anzeigefehler im Gast-/Mitgliedsbereich behoben.");
192                                 break;
193
194                         case '0.1.4': // SQL queries for v0.1.4
195                                 // Update notes (these will be set as task text!)
196                                 setExtensionUpdateNotes("Admin-Mails korregiert.");
197                                 break;
198
199                         case '0.1.5': // SQL queries for v0.1.5
200                                 // Update notes (these will be set as task text!)
201                                 setExtensionUpdateNotes("Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
202                                 break;
203
204                         case '0.1.6': // SQL queries for v0.1.6
205                                 // Update notes (these will be set as task text!)
206                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
207                                 break;
208
209                         case '0.1.7': // SQL queries for v0.1.7
210                                 // Update notes (these will be set as task text!)
211                                 setExtensionUpdateNotes("Aktivierte bzw. abgelaufene Rallyes werden nur ausserhalb des CSS-Modus geladen (wenn also nicht css.php aufgerufen wurde)");
212                                 break;
213
214                         case '0.1.8': // SQL queries for v0.1.8
215                                 // Update notes (these will be set as task text!)
216                                 setExtensionUpdateNotes("Weitere Templates vom Admin-Bereich ausgelagert und Referral-Anazahl in der Mail zur Rallye-Ank&uuml;ndigung repariert.");
217                                 break;
218
219                         case '0.1.9': // SQL queries for v0.1.9
220                                 // Update notes (these will be set as task text!)
221                                 setExtensionUpdateNotes("Funktion <u>generateUserProfileLink()</u> mit Verlinkung auf Referral-Liste implementiert.");
222                                 break;
223
224                         case '0.2.0': // SQL queries for v0.2.0
225                                 addExtensionAddTableColumnSql('rallye_data', 'min_users', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 0');
226                                 addExtensionAddTableColumnSql('rallye_data', 'min_prices', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 3');
227
228                                 // Update notes (these will be set as task text!)
229                                 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 />
230 <ul>
231   <li>&#36;DATA&#91;min_users&#93;</li>
232   <li>&#36;DATA&#91;min_prices&#93;</li>
233 </ul>
234 Zudem sollten Sie mindestens folgende Templates (in <strong>templates/".getLanguage()."/html/guest/</strong> !) aktualisieren:<br />
235 <ul>
236   <li><strong>guest_rallye_footer.tpl</strong></li>
237   <li><strong>guest_rallye_header.tpl</strong></li>
238 </ul>");
239                                 break;
240
241                         case '0.2.1': // SQL queries for v0.2.1
242                                 // Update notes (these will be set as task text!)
243                                 setExtensionUpdateNotes("W&ouml;rter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.");
244                                 break;
245
246                         case '0.2.2': // SQL queries for v0.2.2
247                                 // Update notes (these will be set as task text!)
248                                 setExtensionUpdateNotes("Links wegen <strong>what=admins_contct</strong> ge&auml;ndert.");
249                                 break;
250
251                         case '0.2.3': // SQL queries for v0.2.3
252                                 // Update notes (these will be set as task text!)
253                                 setExtensionUpdateNotes("HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.");
254                                 break;
255
256                         case '0.2.4': // SQL queries for v0.2.4
257                                 // Update notes (these will be set as task text!)
258                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
259                                 break;
260
261                         case '0.2.5': // SQL queries for v0.2.5
262                                 // Update notes (these will be set as task text!)
263                                 setExtensionUpdateNotes("Men&uuml;punkt &quot;Rallyes verwalten&quot; repariert.");
264                                 break;
265
266                         case '0.2.6': // SQL queries for v0.2.6
267                                 // Update notes (these will be set as task text!)
268                                 setExtensionUpdateNotes("Automatisches Starten von Referral-Rallyes repariert.");
269                                 break;
270
271                         case '0.2.7': // SQL queries for v0.2.7
272                                 // Update notes (these will be set as task text!)
273                                 setExtensionUpdateNotes("Fatalen Fehler beseitigt.");
274                                 break;
275
276                         case '0.2.8': // SQL queries for v0.2.8
277                                 // Update notes (these will be set as task text!)
278
279                                 setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
280                                 break;
281
282                         case '0.2.9': // SQL queries for v0.2.9
283                                 // Update notes (these will be set as task text!)
284                                 setExtensionUpdateNotes("Sicherheitsupdate f&uuml;r die Include-Befehle.");
285                                 break;
286
287                         case '0.3.0': // SQL queries for v0.3.0
288                                 // Update notes (these will be set as task text!)
289                                 setExtensionUpdateNotes("if-Anweisungen auf Funktion <strong>empty()</strong> umgestellt.");
290                                 break;
291
292                         case '0.3.1': // SQL queries for v0.3.1
293                                 // Update notes (these will be set as task text!)
294                                 setExtensionUpdateNotes("Erweiterung f&uuml;r automatisch generierte Admin-Kontaktlinks ge&auml;ndert.");
295                                 break;
296
297                         case '0.3.2': // SQL queries for v0.3.2
298                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='rals',`title`='Referral-Rallye',`sort`=1 WHERE `what`='rallyes' LIMIT 1");
299
300                                 // Update notes (these will be set as task text!)
301                                 setExtensionUpdateNotes("Mitgliedsmen&uuml; komplett umgebaut.");
302                                 break;
303
304                         case '0.3.3': // SQL queries for v0.3.3
305                                 // Update notes (these will be set as task text!)
306                                 setExtensionUpdateNotes("Rallyes werden nun nur dann automatisch beseitigt, wenn die Erweiterung <strong>autopurge</strong> installiert und aktiviert ist.");
307                                 break;
308
309                         case '0.3.4': // SQL queries for v0.3.4
310                                 // Update notes (these will be set as task text!)
311                                 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
312                                 break;
313
314                         case '0.3.5': // SQL queries for 0.3.5
315                                 // Register filter
316                                 registerFilter(__FILE__, __LINE__, 'extra_autopurge', 'RALLYE_EXTRA_AUTOPURGE', FALSE, TRUE, isExtensionDryRun());
317
318                                 // Update notes (these will be set as task text!)
319                                 setExtensionUpdateNotes("Filter hinzugef&uuml;gt und ist von <strong>sql_patches</strong> abh&auml;ngig.");
320                                 break;
321
322                         case '0.3.6': // SQL queries for v0.3.6
323                                 // Register points data
324                                 registerExtensionPointsData('rallye_winner', 'points', 'LOCKED', 'DIRECT');
325
326                                 // Update notes
327                                 setExtensionUpdateNotes("Gewinn aus der Referral-Rallye wird nun &uuml;ber die Tabelle <strong>{OPEN_CONFIG}_MYSQL_PREFIX{CLOSE_CONFIG}_points_data</strong> verwaltet.");
328                                 break;
329
330                         case '0.3.7': // SQL queries for v0.3.7
331                                 // Register filter
332                                 registerFilter(__FILE__, __LINE__, 'init', 'RALLYE_NOTIFY_USERS', FALSE, TRUE, isExtensionDryRun());
333                                 registerFilter(__FILE__, __LINE__, 'add_rallye_notify_sqls', 'ADD_RALLYE_SQL_COLUMNS', FALSE, TRUE, isExtensionDryRun());
334
335                                 // Update notes
336                                 setExtensionUpdateNotes("Weitere Filter hinzugef&uuml;gt.");
337                                 break;
338
339                         case '0.3.8': // SQL queries for v0.3.8
340                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `what`='list_rallye_prices' WHERE `action`='rallye' AND `what`='config_rallye_prices' LIMIT 1");
341
342                                 // Update notes
343                                 setExtensionUpdateNotes("Men&uuml; umbenannt, da &quot;config&quot; nur f&uuml;r die Konfigurationstabelle <strong>{?_MYSQL_PREFIX?}_config</strong> ist.");
344                                 break;
345                 } // END - switch
346                 break;
347
348         case 'modify': // When the extension got modified
349                 break;
350
351         case 'test': // For testing purposes
352                 break;
353
354         case 'init': // Do stuff when extension is initialized
355                 break;
356
357         default: // Unknown extension mode
358                 reportBug(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
359                 break;
360 } // END - switch
361
362 // [EOF]
363 ?>