mailer project continued:
[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 - 2012 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
109                 // Unregister points data
110                 unregisterExtensionPointsData('transfer');
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=\"notice\">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                                 addConfigAddSql('ap_transfer', "ENUM('Y','N') NOT NULL DEFAULT 'Y'");
142
143                                 // Update notes (these will be set as task text!)
144                                 setExtensionUpdateNotes("Link <span class=\"bad\">Auflisten</span> 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 ext-sql_patches (or you have to execute these both SQL statements by phpMyAdmin
238                                 addExtensionDependency('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("Eintrag im Mitgliedsmen&uuml; verschoben.");
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 <span class=\"bad\">{--MEMBER_TRANSFER_INVALID_PASSWORD--}</span> 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 <span class=\"bad\">Notice: Undefined index: to_userid in {?PATH?}/inc/modules/member/what-transfer.php on line 301</span> 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                         case '0.3.0': // SQL queries for v0.3.0
277                                 // Register points data
278                                 registerExtensionPointsData('transfer', 'points', 'LOCKED', 'DIRECT');
279
280                                 // This depends on ext-sql_patches
281                                 addExtensionDependency('sql_patches');
282
283                                 // Update notes
284                                 setExtensionUpdateNotes("&Uuml;nerweisungen anderer Mitglieder werden nun &uuml;ber die Tabelle <strong>{OPEN_CONFIG}_MYSQL_PREFIX{CLOSE_CONFIG}_points_data</strong> verwaltet.");
285                                 break;
286                 } // END - switch
287                 break;
288
289         case 'modify': // When the extension got modified
290                 break;
291
292         case 'test': // For testing purposes
293                 break;
294
295         case 'init': // When extension is initialized
296                 if ((isResetModeEnabled()) && (getConfig('ap_transfer') == 'Y')) {
297                         // Automatically remove outdated or not displayed transactions
298                         autoPurgeTransfers(getConfig('transfer_max'), getConfig('transfer_age'));
299                 } // END - if
300                 break;
301
302         default: // Unknown extension mode
303                 logDebugMessage(__FILE__, __LINE__, sprintf("Unknown extension mode %s in extension %s detected.", getExtensionMode(), getCurrentExtensionName()));
304                 break;
305 } // END - switch
306
307 // [EOF]
308 ?>