Code style changed, ext-user continued:
[mailer.git] / inc / extensions / ext-order.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 04/29/2004 *
4  * ===================                          Last change: 11/14/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-order.php                                    *
8  * -------------------------------------------------------------------- *
9  * Short description : Swapped out order system for PRO version         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Ausgelagertes Buchungssytem fuer PRO-Version     *
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.6');
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', '0.5.6'));
48
49 switch (getExtensionMode()) {
50         case 'register': // Do stuff when installation is running
51                 // SQL commands to run
52                 addMemberMenuSql('order', 'order', 'Mailbuchung', 1);
53                 break;
54
55         case 'remove': // Do stuff when removing extension
56                 // SQL commands to run
57                 addDropTableSql('url_blacklist');
58                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='config_order' LIMIT 1");
59                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='order'");
60
61                 // Remove these filters
62                 unregisterFilter(__FILE__, __LINE__, 'get_total_points', 'ORDER_POINTS', TRUE, isExtensionDryRun());
63                 unregisterFilter(__FILE__, __LINE__, 'get_own_points', 'ORDER_POINTS', TRUE, isExtensionDryRun());
64                 unregisterFilter(__FILE__, __LINE__, 'get_locked_points', 'LOCKED_ORDER_POINTS', TRUE, isExtensionDryRun());
65                 unregisterFilter(__FILE__, __LINE__, 'get_all_point_columns', 'GET_ALL_ORDER_POINTS_COLUMN_NAMES', TRUE, isExtensionDryRun());
66                 unregisterFilter(__FILE__, __LINE__, 'user_exclusion_sql', 'ORDER_ZIP_CODE_SQL', TRUE, isExtensionDryRun());
67                 unregisterFilter(__FILE__, __LINE__, 'locked_points_columns_array', 'ORDER_POINTS_COLUMNS', TRUE, isExtensionDryRun());
68                 break;
69
70         case 'activate': // Do stuff when admin activates this extension
71                 // SQL commands to run
72                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `action`='order'");
73                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `hidden`='N',`locked`='N',`admin_only`='N',`mem_only`='Y' WHERE `module`='order' LIMIT 1");
74                 break;
75
76         case 'deactivate': // Do stuff when admin deactivates this extension
77                 // SQL commands to run
78                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N',`locked`='Y' WHERE `action`='order'");
79                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `hidden`='Y',`locked`='Y' WHERE `module`='order' LIMIT 1");
80                 break;
81
82         case 'update': // Update an extension
83                 switch (getCurrentExtensionVersion()) {
84                         case '0.1.0': // SQL queries for v0.1
85                                 addConfigAddSql('order_max_full', "ENUM('ORDER','MAX') NOT NULL DEFAULT 'MAX'");
86                                 addAdminMenuSql('setup','config_order','Mailbuchungsseite','Einstellungen am Mailbuchungsformular.',7);
87
88                                 // Update notes (these will be set as task text!)
89                                 setExtensionUpdateNotes("Maximale Mailbuchungen sind nun vom maximalen Empfang abh&auml;gig.");
90                                 break;
91
92                         case '0.1.1': // SQL queries for v0.1.1
93                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `mail_orders` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
94
95                                 // Update notes (these will be set as task text!)
96                                 setExtensionUpdateNotes("Maximale Mailbuchung vervollst&auml;ndigt (Admin-Bereich und im Buchungsformular selber).");
97                                 break;
98
99                         case '0.1.3': // SQL queries for v0.1.3
100                                 // Update notes (these will be set as task text!)
101                                 setExtensionUpdateNotes("Maximale Mailbuchungen repariert (werden nun hochgez&auml;hlt und bei t&auml;glichem Reset auf 0 gesetzt).");
102                                 break;
103
104                         case '0.1.4': // SQL queries for v0.1.4
105                                 // Update notes (these will be set as task text!)
106                                 setExtensionUpdateNotes("Dummy-Datenfeld wird wieder gel&ouml;scht, um Probleme zu vermeiden. Fehlende Spalte <span class=\"bad\">mail_order</span> korregiert auf <span class=\"bad\">mail_orders</span>.");
107                                 break;
108
109                         case '0.1.5': // SQL queries for v0.1.5
110                                 // Update notes (these will be set as task text!)
111                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
112                                 break;
113
114                         case '0.1.6': // SQL queries for v0.1.6
115                                 // Update notes (these will be set as task text!)
116                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
117                                 break;
118
119                         case '0.1.7': // SQL queries for v0.1.7
120                                 // Update notes (these will be set as task text!)
121                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
122                                 break;
123
124                         case '0.1.8': // SQL queries for v0.1.8
125                                 // Update notes (these will be set as task text!)
126                                 setExtensionUpdateNotes("Problem mit Speicherung der Einstellungen beseitigt.");
127                                 break;
128
129                         case '0.1.9': // SQL queries for v0.1.9
130                                 // Update notes (these will be set as task text!)
131                                 setExtensionUpdateNotes("Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
132                                 break;
133
134                         case '0.2.0': // SQL queries for v0.2.0
135                                 // Update notes (these will be set as task text!)
136                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
137                                 break;
138
139                         case '0.2.1': // SQL queries for v0.2.1
140                                 // Update notes (these will be set as task text!)
141                                 setExtensionUpdateNotes("Templates <u>member_frameset-back.tpl</u> und <u>member_frameset-send.tpl</u> nach <u>member_order_back.tpl</u> und <u>member_order_send.tpl</u> umbenannt.");
142                                 break;
143
144                         case '0.2.2': // SQL queries for v0.2.2
145                                 // Update notes (these will be set as task text!)
146                                 setExtensionUpdateNotes("Es wird nun &uuml;berpr&uuml;ft ob auch gen&uuml;gend Empf&auml;nger eingegeben worden sind und ob auch gen&uuml;gend empfangsbereit sind.");
147                                 break;
148
149                         case '0.2.3': // SQL queries for v0.2.3
150                                 addConfigAddSql('order_min', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 10');
151
152                                 // Update notes (these will be set as task text!)
153                                 setExtensionUpdateNotes("Minimum an Empf&auml;nger pro Mailbuchung einstellbar. Standard: 10 Empf&auml;nger");
154                                 break;
155
156                         case '0.2.4': // SQL queries for v0.2.4
157                                 // Update notes (these will be set as task text!)
158                                 setExtensionUpdateNotes("Anzahl mindestens einszustellende Empf&auml;nger wird nun auch angezeigt.");
159                                 break;
160
161                         case '0.2.5': // SQL queries for v0.2.5
162                                 // Update notes (these will be set as task text!)
163                                 setExtensionUpdateNotes("Speicherung der Einstellungen klappt.");
164                                 break;
165
166                         case '0.2.6': // SQL queries for v0.2.6
167                                 // Update notes (these will be set as task text!)
168                                 setExtensionUpdateNotes("Fehler in Mailbuchung behoben: Es wurde beim Ermitteln der n&ouml;tigen {?POINTS?} die maximale Anzahl von Usern in der Kategorie gew&auml;hlt und
169 nicht die vom Mitglied eingegebene. Resultat: Das Script beschwerte sich, der User h&auml;tte nicht gen&uuml;gend {?POINTS?} auf dem Konto. Ein Rechenbeispiel:
170 <ol>
171   <li>Das Mitglied w&auml;hlt eine Kategorie XYZ mit maximal 15 Empf&auml;ngern aus.</li>
172   <li>Es stellt die Mailart <u>&quot;3 {?POINTS?} Kosten / Mail&quot;</u> ein.</li>
173   <li>Es hat aber nur {?POINTS?} f&uuml;r 10 Empf&auml;nger und gibt 10 ein.</li>
174   <li>Das Script hatte bis zu dieser Version 3 {?POINTS?} * <u>15</u> = 45 {?POINTS?} gerechnet, hat das Mitglied mehr oder gleich 45 {?POINTS?}, fiehl dieser Fehler nicht
175   auf.</li>
176   <li>Hatte es aber, wie hier im Beispiel 31 {?POINTS?}, konnte es nicht mehr buchen.</li>
177   <li>Jetzt ist der Fehler endlich weg! Machen Sie dies bitte Ihren Mitgliedern bekannt.</li>
178 </ol>");
179                                 break;
180
181                         case '0.2.7': // SQL queries for v0.2.7
182                                 // Update notes (these will be set as task text!)
183                                 setExtensionUpdateNotes("Fehler mit <u>__MIN_VALUE</u> behoben.");
184                                 break;
185
186                         case '0.2.8': // SQL queries for v0.2.8
187                                 // Update notes (these will be set as task text!)
188                                 setExtensionUpdateNotes("Konstantenproblem beseitigt.");
189                                 break;
190
191                         case '0.2.9': // SQL queries for v0.2.9
192                                 // Update notes (these will be set as task text!)
193                                 setExtensionUpdateNotes("Problem mit nicht funktionierenden Mailbuchungen beseitigt.");
194                                 break;
195
196                         case '0.3.0': // SQL queries for v0.3.0
197                                 // Update notes (these will be set as task text!)
198                                 setExtensionUpdateNotes("Basis-Modul <strong>order.php</strong> abgesichert, wenn Erweiterung nicht aktiviert ist.");
199                                 break;
200
201                         case '0.3.1': // SQL queries for v0.3.1
202                                 addConfigAddSql('order_select', "VARCHAR(255) NOT NULL DEFAULT 'userid'");
203                                 addConfigAddSql('order_mode', "ENUM('ASC','DESC') NOT NULL DEFAULT 'DESC'");
204
205                                 // Update notes (these will be set as task text!)
206                                 setExtensionUpdateNotes("Beworbene URL wird nun getestet.");
207                                 break;
208
209                         case '0.3.2': // SQL queries for v0.3.2
210                                 // Update notes (these will be set as task text!)
211                                 setExtensionUpdateNotes("Datumsformat festgelegt auf ausf&uuml;hrlich.");
212                                 break;
213
214                         case '0.3.3': // SQL queries for v0.3.3
215                                 // Update notes (these will be set as task text!)
216                                 setExtensionUpdateNotes("Unter <strong>Einstellungen - Mailbuchungsseite</strong> war immer die Tabellenspalte <strong>Mitgliedsnummer</strong> ausgew&auml;hlt.");
217                                 break;
218
219                         case '0.3.4': // SQL queries for v0.3.4
220                                 // Update notes (these will be set as task text!)
221                                 setExtensionUpdateNotes("Dateiamenskonflikt zwischen den Erweiterungen <strong>support</strong> und <strong>order</strong> behoben.");
222                                 break;
223
224                         case '0.3.5': // SQL queries for v0.3.5
225                                 // Update notes (these will be set as task text!)
226                                 setExtensionUpdateNotes("Das Mitglied konnte geziehlt die Anzahl Mailbuchungen durch Abspeichern seines Profiles beeinflussen. Der Fehler war eine falsche Tabellenspalte. Dies war <strong>max_mails</strong>, die durch das Mitglieder ver&auml;nderbar ist und zur Festellung der Maximalen Mailbuchungen herangezogen wurde.");
227                                 break;
228
229                         case '0.3.6': // SQL queries for v0.3.6
230                                 // Update notes (these will be set as task text!)
231                                 setExtensionUpdateNotes("Im Modul order (<strong>inc/modules/order.php</strong>) wurde fehlerhafterweise die Erweiterung <strong>beg</strong> getestet.");
232                                 break;
233
234                         case '0.3.7': // SQL queries for v0.3.7
235                                 // Update notes (these will be set as task text!)
236                                 setExtensionUpdateNotes("SQL-Anweisungen mit SQL_QUERY_ESC() abgesichert.");
237                                 break;
238
239                         case '0.3.8': // SQL queries for v0.3.8
240                                 // Update notes (these will be set as task text!)
241                                 setExtensionUpdateNotes("Mailbuchungsseite korregiert.");
242                                 break;
243
244                         case '0.3.9': // SQL queries for v0.3.9
245                                 // Update notes (these will be set as task text!)
246                                 setExtensionUpdateNotes("Erneuten Fehler in Mailbuchungsseite behoben.");
247                                 break;
248
249                         case '0.4.0': // SQL queries for v0.4.0
250                                 // Update notes (these will be set as task text!)
251                                 setExtensionUpdateNotes("{?POINTS?}-Abzug klappt wieder. Danke an Andreman!");
252                                 break;
253
254                         case '0.4.1': // SQL queries for v0.4.1
255                                 // Update notes (these will be set as task text!)
256                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
257                                 break;
258
259                         case '0.4.2': // SQL queries for v0.4.2
260                                 // Update notes (these will be set as task text!)
261                                 setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
262                                 break;
263
264                         case '0.4.3': // SQL queries for v0.4.3
265                                 // Update notes (these will be set as task text!)
266                                 setExtensionUpdateNotes("Neue Urlaubsschaltung mit integriert.");
267                                 break;
268
269                         case '0.4.4': // SQL queries for v0.4.4
270                                 // Update notes (these will be set as task text!)
271                                 setExtensionUpdateNotes("Ein <strong>WHERE &#96;ext_active&#96;='Y'</strong> tauchte bei einigen Betreibern auf und ist mit dieser Version beseitigt.");
272                                 break;
273
274                         case '0.4.5': // SQL queries for v0.4.5
275                                 // Update notes (these will be set as task text!)
276                                 setExtensionUpdateNotes("De-/Aktivieren des mit dieser Erweiterung verkn&uuml;pften Modules eingebunden.");
277                                 break;
278
279                         case '0.4.6': // SQL queries for v0.4.6
280                                 addMemberMenuSql('order', NULL, 'Mailbuchungen', 3);
281                                 addMemberMenuSql('order', 'order2', 'Framekiller-Mails', 2);
282                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='order',`title`='Klick-Mails',`sort`=1 WHERE `what`='order' LIMIT 1");
283
284                                 // Update notes (these will be set as task text!)
285                                 setExtensionUpdateNotes("Mitgliedsmen&uuml; komplett umgebaut.");
286                                 break;
287
288                         case '0.4.7': // SQL queries for v0.4.7
289                                 // Update notes (these will be set as task text!)
290                                 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
291                                 break;
292
293                         case '0.4.8': // SQL queries for v0.4.8
294                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='Mailbuchung' WHERE `what`='config_order' LIMIT 1");
295
296                                 // Update notes (these will be set as task text!)
297                                 setExtensionUpdateNotes("Men&uuml;punkt &quot;Mailbuchungsseite&quot; nach &quot;Mailbuchung&quot; umbenannt und weitere Einstellungen aus Sonstige Einstellungen verschoben.");
298                                 break;
299
300                         case '0.4.9': // SQL queries for v0.4.9
301                                 addConfigAddSql('repay_deleted_mails', "ENUM('REPAY','JACKPOT','SHRED') NOT NULL DEFAULT 'REPAY'");
302
303                                 // Update notes (these will be set as task text!)
304                                 setExtensionUpdateNotes("Bei L&ouml;schung von Mailbuchungen kann nun scripteweit entschieden werden (Einstellungen also), ob die verbliebenen {?POINTS?} wieder gutgeschrieben werden sollen oder in den Jackpot landen.");
305                                 break;
306
307                         case '0.5.0': // SQL queries for v0.5.0
308                                 addDropTableSql('url_blacklist');
309                                 addCreateTableSql('url_blacklist', "
310 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
311 `url` VARCHAR(255) NOT NULL DEFAULT '',
312 `pool_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
313 `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
314 PRIMARY KEY (`id`),
315 INDEX (`pool_id`)",
316                                         'URL blacklist');
317
318                                 // Update notes (these will be set as task text!)
319                                 setExtensionUpdateNotes("Tabelle f&uuml;r URL-Sperrliste angelegt.");
320                                 break;
321
322                         case '0.5.1': // SQL queries for v0.5.1
323                                 // Update notes (these will be set as task text!)
324                                 setExtensionUpdateNotes("Nicht mehr g&uuml;ltiges Update.");
325                                 break;
326
327                         case '0.5.2': // SQL queries for v0.5.2
328                                 addConfigDropSql('test_text');
329                                 addConfigDropSql('test_subj');
330                                 addConfigAddSql('allow_url_in_text', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
331                                 addConfigAddSql('allow_url_in_subject', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
332
333                                 // Update notes (these will be set as task text!)
334                                 setExtensionUpdateNotes("Inkonsistenz in Konfigurationsnamen korregiert.");
335                                 break;
336
337                         case '0.5.3': // SQL queries for v0.5.3
338                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `order_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
339                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `locked_order_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
340
341                                 // This update depends on ext-user
342                                 addExtensionDependency('user');
343
344                                 // Register filters for gathering points
345                                 registerFilter(__FILE__, __LINE__, 'get_total_points', 'ORDER_POINTS', FALSE, TRUE, isExtensionDryRun());
346                                 registerFilter(__FILE__, __LINE__, 'get_own_points', 'ORDER_POINTS', FALSE, TRUE, isExtensionDryRun());
347
348                                 // Update notes (these will be set as task text!)
349                                 setExtensionUpdateNotes("Weiteres Verwendungszwecke &quot;Werbeguthaben&quot; hinzugef&uuml;gt (verschoben von ext-user) und neue Filter zum Zur&uuml;ckliefern des Werbeguthabens hinzugef&uuml;gt.");
350                                 break;
351
352                         case '0.5.4': // SQL queries for v0.5.4
353                                 // Register filter for handling locked points
354                                 registerFilter(__FILE__, __LINE__, 'get_locked_points', 'LOCKED_ORDER_POINTS', FALSE, TRUE, isExtensionDryRun());
355
356                                 // Register filter for all column names
357                                 registerFilter(__FILE__, __LINE__, 'get_all_point_columns', 'GET_ALL_ORDER_POINTS_COLUMN_NAMES', FALSE, TRUE, isExtensionDryRun());
358
359                                 // Update notes (these will be set as task text!)
360                                 setExtensionUpdateNotes("Filter f&uuml;r gesperrtes Werbeguthaben hinzugef&uuml;gt.");
361                                 break;
362
363                         case '0.5.5': // SQL queries for v0.5.5
364                                 // Register filter
365                                 registerFilter(__FILE__, __LINE__, 'user_exclusion_sql', 'ORDER_ZIP_CODE_SQL', FALSE, TRUE, isExtensionDryRun());
366
367                                 // Update notes (these will be set as task text!)
368                                 setExtensionUpdateNotes("Filter f&uuml;r gesperrtes Werbeguthaben hinzugef&uuml;gt.");
369                                 break;
370
371                         case '0.5.6': // SQL queries for v0.5.6
372                                 // Register filter
373                                 registerFilter(__FILE__, __LINE__, 'locked_points_columns_array', 'ORDER_POINTS_COLUMNS', FALSE, TRUE, isExtensionDryRun());
374
375                                 // Update notes (these will be set as task text!)
376                                 setExtensionUpdateNotes("Filter f&uuml;r Spaltenname des gesperrten Werbeguthabens hinzugef&uuml;gt.");
377                                 break;
378                 } // END - switch
379                 break;
380
381         case 'modify': // When the extension got modified
382                 break;
383
384         case 'test': // For testing purposes
385                 break;
386
387         case 'init': // Do stuff when extension is initialized
388                 break;
389
390         case 'init': // Do stuff when extension is initialized
391                 break;
392
393         default: // Unknown extension mode
394                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
395                 break;
396 } // END - switch
397
398 // [EOF]
399 ?>