Fixes for broken order page and themes
[mailer.git] / inc / extensions / ext-doubler.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 02/03/2005 *
4  * ================                             Last change: 02/03/2005 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-doubler.php                                  *
8  * -------------------------------------------------------------------- *
9  * Short description : Double points                                    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Punkte verdoppeln                                *
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  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 }
43
44 // Version number
45 setThisExtensionVersion('0.1.6');
46
47 // Version history array (add more with , '0.1.0' and so on)
48 setExtensionVersionHistory(array('0.0', '0.0.1', '0.0.2', '0.0.3', '0.0.4', '0.0.5', '0.0.6', '0.0.7', '0.0.8', '0.0.9', '0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.1.4', '0.1.5', '0.1.6'));
49
50 switch (getExtensionMode()) {
51         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
52                 // Doubler table
53                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_doubler`");
54                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_doubler` (
55 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
56 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
57 refid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
58 points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
59 remote_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
60 timemark VARCHAR(10) NOT NULL DEFAULT '',
61 completed ENUM('Y','N') NOT NULL DEFAULT 'N',
62 is_ref ENUM('Y','N') NOT NULL DEFAULT 'N',
63 KEY (refid),
64 KEY (userid),
65 PRIMARY KEY (id)
66 )TYPE=MYISAM");
67
68                 //
69                 // --- SETTINGS ---
70                 //
71                 // Minimum points to double
72                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_min FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 100.00000");
73                 // Maximum points to double
74                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_max FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 10000.00000");
75                 // Points left on users account after doubling
76                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_left BIGINT(20) UNSIGNED NOT NULL DEFAULT 1000");
77                 // Charge for doubling points which goes to the webmaster (shreddered in fact!)
78                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_charge FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.03000");
79                 // Referal percents
80                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_ref FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.02000");
81                 // Shall I use the jackpot to take points from? (Y/N, default=Y)
82                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_jackpot ENUM('Y','N') NOT NULL DEFAULT 'Y'");
83                 // A user account to take points from (default: 0->none)
84                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
85                 // Total payed out points from your doublers
86                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
87                 // Sending mode of mails (immediately/daily reset)
88                 // --> This also means who fast the doubled points will be payed out!
89                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_send_mode ENUM('DIRECT','RESET') NOT NULL DEFAULT 'DIRECT'");
90                 // Timeout for entries to be purged (default: one week)
91                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('ONE_DAY')*7)."");
92                 // Number of newest entries to display
93                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_display_new TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
94                 // Number of entries which will be payed out soon
95                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_display_pay TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
96                 // Number of entries which are already payed out
97                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_display_old TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
98                 // Points used by every member
99                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD doubler_points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
100                 // Counter for usage of the doubler
101                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_counter BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
102
103                 //
104                 // --- MENU SYSTEMS ---
105                 //
106                 // Admin menu
107                 addAdminMenuSql('doubler', NULL, '{?POINTS?}-Verdoppler','Einstellungen und Eintr&auml;ge auflisten.', 4);
108                 addAdminMenuSql('doubler','list_doubler','Auflisten','Eintr&auml;ge aus der Verdiensttabelle auflisten', 1);
109                 addAdminMenuSql('doubler','config_doubler','Einstellungen','Prozentuale Geb&uuml;hr usw. einstellen.', 2);
110
111                 // Guest menu (informations / default doubler link)
112                 addGuestMenuSql('main','doubler','Verdoppeln!','N','Y',3);
113
114                 // Member menu
115                 addMemberMenuSql('main','doubler','Verdoppeln!','N','Y',7);
116                 break;
117
118         case 'remove': // Do stuff when removing extension
119                 // SQL commands to run
120                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_doubler`");
121                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='doubler'");
122                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `what`='doubler'");
123                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='doubler'");
124                 break;
125
126         case 'activate': // Do stuff when admin activates this extension
127                 // SQL commands to run
128                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='doubler' LIMIT 1");
129                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y', `locked`='N' WHERE `what`='doubler' LIMIT 1");
130                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N', `hidden`='N', `admin_only`='N', `mem_only`='N' WHERE `module`='doubler' LIMIT 1");
131                 break;
132
133         case 'deactivate': // Do stuff when admin deactivates this extension
134                 // SQL commands to run
135                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='doubler' LIMIT 1");
136                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='N', `locked`='Y' WHERE `what`='doubler' LIMIT 1");
137                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='Y' WHERE `module`='doubler' LIMIT 1");
138                 break;
139
140         case 'update': // Update an extension
141                 switch (getCurrentExtensionVersion()) {
142                         case '0.0.1': // SQL queries for v0.0.1
143                                 // Update notes (these will be set as task text!)
144                                 setExtensionUpdateNotes("Problem mit User-ID behoben!");
145                                 break;
146
147                         case '0.0.2': // SQL queries for v0.0.2
148                                 // Total used points
149                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_used FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
150
151                                 // Update notes (these will be set as task text!)
152                                 setExtensionUpdateNotes("Geb&uuml;hr wird vom Verdoppler-Pott abgezogen.");
153                                 break;
154
155                         case '0.0.3': // SQL queries for v0.0.3
156                                 // Update notes (these will be set as task text!)
157                                 setExtensionUpdateNotes("Drei SQL-Fehler beseitigt.");
158                                 break;
159
160                         case '0.0.4': // SQL queries for v0.0.4
161                                 // Shall I use the doubler's account to take points from? (Y/N, default=Y)
162                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_own ENUM('Y','N') NOT NULL DEFAULT 'Y'");
163
164                                 // Update notes (these will be set as task text!)
165                                 setExtensionUpdateNotes(POINTS."-Guthaben des Verdopplers kann optional nicht mit einbezogen werden.");
166                                 break;
167
168                                 case '0.0.5': // SQL queries for v0.0.5
169                                         // Update notes (these will be set as task text!)
170                                         setExtensionUpdateNotes("Counter-Stand und noch zum Verdoppeln &uuml;brige {?POINTS?} in Templates eingebunden. Auflistung in Admin-Bereich komplettiert.");
171                                         break;
172
173                                 case '0.0.6': // SQL queries for v0.0.6
174                                         addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_max_sent TINYINT(3) UNSIGNED NOT NULL DEFAULT 1");
175                                         addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_group_sent TINYINT(3) UNSIGNED NOT NULL DEFAULT 1");
176                                         addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_sent_all ENUM('Y','N') NOT NULL DEFAULT 'Y'");
177
178                                         // Update notes (these will be set as task text!)
179                                         setExtensionUpdateNotes("Geb&uuml;hrenabzug wird beim Einzahlen abgezogen (wurde von Auszahlung abgezogen) und maximal bei Auszahlung zu kontrollierende Accounts einstellbar.<br />Template <u>admin_config_doubler_pro.tpl</u> ist &uuml;berfl&uuml;ssig geworden. Bitte l&ouml;schen Sie dies!");
180                                         break;
181
182                                 case '0.0.7': // SQL queries for v0.0.7
183                                         // Update notes (these will be set as task text!)
184                                         setExtensionUpdateNotes("W&ouml;rter <strong>Mailtausch</strong>, <strong>Mailtausches</strong> und <strong>Mailtauscher</strong> sind austauschbar.<br /><br />Minus-Guthaben des Verdoppler-Accounts repariert und Mitgliedsmail erweitert mit Transaktionsummer und IP-Nummer.");
185                                         break;
186
187                                 case '0.0.8': // SQL queries for v0.0.8
188                                         // Update notes (these will be set as task text!)
189                                         setExtensionUpdateNotes("Bitte verschieben Sie die doubler-Templates (Ordner: {?PATH?}/templates/".getLanguage()."/html/) in den neuen Order doubler!");
190                                         break;
191
192                                 case '0.0.9': // SQL queries for v0.0.9
193                                         // Update notes (these will be set as task text!)
194                                         setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
195                                         break;
196
197                                 case '0.1.0': // SQL queries for v0.2.1
198                                         // Update notes (these will be set as task text!)
199                                         setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
200                                         break;
201
202                                 case '0.1.1': // SQL queries for v0.1.1
203                                         // Update notes (these will be set as task text!)
204                                         setExtensionUpdateNotes("Zwei SQL-Fehler in <strong>inc/doubler_send.php</strong> beseitigt.");
205                                         break;
206
207                                 case '0.1.2': // SQL queries for v0.1.2
208                                         // Update notes (these will be set as task text!)
209                                         setExtensionUpdateNotes("Sicherheitsupdate f&uuml;r die Include-Befehle.");
210                                         break;
211
212                                 case '0.1.3': // SQL queries for v0.1.3
213                                         // Update notes (these will be set as task text!)
214                                         setExtensionUpdateNotes("De-/Aktivieren des mit dieser Erweiterung verkn&uuml;pften Modules eingebunden.");
215                                         break;
216
217                                 case '0.1.4': // SQL queries for v0.1.4
218                                         addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='extras', `sort`='4' WHERE `what`='doubler' LIMIT 1");
219
220                                         // Update notes (these will be set as task text!)
221                                         setExtensionUpdateNotes("Mitgliedsmen&uuml; komplett umgebaut.");
222                                         break;
223
224                                 case '0.1.5': // SQL queries for v0.1.5
225                                         // Update notes (these will be set as task text!)
226                                         setExtensionUpdateNotes("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
227                                         break;
228
229                                 case '0.1.6': // SQL queries for v0.1.6
230                                         // Update notes (these will be set as task text!)
231                                         setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
232                                         break;
233                 }
234                 break;
235
236         case 'modify': // When the extension got modified
237                 break;
238
239         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
240                 break;
241
242         case 'init': // Do stuff when extension is initialized
243                 break;
244
245         default: // Unknown extension mode
246                 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));
247                 break;
248 }
249
250 // [EOF]
251 ?>