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