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