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