]> git.mxchange.org Git - mailer.git/blob - inc/modules/member/what-transfer.php
10cc4218b662b24025c93d14ddbd17c0a5629454
[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         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')) {
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 (getConfig('transfer_code') > 0) {
75                                 // Check for code
76                                 $code = generateRandomCode(getConfig('transfer_code'), 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 and fancy date/time in constants
146                                 $content['reason']  = secureString(postRequestParameter('reason'));
147                                 $content['expires'] = '{%config,createFancyTime=transfer_age%}';
148
149                                 // Generate tranafer id
150                                 $content['trans_id'] = bigintval(generateRandomCode('10', mt_rand(0, 99999), getMemberId(), postRequestParameter('reason')));
151
152                                 // Add entries to both tables
153                                 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)",
154                                         array(bigintval(postRequestParameter('to_userid')), getMemberId(), bigintval(postRequestParameter('points')), postRequestParameter('reason'), $content['trans_id']), __FILE__, __LINE__);
155                                 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)",
156                                         array(getMemberId(), bigintval(postRequestParameter('to_userid')), bigintval(postRequestParameter('points')), postRequestParameter('reason'), $content['trans_id']), __FILE__, __LINE__);
157
158                                 // Add points to account *directly* ...
159                                 addPointsDirectly('transfer', bigintval(postRequestParameter('to_userid')), bigintval(postRequestParameter('points')));
160
161                                 // ... and add it to current user's used points
162                                 subtractPoints('transfer', getMemberId(), postRequestParameter('points'));
163
164                                 // First send email to recipient
165                                 $message = loadEmailTemplate('member_transfer_recipient', $content, postRequestParameter('to_userid'));
166                                 sendEmail($content['recipient']['email'], '{--TRANSFER_MEMBER_RECIPIENT_SUBJECT--}' . ': ' . $SENDER, $message);
167
168                                 // Second send email to sender
169                                 $message = loadEmailTemplate('member_transfer_sender', $content, getMemberId());
170                                 sendEmail($content['sender']['email'], '{--TRANSFER_MEMBER_SENDER_SUBJECT--}' . ': ' . $RECIPIENT, $message);
171
172                                 // At last send admin mail(s)
173                                 $adminSubject = sprintf("%s (%s->%s)", '{--TRANSFER_ADMIN_SUBJECT--}', $SENDER, $RECIPIENT);
174                                 sendAdminNotification($adminSubject, 'admin_transfer_points', $content);
175
176                                 // Transfer is completed
177                                 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>');
178                         } elseif ($valid_code === false) {
179                                 // Invalid Touring code!
180                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_CODE--}');
181                                 unsetPostRequestParameter('ok');
182                         } elseif ($valid_pass === false) {
183                                 // Wrong password entered
184                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_PASSWORD--}');
185                                 unsetPostRequestParameter('ok');
186                         } elseif ($valid_amount === false) {
187                                 // Too much points entered
188                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_POINTS--}');
189                                 unsetPostRequestParameter('ok');
190                         } elseif ($valid_reason === false) {
191                                 // No transfer reason entered
192                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_REASON--}');
193                                 unsetPostRequestParameter('ok');
194                         } elseif ($valid_recipient === false) {
195                                 // No recipient selected
196                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_RECIPIENT--}');
197                                 unsetPostRequestParameter('ok');
198                         } elseif ($valid_data === false) {
199                                 // No recipient/sender selected
200                                 loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_DATA--}');
201                                 unsetPostRequestParameter('ok');
202                         }
203
204                         // Free result
205                         SQL_FREERESULT($result);
206                 } // END - if
207
208                 if (!isFormSent()) {
209                         // Load member list
210                         if (isExtensionActive('nickname')) {
211                                 // Load userid and nickname
212                                 $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",
213                                         array(getMemberId()), __FILE__, __LINE__);
214                         } else {
215                                 // Load only userid
216                                 $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",
217                                         array(getMemberId()), __FILE__, __LINE__);
218                         }
219
220                         if (!SQL_HASZERONUMS($result)) {
221                                 // Load list
222                                 $OUT  = '<select name="to_userid" size="1" class="form_select">
223         <option value="0">{--SELECT_NONE--}</option>';
224                                 // @TODO Try to rewrite his to $content = SQL_FETCHARRAY(), see some lines above for two different queries
225                                 while (list($userid, $nick) = SQL_FETCHROW($result)) {
226                                         $OUT .= '       <option value="' . $userid . '"';
227                                         if ((isPostRequestParameterSet('to_userid')) && (postRequestParameter('to_userid') == $userid)) $OUT .= ' selected="selected"';
228                                         $OUT .= '>';
229                                         if (($nick != $userid) && (!empty($nick))) {
230                                                 // Output nickname
231                                                 $OUT .= $nick;
232                                         } else {
233                                                 // Output userid
234                                                 $OUT .= $userid;
235                                         }
236                                         $OUT .= '</option>';
237                                 }
238                                 $OUT .= '</select>';
239                                 $content['to_disabled'] = '';
240
241                                 // Free memory
242                                 SQL_FREERESULT($result);
243                         } else {
244                                 // No one else is opt-in
245                                 $OUT = loadTemplate('admin_settings_saved', true, '{--TRANSFER_NO_ONE_ELSE_OPT_IN--}');
246                                 $content['to_disabled'] = ' disabled="disabled"';
247                         }
248
249                         // Transfer output to constant for the template
250                         $content['userid_selection'] = $OUT;
251
252                         // Generate Code
253                         if (getConfig('transfer_code') > 0) {
254                                 // Generate random number
255                                 $rand = mt_rand(0, 99999);
256
257                                 // Generate CAPTCHA code
258                                 $code = generateRandomCode(getConfig('transfer_code'), $rand, getMemberId(), $content['max_transferable']);
259
260                                 // Generate image (HTML code)
261                                 $img = generateImageOrCode($code, false);
262
263                                 // Add all and hidden field
264                                 $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;
265                         } else {
266                                 $code = '00000';
267                                 $content['captcha_code'] = loadTemplate('admin_settings_saved', true, '{--TRANSFER_NO_CODE--}');
268                         }
269
270                         // Init points/reason
271                         $content['points'] = '';
272                         $content['reason'] = '';
273
274                         // Transfer maybe already entered valued'
275                         if (isPostRequestParameterSet('ok')) {
276                                 // Get values from form
277                                 $content['points'] = postRequestParameter('points');
278                                 $content['reason'] = postRequestParameter('reason');
279                         } // END - if
280
281                         // Output form
282                         loadTemplate('member_transfer_new', false, $content);
283                 } // END - if
284                 break;
285
286         case 'list_in': // List only incoming transactions
287         case 'list_out': // List only outgoing transactions
288                 // 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
289                 $nothingMessage = '';
290                 switch ($mode) {
291                         case 'list_in':
292                                 $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?}";
293                                 $nothingMessage     = '{--TRANSFER_NO_INCOMING_TRANSFERS--}';
294                                 $content['balance'] = '{--TRANSFER_TOTAL_INCOMING--}';
295                                 $content['title']   = '{--TRANSFER_LIST_INCOMING--}';
296                                 break;
297
298                         case 'list_out':
299                                 $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?}";
300                                 $nothingMessage     = '{--TRANSFER_NO_OUTGOING_TRANSFERS--}';
301                                 $content['balance'] = '{--TRANSFER_TOTAL_OUTGOING--}';
302                                 $content['title']   = '{--TRANSFER_LIST_OUTGOING--}';
303                                 break;
304                 } // END - switch
305
306                 // Run the SQL command and set total points to zero
307                 $totalPoints = '0';
308                 $result = SQL_QUERY_ESC($sql, array(getMemberId()), __FILE__, __LINE__);
309
310                 // Do we have entries?
311                 if (!SQL_HASZERONUMS($result)) {
312                         $OUT = '';
313                         while ($content = SQL_FETCHARRAY($result)) {
314                                 // Rewrite points, out is subtracted
315                                 if ($type == 'OUT') {
316                                         $content['points'] = $content['points'] * -1;
317                                 } // END - if
318
319                                 // Prepare content for template
320                                 $$content['time_trans'] = generateDateTime($content['time_trans'], 3);
321
322                                 // Load row template
323                                 $OUT .= loadTemplate('member_transfer_row2', true, $content);
324
325                                 // Add points and switch color
326                                 $totalPoints += $content['points'];
327                         } // END - while
328
329                         // Free memory
330                         SQL_FREERESULT($result);
331                 } else {
332                         // Nothing for in or out
333                         $OUT = '<tr>
334   <td colspan="5" align="center" class="bottom">
335     ' . loadTemplate('admin_settings_saved', true, $nothingMessage) . '
336   </td>
337 </tr>';
338                 }
339
340                 // ... and add them to a constant for the template
341                 $content['rows'] = $OUT;
342
343                 // Remeber total amount
344                 $content['total'] = $totalPoints;
345
346                 // Load final template
347                 loadTemplate('member_transfer_list', false, $content);
348                 break;
349
350         case 'list_all': // List all transactions
351                 /*
352                  * Fill a temporary table with data from both tables. This is much
353                  * easier to code and unstandable by you as sub-SELECT queries. I know
354                  * this is not the fastest way but it shall be fine for now.
355                  */
356
357                 // First of all create the per-user temporary table
358                 $result = SQL_QUERY_ESC("CREATE TEMPORARY TABLE `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (
359 `trans_id` VARCHAR(12) NOT NULL DEFAULT '',
360 `party_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
361 `points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
362 `reason` VARCHAR(255) NOT NULL DEFAULT '',
363 `time_trans` VARCHAR(10) NOT NULL DEFAULT 0,
364 `trans_type` ENUM('IN','OUT') NOT NULL DEFAULT 'IN',
365 KEY (`party_userid`)
366 ) TYPE = HEAP COMMENT = 'Temporary transfer table'", array(getMemberId()), __FILE__, __LINE__);
367
368                 // Let's begin with the incoming list
369                 $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?}",
370                         array(getMemberId()), __FILE__, __LINE__);
371                 while ($DATA = SQL_FETCHROW($result)) {
372                         $DATA[] = 'IN';
373                         $DATA = implode("','", $DATA);
374                         $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__);
375                 } // END - while
376
377                 // Free memory
378                 SQL_FREERESULT($result);
379
380                 // As the last table transfer data from outgoing table to temporary
381                 $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?}",
382                         array(getMemberId()), __FILE__, __LINE__);
383                 while ($DATA = SQL_FETCHROW($result)) {
384                         $DATA[] = 'OUT';
385                         $DATA = implode("','", $DATA);
386                         $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__);
387                 } // END - while
388
389                 // Free memory
390                 SQL_FREERESULT($result);
391
392                 // Search for entries
393                 $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",
394                         array(getMemberId()), __FILE__, __LINE__);
395
396                 $total = '0';
397                 if (!SQL_HASZERONUMS($result)) {
398                         // Output rows
399                         $OUT = '';
400                         while ($content = SQL_FETCHARRAY($result)) {
401                                 // Rewrite points if OUT
402                                 if ($content['trans_type'] == 'OUT') {
403                                         $content['points'] = $content['points'] * -1;
404                                 } // END - if
405
406                                 // Prepare content for template
407                                 $content['time']   = generateDateTime($content['time_trans'], 3);
408
409                                 // Load row template
410                                 $OUT .= loadTemplate('member_transfer_row', true, $content);
411
412                                 // Add points and switch color
413                                 $total += $content['points'];
414                         } // END - while
415                 } else {
416                         // Nothing for in and out
417                         $OUT = '<tr>
418   <td colspan="5" align="center" class="bottom">
419     ' . loadTemplate('admin_settings_saved', true, '{--TRANSFER_NO_INOUT_TRANSFERS--}') . '
420   </td>
421 </tr>';
422                 }
423
424                 // Free memory
425                 SQL_FREERESULT($result);
426
427                 // ... and add them to a constant for the template
428                 $content['rows'] =  $OUT;
429
430                 // Remeber total amount
431                 $content['total'] = $total;
432
433                 // Set title
434                 $content['title'] = '{--TRANSFER_LIST_ALL--}';
435
436                 // Set "balance" word
437                 $content['balance'] = '{--TRANSFER_TOTAL_BALANCE--}';
438
439                 // At the end we don't need a temporary table in memory
440                 $result = SQL_QUERY_ESC("DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_%s_transfers_tmp`", array(getMemberId()), __FILE__, __LINE__);
441
442                 // Load final template
443                 loadTemplate('member_transfer_list', false, $content);
444
445                 // Free some memory...
446                 SQL_FREERESULT($result);
447                 break;
448
449         default: // Overview page
450                 // Check incoming transfers
451                 $totalIn = countSumTotalData(getMemberId(), 'user_transfers_in', 'id', 'userid', true);
452                 $content['in_link'] = $totalIn;
453                 if ($totalIn > 0) {
454                         $content['in_link'] = '<a href="{%url=modules.php?module=login&amp;what=transfer&amp;mode=list_in%}">' . $totalIn . '</a>';
455                 } // END - if
456
457                 // Check outgoing transfers
458                 $totalOut = countSumTotalData(getMemberId(), 'user_transfers_out', 'id', 'userid', true);
459
460                 $content['out_link'] = $totalOut;
461                 if ($totalOut > 0) {
462                         $content['out_link'] = '<a href="{%url=modules.php?module=login&amp;what=transfer&amp;mode=list_out%}">' . $totalOut . '</a>';
463                 } // END - if
464
465                 // Add all to total amount
466                 $total = $totalIn + $totalOut;
467
468                 // Total transactions
469                 $content['all_link'] = $total;
470                 if ($total > 0) {
471                         $content['all_link'] = '<a href="{%url=modules.php?module=login&amp;what=transfer&amp;mode=list_all%}">{%pipe,translateComma=' . $total . '%}</a>';
472                 } // END - if
473
474                 if (isFormSent()) {
475                         // Save settings
476                         SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `opt_in`='%s' WHERE `userid`=%s LIMIT 1",
477                                 array(postRequestParameter('opt_in'), getMemberId()), __FILE__, __LINE__);
478
479                         // "Settings saved..."
480                         loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED--}');
481                 } // END - if
482
483                 // Init entries
484                 foreach (array('allow_y','allow_n') as $entry) {
485                         $content[$entry] = '';
486                 } // END - foreach
487
488                 // Set current selection
489                 $content['allow_' . strtolower(getUserData('opt_in'))] = ' checked="checked"';
490
491                 // Set 'new transfer' link according to above option
492                 switch (getUserData('opt_in')) {
493                         case 'Y':
494                                 $content['new_link'] = '<a href="{%url=modules.php?module=login&amp;what=transfer&amp;mode=new%}" title="{--TRANSFER_NOW_TITLE--}">{--TRANSFER_NOW_LINK--}</a>';
495                                 break;
496
497                         case 'N':
498                                 $content['new_link'] = '{--TRANSFER_PLEASE_ALLOW_OPT_IN--}';
499                                 break;
500                 } // END - switch
501
502                 // Check for latest out-transfers
503                 $result = SQL_QUERY_ESC("SELECT
504         `time_trans`
505 FROM
506         `{?_MYSQL_PREFIX?}_user_transfers_out`
507 WHERE
508         `time_trans` > (UNIX_TIMESTAMP() - {?transfer_timeout?}) AND
509         `userid`=%s
510 ORDER BY
511         `time_trans` DESC
512 LIMIT 1",
513                         array(
514                                 getMemberId()
515                         ), __FILE__, __LINE__);
516
517                 // Do we have an entry?
518                 if (SQL_NUMROWS($result) == 1) {
519                         // Load newest transaction
520                         list($newest) = SQL_FETCHROW($result);
521                         $content['settings'] = getMaskedMessage('TRANSFER_LATEST_IS', generateDateTime($newest, 3));
522                 } else {
523                         // Load template
524                         $content['settings'] = loadTemplate('member_transfer_settings', true, $content);
525                 }
526
527                 // Free result
528                 SQL_FREERESULT($result);
529
530                 // Load template
531                 loadTemplate('member_transfer_overview', false, $content);
532                 break;
533 } // END - switch
534
535 // [EOF]
536 ?>