3a56f2db75bb351150fbbba9d7084b99bab4e5da
[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 ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])))
36 {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 // Version number
42 $EXT_VERSION = "0.2.9";
43
44 // Auto-set extension version
45 if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION;
46
47 // Version history array (add more with , "0.1" and so on)
48 $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");
49
50 switch ($EXT_LOAD_MODE)
51 {
52 case "register": // Do stuff when installtion is running
53         // SQL commands to run
54         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_in";
55         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_out";
56
57         // Transfer from a member
58         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_user_transfers_in (
59 id bigint(20) not null auto_increment,
60 userid bigint(20) not null default '0',
61 from_uid bigint(20) not null default '0',
62 points bigint(20) not null default '0',
63 reason varchar(255) not null default '',
64 time_trans varchar(14) not null default '0',
65 trans_id varchar(12) not null default '',
66 KEY (userid),
67 KEY (from_uid),
68 PRIMARY KEY(id)
69 ) Type=MyISAM";
70
71         // Transfers to a member
72         $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_user_transfers_out (
73 id bigint(20) not null auto_increment,
74 userid bigint(20) not null default '0',
75 to_uid bigint(20) not null default '0',
76 points bigint(20) not null default '0',
77 reason varchar(255) not null default '',
78 time_trans varchar(14) not null default '0',
79 trans_id varchar(12) not null default '',
80 KEY (userid),
81 KEY (to_uid),
82 PRIMARY KEY(id)
83 ) Type=MyISAM";
84
85         // Admin menu
86         $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)";
87         $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)";
88         $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)";
89         $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)";
90
91         // Member menu
92         $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_member_menu (action, what, title, visible, locked, sort) VALUES ('main', 'transfer', '{!POINTS!}-Transfer', 'Y', 'Y', 5)";
93
94         // Add config values
95         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD transfer_max bigint(20) not null default '50'";
96         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD transfer_age bigint(20) not null default '".(ONE_DAY*28)."'";
97         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD transfer_timeout bigint(20) not null default '".ONE_DAY."'";
98         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD transfer_balance bigint(20) not null default '100'";
99         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD transfer_code bigint(20) not null default '5'";
100
101         // Add row(s) to user's data
102         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data ADD opt_in enum('Y', 'N') not null default 'N'";
103         break;
104
105 case "remove": // Do stuff when removing extension
106         // SQL commands to run
107         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_in";
108         $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_user_transfers_out";
109         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE action='transfer' LIMIT 4";
110         $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE what='transfer' LIMIT 1";
111         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config DROP transfer_max";
112         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config DROP transfer_age";
113         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config DROP transfer_timeout";
114         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config DROP transfer_balance";
115         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config DROP transfer_code";
116         $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_data DROP opt_in";
117         break;
118
119 case "activate": // Do stuff when admin activates this extension
120         // SQL commands to run
121         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='Y', locked='N' WHERE what='transfer' LIMIT 1";
122         break;
123
124 case "deactivate": // Do stuff when admin deactivates this extension
125         // SQL commands to run
126         $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET visible='Y', locked='Y' WHERE what='transfer' LIMIT 1";
127         break;
128
129 case "update": // Update an extension
130         switch ($EXT_VER)
131         {
132         case "0.0.2": // SQL queries for v0.0.2
133                 // Update notes (these will be set as task text!)
134                 $UPDATE_NOTES = "Fehler <FONT class=\"admin_failed\">Warning: Missing argument 2 for create_timestamp_from_selections() in ".PATH."inc/libs/pro_functions.php on line 227</FONT> behoben.";
135                 break;
136
137         case "0.0.3": // SQL queries for v0.0.3
138                 // Update notes (these will be set as task text!)
139                 $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.";
140                 break;
141
142         case "0.0.3": // SQL queries for v0.0.3
143                 // Update notes (these will be set as task text!)
144                 $UPDATE_NOTES = "Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.";
145                 break;
146
147         case "0.0.5": // SQL queries for v0.0.5
148                 $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_config ADD ap_transfer enum('Y', 'N') not null default 'Y'";
149
150                 // Update notes (these will be set as task text!)
151                 $UPDATE_NOTES = "Link <I>Auflisten</LI> 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!";
152                 break;
153
154         case "0.0.6": // SQL queries for v0.0.6
155                 // Update notes (these will be set as task text!)
156                 $UPDATE_NOTES = "Wegen des Theme-Supportes hat sich die URL zur CSS-Datei ge&auml;ndert.";
157                 break;
158
159         case "0.0.7": // SQL queries for v0.0.7
160                 // Update notes (these will be set as task text!)
161                 $UPDATE_NOTES = "Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.";
162                 break;
163
164         case "0.0.8": // SQL queries for v0.0.8
165                 // Update notes (these will be set as task text!)
166                 $UPDATE_NOTES = "Problem mit E in Transaktionsnummer beseitigt.";
167                 break;
168
169         case "0.0.9": // SQL queries for v0.0.9
170                 // Update notes (these will be set as task text!)
171                 $UPDATE_NOTES = "Problem mit Speicherung der Einstellungen beseitigt.";
172                 break;
173
174         case "0.1.0": // SQL queries for v0.2.1
175                 // Update notes (these will be set as task text!)
176                 $UPDATE_NOTES = "Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.";
177                 break;
178
179         case "0.1.1": // SQL queries for v0.1.1
180                 // Update notes (these will be set as task text!)
181                 $UPDATE_NOTES = "Design &quot;Solid-Business&quot; eingebaut.";
182                 break;
183
184         case "0.1.2": // SQL queries for v0.1.2
185                 // Update notes (these will be set as task text!)
186                 $UPDATE_NOTES = "Seit <A href=\"".SERVER_URL."/patches/340-Gast_Mitgliedsmenue_Deaktivieren.zip\">Patch 340</A> &uuml;berfl&uuml;ssige HTML-Tags entfernt.";
187                 break;
188
189         case "0.1.3": // SQL queries for v0.1.3
190                 // Update notes (these will be set as task text!)
191                 $UPDATE_NOTES = "IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.";
192                 break;
193
194         case "0.1.4": // SQL queries for v0.1.4
195                 // Update notes (these will be set as task text!)
196                 $UPDATE_NOTES = "Link zum Mitgliedsprofil in Funktion <U>ADMIN_USER_PROFILE_LINK()</U> ausgelagert.";
197                 break;
198
199         case "0.1.5": // SQL queries for v0.1.5
200                 // Update notes (these will be set as task text!)
201                 $UPDATE_NOTES = "Template <u>admin_config_transfer_pro.tpl</u> ist &uuml;berfl&uuml;ssig geworden. Bitte l&ouml;schen Sie dies!";
202                 break;
203
204         case "0.1.6": // SQL queries for v0.1.6
205                 // Update notes (these will be set as task text!)
206                 $UPDATE_NOTES = "W&ouml;rter <STRONG>Mailtausch</STRONG>, <STRONG>Mailtausches</STRONG> und <STRONG>Mailtauscher</STRONG> sind austauschbar.";
207                 break;
208
209         case "0.1.7": // SQL queries for v0.1.7
210                 // Update notes (these will be set as task text!)
211                 $UPDATE_NOTES = "Wort <STRONG>Punkte</STRONG> dynamisiert.";
212                 break;
213
214         case "0.1.8": // SQL queries for v0.1.8
215                 // Update notes (these will be set as task text!)
216                 $UPDATE_NOTES = "HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.";
217                 break;
218
219         case "0.1.9": // SQL queries for v0.1.9
220                 // Update notes (these will be set as task text!)
221                 $UPDATE_NOTES = "Parser-Error im Mitgliedsbereich beseitigt.";
222                 break;
223
224         case "0.2.0": // SQL queries for v0.2.0
225                 // Update notes (these will be set as task text!)
226                 $UPDATE_NOTES = "Abspeichern von Einstellungen repariert.";
227                 break;
228
229         case "0.2.1": // SQL queries for v0.2.1
230                 // Update notes (these will be set as task text!)
231                 $UPDATE_NOTES = "Durchf&uuml;hrung des Transfers korregiert.";
232                 break;
233
234         case "0.2.2": // SQL queries for v0.2.2
235                 // Update notes (these will be set as task text!)
236                 $UPDATE_NOTES = "Sicherheitsupdate f&uuml;r die Include-Befehle.";
237                 break;
238
239         case "0.2.3": // SQL queries for v0.2.3
240                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('member', NULL, 'list_transfer')";
241                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('member', NULL, 'del_transfer')";
242                 $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu_las (la_id, la_action, la_what) VALUES ('config', NULL, 'config_transfer')";
243
244                 // Depends on sql_patches (or you have to execute these both SQL statements by phpMyAdmin
245                 $EXT_UPDATE_DEPENDS = "sql_patches";
246
247                 // Update notes (these will be set as task text!)
248                 $UPDATE_NOTES = "Erweiterung in's neue Men&uuml;system integriert.";
249                 break;
250
251         case "0.2.4": // SQL queries for v0.2.4
252                 // Update notes (these will be set as task text!)
253                 $UPDATE_NOTES = "<STRONG>Touring-Code wiederholen</STRONG> nach <STRONG>Touring-Code eingeben</STRONG> hin ge&auml;ndert.";
254                 break;
255
256         case "0.2.5": // SQL queries for v0.2.5
257                 $SQLs[] = "UPDATE "._MYSQL_PREFIX."_member_menu SET action='extras', sort='5' WHERE what='transfer' LIMIT 1";
258
259                 // Update notes (these will be set as task text!)
260                 $UPDATE_NOTES = "Mitgliedsmen&uuml; komplett ge&auml;ndert.";
261                 break;
262
263         case "0.2.6": // SQL queries for v0.2.6
264                 // Update notes (these will be set as task text!)
265                 $UPDATE_NOTES = "Hash-Erstellung von <STRONG>md5()</STRONG> auf bessere Funktion <STRONG>generateHash()</STRONG> umgestellt.";
266                 break;
267
268         case "0.2.7": // SQL queries for v0.2.7
269                 // Update notes (these will be set as task text!)
270                 $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... :-/";
271                 break;
272
273         case "0.2.8": // SQL queries for v0.2.8
274                 // Update notes (these will be set as task text!)
275                 $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>.";
276                 break;
277
278         case "0.2.9": // SQL queries for v0.2.9
279                 // Update notes (these will be set as task text!)
280                 $UPDATE_NOTES = "Fehlerhinweis bei deaktivierter Erweiterung verbessert.";
281                 break;
282         }
283         break;
284
285 default: // Do stuff when extension is loaded
286         $dummy = LOAD_CONFIG();
287         $_CONFIG = array_merge($_CONFIG, $dummy);
288         unset($dummy);
289
290         if ((defined('__DAILY_RESET')) && ($_CONFIG['ap_transfer'] == 'Y'))
291         {
292                 // Automatically remove outdated or not displayed transactions
293                 TRANSFER_AUTPPURGE($_CONFIG['transfer_max'], $_CONFIG['transfer_age']);
294         }
295         break;
296 }
297 // Language file prefix
298 $EXT_LANG_PREFIX = "transfer";
299
300 // Extension is always active?
301 $EXT_ALWAYS_ACTIVE = 'N';
302
303 //
304 ?>