8a125bf515f60b4231b6fead745bd1618e6fdf8e
[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 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.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.3');
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'));
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(__FUNCTION__, __LINE__, 'get_total_points', 'ORDER_POINTS', true, isExtensionDryRun());
63                 unregisterFilter(__FUNCTION__, __LINE__, 'get_own_points', 'ORDER_POINTS', true, isExtensionDryRun());
64                 break;
65
66         case 'activate': // Do stuff when admin activates this extension
67                 // SQL commands to run
68                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `action`='order'");
69                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `hidden`='N', `locked`='N', `admin_only`='N', `mem_only`='Y' WHERE `module`='order' LIMIT 1");
70                 break;
71
72         case 'deactivate': // Do stuff when admin deactivates this extension
73                 // SQL commands to run
74                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `action`='order'");
75                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `hidden`='Y', `locked`='Y' WHERE `module`='order' LIMIT 1");
76                 break;
77
78         case 'update': // Update an extension
79                 switch (getCurrentExtensionVersion()) {
80                         case '0.1.0': // SQL queries for v0.1
81                                 addConfigAddSql('order_max_full', "ENUM('ORDER','MAX') NOT NULL DEFAULT 'MAX'");
82                                 addAdminMenuSql('setup','config_order','Mailbuchungsseite','Einstellungen am Mailbuchungsformular.',7);
83
84                                 // Update notes (these will be set as task text!)
85                                 setExtensionUpdateNotes("Maximale Mailbuchungen sind nun vom maximalen Empfang abh&auml;gig.");
86                                 break;
87
88                         case '0.1.1': // SQL queries for v0.1.1
89                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD `mail_orders` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
90
91                                 // Update notes (these will be set as task text!)
92                                 setExtensionUpdateNotes("Maximale Mailbuchung vervollst&auml;ndigt (Admin-Bereich und im Buchungsformular selber).");
93                                 break;
94
95                         case '0.1.3': // SQL queries for v0.1.3
96                                 // Update notes (these will be set as task text!)
97                                 setExtensionUpdateNotes("Maximale Mailbuchungen repariert (werden nun hochgez&auml;hlt und bei t&auml;glichem Reset auf 0 gesetzt).");
98                                 break;
99
100                         case '0.1.4': // SQL queries for v0.1.4
101                                 // Update notes (these will be set as task text!)
102                                 setExtensionUpdateNotes("Dummy-Datenfeld wird wieder gel&ouml;scht, um Probleme zu vermeiden. Fehlende Spalte <em>mail_order</em> korregiert auf <em>mail_orders</em>.");
103                                 break;
104
105                         case '0.1.5': // SQL queries for v0.1.5
106                                 // Update notes (these will be set as task text!)
107                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
108                                 break;
109
110                         case '0.1.6': // SQL queries for v0.1.6
111                                 // Update notes (these will be set as task text!)
112                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
113                                 break;
114
115                         case '0.1.7': // SQL queries for v0.1.7
116                                 // Update notes (these will be set as task text!)
117                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
118                                 break;
119
120                         case '0.1.8': // SQL queries for v0.1.8
121                                 // Update notes (these will be set as task text!)
122                                 setExtensionUpdateNotes("Problem mit Speicherung der Einstellungen beseitigt.");
123                                 break;
124
125                         case '0.1.9': // SQL queries for v0.1.9
126                                 // Update notes (these will be set as task text!)
127                                 setExtensionUpdateNotes("Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
128                                 break;
129
130                         case '0.2.0': // SQL queries for v0.2.0
131                                 // Update notes (these will be set as task text!)
132                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
133                                 break;
134
135                         case '0.2.1': // SQL queries for v0.2.1
136                                 // Update notes (these will be set as task text!)
137                                 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.");
138                                 break;
139
140                         case '0.2.2': // SQL queries for v0.2.2
141                                 // Update notes (these will be set as task text!)
142                                 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.");
143                                 break;
144
145                         case '0.2.3': // SQL queries for v0.2.3
146                                 addConfigAddSql('order_min', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 10');
147
148                                 // Update notes (these will be set as task text!)
149                                 setExtensionUpdateNotes("Minimum an Empf&auml;nger pro Mailbuchung einstellbar. Standard: 10 Empf&auml;nger");
150                                 break;
151
152                         case '0.2.4': // SQL queries for v0.2.4
153                                 // Update notes (these will be set as task text!)
154                                 setExtensionUpdateNotes("Anzahl mindestens einszustellende Empf&auml;nger wird nun auch angezeigt.");
155                                 break;
156
157                         case '0.2.5': // SQL queries for v0.2.5
158                                 // Update notes (these will be set as task text!)
159                                 setExtensionUpdateNotes("Speicherung der Einstellungen klappt.");
160                                 break;
161
162                         case '0.2.6': // SQL queries for v0.2.6
163                                 // Update notes (these will be set as task text!)
164                                 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
165 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:
166 <ol>
167   <li>Das Mitglied w&auml;hlt eine Kategorie XYZ mit maximal 15 Empf&auml;ngern aus.</li>
168   <li>Es stellt die Mailart <u>&quot;3 {?POINTS?} Kosten / Mail&quot;</u> ein.</li>
169   <li>Es hat aber nur {?POINTS?} f&uuml;r 10 Empf&auml;nger und gibt 10 ein.</li>
170   <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
171   auf.</li>
172   <li>Hatte es aber, wie hier im Beispiel 31 {?POINTS?}, konnte es nicht mehr buchen.</li>
173   <li>Jetzt ist der Fehler endlich weg! Machen Sie dies bitte Ihren Mitgliedern bekannt.</li>
174 </ol>");
175                                 break;
176
177                         case '0.2.7': // SQL queries for v0.2.7
178                                 // Update notes (these will be set as task text!)
179                                 setExtensionUpdateNotes("Fehler mit <u>__MIN_VALUE</u> behoben.");
180                                 break;
181
182                         case '0.2.8': // SQL queries for v0.2.8
183                                 // Update notes (these will be set as task text!)
184                                 setExtensionUpdateNotes("Konstantenproblem beseitigt.");
185                                 break;
186
187                         case '0.2.9': // SQL queries for v0.2.9
188                                 // Update notes (these will be set as task text!)
189                                 setExtensionUpdateNotes("Problem mit nicht funktionierenden Mailbuchungen beseitigt.");
190                                 break;
191
192                         case '0.3.0': // SQL queries for v0.3.0
193                                 // Update notes (these will be set as task text!)
194                                 setExtensionUpdateNotes("Basis-Modul <strong>order.php</strong> abgesichert, wenn Erweiterung nicht aktiviert ist.");
195                                 break;
196
197                         case '0.3.1': // SQL queries for v0.3.1
198                                 addConfigAddSql('order_select', "VARCHAR(255) NOT NULL DEFAULT 'userid'");
199                                 addConfigAddSql('order_mode', "ENUM('ASC','DESC') NOT NULL DEFAULT 'DESC'");
200
201                                 // Update notes (these will be set as task text!)
202                                 setExtensionUpdateNotes("Beworbene URL wird nun getestet.");
203                                 break;
204
205                         case '0.3.2': // SQL queries for v0.3.2
206                                 // Update notes (these will be set as task text!)
207                                 setExtensionUpdateNotes("Datumsformat festgelegt auf ausf&uuml;hrlich.");
208                                 break;
209
210                         case '0.3.3': // SQL queries for v0.3.3
211                                 // Update notes (these will be set as task text!)
212                                 setExtensionUpdateNotes("Unter <strong>Einstellungen - Mailbuchungsseite</strong> war immer die Tabellenspalte <strong>Mitgliedsnummer</strong> ausgew&auml;hlt.");
213                                 break;
214
215                         case '0.3.4': // SQL queries for v0.3.4
216                                 // Update notes (these will be set as task text!)
217                                 setExtensionUpdateNotes("Dateiamenskonflikt zwischen den Erweiterungen <strong>support</strong> und <strong>order</strong> behoben.");
218                                 break;
219
220                         case '0.3.5': // SQL queries for v0.3.5
221                                 // Update notes (these will be set as task text!)
222                                 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.");
223                                 break;
224
225                         case '0.3.6': // SQL queries for v0.3.6
226                                 // Update notes (these will be set as task text!)
227                                 setExtensionUpdateNotes("Im Modul order (<strong>inc/modules/order.php</strong>) wurde fehlerhafterweise die Erweiterung <strong>beg</strong> getestet.");
228                                 break;
229
230                         case '0.3.7': // SQL queries for v0.3.7
231                                 // Update notes (these will be set as task text!)
232                                 setExtensionUpdateNotes("SQL-Anweisungen mit SQL_QUERY_ESC() abgesichert.");
233                                 break;
234
235                         case '0.3.8': // SQL queries for v0.3.8
236                                 // Update notes (these will be set as task text!)
237                                 setExtensionUpdateNotes("Mailbuchungsseite korregiert.");
238                                 break;
239
240                         case '0.3.9': // SQL queries for v0.3.9
241                                 // Update notes (these will be set as task text!)
242                                 setExtensionUpdateNotes("Erneuten Fehler in Mailbuchungsseite behoben.");
243                                 break;
244
245                         case '0.4.0': // SQL queries for v0.4.0
246                                 // Update notes (these will be set as task text!)
247                                 setExtensionUpdateNotes("{?POINTS?}-Abzug klappt wieder. Danke an Andreman!");
248                                 break;
249
250                         case '0.4.1': // SQL queries for v0.4.1
251                                 // Update notes (these will be set as task text!)
252                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
253                                 break;
254
255                         case '0.4.2': // SQL queries for v0.4.2
256                                 // Update notes (these will be set as task text!)
257                                 setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
258                                 break;
259
260                         case '0.4.3': // SQL queries for v0.4.3
261                                 // Update notes (these will be set as task text!)
262                                 setExtensionUpdateNotes("Neue Urlaubsschaltung mit integriert.");
263                                 break;
264
265                         case '0.4.4': // SQL queries for v0.4.4
266                                 // Update notes (these will be set as task text!)
267                                 setExtensionUpdateNotes("Ein <strong>WHERE &#96;ext_active&#96;='Y'</strong> tauchte bei einigen Betreibern auf und ist mit dieser Version beseitigt.");
268                                 break;
269
270                         case '0.4.5': // SQL queries for v0.4.5
271                                 // Update notes (these will be set as task text!)
272                                 setExtensionUpdateNotes("De-/Aktivieren des mit dieser Erweiterung verkn&uuml;pften Modules eingebunden.");
273                                 break;
274
275                         case '0.4.6': // SQL queries for v0.4.6
276                                 addMemberMenuSql('order', NULL, 'Mailbuchungen', 3);
277                                 addMemberMenuSql('order', 'order2', 'Framekiller-Mails', 2);
278                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='order', `sort`=1, `title`='Klick-Mails' WHERE `what`='order' LIMIT 1");
279
280                                 // Update notes (these will be set as task text!)
281                                 setExtensionUpdateNotes("Mitgliedsmen&uuml; komplett umgebaut.");
282                                 break;
283
284                         case '0.4.7': // SQL queries for v0.4.7
285                                 // Update notes (these will be set as task text!)
286                                 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
287                                 break;
288
289                         case '0.4.8': // SQL queries for v0.4.8
290                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `title`='Mailbuchung' WHERE `what`='config_order' LIMIT 1");
291
292                                 // Update notes (these will be set as task text!)
293                                 setExtensionUpdateNotes("Men&uuml;punkt &quot;Mailbuchungsseite&quot; nach &quot;Mailbuchung&quot; umbenannt und weitere Einstellungen aus Sonstige Einstellungen verschoben.");
294                                 break;
295
296                         case '0.4.9': // SQL queries for v0.4.9
297                                 addConfigAddSql('repay_deleted_mails', "ENUM('REPAY','JACKPOT','SHRED') NOT NULL DEFAULT 'REPAY'");
298
299                                 // Update notes (these will be set as task text!)
300                                 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.");
301                                 break;
302
303                         case '0.5.0': // SQL queries for v0.5.0
304                                 addDropTableSql('url_blacklist');
305                                 addCreateTableSql('url_blacklist', "
306 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
307 `url` VARCHAR(255) NOT NULL DEFAULT '',
308 `pool_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
309 `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
310 PRIMARY KEY (`id`),
311 INDEX (`pool_id`)",
312                                         'URL blacklist');
313
314                                 // Update notes (these will be set as task text!)
315                                 setExtensionUpdateNotes("Tabelle f&uuml;r URL-Sperrliste angelegt.");
316                                 break;
317
318                         case '0.5.1': // SQL queries for v0.5.1
319                                 // Update notes (these will be set as task text!)
320                                 setExtensionUpdateNotes("Nicht mehr g&uuml;ltiges Update.");
321                                 break;
322
323                         case '0.5.2': // SQL queries for v0.5.2
324                                 addConfigDropSql('test_text');
325                                 addConfigDropSql('test_subj');
326                                 addConfigAddSql('allow_url_in_text', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
327                                 addConfigAddSql('allow_url_in_subject', "ENUM('Y','N') NOT NULL DEFAULT 'N'");
328
329                                 // Update notes (these will be set as task text!)
330                                 setExtensionUpdateNotes("Inkonsistenz in Konfigurationsnamen korregiert.");
331                                 break;
332
333                         case '0.5.3': // SQL queries for v0.5.3
334                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `order_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
335                                 addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_user_points` ADD `locked_order_points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
336
337                                 // This update depends on ext-user
338                                 addExtensionDependency('user');
339
340                                 // Register filters for gathering points
341                                 registerFilter(__FUNCTION__, __LINE__, 'get_total_points', 'ORDER_POINTS', true, isExtensionDryRun());
342                                 registerFilter(__FUNCTION__, __LINE__, 'get_own_points', 'ORDER_POINTS', true, isExtensionDryRun());
343
344                                 // Update notes (these will be set as task text!)
345                                 setExtensionUpdateNotes("Weiteres {?POINTS?}-Guthabenkonto &quot;Werbeguthaben&quot; hinzugef&uuml;gt (verschoben von ext-user) und neue Filter zum Zur&uuml;ckliefern des Werbeguthabens hinzugef&uuml;gt.");
346                                 break;
347                 } // END - switch
348                 break;
349
350         case 'modify': // When the extension got modified
351                 break;
352
353         case 'test': // For testing purposes
354                 break;
355
356         case 'init': // Do stuff when extension is initialized
357                 // Do daily reset only when installed and extension version is at least 0.1.1
358                 // @TODO This should be moved out to inc/daily/
359                 if ((isResetModeEnabled()) && (isInstalled()) && (isAdminRegistered()) && (isExtensionInstalledAndNewer('order', '0.1.1'))) {
360                         // Reset mail order values
361                         $result_ext = SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `mail_orders`=0 WHERE `mail_orders` > 0', __FILE__, __LINE__);
362                 } // END - if
363                 break;
364
365         case 'init': // Do stuff when extension is initialized
366                 break;
367
368         default: // Unknown extension mode
369                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
370                 break;
371 } // END - switch
372
373 // [EOF]
374 ?>