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