Marked some unfinished extensions as 'work-in-progress'
[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  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         die();
43 } // END - if
44
45 // Version number
46 setThisExtensionVersion('0.5.2');
47
48 // Version history array (add more with , '0.1.0' and so on)
49 setExtensionVersionHistory(array('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'));
50
51 switch (getExtensionMode()) {
52         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
53                 // SQL commands to run
54                 addExtensionSql('');
55                 break;
56
57         case 'remove': // Do stuff when removing extension
58                 // SQL commands to run
59                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='config_order' LIMIT 1");
60                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `action`='order'");
61                 break;
62
63         case 'activate': // Do stuff when admin activates this extension
64                 // SQL commands to run
65                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `action`='order'");
66                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `hidden`='N', `locked`='N', `admin_only`='N', `mem_only`='Y' WHERE `module`='order' LIMIT 1");
67                 break;
68
69         case 'deactivate': // Do stuff when admin deactivates this extension
70                 // SQL commands to run
71                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `action`='order'");
72                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `hidden`='Y', `locked`='Y' WHERE `module`='order' LIMIT 1");
73                 break;
74
75         case 'update': // Update an extension
76                 switch (getCurrentExtensionVersion()) {
77                         case '0.1.0': // SQL queries for v0.1
78                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD order_max_full ENUM('ORDER','MAX') NOT NULL DEFAULT 'MAX'");
79                                 addAdminMenuSql('setup','config_order','Mailbuchungsseite','Einstellungen am Mailbuchungsformular.',7);
80
81                                 // Update notes (these will be set as task text!)
82                                 setExtensionUpdateNotes("Maximale Mailbuchungen sind nun vom maximalen Empfang abh&auml;gig.");
83                                 break;
84
85                         case '0.1.1': // SQL queries for v0.1.1
86                                 // OLD QUERIES: addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `what`='config_order' LIMIT 1");
87                                 // OLD QUERIES: addAdminMenuSql('setup','config_order','Mailbuchungsseite','Einstellungen am Mailbuchungsformular.',7);
88                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `mail_orders` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
89
90                                 // Update notes (these will be set as task text!)
91                                 setExtensionUpdateNotes("Maximale Mailbuchung vervollst&auml;ndigt (Admin-Bereich und im Buchungsformular selber).");
92                                 break;
93
94                         case '0.1.3': // SQL queries for v0.1.3
95                                 // Update notes (these will be set as task text!)
96                                 setExtensionUpdateNotes("Maximale Mailbuchungen repariert (werden nun hochgez&auml;hlt und bei t&auml;glichem Reset auf 0 gesetzt).");
97                                 break;
98
99                         case '0.1.4': // SQL queries for v0.1.4
100                                 // Update notes (these will be set as task text!)
101                                 setExtensionUpdateNotes("Dummy-Datenfeld wird wieder gel&ouml;scht, um Probleme zu vermeiden. Fehlende Spalte <em>mail_order</em> korregiert auf <em>mail_orders</em>.");
102                                 break;
103
104                         case '0.1.5': // SQL queries for v0.1.5
105                                 // Update notes (these will be set as task text!)
106                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
107                                 break;
108
109                         case '0.1.6': // SQL queries for v0.1.6
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.7': // SQL queries for v0.1.7
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.8': // SQL queries for v0.1.8
120                                 // Update notes (these will be set as task text!)
121                                 setExtensionUpdateNotes("Problem mit Speicherung der Einstellungen beseitigt.");
122                                 break;
123
124                         case '0.1.9': // SQL queries for v0.1.9
125                                 // Update notes (these will be set as task text!)
126                                 setExtensionUpdateNotes("Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
127                                 break;
128
129                         case '0.2.0': // SQL queries for v0.2.0
130                                 // Update notes (these will be set as task text!)
131                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
132                                 break;
133
134                         case '0.2.1': // SQL queries for v0.2.1
135                                 // Update notes (these will be set as task text!)
136                                 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.");
137                                 break;
138
139                         case '0.2.2': // SQL queries for v0.2.2
140                                 // Update notes (these will be set as task text!)
141                                 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.");
142                                 break;
143
144                         case '0.2.3': // SQL queries for v0.2.3
145                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD order_min BIGINT(20) UNSIGNED NOT NULL DEFAULT 10");
146
147                                 // Update notes (these will be set as task text!)
148                                 setExtensionUpdateNotes("Minimum an Empf&auml;nger pro Mailbuchung einstellbar. Standart: 10 Empf&auml;nger");
149                                 break;
150
151                         case '0.2.4': // SQL queries for v0.2.4
152                                 // Update notes (these will be set as task text!)
153                                 setExtensionUpdateNotes("Anzahl mindestens einszustellende Empf&auml;nger wird nun auch angezeigt.");
154                                 break;
155
156                         case '0.2.5': // SQL queries for v0.2.5
157                                 // Update notes (these will be set as task text!)
158                                 setExtensionUpdateNotes("Speicherung der Einstellungen klappt.");
159                                 break;
160
161                         case '0.2.6': // SQL queries for v0.2.6
162                                 // Update notes (these will be set as task text!)
163                                 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
164 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:
165 <ol>
166   <li>Das Mitglied w&auml;hlt eine Kategorie XYZ mit maximal 15 Empf&auml;ngern aus.</li>
167   <li>Es stellt die Mailart <u>&quot;3 {?POINTS?} Kosten / Mail&quot;</u> ein.</li>
168   <li>Es hat aber nur {?POINTS?} f&uuml;r 10 Empf&auml;nger und gibt 10 ein.</li>
169   <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
170   auf.</li>
171   <li>Hatte es aber, wie hier im Beispiel 31 {?POINTS?}, konnte es nicht mehr buchen.</li>
172   <li>Jetzt ist der Fehler endlich weg! Machen Sie dies bitte Ihren Mitgliedern bekannt.</li>
173 </ol>");
174                                 break;
175
176                         case '0.2.7': // SQL queries for v0.2.7
177                                 // Update notes (these will be set as task text!)
178                                 setExtensionUpdateNotes("Fehler mit <u>__MIN_VALUE</u> behoben.");
179                                 break;
180
181                         case '0.2.8': // SQL queries for v0.2.8
182                                 // Update notes (these will be set as task text!)
183                                 setExtensionUpdateNotes("Konstantenproblem beseitigt.");
184                                 break;
185
186                         case '0.2.9': // SQL queries for v0.2.9
187                                 // Update notes (these will be set as task text!)
188                                 setExtensionUpdateNotes("Problem mit nicht funktionierenden Mailbuchungen beseitigt.");
189                                 break;
190
191                         case '0.3.0': // SQL queries for v0.3.0
192                                 // Update notes (these will be set as task text!)
193                                 setExtensionUpdateNotes("Basis-Modul <strong>order.php</strong> abgesichert, wenn Erweiterung nicht aktiviert ist.");
194                                 break;
195
196                         case '0.3.1': // SQL queries for v0.3.1
197                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD order_select VARCHAR(255) NOT NULL DEFAULT 'userid'");
198                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD order_mode ENUM('ASC','DESC') NOT NULL DEFAULT 'DESC'");
199
200                                 // Update notes (these will be set as task text!)
201                                 setExtensionUpdateNotes("Beworbene URL wird nun getestet.");
202                                 break;
203
204                         case '0.3.2': // SQL queries for v0.3.2
205                                 // Update notes (these will be set as task text!)
206                                 setExtensionUpdateNotes("Datumsformat festgelegt auf ausf&uuml;hrlich.");
207                                 break;
208
209                         case '0.3.3': // SQL queries for v0.3.3
210                                 // Update notes (these will be set as task text!)
211                                 setExtensionUpdateNotes("Unter <strong>Einstellungen - Mailbuchungsseite</strong> war immer die Tabellenspalte <strong>Mitgliedsnummer</strong> ausgew&auml;hlt.");
212                                 break;
213
214                         case '0.3.4': // SQL queries for v0.3.4
215                                 // Update notes (these will be set as task text!)
216                                 setExtensionUpdateNotes("Dateiamenskonflikt zwischen den Erweiterungen <strong>support</strong> und <strong>order</strong> behoben.");
217                                 break;
218
219                         case '0.3.5': // SQL queries for v0.3.5
220                                 // Update notes (these will be set as task text!)
221                                 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.");
222                                 break;
223
224                         case '0.3.6': // SQL queries for v0.3.6
225                                 // Update notes (these will be set as task text!)
226                                 setExtensionUpdateNotes("Im Modul order (<strong>inc/modules/order.php</strong>) wurde fehlerhafterweise die Erweiterung <strong>beg</strong> getestet.");
227                                 break;
228
229                         case '0.3.7': // SQL queries for v0.3.7
230                                 // Update notes (these will be set as task text!)
231                                 setExtensionUpdateNotes("SQL-Anweisungen mit SQL_QUERY_ESC() abgesichert.");
232                                 break;
233
234                         case '0.3.8': // SQL queries for v0.3.8
235                                 // Update notes (these will be set as task text!)
236                                 setExtensionUpdateNotes("Mailbuchungsseite korregiert.");
237                                 break;
238
239                         case '0.3.9': // SQL queries for v0.3.9
240                                 // Update notes (these will be set as task text!)
241                                 setExtensionUpdateNotes("Erneuten Fehler in Mailbuchungsseite behoben.");
242                                 break;
243
244                         case '0.4.0': // SQL queries for v0.4.0
245                                 // Update notes (these will be set as task text!)
246                                 setExtensionUpdateNotes("{?POINTS?}-Abzug klappt wieder. Danke an Andreman!");
247                                 break;
248
249                         case '0.4.1': // SQL queries for v0.4.1
250                                 // Update notes (these will be set as task text!)
251                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
252                                 break;
253
254                         case '0.4.2': // SQL queries for v0.4.2
255                                 // Update notes (these will be set as task text!)
256                                 setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
257                                 break;
258
259                         case '0.4.3': // SQL queries for v0.4.3
260                                 // Update notes (these will be set as task text!)
261                                 setExtensionUpdateNotes("Neue Urlaubsschaltung mit integriert.");
262                                 break;
263
264                         case '0.4.4': // SQL queries for v0.4.4
265                                 // Update notes (these will be set as task text!)
266                                 setExtensionUpdateNotes("Ein <strong>WHERE &#96;ext_active&#96;='Y'</strong> tauchte bei einigen Betreibern auf und ist mit dieser Version beseitigt.");
267                                 break;
268
269                         case '0.4.5': // SQL queries for v0.4.5
270                                 // Update notes (these will be set as task text!)
271                                 setExtensionUpdateNotes("De-/Aktivieren des mit dieser Erweiterung verkn&uuml;pften Modules eingebunden.");
272                                 break;
273
274                         case '0.4.6': // SQL queries for v0.4.6
275                                 addMemberMenuSql('order',NULL,'Mailbuchungen','N','Y',3);
276                                 addMemberMenuSql('order','order2','Framekiller-Mails','N','Y',2);
277                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='order', `sort`=1, `title`='Klick-Mails' WHERE `what`='order' LIMIT 1");
278
279                                 // Update notes (these will be set as task text!)
280                                 setExtensionUpdateNotes("Mitgliedsmen&uuml; komplett umgebaut.");
281                                 break;
282
283                         case '0.4.7': // SQL queries for v0.4.7
284                                 // Update notes (these will be set as task text!)
285                                 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
286                                 break;
287
288                         case '0.4.8': // SQL queries for v0.4.8
289                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='Mailbuchung' WHERE `what`='config_order' LIMIT 1");
290
291                                 // Update notes (these will be set as task text!)
292                                 setExtensionUpdateNotes("Men&uuml;punkt &quot;Mailbuchungsseite&quot; nach &quot;Mailbuchung&quot; umbenannt und weitere Einstellungen aus Sonstige Einstellungen verschoben.");
293                                 break;
294
295                         case '0.4.9': // SQL queries for v0.4.9
296                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD repay_deleted_mails ENUM('REPAY','JACKPOT','SHRED') NOT NULL DEFAULT 'REPAY'");
297
298                                 // Update notes (these will be set as task text!)
299                                 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.");
300                                 break;
301
302                         case '0.5.0': // SQL queries for v0.5.0
303                                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_url_blacklist`");
304                                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_url_blacklist` (
305 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
306 `url` VARCHAR(255) NOT NULL DEFAULT '',
307 `pool_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
308 `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
309 PRIMARY KEY (`id`),
310 INDEX (`pool_id`)
311 ) TYPE={?_TABLE_TYPE?} COMMENT='URL blacklist'");
312
313                                 // Update notes (these will be set as task text!)
314                                 setExtensionUpdateNotes("Tabelle f&uuml;r URL-Sperrliste angelegt.");
315                                 break;
316
317                         case '0.5.1': // SQL queries for v0.5.1
318                                 addMemberMenuSql('main','order','Mailbuchung','N','Y',8);
319
320                                 // Update notes (these will be set as task text!)
321                                 setExtensionUpdateNotes("Weiteren Men&uuml;-Query in Erweiterung verlagert.");
322                                 break;
323
324                         case '0.5.2': // SQL queries for v0.5.2
325                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `test_text`");
326                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` DROP `test_subj`");
327                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `allow_url_in_text` ENUM('Y','N') NOT NULL DEFAULT 'N'");
328                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `allow_url_in_subject` ENUM('Y','N') NOT NULL DEFAULT 'N'");
329
330                                 // Update notes (these will be set as task text!)
331                                 setExtensionUpdateNotes("Inkonsistenz in Konfigurationsnamen korregiert.");
332                                 break;
333                 }
334                 break;
335
336         case 'modify': // When the extension got modified
337                 break;
338
339         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
340                 break;
341
342         case 'init': // Do stuff when extension is initialized
343                 // Do daily reset only when installed and extension version is at least 0.1.1
344                 if ((isResetModeEnabled()) && (isInstalled()) && (isAdminRegistered()) && (getExtensionVersion('order') >= '0.1.1')) {
345                         // Reset mail order values
346                         $result_ext = SQL_QUERY("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET mail_orders=0 WHERE mail_orders > 0", __FILE__, __LINE__);
347                 } // END - if
348                 break;
349
350         case 'init': // Do stuff when extension is initialized
351                 break;
352
353         default: // Unknown extension mode
354                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
355                 break;
356 }
357
358 // [EOF]
359 ?>