2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 02/03/2005 *
4 * =================== Last change: 02/03/2005 *
6 * -------------------------------------------------------------------- *
7 * File : ext-doubler.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Double points *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Punkte verdoppeln *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2011 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
44 setThisExtensionVersion('0.1.9');
46 // Version history array (add more with , '0.0.1' and so on)
47 setExtensionVersionHistory(array('0.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', '0.1.8', '0.1.9'));
49 switch (getExtensionMode()) {
50 case 'register': // Do stuff when installation is running
52 addDropTableSql('doubler');
53 addCreateTableSql('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',
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');
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');
103 // --- MENU SYSTEMS ---
106 addAdminMenuSql('doubler', NULL, '{OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Verdoppler','Einstellungen und Einträge auflisten.', 4);
107 addAdminMenuSql('doubler','list_doubler','Auflisten','Einträge aus der Verdiensttabelle auflisten', 1);
108 addAdminMenuSql('doubler','config_doubler','Einstellungen','Prozentuale Gebühr usw. einstellen.', 2);
110 // Guest menu (informations / default doubler link)
111 addGuestMenuSql('main', 'doubler', 'Verdoppeln!', 3);
114 addMemberMenuSql('main', 'doubler', 'Verdoppeln!', 7);
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' LIMIT 1");
122 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='doubler' LIMIT 1");
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");
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");
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 Mitglied-Id behoben.");
146 case '0.0.2': // SQL queries for v0.0.2
148 addConfigAddSql('doubler_user', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
150 // Update notes (these will be set as task text!)
151 setExtensionUpdateNotes("Gebühr wird vom Verdoppler-Pott abgezogen.");
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.");
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'");
163 // Update notes (these will be set as task text!)
164 setExtensionUpdateNotes("{?POINTS?}-Guthaben des Verdopplers kann optional nicht mit einbezogen werden.");
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 übrige {?POINTS?} in Templates eingebunden. Auflistung in Admin-Bereich komplettiert.");
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'");
177 // Update notes (these will be set as task text!)
178 setExtensionUpdateNotes("Gebü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 überflüssig geworden. Bitte löschen Sie dies!");
181 case '0.0.7': // SQL queries for v0.0.7
182 // Update notes (these will be set as task text!)
183 setExtensionUpdateNotes("Wö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 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!");
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.");
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.");
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.");
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ür die Include-Befehle.");
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üpften Modules eingebunden.");
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");
219 // Update notes (these will be set as task text!)
220 setExtensionUpdateNotes("Mitgliedsmenü komplett umgebaut.");
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.");
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.");
233 case '0.1.7': // SQL queries for v0.1.7
234 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_config` SET `doubler_charge`=`doubler_charge`*100 WHERE `config`=0 LIMIT 1');
235 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_config` SET `doubler_ref`=`doubler_ref`*100 WHERE `config`=0 LIMIT 1');
237 // Update notes (these will be set as task text!)
238 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
241 case '0.1.8': // SQL queries for v0.1.8
242 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`,`column_name`,`locked_mode`,`payment_method`) VALUES ('doubler_direct','points','LOCKED','DIRECT')");
243 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`,`column_name`,`locked_mode`,`payment_method`) VALUES ('doubler_reset','points','LOCKED','DIRECT')");
245 // This depends on ext-sql_patches
246 addExtensionDependency('sql_patches');
249 setExtensionUpdateNotes("Doppler-Gutschriften werden nun über die Tabelle <strong>{OPEN_CONFIG}_MYSQL_PREFIX{CLOSE_CONFIG}_points_data</strong> verwaltet.");
252 case '0.1.9': // SQL queries for v0.1.9
253 // Total payed out points from your doublers
254 addConfigAddSql('doubler_used', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
257 setExtensionUpdateNotes("Fehlender Konfigurationseintrag <strong>doubler_used</strong> hinzgefügt.");
262 case 'modify': // When the extension got modified
265 case 'test': // For testing purposes
268 case 'init': // Do stuff when extension is initialized
271 default: // Unknown extension mode
272 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));