Some major rewrites + ext-network continued:
[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 - 2012 by Mailer Developer Team                   *
20  * For more information visit: http://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.2.0');
45
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', '0.2.0'));
48
49 switch (getExtensionMode()) {
50         case 'setup': // Do stuff when installation is running
51                 // Doubler table
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',
62 PRIMARY KEY (`id`),
63 INDEX (`refid`),
64 INDEX (`userid`)",
65                         'User doubler data');
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                 // Referral 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                 addExtensionAddTableColumnSql('user_data', '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!', 3);
112
113                 // Member menu
114                 addMemberMenuSql('main', 'doubler', 'Verdoppeln!', 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' LIMIT 1");
122                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='doubler' LIMIT 1");
123
124                 // Unregister points data
125                 unregisterExtensionPointsData('doubler_direct');
126                 unregisterExtensionPointsData('doubler_reset');
127
128                 // Unregister filters
129                 unregisterFilter(__FILE__, __LINE__, 'config_userid_exclusion_sql', 'EXLCUDE_DOUBLER_USERID', TRUE, isExtensionDryRun());
130                 break;
131
132         case 'activate': // Do stuff when admin activates this extension
133                 // SQL commands to run
134                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y',`locked`='N' WHERE `what`='doubler' LIMIT 1");
135                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='Y',`locked`='N' WHERE `what`='doubler' LIMIT 1");
136                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='N',`hidden`='N',`admin_only`='N',`mem_only`='N' WHERE `module`='doubler' LIMIT 1");
137                 break;
138
139         case 'deactivate': // Do stuff when admin deactivates this extension
140                 // SQL commands to run
141                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N',`locked`='Y' WHERE `what`='doubler' LIMIT 1");
142                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `visible`='N',`locked`='Y' WHERE `what`='doubler' LIMIT 1");
143                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_mod_reg` SET `locked`='Y' WHERE `module`='doubler' LIMIT 1");
144                 break;
145
146         case 'update': // Update an extension
147                 switch (getCurrentExtensionVersion()) {
148                         case '0.0.1': // SQL queries for v0.0.1
149                                 // Update notes (these will be set as task text!)
150                                 setExtensionUpdateNotes("Problem mit Mitglieds-Id behoben.");
151                                 break;
152
153                         case '0.0.2': // SQL queries for v0.0.2
154                                 // Total used points
155                                 addConfigAddSql('doubler_user', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000');
156
157                                 // Update notes (these will be set as task text!)
158                                 setExtensionUpdateNotes("Geb&uuml;hr wird vom Verdoppler-Pott abgezogen.");
159                                 break;
160
161                         case '0.0.3': // SQL queries for v0.0.3
162                                 // Update notes (these will be set as task text!)
163                                 setExtensionUpdateNotes("Drei SQL-Fehler beseitigt.");
164                                 break;
165
166                         case '0.0.4': // SQL queries for v0.0.4
167                                 // Shall I use the doubler's account to take points from? (Y/N, default=Y)
168                                 addConfigAddSql('doubler_own', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
169
170                                 // Update notes (these will be set as task text!)
171                                 setExtensionUpdateNotes("{?POINTS?}-Guthaben des Verdopplers kann optional nicht mit einbezogen werden.");
172                                 break;
173
174                         case '0.0.5': // SQL queries for v0.0.5
175                                 // Update notes (these will be set as task text!)
176                                 setExtensionUpdateNotes("Counter-Stand und noch zum Verdoppeln &uuml;brige {?POINTS?} in Templates eingebunden. Auflistung in Admin-Bereich komplettiert.");
177                                 break;
178
179                         case '0.0.6': // SQL queries for v0.0.6
180                                 addConfigAddSql('doubler_max_sent', 'TINYINT(3) UNSIGNED NOT NULL DEFAULT 1');
181                                 addConfigAddSql('doubler_group_sent', 'TINYINT(3) UNSIGNED NOT NULL DEFAULT 1');
182                                 addConfigAddSql('doubler_sent_all', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
183
184                                 // Update notes (these will be set as task text!)
185                                 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!");
186                                 break;
187
188                         case '0.0.7': // SQL queries for v0.0.7
189                                 // Update notes (these will be set as task text!)
190                                 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.");
191                                 break;
192
193                         case '0.0.8': // SQL queries for v0.0.8
194                                 // Update notes (these will be set as task text!)
195                                 setExtensionUpdateNotes("Bitte verschieben Sie die doubler-Templates (Ordner: {?PATH?}/templates/".getLanguage()."/html/) in den neuen Order doubler!");
196                                 break;
197
198                         case '0.0.9': // SQL queries for v0.0.9
199                                 // Update notes (these will be set as task text!)
200                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
201                                 break;
202
203                         case '0.1.0': // SQL queries for v0.2.1
204                                 // Update notes (these will be set as task text!)
205                                 setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
206                                 break;
207
208                         case '0.1.1': // SQL queries for v0.1.1
209                                 // Update notes (these will be set as task text!)
210                                 setExtensionUpdateNotes("Zwei SQL-Fehler in <strong>inc/doubler_send.php</strong> beseitigt.");
211                                 break;
212
213                         case '0.1.2': // SQL queries for v0.1.2
214                                 // Update notes (these will be set as task text!)
215                                 setExtensionUpdateNotes("Sicherheitsupdate f&uuml;r die Include-Befehle.");
216                                 break;
217
218                         case '0.1.3': // SQL queries for v0.1.3
219                                 // Update notes (these will be set as task text!)
220                                 setExtensionUpdateNotes("De-/Aktivieren des mit dieser Erweiterung verkn&uuml;pften Modules eingebunden.");
221                                 break;
222
223                         case '0.1.4': // SQL queries for v0.1.4
224                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='extras',`sort`=4 WHERE `what`='doubler' LIMIT 1");
225
226                                 // Update notes (these will be set as task text!)
227                                 setExtensionUpdateNotes("Mitgliedsmen&uuml; komplett umgebaut.");
228                                 break;
229
230                         case '0.1.5': // SQL queries for v0.1.5
231                                 // Update notes (these will be set as task text!)
232                                 setExtensionUpdateNotes("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
233                                 break;
234
235                         case '0.1.6': // SQL queries for v0.1.6
236                                 // Update notes (these will be set as task text!)
237                                 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
238                                 break;
239
240                         case '0.1.7': // SQL queries for v0.1.7
241                                 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_config` SET `doubler_charge`=`doubler_charge`*100 WHERE `config`=0 LIMIT 1');
242                                 addExtensionSql('UPDATE `{?_MYSQL_PREFIX?}_config` SET `doubler_ref`=`doubler_ref`*100 WHERE `config`=0 LIMIT 1');
243
244                                 // Update notes (these will be set as task text!)
245                                 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
246                                 break;
247
248                         case '0.1.8': // SQL queries for v0.1.8
249                                 // Register points data
250                                 registerExtensionPointsData('doubler_direct', 'points', 'LOCKED', 'DIRECT');
251                                 registerExtensionPointsData('doubler_reset' , 'points', 'LOCKED', 'DIRECT');
252
253                                 // Update notes
254                                 setExtensionUpdateNotes("Doppler-Gutschriften werden nun &uuml;ber die Tabelle <strong>{OPEN_CONFIG}_MYSQL_PREFIX{CLOSE_CONFIG}_points_data</strong> verwaltet.");
255                                 break;
256
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');
260
261                                 // Update notes
262                                 setExtensionUpdateNotes("Fehlender Konfigurationseintrag <strong>doubler_used</strong> hinzgef&uuml;gt.");
263                                 break;
264
265                         case '0.2.0': // SQL queries for v0.2.0
266                                 // Register filter
267                                 registerFilter(__FILE__, __LINE__, 'config_userid_exclusion_sql', 'EXLCUDE_DOUBLER_USERID', FALSE, TRUE, isExtensionDryRun());
268
269                                 // Update notes (these will be set as task text!)
270                                 setExtensionUpdateNotes("Filter zum Ausschlie&szlig;en des konfigurierten Mitgliedaccounts.");
271                                 break;
272                 } // END - switch
273                 break;
274
275         case 'modify': // When the extension got modified
276                 break;
277
278         case 'test': // For testing purposes
279                 break;
280
281         case 'init': // Do stuff when extension is initialized
282                 break;
283
284         default: // Unknown extension mode
285                 reportBug(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
286                 break;
287 } // END - switch
288
289 // [EOF]
290 ?>