Fixes saving of settings, inconsistency fixed in config entries
[mailer.git] / inc / extensions / ext-transfer.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * $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  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 }
43
44 // Version number
45 setThisExtensionVersion('0.2.9');
46
47 // Version history array (add more with , '0.1.0' and so on)
48 setExtensionVersionHistory(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 (getExtensionMode()) {
51         case 'register': // Do stuff when installation is running
52                 // SQL commands to run
53                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_transfers_in`");
54                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_transfers_out`");
55
56                 // Transfer from a member
57                 addExtensionSql("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_userid 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_userid),
67 PRIMARY KEY (id)
68 ) Type={?_TABLE_TYPE?}");
69
70                 // Transfers to a member
71                 addExtensionSql("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_userid 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_userid),
81 PRIMARY KEY (id)
82 ) Type={?_TABLE_TYPE?}");
83
84                 // Admin menu
85                 addAdminMenuSql('transfer', NULL, '{OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Transfer','Verwalten Sie hier die {OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Transaktionen zwischen Ihren Mitgliedern.', 7);
86                 addAdminMenuSql('transfer','list_transfer','Auflisten','Hier bekommen Sie alle ein- und ausgehende Transaktionen aufgelistet.', 1);
87                 addAdminMenuSql('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                 addAdminMenuSql('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                 addMemberMenuSql('main','transfer','{OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Transfer','N','Y', 5);
92
93                 // Add config values
94                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD transfer_max BIGINT(20) UNSIGNED NOT NULL DEFAULT '50'");
95                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD transfer_age BIGINT(20) UNSIGNED NOT NULL DEFAULT '".(getConfig('ONE_DAY')*28)."'");
96                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD transfer_timeout BIGINT(20) UNSIGNED NOT NULL DEFAULT '".getConfig('ONE_DAY')."'");
97                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD transfer_balance BIGINT(20) UNSIGNED NOT NULL DEFAULT 100");
98                 addExtensionSql("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                 addExtensionSql("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                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_transfers_in`");
107                 addExtensionSql("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_user_transfers_out`");
108                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='transfer'");
109                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='transfer'");
110                 addExtensionSql("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                 addExtensionSql("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                 addExtensionSql("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 (getCurrentExtensionVersion()) {
125                         case '0.0.2': // SQL queries for v0.0.2
126                                 // Update notes (these will be set as task text!)
127                                 setExtensionUpdateNotes("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.");
128                                 break;
129
130                         case '0.0.3': // SQL queries for v0.0.3
131                                 // Update notes (these will be set as task text!)
132                                 setExtensionUpdateNotes("&Uuml;berfl&uuml;ssige unset()-Anweisungen aus der what-config_transfer.php entfernt. Dies wird bereits von der eigenen Funktion adminSaveSettings() erledigt.");
133                                 break;
134
135                         case '0.0.3': // SQL queries for v0.0.3
136                                 // Update notes (these will be set as task text!)
137                                 setExtensionUpdateNotes("Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.");
138                                 break;
139
140                         case '0.0.5': // SQL queries for v0.0.5
141                                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD ap_transfer ENUM('Y','N') NOT NULL DEFAULT 'Y'");
142
143                                 // Update notes (these will be set as task text!)
144                                 setExtensionUpdateNotes("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!");
145                                 break;
146
147                         case '0.0.6': // SQL queries for v0.0.6
148                                 // Update notes (these will be set as task text!)
149                                 setExtensionUpdateNotes("Wegen des Theme-Supportes hat sich die URL zur CSS-Datei ge&auml;ndert.");
150                                 break;
151
152                         case '0.0.7': // SQL queries for v0.0.7
153                                 // Update notes (these will be set as task text!)
154                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
155                                 break;
156
157                         case '0.0.8': // SQL queries for v0.0.8
158                                 // Update notes (these will be set as task text!)
159                                 setExtensionUpdateNotes("Problem mit E in Transaktionsnummer beseitigt.");
160                                 break;
161
162                         case '0.0.9': // SQL queries for v0.0.9
163                                 // Update notes (these will be set as task text!)
164                                 setExtensionUpdateNotes("Problem mit Speicherung der Einstellungen beseitigt.");
165                                 break;
166
167                         case '0.1.0': // SQL queries for v0.2.1
168                                 // Update notes (these will be set as task text!)
169                                 setExtensionUpdateNotes("Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
170                                 break;
171
172                         case '0.1.1': // SQL queries for v0.1.1
173                                 // Update notes (these will be set as task text!)
174                                 setExtensionUpdateNotes("Design &quot;Solid-Business&quot; eingebaut.");
175                                 break;
176
177                         case '0.1.2': // SQL queries for v0.1.2
178                                 // Update notes (these will be set as task text!)
179                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
180                                 break;
181
182                         case '0.1.3': // SQL queries for v0.1.3
183                                 // Update notes (these will be set as task text!)
184                                 setExtensionUpdateNotes("IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.");
185                                 break;
186
187                         case '0.1.4': // SQL queries for v0.1.4
188                                 // Update notes (these will be set as task text!)
189                                 setExtensionUpdateNotes("Link zum Mitgliedsprofil in Funktion <u>generateUserProfileLink()</u> ausgelagert.");
190                                 break;
191
192                         case '0.1.5': // SQL queries for v0.1.5
193                                 // Update notes (these will be set as task text!)
194                                 setExtensionUpdateNotes("Template <u>admin_config_transfer_pro.tpl</u> ist &uuml;berfl&uuml;ssig geworden. Bitte l&ouml;schen Sie dies!");
195                                 break;
196
197                         case '0.1.6': // SQL queries for v0.1.6
198                                 // Update notes (these will be set as task text!)
199                                 setExtensionUpdateNotes("W&ouml;rter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.");
200                                 break;
201
202                         case '0.1.7': // SQL queries for v0.1.7
203                                 // Update notes (these will be set as task text!)
204                                 setExtensionUpdateNotes("Wort <strong>Punkte</strong> dynamisiert.");
205                                 break;
206
207                         case '0.1.8': // SQL queries for v0.1.8
208                                 // Update notes (these will be set as task text!)
209                                 setExtensionUpdateNotes("HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.");
210                                 break;
211
212                         case '0.1.9': // SQL queries for v0.1.9
213                                 // Update notes (these will be set as task text!)
214                                 setExtensionUpdateNotes("Parser-Error im Mitgliedsbereich beseitigt.");
215                                 break;
216
217                         case '0.2.0': // SQL queries for v0.2.0
218                                 // Update notes (these will be set as task text!)
219                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
220                                 break;
221
222                         case '0.2.1': // SQL queries for v0.2.1
223                                 // Update notes (these will be set as task text!)
224                                 setExtensionUpdateNotes("Durchf&uuml;hrung des Transfers korregiert.");
225                                 break;
226
227                         case '0.2.2': // SQL queries for v0.2.2
228                                 // Update notes (these will be set as task text!)
229                                 setExtensionUpdateNotes("Sicherheitsupdate f&uuml;r die Include-Befehle.");
230                                 break;
231
232                         case '0.2.3': // SQL queries for v0.2.3
233                                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (la_id, la_action, la_what) VALUES ('member', '', 'list_transfer')");
234                                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (la_id, la_action, la_what) VALUES ('member', '', 'del_transfer')");
235                                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (la_id, la_action, la_what) VALUES ('config', '', 'config_transfer')");
236
237                                 // Depends on sql_patches (or you have to execute these both SQL statements by phpMyAdmin
238                                 addExtensionUpdateDependency('sql_patches');
239
240                                 // Update notes (these will be set as task text!)
241                                 setExtensionUpdateNotes("Erweiterung in's neue Men&uuml;system integriert.");
242                                 break;
243
244                         case '0.2.4': // SQL queries for v0.2.4
245                                 // Update notes (these will be set as task text!)
246                                 setExtensionUpdateNotes("<strong>Touring-Code wiederholen</strong> nach <strong>Touring-Code eingeben</strong> hin ge&auml;ndert.");
247                                 break;
248
249                         case '0.2.5': // SQL queries for v0.2.5
250                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='extras', `sort`=5 WHERE `what`='transfer' LIMIT 1");
251
252                                 // Update notes (these will be set as task text!)
253                                 setExtensionUpdateNotes("Mitgliedsmen&uuml; komplett ge&auml;ndert.");
254                                 break;
255
256                         case '0.2.6': // SQL queries for v0.2.6
257                                 // Update notes (these will be set as task text!)
258                                 setExtensionUpdateNotes("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
259                                 break;
260
261                         case '0.2.7': // SQL queries for v0.2.7
262                                 // Update notes (these will be set as task text!)
263                                 setExtensionUpdateNotes("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... :-/");
264                                 break;
265
266                         case '0.2.8': // SQL queries for v0.2.8
267                                 // Update notes (these will be set as task text!)
268                                 setExtensionUpdateNotes("Fehlermeldung <em>Notice: Undefined index: to_userid 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>.");
269                                 break;
270
271                         case '0.2.9': // SQL queries for v0.2.9
272                                 // Update notes (these will be set as task text!)
273                                 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
274                                 break;
275                 }
276                 break;
277
278         case 'modify': // When the extension got modified
279                 break;
280
281         case 'test': // For testing purposes. For details see file inc/modules/admin/what-extensions.php, arround line 305.
282                 break;
283
284         case 'init': // When extension is initialized
285                 if ((isResetModeEnabled()) && (getConfig('ap_transfer') == 'Y')) {
286                         // Automatically remove outdated or not displayed transactions
287                         autoPurgeTransfers(getConfig('transfer_max'), getConfig('transfer_age'));
288                 } // END - if
289                 break;
290
291         default: // Unknown extension mode
292                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s detected.", getExtensionMode()));
293                 break;
294 }
295
296 // [EOF]
297 ?>