Rewrites/fixes for handling config entries in SQLs
[mailer.git] / inc / extensions / ext-doubler.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * 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.1.6');
47
48 // Version history array (add more with , '0.1.0' and so on)
49 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'));
50
51 switch (getExtensionMode()) {
52         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
53                 // Doubler table
54                 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_doubler`');
55                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_doubler` (
56 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
57 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
58 `refid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
59 `points` FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000,
60 `remote_ip` VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
61 `timemark` VARCHAR(10) NOT NULL DEFAULT '',
62 `completed` ENUM('Y','N') NOT NULL DEFAULT 'N',
63 `is_ref` ENUM('Y','N') NOT NULL DEFAULT 'N',
64 KEY (`refid`),
65 KEY (`userid`),
66 PRIMARY KEY (`id`)
67 )TYPE={?_TABLE_TYPE?}");
68
69                 //
70                 // --- SETTINGS ---
71                 //
72                 // Minimum points to double
73                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_min FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 100.00000");
74                 // Maximum points to double
75                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_max FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 10000.00000");
76                 // Points left on users account after doubling
77                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_left BIGINT(20) UNSIGNED NOT NULL DEFAULT 1000");
78                 // Charge for doubling points which goes to the webmaster (shreddered in fact!)
79                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_charge FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.03000");
80                 // Referal percents
81                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_ref FLOAT(7,5) UNSIGNED NOT NULL DEFAULT 0.02000");
82                 // Shall I use the jackpot to take points from? (Y/N, default=Y)
83                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_jackpot ENUM('Y','N') NOT NULL DEFAULT 'Y'");
84                 // A user account to take points from (default: 0->none)
85                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
86                 // Total payed out points from your doublers
87                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
88                 // Sending mode of mails (immediately/daily reset)
89                 // --> This also means who fast the doubled points will be payed out!
90                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_send_mode ENUM('DIRECT','RESET') NOT NULL DEFAULT 'DIRECT'");
91                 // Timeout for entries to be purged (default: one week)
92                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT ".(getConfig('ONE_DAY')*7)."");
93                 // Number of newest entries to display
94                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_display_new TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
95                 // Number of entries which will be payed out soon
96                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_display_pay TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
97                 // Number of entries which are already payed out
98                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_display_old TINYINT(3) UNSIGNED NOT NULL DEFAULT 10");
99                 // Points used by every member
100                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD doubler_points FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
101                 // Counter for usage of the doubler
102                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_counter BIGINT(20) UNSIGNED NOT NULL DEFAULT 0");
103
104                 //
105                 // --- MENU SYSTEMS ---
106                 //
107                 // Admin menu
108                 addAdminMenuSql('doubler', NULL, '{OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Verdoppler','Einstellungen und Eintr&auml;ge auflisten.', 4);
109                 addAdminMenuSql('doubler','list_doubler','Auflisten','Eintr&auml;ge aus der Verdiensttabelle auflisten', 1);
110                 addAdminMenuSql('doubler','config_doubler','Einstellungen','Prozentuale Geb&uuml;hr usw. einstellen.', 2);
111
112                 // Guest menu (informations / default doubler link)
113                 addGuestMenuSql('main','doubler','Verdoppeln!','N','Y',3);
114
115                 // Member menu
116                 addMemberMenuSql('main','doubler','Verdoppeln!','N','Y',7);
117                 break;
118
119         case 'remove': // Do stuff when removing extension
120                 // SQL commands to run
121                 addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_doubler`');
122                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='doubler'");
123                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_guest_menu` WHERE `what`='doubler'");
124                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='doubler'");
125                 break;
126
127         case 'activate': // Do stuff when admin activates this extension
128                 // SQL commands to run
129                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='doubler' LIMIT 1");
130                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y', `locked`='N' WHERE `what`='doubler' LIMIT 1");
131                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N', `hidden`='N', `admin_only`='N', `mem_only`='N' WHERE `module`='doubler' LIMIT 1");
132                 break;
133
134         case 'deactivate': // Do stuff when admin deactivates this extension
135                 // SQL commands to run
136                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='doubler' LIMIT 1");
137                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='N', `locked`='Y' WHERE `what`='doubler' LIMIT 1");
138                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='Y' WHERE `module`='doubler' LIMIT 1");
139                 break;
140
141         case 'update': // Update an extension
142                 switch (getCurrentExtensionVersion()) {
143                         case '0.0.1': // SQL queries for v0.0.1
144                                 // Update notes (these will be set as task text!)
145                                 setExtensionUpdateNotes("Problem mit Mitglieder-Id behoben.");
146                                 break;
147
148                         case '0.0.2': // SQL queries for v0.0.2
149                                 // Total used points
150                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_used FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
151
152                                 // Update notes (these will be set as task text!)
153                                 setExtensionUpdateNotes("Geb&uuml;hr wird vom Verdoppler-Pott abgezogen.");
154                                 break;
155
156                         case '0.0.3': // SQL queries for v0.0.3
157                                 // Update notes (these will be set as task text!)
158                                 setExtensionUpdateNotes("Drei SQL-Fehler beseitigt.");
159                                 break;
160
161                         case '0.0.4': // SQL queries for v0.0.4
162                                 // Shall I use the doubler's account to take points from? (Y/N, default=Y)
163                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_own ENUM('Y','N') NOT NULL DEFAULT 'Y'");
164
165                                 // Update notes (these will be set as task text!)
166                                 setExtensionUpdateNotes("{?POINTS?}-Guthaben des Verdopplers kann optional nicht mit einbezogen werden.");
167                                 break;
168
169                                 case '0.0.5': // SQL queries for v0.0.5
170                                         // Update notes (these will be set as task text!)
171                                         setExtensionUpdateNotes("Counter-Stand und noch zum Verdoppeln &uuml;brige {?POINTS?} in Templates eingebunden. Auflistung in Admin-Bereich komplettiert.");
172                                         break;
173
174                                 case '0.0.6': // SQL queries for v0.0.6
175                                         addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_max_sent TINYINT(3) UNSIGNED NOT NULL DEFAULT 1");
176                                         addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_group_sent TINYINT(3) UNSIGNED NOT NULL DEFAULT 1");
177                                         addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD doubler_sent_all ENUM('Y','N') NOT NULL DEFAULT 'Y'");
178
179                                         // Update notes (these will be set as task text!)
180                                         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!");
181                                         break;
182
183                                 case '0.0.7': // SQL queries for v0.0.7
184                                         // Update notes (these will be set as task text!)
185                                         setExtensionUpdateNotes("W&ouml;rter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.<br /><br />Minus-Guthaben des Verdoppler-Accounts repariert und Mitgliedsmail erweitert mit Transaktionsummer und IP-Nummer.");
186                                         break;
187
188                                 case '0.0.8': // SQL queries for v0.0.8
189                                         // Update notes (these will be set as task text!)
190                                         setExtensionUpdateNotes("Bitte verschieben Sie die doubler-Templates (Ordner: {?PATH?}/templates/".getLanguage()."/html/) in den neuen Order doubler!");
191                                         break;
192
193                                 case '0.0.9': // SQL queries for v0.0.9
194                                         // Update notes (these will be set as task text!)
195                                         setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
196                                         break;
197
198                                 case '0.1.0': // SQL queries for v0.2.1
199                                         // Update notes (these will be set as task text!)
200                                         setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
201                                         break;
202
203                                 case '0.1.1': // SQL queries for v0.1.1
204                                         // Update notes (these will be set as task text!)
205                                         setExtensionUpdateNotes("Zwei SQL-Fehler in <strong>inc/doubler_send.php</strong> beseitigt.");
206                                         break;
207
208                                 case '0.1.2': // SQL queries for v0.1.2
209                                         // Update notes (these will be set as task text!)
210                                         setExtensionUpdateNotes("Sicherheitsupdate f&uuml;r die Include-Befehle.");
211                                         break;
212
213                                 case '0.1.3': // SQL queries for v0.1.3
214                                         // Update notes (these will be set as task text!)
215                                         setExtensionUpdateNotes("De-/Aktivieren des mit dieser Erweiterung verkn&uuml;pften Modules eingebunden.");
216                                         break;
217
218                                 case '0.1.4': // SQL queries for v0.1.4
219                                         addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='extras', `sort`=4 WHERE `what`='doubler' LIMIT 1");
220
221                                         // Update notes (these will be set as task text!)
222                                         setExtensionUpdateNotes("Mitgliedsmen&uuml; komplett umgebaut.");
223                                         break;
224
225                                 case '0.1.5': // SQL queries for v0.1.5
226                                         // Update notes (these will be set as task text!)
227                                         setExtensionUpdateNotes("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
228                                         break;
229
230                                 case '0.1.6': // SQL queries for v0.1.6
231                                         // Update notes (these will be set as task text!)
232                                         setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
233                                         break;
234                 }
235                 break;
236
237         case 'modify': // When the extension got modified
238                 break;
239
240         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
241                 break;
242
243         case 'init': // Do stuff when extension is initialized
244                 break;
245
246         default: // Unknown extension mode
247                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
248                 break;
249 }
250
251 // [EOF]
252 ?>