* $Author:: $ *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
- * Copyright (c) 2009, 2010 by Mailer Developer Team *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
}
// Add description as navigation point
-addMenuDescription('member', __FILE__);
+addYouAreHereLink('member', __FILE__);
+// Extension ext-transfer must be avtive
if ((!isExtensionActive('transfer')) && (!isAdmin())) {
- loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('transfer'));
+ displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=transfer%}');
return;
} // END - if
if (isFormSent()) {
// Add new transfer
- if (getConfig('transfer_code') > 0) {
+ if (getTransferCode() > 0) {
// Check for code
- $code = generateRandomCode(getConfig('transfer_code'), postRequestParameter('code_chk'), getMemberId(), $content['max_transferable']);
+ $code = generateRandomCode(getTransferCode(), postRequestParameter('code_chk'), getMemberId(), $content['max_transferable']);
$valid_code = ($code == postRequestParameter('code'));
} else {
// Zero length (= disabled) is always valid!
// Test if a recipient is selected
$valid_recipient = isValidUserId(postRequestParameter('to_userid'));
- // Check for nickname extension and set additional data
- // @TODO Rewrite this to a filter
- $add = '';
- if (isExtensionActive('nickname')) {
- $add = ', `nickname`';
- } // END - if
-
// Re-check receivers and own personal data
- $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",
+ $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",
array(
getMemberId(),
bigintval(postRequestParameter('to_userid'))
} // END - if
} // END - if
- // Remember transfer reason and fancy date/time in constants
- $content['reason'] = secureString(postRequestParameter('reason'));
- $content['expires'] = '{%config,createFancyTime=transfer_age%}';
+ // Remember transfer reason
+ $content['reason'] = postRequestParameter('reason');
// Generate tranafer id
$content['trans_id'] = bigintval(generateRandomCode('10', mt_rand(0, 99999), getMemberId(), postRequestParameter('reason')));
// Add entries to both tables
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)",
- array(bigintval(postRequestParameter('to_userid')), getMemberId(), bigintval(postRequestParameter('points')), postRequestParameter('reason'), $content['trans_id']), __FILE__, __LINE__);
+ array(
+ bigintval(postRequestParameter('to_userid')),
+ getMemberId(),
+ bigintval(postRequestParameter('points')),
+ postRequestParameter('reason'),
+ $content['trans_id']
+ ), __FILE__, __LINE__);
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)",
- array(getMemberId(), bigintval(postRequestParameter('to_userid')), bigintval(postRequestParameter('points')), postRequestParameter('reason'), $content['trans_id']), __FILE__, __LINE__);
+ array(
+ getMemberId(),
+ bigintval(postRequestParameter('to_userid')),
+ bigintval(postRequestParameter('points')),
+ postRequestParameter('reason'),
+ $content['trans_id']
+ ), __FILE__, __LINE__);
// Add points to account *directly* ...
- addPointsDirectly('transfer', bigintval(postRequestParameter('to_userid')), bigintval(postRequestParameter('points')));
+ addPointsThroughReferalSystem('transfer', bigintval(postRequestParameter('to_userid')), bigintval(postRequestParameter('points')));
// ... and add it to current user's used points
subtractPoints('transfer', getMemberId(), postRequestParameter('points'));
// First send email to recipient
$message = loadEmailTemplate('member_transfer_recipient', $content, postRequestParameter('to_userid'));
- sendEmail($content['recipient']['email'], '{--TRANSFER_MEMBER_RECIPIENT_SUBJECT--}' . ': ' . $SENDER, $message);
+ sendEmail($content['recipient']['userid'], '{--TRANSFER_MEMBER_RECIPIENT_SUBJECT--}' . ': ' . $SENDER, $message);
// Second send email to sender
$message = loadEmailTemplate('member_transfer_sender', $content, getMemberId());
- sendEmail($content['sender']['email'], '{--TRANSFER_MEMBER_SENDER_SUBJECT--}' . ': ' . $RECIPIENT, $message);
+ sendEmail($content['sender']['userid'], '{--TRANSFER_MEMBER_SENDER_SUBJECT--}' . ': ' . $RECIPIENT, $message);
// At last send admin mail(s)
$adminSubject = sprintf("%s (%s->%s)", '{--TRANSFER_ADMIN_SUBJECT--}', $SENDER, $RECIPIENT);
sendAdminNotification($adminSubject, 'admin_transfer_points', $content);
// Transfer is completed
- loadTemplate('admin_settings_saved', false, '<div>{--TRANSFER_COMPLETED--}' . '</div><div><a href="{%url=modules.php?module=login&what=transfer%}">{--TRANSFER_CONTINUE_OVERVIEW--}</a></div>');
+ displayMessage('<div>{--TRANSFER_COMPLETED--}' . '</div><div><a href="{%url=modules.php?module=login&what=transfer%}">{--TRANSFER_CONTINUE_OVERVIEW--}</a></div>');
} elseif ($valid_code === false) {
// Invalid Touring code!
loadTemplate('admin_settings_unsaved', false, '{--TRANSFER_INVALID_CODE--}');
if (!isFormSent()) {
// Load member list
- if (isExtensionActive('nickname')) {
- // Load userid and nickname
- $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",
- array(getMemberId()), __FILE__, __LINE__);
- } else {
- // Load only userid
- $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",
- array(getMemberId()), __FILE__, __LINE__);
- }
+ $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",
+ array(getMemberId()), __FILE__, __LINE__);
if (!SQL_HASZERONUMS($result)) {
// Load list
$OUT = '<select name="to_userid" size="1" class="form_select">
<option value="0">{--SELECT_NONE--}</option>';
- // @TODO Try to rewrite his to $content = SQL_FETCHARRAY(), see some lines above for two different queries
- while (list($userid, $nick) = SQL_FETCHROW($result)) {
+ while (list($userid) = SQL_FETCHROW($result)) {
$OUT .= ' <option value="' . $userid . '"';
- if ((isPostRequestParameterSet('to_userid')) && (postRequestParameter('to_userid') == $userid)) $OUT .= ' selected="selected"';
- $OUT .= '>';
- if (($nick != $userid) && (!empty($nick))) {
- // Output nickname
- $OUT .= $nick;
- } else {
- // Output userid
- $OUT .= $userid;
- }
- $OUT .= '</option>';
- }
+ if ((isPostRequestParameterSet('to_userid')) && (postRequestParameter('to_userid') == $userid)) {
+ $OUT .= ' selected="selected"';
+ } // END - if
+ $OUT .= '>' . $userid . ' ({%user,nickname,fixEmptyContentToDashes=' . $userid . '%})</option>';
+ } // END - while
$OUT .= '</select>';
$content['to_disabled'] = '';
SQL_FREERESULT($result);
} else {
// No one else is opt-in
- $OUT = loadTemplate('admin_settings_saved', true, '{--TRANSFER_NO_ONE_ELSE_OPT_IN--}');
+ $OUT = displayMessage('{--TRANSFER_NO_ONE_ELSE_OPT_IN--}', true);
$content['to_disabled'] = ' disabled="disabled"';
}
$content['userid_selection'] = $OUT;
// Generate Code
- if (getConfig('transfer_code') > 0) {
+ if (getTransferCode() > 0) {
// Generate random number
$rand = mt_rand(0, 99999);
// Generate CAPTCHA code
- $code = generateRandomCode(getConfig('transfer_code'), $rand, getMemberId(), $content['max_transferable']);
+ $code = generateRandomCode(getTransferCode(), $rand, getMemberId(), $content['max_transferable']);
// Generate image (HTML code)
$img = generateImageOrCode($code, false);
$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'] . ' /> ' . $img;
} else {
$code = '00000';
- $content['captcha_code'] = loadTemplate('admin_settings_saved', true, '{--TRANSFER_NO_CODE--}');
+ $content['captcha_code'] = displayMessage('{--TRANSFER_NO_CODE--}', true);
}
// Init points/reason
$nothingMessage = '';
switch ($mode) {
case 'list_in':
- $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?}";
+ $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?}';
$nothingMessage = '{--TRANSFER_NO_INCOMING_TRANSFERS--}';
$content['balance'] = '{--TRANSFER_TOTAL_INCOMING--}';
$content['title'] = '{--TRANSFER_LIST_INCOMING--}';
break;
case 'list_out':
- $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?}";
+ $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?}';
$nothingMessage = '{--TRANSFER_NO_OUTGOING_TRANSFERS--}';
$content['balance'] = '{--TRANSFER_TOTAL_OUTGOING--}';
$content['title'] = '{--TRANSFER_LIST_OUTGOING--}';
// Nothing for in or out
$OUT = '<tr>
<td colspan="5" align="center" class="bottom">
- ' . loadTemplate('admin_settings_saved', true, $nothingMessage) . '
+ ' . displayMessage($nothingMessage, true) . '
</td>
</tr>';
}
$content['rows'] = $OUT;
// Remeber total amount
- $content['total'] = $totalPoints;
+ $content['total_points'] = $totalPoints;
// Load final template
loadTemplate('member_transfer_list', false, $content);
`time_trans` VARCHAR(10) NOT NULL DEFAULT 0,
`trans_type` ENUM('IN','OUT') NOT NULL DEFAULT 'IN',
KEY (`party_userid`)
-) TYPE=HEAP", array(getMemberId()), __FILE__, __LINE__);
+) ENGINE = HEAP COMMENT = 'Temporary transfer table'", array(getMemberId()), __FILE__, __LINE__);
// Let's begin with the incoming list
$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?}",
// Nothing for in and out
$OUT = '<tr>
<td colspan="5" align="center" class="bottom">
- ' . loadTemplate('admin_settings_saved', true, '{--TRANSFER_NO_INOUT_TRANSFERS--}') . '
+ ' . displayMessage('{--TRANSFER_NO_INOUT_TRANSFERS--}', true) . '
</td>
</tr>';
}
$content['rows'] = $OUT;
// Remeber total amount
- $content['total'] = $total;
+ $content['total_points'] = $total;
// Set title
$content['title'] = '{--TRANSFER_LIST_ALL--}';
$content['out_link'] = '<a href="{%url=modules.php?module=login&what=transfer&mode=list_out%}">' . $totalOut . '</a>';
} // END - if
- // Add to total amount
- $total += $totalOut;
+ // Add all to total amount
+ $total = $totalIn + $totalOut;
// Total transactions
$content['all_link'] = $total;
if ($total > 0) {
- $content['all_link'] = '<a href="{%url=modules.php?module=login&what=transfer&mode=list_all%}">' . $total . '</a>';
+ $content['all_link'] = '<a href="{%url=modules.php?module=login&what=transfer&mode=list_all%}">{%pipe,translateComma=' . $total . '%}</a>';
} // END - if
if (isFormSent()) {
array(postRequestParameter('opt_in'), getMemberId()), __FILE__, __LINE__);
// "Settings saved..."
- loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED--}');
+ displayMessage('{--SETTINGS_SAVED--}');
} // END - if
// Init entries
FROM
`{?_MYSQL_PREFIX?}_user_transfers_out`
WHERE
- `time_trans` > (UNIX_TIMESTAMP() - {?transfer_timeout?}) AND
+ (UNIX_TIMESTAMP() - `time_trans`) >= {?transfer_timeout?} AND
`userid`=%s
ORDER BY
`time_trans` DESC
if (SQL_NUMROWS($result) == 1) {
// Load newest transaction
list($newest) = SQL_FETCHROW($result);
- $content['settings'] = getMaskedMessage('TRANSFER_LATEST_IS', generateDateTime($newest, 3));
+ $content['settings'] = '{%message,TRANSFER_LATEST_IS=' . generateDateTime($newest, '3') . '%}';
} else {
// Load template
$content['settings'] = loadTemplate('member_transfer_settings', true, $content);