Some typos fixed
[mailer.git] / inc / extensions / ext-transfer.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/07/2004 *
4  * ================                             Last change: 07/08/2007 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : ext-transfer.php                                 *
8  * -------------------------------------------------------------------- *
9  * Short description : Point transfers between members                  *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Punktetransfers zwischen Mitgliedern             *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Version number
41 $EXT_VERSION = "0.2.9";
42
43 // Auto-set extension version
44 if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;
45
46 // Version history array (add more with , "0.1" and so on)
47 $EXT_VER_HISTORY = 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", "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");
48
49 switch ($EXT_LOAD_MODE)
50 {
51 case "register": // Do stuff when installation is running
52         // SQL commands to run
53         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_in";
54         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_out";
55
56         // Transfer from a member
57         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_user_transfers_in (
58 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
59 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
60 from_uid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
61 points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
62 reason VARCHAR(255) NOT NULL DEFAULT '',
63 time_trans VARCHAR(14) NOT NULL DEFAULT 0,
64 trans_id VARCHAR(12) NOT NULL DEFAULT '',
65 KEY (userid),
66 KEY (from_uid),
67 PRIMARY KEY(id)
68 ) Type=MyISAM";
69
70         // Transfers to a member
71         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_user_transfers_out (
72 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
73 userid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
74 to_uid BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
75 points BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
76 reason VARCHAR(255) NOT NULL DEFAULT '',
77 time_trans VARCHAR(14) NOT NULL DEFAULT 0,
78 trans_id VARCHAR(12) NOT NULL DEFAULT '',
79 KEY (userid),
80 KEY (to_uid),
81 PRIMARY KEY(id)
82 ) Type=MyISAM";
83
84         // Admin menu
85         $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('transfer', NULL, '{!POINTS!}-Transfer','Verwalten Sie hier die {!POINTS!}-Transaktionen zwischen Ihren Mitgliedern.', 7)";
86         $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('transfer','list_transfer','Auflisten','Hier bekommen Sie alle ein- und ausgehende Transaktionen aufgelistet.', 1)";
87         $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('transfer','config_transfer','Einstellungen','Stellen Sie ein, wie viele Transaktionen aufgelistet werden sollen und wie alt diese werden d&uuml;rfen. Die evtl. installierte autopurge-Erweiterung kann dann automatisch die veralteten Transktionen l&ouml;schen.', 2)";
88         $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('transfer','del_transfer','Manuell l&ouml;schen','Hier k&ouml;nnen Sie - abgesehen von der automatischen L&ouml;schung - Transaktionen selber l&ouml;schen. Bitte beachten Sie, dass immer aus- und eingehende Transaktionen gleichzeitig gel&ouml;scht werden.', 3)";
89
90         // Member menu
91         $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_member_menu` (`action`,`what`,`title`,`visible`,`locked`,`sort`) VALUES ('main','transfer','{!POINTS!}-Transfer','Y','Y', 5)";
92
93         // Add config values
94         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD transfer_max BIGINT(20) UNSIGNED NOT NULL DEFAULT '50'";
95         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD transfer_age BIGINT(20) UNSIGNED NOT NULL DEFAULT '".(getConfig('one_day')*28)."'";
96         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD transfer_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT '".getConfig('one_day')."'";
97         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD transfer_balance BIGINT(20) UNSIGNED NOT NULL DEFAULT 100";
98         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD transfer_code BIGINT(20) UNSIGNED NOT NULL DEFAULT 5";
99
100         // Add row(s) to user's data
101         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_user_data` ADD opt_in ENUM('Y','N') NOT NULL DEFAULT 'N'";
102         break;
103
104 case "remove": // Do stuff when removing extension
105         // SQL commands to run
106         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_in";
107         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_out";
108         $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_admin_menu` WHERE action='transfer' LIMIT 4";
109         $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_member_menu` WHERE what='transfer' LIMIT 1";
110         $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_user_data` DROP opt_in";
111         break;
112
113 case "activate": // Do stuff when admin activates this extension
114         // SQL commands to run
115         $SQLs[] = "UPDATE `"._MYSQL_PREFIX."_member_menu` SET visible='Y', locked='N' WHERE what='transfer' LIMIT 1";
116         break;
117
118 case "deactivate": // Do stuff when admin deactivates this extension
119         // SQL commands to run
120         $SQLs[] = "UPDATE `"._MYSQL_PREFIX."_member_menu` SET visible='Y', locked='N' WHERE what='transfer' LIMIT 1";
121         break;
122
123 case "update": // Update an extension
124         switch ($EXT_VER)
125         {
126         case "0.0.2": // SQL queries for v0.0.2
127                 // Update notes (these will be set as task text!)
128                 $UPDATE_NOTES = "Fehler <div class=\"admin_failed\">Warning: Missing argument 2 for create_timestamp_from_selections() in {!PATH!}inc/libs/pro_functions.php on line 227</div> behoben.";
129                 break;
130
131         case "0.0.3": // SQL queries for v0.0.3
132                 // Update notes (these will be set as task text!)
133                 $UPDATE_NOTES = "&Uuml;berfl&uuml;ssige unset()-Anweisungen aus der what-config_transfer.php entfernt. Dies wird bereits von der eigenen Funktion ADMIN_SAVE_SETTINGS() erledigt.";
134                 break;
135
136         case "0.0.3": // SQL queries for v0.0.3
137                 // Update notes (these will be set as task text!)
138                 $UPDATE_NOTES = "Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.";
139                 break;
140
141         case "0.0.5": // SQL queries for v0.0.5
142                 $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD ap_transfer ENUM('Y','N') NOT NULL DEFAULT 'Y'";
143
144                 // Update notes (these will be set as task text!)
145                 $UPDATE_NOTES = "Link <em>Auflisten</em> im Admin-Bereich hatte das eingeloggte Mitglied und nicht den eingeloggten Admin abgefragt. Automatisches L&ouml;schen von veraltete Eintr&auml;gen kann unabh&auml;ngig von der autopurge-Erweiterung de-/aktiviert werden. Bitte aktualisieren Sie auch die beiden Admin-Templates!";
146                 break;
147
148         case "0.0.6": // SQL queries for v0.0.6
149                 // Update notes (these will be set as task text!)
150                 $UPDATE_NOTES = "Wegen des Theme-Supportes hat sich die URL zur CSS-Datei ge&auml;ndert.";
151                 break;
152
153         case "0.0.7": // SQL queries for v0.0.7
154                 // Update notes (these will be set as task text!)
155                 $UPDATE_NOTES = "Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.";
156                 break;
157
158         case "0.0.8": // SQL queries for v0.0.8
159                 // Update notes (these will be set as task text!)
160                 $UPDATE_NOTES = "Problem mit E in Transaktionsnummer beseitigt.";
161                 break;
162
163         case "0.0.9": // SQL queries for v0.0.9
164                 // Update notes (these will be set as task text!)
165                 $UPDATE_NOTES = "Problem mit Speicherung der Einstellungen beseitigt.";
166                 break;
167
168         case "0.1.0": // SQL queries for v0.2.1
169                 // Update notes (these will be set as task text!)
170                 $UPDATE_NOTES = "Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.";
171                 break;
172
173         case "0.1.1": // SQL queries for v0.1.1
174                 // Update notes (these will be set as task text!)
175                 $UPDATE_NOTES = "Design &quot;Solid-Business&quot; eingebaut.";
176                 break;
177
178         case "0.1.2": // SQL queries for v0.1.2
179                 // Update notes (these will be set as task text!)
180                 $UPDATE_NOTES = "Seit <a href=\"#\">Patch 340</a> &uuml;berfl&uuml;ssige HTML-Tags entfernt.";
181                 break;
182
183         case "0.1.3": // SQL queries for v0.1.3
184                 // Update notes (these will be set as task text!)
185                 $UPDATE_NOTES = "IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.";
186                 break;
187
188         case "0.1.4": // SQL queries for v0.1.4
189                 // Update notes (these will be set as task text!)
190                 $UPDATE_NOTES = "Link zum Mitgliedsprofil in Funktion <u>ADMIN_USER_PROFILE_LINK()</u> ausgelagert.";
191                 break;
192
193         case "0.1.5": // SQL queries for v0.1.5
194                 // Update notes (these will be set as task text!)
195                 $UPDATE_NOTES = "Template <u>admin_config_transfer_pro.tpl</u> ist &uuml;berfl&uuml;ssig geworden. Bitte l&ouml;schen Sie dies!";
196                 break;
197
198         case "0.1.6": // SQL queries for v0.1.6
199                 // Update notes (these will be set as task text!)
200                 $UPDATE_NOTES = "W&ouml;rter <strong>Mailtausch</strong>, <strong>Mailtausches</strong> und <strong>Mailtauscher</strong> sind austauschbar.";
201                 break;
202
203         case "0.1.7": // SQL queries for v0.1.7
204                 // Update notes (these will be set as task text!)
205                 $UPDATE_NOTES = "Wort <strong>Punkte</strong> dynamisiert.";
206                 break;
207
208         case "0.1.8": // SQL queries for v0.1.8
209                 // Update notes (these will be set as task text!)
210                 $UPDATE_NOTES = "HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.";
211                 break;
212
213         case "0.1.9": // SQL queries for v0.1.9
214                 // Update notes (these will be set as task text!)
215                 $UPDATE_NOTES = "Parser-Error im Mitgliedsbereich beseitigt.";
216                 break;
217
218         case "0.2.0": // SQL queries for v0.2.0
219                 // Update notes (these will be set as task text!)
220                 $UPDATE_NOTES = "Abspeichern von Einstellungen repariert.";
221                 break;
222
223         case "0.2.1": // SQL queries for v0.2.1
224                 // Update notes (these will be set as task text!)
225                 $UPDATE_NOTES = "Durchf&uuml;hrung des Transfers korregiert.";
226                 break;
227
228         case "0.2.2": // SQL queries for v0.2.2
229                 // Update notes (these will be set as task text!)
230                 $UPDATE_NOTES = "Sicherheitsupdate f&uuml;r die Include-Befehle.";
231                 break;
232
233         case "0.2.3": // SQL queries for v0.2.3
234                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('member', '', 'list_transfer')";
235                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('member', '', 'del_transfer')";
236                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('config', '', 'config_transfer')";
237
238                 // Depends on sql_patches (or you have to execute these both SQL statements by phpMyAdmin
239                 $EXT_UPDATE_DEPENDS = "sql_patches";
240
241                 // Update notes (these will be set as task text!)
242                 $UPDATE_NOTES = "Erweiterung in's neue Men&uuml;system integriert.";
243                 break;
244
245         case "0.2.4": // SQL queries for v0.2.4
246                 // Update notes (these will be set as task text!)
247                 $UPDATE_NOTES = "<strong>Touring-Code wiederholen</strong> nach <strong>Touring-Code eingeben</strong> hin ge&auml;ndert.";
248                 break;
249
250         case "0.2.5": // SQL queries for v0.2.5
251                 $SQLs[] = "UPDATE `"._MYSQL_PREFIX."_member_menu` SET action='extras', sort='5' WHERE what='transfer' LIMIT 1";
252
253                 // Update notes (these will be set as task text!)
254                 $UPDATE_NOTES = "Mitgliedsmen&uuml; komplett ge&auml;ndert.";
255                 break;
256
257         case "0.2.6": // SQL queries for v0.2.6
258                 // Update notes (these will be set as task text!)
259                 $UPDATE_NOTES = "Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.";
260                 break;
261
262         case "0.2.7": // SQL queries for v0.2.7
263                 // Update notes (these will be set as task text!)
264                 $UPDATE_NOTES = "Die {!POINTS!} k&ouml;nnen nun wieder wie gewohnt transferiert werden. Der Grund f&uuml;r <em>{--TRANSFER_INVALID_PASSWORD--}</em> war, dass der Cookie-Hash ein anderer ist, als der in der Datenbank... :-/";
265                 break;
266
267         case "0.2.8": // SQL queries for v0.2.8
268                 // Update notes (these will be set as task text!)
269                 $UPDATE_NOTES = "Fehlermeldung <em>Notice: Undefined index: to_uid in {!PATH!}/inc/modules/member/what-transfer.php on line 301</em> gefixt. Danke an <a href=\"http://forum.mxchange.org/profile-8.html\" target=\"_blank\" title=\"Forumprofil von Piter01\">Piter01</a>.";
270                 break;
271
272         case "0.2.9": // SQL queries for v0.2.9
273                 // Update notes (these will be set as task text!)
274                 $UPDATE_NOTES = "Fehlerhinweis bei deaktivierter Erweiterung verbessert.";
275                 break;
276         }
277         break;
278
279 case "test": // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
280         break;
281
282 default: // Do stuff when extension is loaded
283         if ((isBooleanConstantAndTrue('__DAILY_RESET')) && (getConfig('ap_transfer') == "Y")) {
284                 // Automatically remove outdated or not displayed transactions
285                 TRANSFER_AUTPPURGE(getConfig('transfer_max'), getConfig('transfer_age'));
286         }
287         break;
288 }
289
290 //
291 ?>