Way more usage of EL code:
[mailer.git] / inc / modules / member / what-transfer.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/07/2004 *
4  * ===================                          Last change: 10/07/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-transfer.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : Point transfers                                  *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Punktetransfers                                  *
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://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 } elseif (!isMember()) {
42         redirectToIndexMemberOnlyModule();
43 }
44
45 // Add description as navigation point
46 addYouAreHereLink('member', __FILE__);
47
48 if ((!isExtensionActive('transfer')) && (!isAdmin())) {
49         displayMessage(generateExtensionInactiveNotInstalledMessage('transfer'));
50         return;
51 } // END - if
52
53 // Check for mode in GET
54 $mode = '';
55 if (isGetRequestParameterSet('mode')) {
56         $mode = getRequestParameter('mode');
57 } // END - if
58
59 // Check for "faker"
60 if ((getUserData('opt_in') != 'Y') && ($mode == 'new')) {
61         $mode = '';
62 } // END - if
63
64 switch ($mode) {
65         case 'new': // Start new transfer
66                 // Get total points and subtract the balance amount from it = maximum transferable points
67                 $total = getTotalPoints(getMemberId());
68
69                 // Remember maximum value for template
70                 $content['max_transferable'] = round($total - getConfig('transfer_balance') - 0.5);
71
72                 if (isFormSent()) {
73                         // Add new transfer
74                         if (getTransferCode() > 0) {
75                                 // Check for code
76                                 $code = generateRandomCode(getTransferCode(), postRequestParameter('code_chk'), getMemberId(), $content['max_transferable']);
77                                 $valid_code = ($code == postRequestParameter('code'));
78                         } else {
79                                 // Zero length (= disabled) is always valid!
80                                 $valid_code = true;
81                         }
82
83                         // Test password
84                         $valid_pass = ($pass == generateHash(postRequestParameter('password'), $pass));
85
86                         // Test transfer amount
87                         $valid_amount = ((isPostRequestParameterSet('points')) && (postRequestParameter('points') <= $content['max_transferable']));
88
89                         // Test reason for transfer
90                         $valid_reason = (isPostRequestParameterSet('reason'));
91
92                         // Test if a recipient is selected
93                         $valid_recipient = isValidUserId(postRequestParameter('to_userid'));
94
95                         // Check for nickname extension and set additional data
96                         // @TODO Rewrite this to a filter
97                         $add = '';
98                         if (isExtensionActive('nickname')) {
99                                 $add = ', `nickname`';
100                         } // END - if
101
102                         // Re-check receivers and own personal data
103                         $result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email`".$add." FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid` IN ('%s','%s') AND `status`='CONFIRMED' LIMIT 2",
104                                 array(
105                                         getMemberId(),
106                                         bigintval(postRequestParameter('to_userid'))
107                                 ), __FILE__, __LINE__);
108
109                         // Do we have two entries?
110                         $valid_data = (SQL_NUMROWS($result) == 2);
111
112                         // Final check if all is fine
113                         if ($valid_code && $valid_data && $valid_pass && $valid_amount && $valid_reason && $valid_recipient) {
114                                 // Let's start the transfer and load user data
115                                 $content['sender']    = SQL_FETCHARRAY($result);
116                                 $content['recipient'] = SQL_FETCHARRAY($result);
117
118                                 // Is the nickname extension not installed?
119                                 if (!isExtensionActive('nickname')) {
120                                         // Fix empty nicknames
121                                         $content['sender']['nickname']    = '';
122                                         $content['recipient']['nickname'] = '';
123                                 } // END - if
124
125                                 // Prepare variables for testing
126                                 $TEST_NICK_SENDER = $content['sender']['nickname'];
127                                 $TEST_NICK_REC    = $content['recipient']['nickname'];
128
129                                 // Default is userids for subject line
130                                 $SENDER    = getMemberId();
131                                 $RECIPIENT = bigintval(postRequestParameter('to_userid'));
132
133                                 // If nickname is installed we can set the nickname
134                                 // @TODO Rewrite this to a filter
135                                 if (isExtensionActive('nickname')) {
136                                         if (($TEST_NICK_SENDER != getMemberId()) && (!empty($TEST_NICK_SENDER))) {
137                                                 $SENDER = $content['sender']['nickname'];
138                                         } // END - if
139
140                                         if (($TEST_NICK_REC != postRequestParameter('to_userid')) && (!empty($TEST_NICK_REC))) {
141                                                 $RECIPIENT = $content['recipient']['nickname'];
142                                         } // END - if
143                                 } // END - if
144
145                                 // Remember transfer reason
146                                 $content['reason']  = postRequestParameter('reason');
147
148                                 // Generate tranafer id
149                                 $content['trans_id'] = bigintval(generateRandomCode('10', mt_rand(0, 99999), getMemberId(), postRequestParameter('reason')));
150
151                                 // Add entries to both tables
152                                 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_transfers_in` (`userid`, `from_userid`, `points`, `reason`, `time_trans`, `trans_id`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(),%s)",
153                                         array(bigintval(postRequestParameter('to_userid')), getMemberId(), bigintval(postRequestParameter('points')), postRequestParameter('reason'), $content['trans_id']), __FILE__, __LINE__);
154                                 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_transfers_out` (`userid`, `to_userid`, `points`, `reason`, `time_trans`, `trans_id`) VALUES (%s,%s,%s,'%s', UNIX_TIMESTAMP(),%s)",
155                                         array(getMemberId(), bigintval(postRequestParameter('to_userid')), bigintval(postRequestParameter('points')), postRequestParameter('reason'), $content['trans_id']), __FILE__, __LINE__);
156
157                                 // Add points to account *directly* ...
158                                 addPointsDirectly('transfer', bigintval(postRequestParameter('to_userid')), bigintval(postRequestParameter('points')));
159
160                                 // ... and add it to current user's used points
161                                 subtractPoints('transfer', getMemberId(), postRequestParameter('points'));
162
163                                 // First send email to recipient
164                                 $message = loadEmailTemplate('member_transfer_recipient', $content, postRequestParameter('to_userid'));
165                                 sendEmail($content['recipient']['email'], '{--TRANSFER_MEMBER_RECIPIENT_SUBJECT--}' . ': ' . $SENDER, $message);
166
167                                 // Second send email to sender
168                                 $message = loadEmailTemplate('member_transfer_sender', $content, getMemberId());
169                                 sendEmail($content['sender']['email'], '{--TRANSFER_MEMBER_SENDER_SUBJECT--}' . ': ' . $RECIPIENT, $message);
170
171                                 // At last send admin mail(s)
172                                 $adminSubject = sprintf("%s (%s->%s)", '{--TRANSFER_ADMIN_SUBJECT--}', $SENDER, $RECIPIENT);
173                                 sendAdminNotification($adminSubject, 'admin_transfer_points', $content);
174
175                                 // Transfer is completed
176                                 displayMessage('<div>{--TRANSFER_COMPLETED--}' . '</div><div><a href="{%url=modules.php?module=login&amp;what=transfer%}">{--TRANSFER_CONTINUE_OVERVIEW--}</a></div>');
177                         } elseif ($valid_code === false) {
178                                 // Invalid Touring code!
179                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_CODE--}');
180                                 unsetPostRequestParameter('ok');
181                         } elseif ($valid_pass === false) {
182                                 // Wrong password entered
183                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_PASSWORD--}');
184                                 unsetPostRequestParameter('ok');
185                         } elseif ($valid_amount === false) {
186                                 // Too much points entered
187                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_POINTS--}');
188                                 unsetPostRequestParameter('ok');
189                         } elseif ($valid_reason === false) {
190                                 // No transfer reason entered
191                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_REASON--}');
192                                 unsetPostRequestParameter('ok');
193                         } elseif ($valid_recipient === false) {
194                                 // No recipient selected
195                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_RECIPIENT--}');
196                                 unsetPostRequestParameter('ok');
197                         } elseif ($valid_data === false) {
198                                 // No recipient/sender selected
199                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_DATA--}');
200                                 unsetPostRequestParameter('ok');
201                         }
202
203                         // Free result
204                         SQL_FREERESULT($result);
205                 } // END - if
206
207                 if (!isFormSent()) {
208                         // Load member list
209                         if (isExtensionActive('nickname')) {
210                                 // Load userid and nickname
211                                 $result = SQL_QUERY_ESC("SELECT `userid`, `nickname` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' AND `opt_in`='Y' AND `userid` != '%s' ORDER BY `userid` ASC",
212                                         array(getMemberId()), __FILE__, __LINE__);
213                         } else {
214                                 // Load only userid
215                                 $result = SQL_QUERY_ESC("SELECT `userid`, `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `status`='CONFIRMED' AND `opt_in`='Y' AND `userid` != '%s' ORDER BY `userid` ASC",
216                                         array(getMemberId()), __FILE__, __LINE__);
217                         }
218
219                         if (!SQL_HASZERONUMS($result)) {
220                                 // Load list
221                                 $OUT  = '<select name="to_userid" size="1" class="form_select">
222         <option value="0">{--SELECT_NONE--}</option>';
223                                 // @TODO Try to rewrite his to $content = SQL_FETCHARRAY(), see some lines above for two different queries
224                                 while (list($userid, $nick) = SQL_FETCHROW($result)) {
225                                         $OUT .= '       <option value="' . $userid . '"';
226                                         if ((isPostRequestParameterSet('to_userid')) && (postRequestParameter('to_userid') == $userid)) $OUT .= ' selected="selected"';
227                                         $OUT .= '>';
228                                         if (($nick != $userid) && (!empty($nick))) {
229                                                 // Output nickname
230                                                 $OUT .= $nick;
231                                         } else {
232                                                 // Output userid
233                                                 $OUT .= $userid;
234                                         }
235                                         $OUT .= '</option>';
236                                 }
237                                 $OUT .= '</select>';
238                                 $content['to_disabled'] = '';
239
240                                 // Free memory
241                                 SQL_FREERESULT($result);
242                         } else {
243                                 // No one else is opt-in
244                                 $OUT = displayMessage('{--TRANSFER_NO_ONE_ELSE_OPT_IN--}', true);
245                                 $content['to_disabled'] = ' disabled="disabled"';
246                         }
247
248                         // Transfer output to constant for the template
249                         $content['userid_selection'] = $OUT;
250
251                         // Generate Code
252                         if (getTransferCode() > 0) {
253                                 // Generate random number
254                                 $rand = mt_rand(0, 99999);
255
256                                 // Generate CAPTCHA code
257                                 $code = generateRandomCode(getTransferCode(), $rand, getMemberId(), $content['max_transferable']);
258
259                                 // Generate image (HTML code)
260                                 $img = generateImageOrCode($code, false);
261
262                                 // Add all and hidden field
263                                 $content['captcha_code'] = '<input type="hidden" name="code_chk" value="' . $rand . '" /><input type="text" name="code" class="form_field" size="5" maxlength="7"' . $content['to_disabled'] . ' />&nbsp;' . $img;
264                         } else {
265                                 $code = '00000';
266                                 $content['captcha_code'] = displayMessage('{--TRANSFER_NO_CODE--}', true);
267                         }
268
269                         // Init points/reason
270                         $content['points'] = '';
271                         $content['reason'] = '';
272
273                         // Transfer maybe already entered valued'
274                         if (isPostRequestParameterSet('ok')) {
275                                 // Get values from form
276                                 $content['points'] = postRequestParameter('points');
277                                 $content['reason'] = postRequestParameter('reason');
278                         } // END - if
279
280                         // Output form
281                         loadTemplate('member_transfer_new', false, $content);
282                 } // END - if
283                 break;
284
285         case 'list_in': // List only incoming transactions
286         case 'list_out': // List only outgoing transactions
287                 // As you can see I put list_in and list_out together. I now do a switch() again on it for the right SQL command
288                 $nothingMessage = '';
289                 switch ($mode) {
290                         case 'list_in':
291                                 $sql = 'SELECT `trans_id`, `from_userid` AS party_userid, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `userid`=%s ORDER BY `time_trans` DESC LIMIT {?transfer_max?}';
292                                 $nothingMessage     = '{--TRANSFER_NO_INCOMING_TRANSFERS--}';
293                                 $content['balance'] = '{--TRANSFER_TOTAL_INCOMING--}';
294                                 $content['title']   = '{--TRANSFER_LIST_INCOMING--}';
295                                 break;
296
297                         case 'list_out':
298                                 $sql = 'SELECT `trans_id`, `to_userid` AS party_userid, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `userid`=%s ORDER BY `time_trans` DESC LIMIT {?transfer_max?}';
299                                 $nothingMessage     = '{--TRANSFER_NO_OUTGOING_TRANSFERS--}';
300                                 $content['balance'] = '{--TRANSFER_TOTAL_OUTGOING--}';
301                                 $content['title']   = '{--TRANSFER_LIST_OUTGOING--}';
302                                 break;
303                 } // END - switch
304
305                 // Run the SQL command and set total points to zero
306                 $totalPoints = '0';
307                 $result = SQL_QUERY_ESC($sql, array(getMemberId()), __FILE__, __LINE__);
308
309                 // Do we have entries?
310                 if (!SQL_HASZERONUMS($result)) {
311                         $OUT = '';
312                         while ($content = SQL_FETCHARRAY($result)) {
313                                 // Rewrite points, out is subtracted
314                                 if ($type == 'OUT') {
315                                         $content['points'] = $content['points'] * -1;
316                                 } // END - if
317
318                                 // Prepare content for template
319                                 $$content['time_trans'] = generateDateTime($content['time_trans'], 3);
320
321                                 // Load row template
322                                 $OUT .= loadTemplate('member_transfer_row2', true, $content);
323
324                                 // Add points and switch color
325                                 $totalPoints += $content['points'];
326                         } // END - while
327
328                         // Free memory
329                         SQL_FREERESULT($result);
330                 } else {
331                         // Nothing for in or out
332                         $OUT = '<tr>
333   <td colspan="5" align="center" class="bottom">
334     ' . displayMessage($nothingMessage, true) . '
335   </td>
336 </tr>';
337                 }
338
339                 // ... and add them to a constant for the template
340                 $content['rows'] = $OUT;
341
342                 // Remeber total amount
343                 $content['total_points'] = $totalPoints;
344
345                 // Load final template
346                 loadTemplate('member_transfer_list', false, $content);
347                 break;
348
349         case 'list_all': // List all transactions
350                 /*
351                  * Fill a temporary table with data from both tables. This is much
352                  * easier to code and unstandable by you as sub-SELECT queries. I know
353                  * this is not the fastest way but it shall be fine for now.
354                  */
355
356                 // First of all create the per-user temporary table
357                 $result = SQL_QUERY_ESC("CREATE TEMPORARY TABLE `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (
358 `trans_id` VARCHAR(12) NOT NULL DEFAULT '',
359 `party_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
360 `points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
361 `reason` VARCHAR(255) NOT NULL DEFAULT '',
362 `time_trans` VARCHAR(10) NOT NULL DEFAULT 0,
363 `trans_type` ENUM('IN','OUT') NOT NULL DEFAULT 'IN',
364 KEY (`party_userid`)
365 ) TYPE = HEAP COMMENT = 'Temporary transfer table'", array(getMemberId()), __FILE__, __LINE__);
366
367                 // Let's begin with the incoming list
368                 $result = SQL_QUERY_ESC("SELECT `trans_id`, `from_userid`, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `userid`=%s ORDER BY `id` ASC LIMIT {?transfer_max?}",
369                         array(getMemberId()), __FILE__, __LINE__);
370                 while ($DATA = SQL_FETCHROW($result)) {
371                         $DATA[] = 'IN';
372                         $DATA = implode("','", $DATA);
373                         $res_temp = SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $DATA . "')", array(getMemberId()), __FILE__, __LINE__);
374                 } // END - while
375
376                 // Free memory
377                 SQL_FREERESULT($result);
378
379                 // As the last table transfer data from outgoing table to temporary
380                 $result = SQL_QUERY_ESC("SELECT `trans_id`, `to_userid`, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_out` WHERE `userid`=%s ORDER BY `id` LIMIT {?transfer_max?}",
381                         array(getMemberId()), __FILE__, __LINE__);
382                 while ($DATA = SQL_FETCHROW($result)) {
383                         $DATA[] = 'OUT';
384                         $DATA = implode("','", $DATA);
385                         $res_temp = SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $DATA . "')", array(getMemberId()), __FILE__, __LINE__);
386                 } // END - while
387
388                 // Free memory
389                 SQL_FREERESULT($result);
390
391                 // Search for entries
392                 $result = SQL_QUERY_ESC("SELECT `party_userid`, `trans_id`, `points`, `reason`, `time_trans`, `trans_type` FROM `{?_MYSQL_PREFIX?}_%s_transfers_tmp` ORDER BY `time_trans` DESC",
393                         array(getMemberId()), __FILE__, __LINE__);
394
395                 $total = '0';
396                 if (!SQL_HASZERONUMS($result)) {
397                         // Output rows
398                         $OUT = '';
399                         while ($content = SQL_FETCHARRAY($result)) {
400                                 // Rewrite points if OUT
401                                 if ($content['trans_type'] == 'OUT') {
402                                         $content['points'] = $content['points'] * -1;
403                                 } // END - if
404
405                                 // Prepare content for template
406                                 $content['time']   = generateDateTime($content['time_trans'], 3);
407
408                                 // Load row template
409                                 $OUT .= loadTemplate('member_transfer_row', true, $content);
410
411                                 // Add points and switch color
412                                 $total += $content['points'];
413                         } // END - while
414                 } else {
415                         // Nothing for in and out
416                         $OUT = '<tr>
417   <td colspan="5" align="center" class="bottom">
418     ' . displayMessage('{--TRANSFER_NO_INOUT_TRANSFERS--}', true) . '
419   </td>
420 </tr>';
421                 }
422
423                 // Free memory
424                 SQL_FREERESULT($result);
425
426                 // ... and add them to a constant for the template
427                 $content['rows'] =  $OUT;
428
429                 // Remeber total amount
430                 $content['total_points'] = $total;
431
432                 // Set title
433                 $content['title'] = '{--TRANSFER_LIST_ALL--}';
434
435                 // Set "balance" word
436                 $content['balance'] = '{--TRANSFER_TOTAL_BALANCE--}';
437
438                 // At the end we don't need a temporary table in memory
439                 $result = SQL_QUERY_ESC("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_%s_transfers_tmp`", array(getMemberId()), __FILE__, __LINE__);
440
441                 // Load final template
442                 loadTemplate('member_transfer_list', false, $content);
443
444                 // Free some memory...
445                 SQL_FREERESULT($result);
446                 break;
447
448         default: // Overview page
449                 // Check incoming transfers
450                 $totalIn = countSumTotalData(getMemberId(), 'user_transfers_in', 'id', 'userid', true);
451                 $content['in_link'] = $totalIn;
452                 if ($totalIn > 0) {
453                         $content['in_link'] = '<a href="{%url=modules.php?module=login&amp;what=transfer&amp;mode=list_in%}">' . $totalIn . '</a>';
454                 } // END - if
455
456                 // Check outgoing transfers
457                 $totalOut = countSumTotalData(getMemberId(), 'user_transfers_out', 'id', 'userid', true);
458
459                 $content['out_link'] = $totalOut;
460                 if ($totalOut > 0) {
461                         $content['out_link'] = '<a href="{%url=modules.php?module=login&amp;what=transfer&amp;mode=list_out%}">' . $totalOut . '</a>';
462                 } // END - if
463
464                 // Add all to total amount
465                 $total = $totalIn + $totalOut;
466
467                 // Total transactions
468                 $content['all_link'] = $total;
469                 if ($total > 0) {
470                         $content['all_link'] = '<a href="{%url=modules.php?module=login&amp;what=transfer&amp;mode=list_all%}">{%pipe,translateComma=' . $total . '%}</a>';
471                 } // END - if
472
473                 if (isFormSent()) {
474                         // Save settings
475                         SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `opt_in`='%s' WHERE `userid`=%s LIMIT 1",
476                                 array(postRequestParameter('opt_in'), getMemberId()), __FILE__, __LINE__);
477
478                         // "Settings saved..."
479                         displayMessage('{--SETTINGS_SAVED--}');
480                 } // END - if
481
482                 // Init entries
483                 foreach (array('allow_y','allow_n') as $entry) {
484                         $content[$entry] = '';
485                 } // END - foreach
486
487                 // Set current selection
488                 $content['allow_' . strtolower(getUserData('opt_in'))] = ' checked="checked"';
489
490                 // Set 'new transfer' link according to above option
491                 switch (getUserData('opt_in')) {
492                         case 'Y':
493                                 $content['new_link'] = '<a href="{%url=modules.php?module=login&amp;what=transfer&amp;mode=new%}" title="{--TRANSFER_NOW_TITLE--}">{--TRANSFER_NOW_LINK--}</a>';
494                                 break;
495
496                         case 'N':
497                                 $content['new_link'] = '{--TRANSFER_PLEASE_ALLOW_OPT_IN--}';
498                                 break;
499                 } // END - switch
500
501                 // Check for latest out-transfers
502                 $result = SQL_QUERY_ESC("SELECT
503         `time_trans`
504 FROM
505         `{?_MYSQL_PREFIX?}_user_transfers_out`
506 WHERE
507         (UNIX_TIMESTAMP() - `time_trans`) >= {?transfer_timeout?} AND
508         `userid`=%s
509 ORDER BY
510         `time_trans` DESC
511 LIMIT 1",
512                         array(
513                                 getMemberId()
514                         ), __FILE__, __LINE__);
515
516                 // Do we have an entry?
517                 if (SQL_NUMROWS($result) == 1) {
518                         // Load newest transaction
519                         list($newest) = SQL_FETCHROW($result);
520                         $content['settings'] = '{%message,TRANSFER_LATEST_IS=' . generateDateTime($newest, '3') . '%}';
521                 } else {
522                         // Load template
523                         $content['settings'] = loadTemplate('member_transfer_settings', true, $content);
524                 }
525
526                 // Free result
527                 SQL_FREERESULT($result);
528
529                 // Load template
530                 loadTemplate('member_transfer_overview', false, $content);
531                 break;
532 } // END - switch
533
534 // [EOF]
535 ?>