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