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 - 2012 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 addExtensionAddTableColumnSql('online', '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");
124 // Unregister points data
125 unregisterExtensionPointsData('doubler_direct');
126 unregisterExtensionPointsData('doubler_reset');
129 case 'activate': // Do stuff when admin activates this extension
130 // SQL commands to run
131 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='doubler' LIMIT 1");
132 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y',`locked`='N' WHERE `what`='doubler' LIMIT 1");
133 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N',`hidden`='N',`admin_only`='N',`mem_only`='N' WHERE `module`='doubler' LIMIT 1");
136 case 'deactivate': // Do stuff when admin deactivates this extension
137 // SQL commands to run
138 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N',`locked`='Y' WHERE `what`='doubler' LIMIT 1");
139 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='N',`locked`='Y' WHERE `what`='doubler' LIMIT 1");
140 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='Y' WHERE `module`='doubler' LIMIT 1");
143 case 'update': // Update an extension
144 switch (getCurrentExtensionVersion()) {
145 case '0.0.1': // SQL queries for v0.0.1
146 // Update notes (these will be set as task text!)
147 setExtensionUpdateNotes("Problem mit Mitglied-Id behoben.");
150 case '0.0.2': // SQL queries for v0.0.2
152 addConfigAddSql('doubler_user', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
154 // Update notes (these will be set as task text!)
155 setExtensionUpdateNotes("Gebühr wird vom Verdoppler-Pott abgezogen.");
158 case '0.0.3': // SQL queries for v0.0.3
159 // Update notes (these will be set as task text!)
160 setExtensionUpdateNotes("Drei SQL-Fehler beseitigt.");
163 case '0.0.4': // SQL queries for v0.0.4
164 // Shall I use the doubler's account to take points from? (Y/N, default=Y)
165 addConfigAddSql('doubler_own', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
167 // Update notes (these will be set as task text!)
168 setExtensionUpdateNotes("{?POINTS?}-Guthaben des Verdopplers kann optional nicht mit einbezogen werden.");
171 case '0.0.5': // SQL queries for v0.0.5
172 // Update notes (these will be set as task text!)
173 setExtensionUpdateNotes("Counter-Stand und noch zum Verdoppeln übrige {?POINTS?} in Templates eingebunden. Auflistung in Admin-Bereich komplettiert.");
176 case '0.0.6': // SQL queries for v0.0.6
177 addConfigAddSql('doubler_max_sent', 'TINYINT(3) UNSIGNED NOT NULL DEFAULT 1');
178 addConfigAddSql('doubler_group_sent', 'TINYINT(3) UNSIGNED NOT NULL DEFAULT 1');
179 addConfigAddSql('doubler_sent_all', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
181 // Update notes (these will be set as task text!)
182 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!");
185 case '0.0.7': // SQL queries for v0.0.7
186 // Update notes (these will be set as task text!)
187 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.");
190 case '0.0.8': // SQL queries for v0.0.8
191 // Update notes (these will be set as task text!)
192 setExtensionUpdateNotes("Bitte verschieben Sie die doubler-Templates (Ordner: {?PATH?}/templates/".getLanguage()."/html/) in den neuen Order doubler!");
195 case '0.0.9': // SQL queries for v0.0.9
196 // Update notes (these will be set as task text!)
197 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
200 case '0.1.0': // SQL queries for v0.2.1
201 // Update notes (these will be set as task text!)
202 setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
205 case '0.1.1': // SQL queries for v0.1.1
206 // Update notes (these will be set as task text!)
207 setExtensionUpdateNotes("Zwei SQL-Fehler in <strong>inc/doubler_send.php</strong> beseitigt.");
210 case '0.1.2': // SQL queries for v0.1.2
211 // Update notes (these will be set as task text!)
212 setExtensionUpdateNotes("Sicherheitsupdate für die Include-Befehle.");
215 case '0.1.3': // SQL queries for v0.1.3
216 // Update notes (these will be set as task text!)
217 setExtensionUpdateNotes("De-/Aktivieren des mit dieser Erweiterung verknüpften Modules eingebunden.");
220 case '0.1.4': // SQL queries for v0.1.4
221 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='extras',`sort`=4 WHERE `what`='doubler' LIMIT 1");
223 // Update notes (these will be set as task text!)
224 setExtensionUpdateNotes("Mitgliedsmenü komplett umgebaut.");
227 case '0.1.5': // SQL queries for v0.1.5
228 // Update notes (these will be set as task text!)
229 setExtensionUpdateNotes("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
232 case '0.1.6': // SQL queries for v0.1.6
233 // Update notes (these will be set as task text!)
234 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
237 case '0.1.7': // SQL queries for v0.1.7
238 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_config` SET `doubler_charge`=`doubler_charge`*100 WHERE `config`=0 LIMIT 1');
239 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_config` SET `doubler_ref`=`doubler_ref`*100 WHERE `config`=0 LIMIT 1');
241 // Update notes (these will be set as task text!)
242 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
245 case '0.1.8': // SQL queries for v0.1.8
246 // Register points data
247 registerExtensionPointsData('doubler_direct', 'points', 'LOCKED', 'DIRECT');
248 registerExtensionPointsData('doubler_reset' , 'points', 'LOCKED', 'DIRECT');
250 // This depends on ext-sql_patches
251 addExtensionDependency('sql_patches');
254 setExtensionUpdateNotes("Doppler-Gutschriften werden nun über die Tabelle <strong>{OPEN_CONFIG}_MYSQL_PREFIX{CLOSE_CONFIG}_points_data</strong> verwaltet.");
257 case '0.1.9': // SQL queries for v0.1.9
258 // Total payed out points from your doublers
259 addConfigAddSql('doubler_used', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
262 setExtensionUpdateNotes("Fehlender Konfigurationseintrag <strong>doubler_used</strong> hinzgefügt.");
267 case 'modify': // When the extension got modified
270 case 'test': // For testing purposes
273 case 'init': // Do stuff when extension is initialized
276 default: // Unknown extension mode
277 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));