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