604dcac05e6c07e6b45a6791a20d8a06cb700bcc
[mailer.git] / inc / extensions / ext-payout.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 04/11/2004 *
4  * ===================                          Last change: 11/15/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-payout.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : Payout extension                                 *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Auszahlung-Erweiterung                           *
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 of this extension
46 setThisExtensionVersion('0.3.8');
47
48 // Version history array (add more with , '0.1.0' and so on)
49 setExtensionVersionHistory(array('0.0', '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', '0.2.1', '0.2.2', '0.2.3', '0.2.4', '0.2.5', '0.2.6', '0.2.7', '0.2.8', '0.2.9', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6', '0.3.7', '0.3.8'));
50
51 switch (getExtensionMode()) {
52         case 'register': // Do stuff when installation is running (modules.php?module=admin is called)
53                 // SQL commands to run
54                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_payouts`");
55                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_user_payouts` (
56 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
57 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
58 payout_total FLOAT(22,3) UNSIGNED NOT NULL DEFAULT '0.000',
59 target_account VARCHAR(255) NOT NULL DEFAULT '',
60 target_bank VARCHAR(255) NOT NULL DEFAULT '',
61 payout_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
62 payout_timestamp VARCHAR(10) NOT NULL DEFAULT 0,
63 status ENUM('NEW','ACCEPTED','REJECTED') NOT NULL DEFAULT 'NEW',
64 KEY (userid),
65 KEY (payout_id),
66 PRIMARY KEY (id)
67 ) TYPE={?_TABLE_TYPE?}");
68                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_payout_types`");
69                 addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_payout_types` (
70 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
71 type VARCHAR(255) NOT NULL DEFAULT '',
72 rate FLOAT(22,3) UNSIGNED NOT NULL DEFAULT '0.000',
73 min_points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
74 PRIMARY KEY (id)
75 ) TYPE={?_TABLE_TYPE?}");
76                 addAdminMenuSql('setup','config_payouts','Auszahlungen','Auszahlungsarten einstellen, neu anlegen oder l&ouml;schen.',15);
77                 addAdminMenuSql('payouts','list_payouts','Anfragen auflisten','Listet alle Auszahlungsanfragen Ihrer Mitglieder auf.',16);
78                 addMemberMenuSql('main','payout','Auszahlungen','N','N',11);
79                 break;
80
81         case 'remove': // Do stuff when removing extension
82                 // SQL commands to run
83                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_payouts`");
84                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_payout_types`");
85                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='payouts'");
86                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='payout'");
87                 break;
88
89         case 'activate': // Do stuff when admin activates this extension
90                 // SQL commands to run
91                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='payout' LIMIT 1");
92                 break;
93
94         case 'deactivate': // Do stuff when admin deactivates this extension
95                 // SQL commands to run
96                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='N', `locked`='Y' WHERE `what`='payout' LIMIT 1");
97                 break;
98
99         case 'update': // Update an extension
100                 switch (getCurrentExtensionVersion())
101                 {
102                         case '0.1.2': // SQL queries for v0.1.2
103                                 addAdminMenuSql('payouts', NULL, 'Auszahlungsmanagement','Management der Auszahlungsarten.',8);
104                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `action`='payouts', `title`='Einstellungen' WHERE `action`='setup' AND `what`='config_payouts' LIMIT 1");
105                                 break;
106
107                         case '0.1.3': // SQL queries for v0.1.3
108                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_payout_types` ADD from_account VARCHAR(255) NOT NULL DEFAULT ''");
109                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_payout_types` ADD from_pass VARCHAR(255) NOT NULL DEFAULT ''");
110                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_payout_types` ADD engine_url VARCHAR(255) NOT NULL DEFAULT ''");
111                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_payout_types` ADD engine_ret_ok VARCHAR(255) NOT NULL DEFAULT ''");
112                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_payout_types` ADD engine_ret_failed VARCHAR(255) NOT NULL DEFAULT ''");
113                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_payout_types` ADD pass_enc ENUM('md5','base64','none') NOT NULL DEFAULT 'md5'");
114                                 break;
115
116                         case '0.1.4': // SQL queries for v0.1.4
117                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_payouts` ADD password VARCHAR(255) NOT NULL DEFAULT ''");
118                                 break;
119
120                         case '0.1.5': // SQL queries for v0.1.5
121                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_payouts` ADD target_url LONGTEXT NOT NULL");
122                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_payouts` ADD banner_url LONGTEXT NOT NULL");
123                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_payouts` ADD link_text VARCHAR(30) NOT NULL DEFAULT ''");
124                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_payout_types` ADD allow_url ENUM('Y','N') NOT NULL DEFAULT 'N'");
125                                 break;
126
127                         case '0.1.6': // SQL queries for v0.1.6
128                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_payout_types` CHANGE pass_enc pass_enc ENUM('md5','base64','xxx') NOT NULL DEFAULT 'xxx'");
129                                 break;
130
131                         case '0.1.8': // SQL queries for v0.1.8
132                                 // Update notes (these will be set as task text!)
133                                 setExtensionUpdateNotes("Auflistung der Auszahlungen ausgelagert in Template <em>member_payout.tpl</em>.");
134                                 break;
135
136                         case '0.1.9': // SQL queries for v0.1.9
137                                 // Update notes (these will be set as task text!)
138                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
139                                 break;
140
141                         case '0.2.0': // SQL queries for v0.2.0
142                                 // Update notes (these will be set as task text!)
143                                 setExtensionUpdateNotes("5 Nachkommastellen implementiert.");
144                                 break;
145
146                         case '0.2.1': // SQL queries for v0.2.1
147                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_payouts` CHANGE payout_total payout_total FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
148                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_payout_types` CHANGE rate rate FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.00000");
149
150                                 // Update notes (these will be set as task text!)
151                                 setExtensionUpdateNotes("Problem mit Speicherung der Einstellungen beseitigt.");
152
153                         case '0.2.2': // SQL queries for v0.2.2
154                                 // Update notes (these will be set as task text!)
155                                 setExtensionUpdateNotes("Buttons aus Aufgabenauflisten ausgelagert");
156                                 break;
157
158                         case '0.2.3': // SQL queries for v0.2.3
159                                 // Update notes (these will be set as task text!)
160                                 setExtensionUpdateNotes("Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
161                                 break;
162
163                         case '0.2.4': // SQL queries for v0.2.4
164                                 // Update notes (these will be set as task text!)
165                                 setExtensionUpdateNotes("Ausgabe der Auszahlungsm&ouml;glichkeiten im Mitgliedsbereich repariert.");
166                                 break;
167
168                         case '0.2.5': // SQL queries for v0.2.5
169                                 // Update notes (these will be set as task text!)
170                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
171                                 break;
172
173                         case '0.2.6': // SQL queries for v0.2.6
174                                 // Update notes (these will be set as task text!)
175                                 setExtensionUpdateNotes("IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.");
176                                 break;
177
178                         case '0.2.7': // SQL queries for v0.2.7
179                                 // Update notes (these will be set as task text!)
180                                 setExtensionUpdateNotes("Link zum Mitgliedsprofil in Funktion <u>generateUserProfileLink()</u> ausgelagert.");
181                                 break;
182
183                         case '0.2.8': // SQL queries for v0.2.8
184                                 // Update notes (these will be set as task text!)
185                                 setExtensionUpdateNotes("Work-Arount-L&ouml;sung zu tempor&auml;ren Problemen mit der Task-Id eingebaut.");
186                                 break;
187
188                         case '0.2.9': // SQL queries for v0.2.9
189                                 // Update notes (these will be set as task text!)
190                                 setExtensionUpdateNotes("Nachricht an Admin bei Auszahlungsanfrage wird endlich versendet.");
191                                 break;
192
193                         case '0.3.0': // SQL queries for v0.3.0
194                                 // Update notes (these will be set as task text!)
195                                 setExtensionUpdateNotes("HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.");
196                                 break;
197
198                         case '0.3.1': // SQL queries for v0.3.1
199                                 // Update notes (these will be set as task text!)
200                                 setExtensionUpdateNotes("Fehler in Auszahlungsfunktion beseitigt, wenn Umrechnungsrate ungleich 1 eingestellt ist.");
201                                 break;
202
203                         case '0.3.2': // SQL queries for v0.3.2
204                                 // Update notes (these will be set as task text!)
205                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
206                                 break;
207
208                         case '0.3.3': // SQL queries for v0.3.3
209                                 // Update notes (these will be set as task text!)
210                                 setExtensionUpdateNotes("Vorbereitung auf die neue Mediendaten v0.0.4.");
211                                 break;
212
213                         case '0.3.4': // SQL queries for v0.3.4
214                                 // Update notes (these will be set as task text!)
215                                 setExtensionUpdateNotes("Anzahl zu &uuml;berweisende {?POINTS?} m&uuml;ssen immer gr&ouml;sser 0 sein, ansonsten bricht das Script mit einer Fehlermeldung an das Mitglied ab.");
216                                 break;
217
218                         case '0.3.5': // SQL queries for v0.3.5
219                                 // Update notes (these will be set as task text!)
220                                 setExtensionUpdateNotes("Sicherheitsupdate f&uuml;r die Include-Befehle.");
221                                 break;
222
223                         case '0.3.6': // SQL queries for v0.3.6
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.3.7': // SQL queries for v0.3.7
229                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET title = 'Auszahlungsmanagement' WHERE action = 'payouts' AND (`what`='' OR `what` IS NULL) LIMIT 1");
230
231                                 // Update notes (these will be set as task text!)
232                                 setExtensionUpdateNotes("Verwaltung nach Management umgestellt.");
233                                 break;
234
235                         case '0.3.8': // SQL queries for v0.3.8
236                                 // Update notes (these will be set as task text!)
237                                 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
238                                 break;
239                 }
240                 break;
241
242         case 'modify': // When the extension got modified
243                 break;
244
245         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
246                 break;
247
248         case 'init': // Do stuff when extension is initialized
249                 break;
250
251         default: // Unknown extension mode
252                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
253                 break;
254 }
255
256 // [EOF]
257 ?>