abcc5f55faeb3dd09bea283b1a21828dbcf00f4a
[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  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 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.3.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', '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'));
48
49 switch (getExtensionMode()) {
50         case 'register': // Do stuff when installation is running
51                 // Transfer from a member
52                 addDropTableSql('user_transfers_in');
53                 addCreateTableSql('user_transfers_in', "
54 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
55 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
56 `from_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
57 `points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
58 `reason` VARCHAR(255) NOT NULL DEFAULT '',
59 `time_trans` VARCHAR(14) NOT NULL DEFAULT 0,
60 `trans_id` VARCHAR(12) NOT NULL DEFAULT '',
61 PRIMARY KEY (`id`),
62 INDEX (`userid`),
63 INDEX (`from_userid`)",
64                         'Ingoing points transfers');
65
66                 // Transfers to a member
67                 addDropTableSql('user_transfers_out');
68                 addCreateTableSql('user_transfers_out', "
69 `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
70 `userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
71 `to_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
72 `points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
73 `reason` VARCHAR(255) NOT NULL DEFAULT '',
74 `time_trans` VARCHAR(14) NOT NULL DEFAULT 0,
75 `trans_id` VARCHAR(12) NOT NULL DEFAULT '',
76 PRIMARY KEY (`id`),
77 INDEX (`userid`),
78 INDEX (`to_userid`)",
79                         'Outgoing points transfers');
80
81                 // Admin menu
82                 addAdminMenuSql('transfer', NULL, '{OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Transfer','Verwalten Sie hier die {OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Transaktionen zwischen Ihren Mitgliedern.', 7);
83                 addAdminMenuSql('transfer','list_transfer','Auflisten','Hier bekommen Sie alle ein- und ausgehende Transaktionen aufgelistet.', 1);
84                 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);
85                 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);
86
87                 // Member menu
88                 addMemberMenuSql('extras', 'transfer', '{OPEN_CONFIG}POINTS{CLOSE_CONFIG}-Transfer', 5);
89
90                 // Add config values
91                 addConfigAddSql('transfer_max', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 50');
92                 addConfigAddSql('transfer_age', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT ' . (getOneDay() * 28));
93                 addConfigAddSql('transfer_timeout', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT {?ONE_DAY?}');
94                 addConfigAddSql('transfer_balance', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 100');
95                 addConfigAddSql('transfer_code', 'BIGINT(20) UNSIGNED NOT NULL DEFAULT 5');
96
97                 // Add row(s) to user's data
98                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` ADD opt_in ENUM('Y','N') NOT NULL DEFAULT 'N'");
99                 break;
100
101         case 'remove': // Do stuff when removing extension
102                 // SQL commands to run
103                 addDropTableSql('user_transfers_in');
104                 addDropTableSql('user_transfers_out');
105                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='transfer'");
106                 addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_member_menu` WHERE `what`='transfer' LIMIT 1");
107                 addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_user_data` DROP `opt_in`");
108                 break;
109
110         case 'activate': // Do stuff when admin activates this extension
111                 // SQL commands to run
112                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='transfer' LIMIT 1");
113                 break;
114
115         case 'deactivate': // Do stuff when admin deactivates this extension
116                 // SQL commands to run
117                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `visible`='Y', `locked`='N' WHERE `what`='transfer' LIMIT 1");
118                 break;
119
120         case 'update': // Update an extension
121                 switch (getCurrentExtensionVersion()) {
122                         case '0.0.2': // SQL queries for v0.0.2
123                                 // Update notes (these will be set as task text!)
124                                 setExtensionUpdateNotes("Fehler <div class=\"notice\">Warning: Missing argument 2 for create_timestamp_from_selections() in {?PATH?}inc/libs/pro_functions.php on line 227</div> behoben.");
125                                 break;
126
127                         case '0.0.3': // SQL queries for v0.0.3
128                                 // Update notes (these will be set as task text!)
129                                 setExtensionUpdateNotes("&Uuml;berfl&uuml;ssige unset()-Anweisungen aus der what-config_transfer.php entfernt. Dies wird bereits von der eigenen Funktion adminSaveSettings() erledigt.");
130                                 break;
131
132                         case '0.0.3': // SQL queries for v0.0.3
133                                 // Update notes (these will be set as task text!)
134                                 setExtensionUpdateNotes("Fehlende Abfrage im Mitlieder-Modul, on Erweiterung auch aktiviert ist.");
135                                 break;
136
137                         case '0.0.5': // SQL queries for v0.0.5
138                                 addConfigAddSql('ap_transfer', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
139
140                                 // Update notes (these will be set as task text!)
141                                 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!");
142                                 break;
143
144                         case '0.0.6': // SQL queries for v0.0.6
145                                 // Update notes (these will be set as task text!)
146                                 setExtensionUpdateNotes("Wegen des Theme-Supportes hat sich die URL zur CSS-Datei ge&auml;ndert.");
147                                 break;
148
149                         case '0.0.7': // SQL queries for v0.0.7
150                                 // Update notes (these will be set as task text!)
151                                 setExtensionUpdateNotes("Fehler beseitigt, wenn error_reporting=E_ALL gesetzt ist.");
152                                 break;
153
154                         case '0.0.8': // SQL queries for v0.0.8
155                                 // Update notes (these will be set as task text!)
156                                 setExtensionUpdateNotes("Problem mit E in Transaktionsnummer beseitigt.");
157                                 break;
158
159                         case '0.0.9': // SQL queries for v0.0.9
160                                 // Update notes (these will be set as task text!)
161                                 setExtensionUpdateNotes("Problem mit Speicherung der Einstellungen beseitigt.");
162                                 break;
163
164                         case '0.1.0': // SQL queries for v0.2.1
165                                 // Update notes (these will be set as task text!)
166                                 setExtensionUpdateNotes("Men&uuml;punkte im Gast-/Mitgliedsbereich k&ouml;nnen nicht mehr aufgerufen werden, wenn die Erweiterung deaktiviert ist.");
167                                 break;
168
169                         case '0.1.1': // SQL queries for v0.1.1
170                                 // Update notes (these will be set as task text!)
171                                 setExtensionUpdateNotes("Design &quot;Solid-Business&quot; eingebaut.");
172                                 break;
173
174                         case '0.1.2': // SQL queries for v0.1.2
175                                 // Update notes (these will be set as task text!)
176                                 setExtensionUpdateNotes("Seit <strong>Patch 340</strong> &uuml;berfl&uuml;ssige HTML-Tags entfernt.");
177                                 break;
178
179                         case '0.1.3': // SQL queries for v0.1.3
180                                 // Update notes (these will be set as task text!)
181                                 setExtensionUpdateNotes("IP-Nummer und Browserbezeichnung wird in Admin-Mails eingesetzt.");
182                                 break;
183
184                         case '0.1.4': // SQL queries for v0.1.4
185                                 // Update notes (these will be set as task text!)
186                                 setExtensionUpdateNotes("Link zum Mitgliedsprofil in Funktion <u>generateUserProfileLink()</u> ausgelagert.");
187                                 break;
188
189                         case '0.1.5': // SQL queries for v0.1.5
190                                 // Update notes (these will be set as task text!)
191                                 setExtensionUpdateNotes("Template <u>admin_config_transfer_pro.tpl</u> ist &uuml;berfl&uuml;ssig geworden. Bitte l&ouml;schen Sie dies!");
192                                 break;
193
194                         case '0.1.6': // SQL queries for v0.1.6
195                                 // Update notes (these will be set as task text!)
196                                 setExtensionUpdateNotes("W&ouml;rter <strong>{?mt_word?}</strong>, <strong>{?mt_word2?}</strong> und <strong>{?mt_word3?}</strong> sind austauschbar.");
197                                 break;
198
199                         case '0.1.7': // SQL queries for v0.1.7
200                                 // Update notes (these will be set as task text!)
201                                 setExtensionUpdateNotes("Wort <strong>Punkte</strong> dynamisiert.");
202                                 break;
203
204                         case '0.1.8': // SQL queries for v0.1.8
205                                 // Update notes (these will be set as task text!)
206                                 setExtensionUpdateNotes("HTML-Code ausgelagert in Templates und SQL-Anweisungen abgesichert.");
207                                 break;
208
209                         case '0.1.9': // SQL queries for v0.1.9
210                                 // Update notes (these will be set as task text!)
211                                 setExtensionUpdateNotes("Parser-Error im Mitgliedsbereich beseitigt.");
212                                 break;
213
214                         case '0.2.0': // SQL queries for v0.2.0
215                                 // Update notes (these will be set as task text!)
216                                 setExtensionUpdateNotes("Abspeichern von Einstellungen repariert.");
217                                 break;
218
219                         case '0.2.1': // SQL queries for v0.2.1
220                                 // Update notes (these will be set as task text!)
221                                 setExtensionUpdateNotes("Durchf&uuml;hrung des Transfers korregiert.");
222                                 break;
223
224                         case '0.2.2': // SQL queries for v0.2.2
225                                 // Update notes (these will be set as task text!)
226                                 setExtensionUpdateNotes("Sicherheitsupdate f&uuml;r die Include-Befehle.");
227                                 break;
228
229                         case '0.2.3': // SQL queries for v0.2.3
230                                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`,`la_action`,`la_what`) VALUES ('member', '', 'list_transfer')");
231                                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`,`la_action`,`la_what`) VALUES ('member', '', 'del_transfer')");
232                                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_admin_menu_las` (`la_id`,`la_action`,`la_what`) VALUES ('config', '', 'config_transfer')");
233
234                                 // Depends on ext-sql_patches (or you have to execute these both SQL statements by phpMyAdmin
235                                 addExtensionDependency('sql_patches');
236
237                                 // Update notes (these will be set as task text!)
238                                 setExtensionUpdateNotes("Erweiterung in's neue Men&uuml;system integriert.");
239                                 break;
240
241                         case '0.2.4': // SQL queries for v0.2.4
242                                 // Update notes (these will be set as task text!)
243                                 setExtensionUpdateNotes("<strong>Touring-Code wiederholen</strong> nach <strong>Touring-Code eingeben</strong> hin ge&auml;ndert.");
244                                 break;
245
246                         case '0.2.5': // SQL queries for v0.2.5
247                                 addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `action`='extras', `sort`=5 WHERE `what`='transfer' LIMIT 1");
248
249                                 // Update notes (these will be set as task text!)
250                                 setExtensionUpdateNotes("Eintrag im Mitgliedsmen&uuml; verschoben.");
251                                 break;
252
253                         case '0.2.6': // SQL queries for v0.2.6
254                                 // Update notes (these will be set as task text!)
255                                 setExtensionUpdateNotes("Hash-Erstellung von <strong>md5()</strong> auf bessere Funktion <strong>generateHash()</strong> umgestellt.");
256                                 break;
257
258                         case '0.2.7': // SQL queries for v0.2.7
259                                 // Update notes (these will be set as task text!)
260                                 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... :-/");
261                                 break;
262
263                         case '0.2.8': // SQL queries for v0.2.8
264                                 // Update notes (these will be set as task text!)
265                                 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>.");
266                                 break;
267
268                         case '0.2.9': // SQL queries for v0.2.9
269                                 // Update notes (these will be set as task text!)
270                                 setExtensionUpdateNotes("Fehlerhinweis bei deaktivierter Erweiterung verbessert.");
271                                 break;
272
273                         case '0.3.0': // SQL queries for v0.3.0
274                                 addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`,`column_name`,`locked_mode`,`payment_method`) VALUES ('transfer','points','LOCKED','DIRECT')");
275
276                                 // This depends on ext-sql_patches
277                                 addExtensionDependency('sql_patches');
278
279                                 // Update notes
280                                 setExtensionUpdateNotes("&Uuml;nerweisungen anderer Mitglieder werden nun &uuml;ber die Tabelle <strong>{OPEN_CONFIG}_MYSQL_PREFIX{CLOSE_CONFIG}_points_data</strong> verwaltet.");
281                                 break;
282                 } // END - switch
283                 break;
284
285         case 'modify': // When the extension got modified
286                 break;
287
288         case 'test': // For testing purposes
289                 break;
290
291         case 'init': // When extension is initialized
292                 if ((isResetModeEnabled()) && (getConfig('ap_transfer') == 'Y')) {
293                         // Automatically remove outdated or not displayed transactions
294                         autoPurgeTransfers(getConfig('transfer_max'), getConfig('transfer_age'));
295                 } // END - if
296                 break;
297
298         default: // Unknown extension mode
299                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
300                 break;
301 } // END - switch
302
303 // [EOF]
304 ?>