* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
* Copyright (c) 2009 - 2011 by Mailer Developer Team *
- * For more information visit: http://www.mxchange.org *
+ * For more information visit: http://mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
// Add links for selecting some users
function alpha ($sortby) {
$add = '';
- foreach (array('page','offset','mode','status') as $param) {
- if (isGetRequestParameterSet($param)) {
- $add .= '&' . $param . '=' . getRequestParameter($param);
+ foreach (array('page','offset','do','status') as $param) {
+ if (isGetRequestElementSet($param)) {
+ $add .= '&' . $param . '=' . getRequestElement($param);
} // END - if
} // END - foreach
$num = count($alphabet) - 1;
$OUT = '';
while (list($counter, $ltr) = each($alphabet)) {
- if (getRequestParameter('letter') == $ltr) {
+ if (getRequestElement('letter') == $ltr) {
// Current letter is letter from URL
$OUT .= '<strong>' . $ltr . '</strong>';
} else {
// Add links for sorting
function addSortLinks ($letter, $sortby) {
$OUT = '';
- if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', 0);
- if (!isGetRequestParameterSet('page')) setGetRequestParameter('page' , 0);
+ if (!isGetRequestElementSet('offset')) setGetRequestElement('offset', 0);
+ if (!isGetRequestElementSet('page')) setGetRequestElement('page' , 0);
// Add page and offset
- $add = '&page=' . getRequestParameter('page') . '&offset=' . getRequestParameter('offset');
+ $add = '&page=' . getRequestElement('page') . '&offset=' . getRequestElement('offset');
// Add status/ mode
- foreach (array('mode','status') as $param) {
- if (isGetRequestParameterSet($param)) {
- $add .= '&' . $param . '=' . getRequestParameter($param);
+ foreach (array('do','status') as $param) {
+ if (isGetRequestElementSet($param)) {
+ $add .= '&' . $param . '=' . getRequestElement($param);
} // END - if
} // END - foreach
if ($numPages > 1) {
// Create navigation links for every page
for ($page = 1; $page <= $numPages; $page++) {
- if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
+ if (($page == getRequestElement('page')) || ((!isGetRequestElementSet('page')) && ($page == 1))) {
$OUT .= '<strong>-';
} else {
- if (!isGetRequestParameterSet('letter')) setGetRequestParameter('letter', '');
- if (!isGetRequestParameterSet('sortby')) setGetRequestParameter('sortby', 'userid');
+ if (!isGetRequestElementSet('letter')) setGetRequestElement('letter', '');
+ if (!isGetRequestElementSet('sortby')) setGetRequestElement('sortby', 'userid');
// Base link
$OUT .= '<a href="{%url=modules.php?module=admin&what=' . getWhat();
// Add status/mode
- foreach (array('mode','status') as $param) {
- if (isGetRequestParameterSet($param)) {
- $OUT .= '&' . $param . '=' . getRequestParameter($param);
+ foreach (array('do','status') as $param) {
+ if (isGetRequestElementSet($param)) {
+ $OUT .= '&' . $param . '=' . getRequestElement($param);
} // END - if
} // END - foreach
// Letter and so on
- $OUT .= '&letter=' . getRequestParameter('letter') . '&sortby=' . getRequestParameter('sortby') . '&page=' . $page . '&offset=' . getConfig('user_limit') . '%}">';
+ $OUT .= '&letter=' . getRequestElement('letter') . '&sortby=' . getRequestElement('sortby') . '&page=' . $page . '&offset=' . getConfig('user_limit') . '%}">';
}
$OUT .= $page;
- if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
+ if (($page == getRequestElement('page')) || ((!isGetRequestElementSet('page')) && ($page == 1))) {
$OUT .= '-</strong>';
} else {
$OUT .= '</a>';
$locked = " AND `status`='CONFIRMED'";
// But admins shall always see it
- if (isAdmin()) $locked = '';
+ if (isAdmin()) {
+ $locked = '';
+ } // END - if
+ // Search for the email address
$result = SQL_QUERY_ESC("SELECT
`userid`
FROM
`{?_MYSQL_PREFIX?}_user_data`
WHERE
- `email`='%s'" . $locked."
+ '%s' REGEXP `email`
+ " . $locked . "
LIMIT 1",
array($email), __FUNCTION__, __LINE__);
+
+ // Do we have an entry?
if (SQL_NUMROWS($result) == 1) {
// Load userid
list($userid) = SQL_FETCHROW($result);
return $email;
}
-// Selects a random user id as the new referal id if they have at least X confirmed mails in this run
+// Selects a random user id as the new referral id if they have at least X confirmed mails in this run
// @TODO Double-check configuration entry here
-function determineRandomReferalId () {
+function determineRandomReferralId () {
// Default is zero refid
$refid = NULL;
// Do we have one entry there?
if (SQL_NUMROWS($result) == 1) {
- // Use that userid as new referal id
+ // Use that userid as new referral id
list($refid) = SQL_FETCHROW($result);
-
- // Reset all users, this makes this random referal id more challenging
- SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `rand_confirmed`=0', __FUNCTION__, __LINE__);
} // END - if
// Free result
// Is the timeout reached?
if ($probe >= getConfig('login_timeout')) {
// Add login bonus to user's account
- $add = ', `login_bonus`=`login_bonus`+{?login_bonus?}';
+ $add = ',`login_bonus`=`login_bonus`+{?login_bonus?}';
$GLOBALS['bonus_payed'] = true;
// Subtract login bonus from userid's account or jackpot
if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD')) {
- handleBonusPoints('login_bonus');
+ handleBonusPoints('login_bonus', $userid);
} // END - if
} // END - if
} // END - if
// Procedure to checking for login data
if (($GLOBALS['bonus_payed'] === true) && (isExtensionActive('bonus'))) {
// Bonus added (just displaying!)
- $url = 'modules.php?module=chk_login&mode=bonus';
+ $url = 'modules.php?module=chk_login&do=bonus';
} else {
// Bonus not added
- $url = 'modules.php?module=chk_login&mode=login';
+ $url = 'modules.php?module=chk_login&do=login';
}
} else {
// Use this URL
redirectToUrl('modules.php?module=index&what=login&login=' . $errorCode);
}
} else {
- // id or email is wrong
- displayMessage('<span class="notice">{--GUEST_WRONG_ID_EMAIL--}</span>');
+ // Id or email is wrong
+ displayMessage('<span class="bad">{--GUEST_WRONG_ID_EMAIL--}</span>');
}
// Return the error code
}
// Get timestamp for given stats type and data
-function getEpocheTimeFromUserStats ($statsType, $statsData, $userid = '0') {
+function getEpocheTimeFromUserStats ($statsType, $statsData, $userid = NULL) {
// Default timestamp is zero
$data['inserted'] = '0';
// User id set?
- if ((isMemberIdSet()) && ($userid == '0')) {
+ if ((isMemberIdSet()) && (is_null($userid))) {
$userid = getMemberId();
} // END - if
return false;
} // END - if
+ // Default is not working
+ $return = false;
+
// Does it exist?
if ((!getEpocheTimeFromUserStats($statsType, $statsData, $userid)) && (!is_array($statsData))) {
// Then insert it!
- SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats_data` (`userid`, `stats_type`, `stats_data`) VALUES (%s,'%s','%s')",
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats_data` (`userid`,`stats_type`,`stats_data`) VALUES (%s,'%s','%s')",
array(
bigintval($userid),
$statsType,
$statsData
), __FUNCTION__, __LINE__);
+
+ // Does it have worked?
+ $return = (!SQL_HASZEROAFFECTED());
} elseif (is_array($statsData)) {
// Invalid data!
logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',type=' . $statsType . ',data=' . gettype($statsData) . ': Invalid statistics data type!');
}
+
+ // Return status
+ return $return;
}
// Confirms a user account
);
// Initialize the user id
- $userid = '0';
+ $userid = NULL;
// Search for an unconfirmed or confirmed account
- $result = SQL_QUERY_ESC("SELECT `userid`, `refid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1",
+ $result = SQL_QUERY_ESC("SELECT `userid`,`refid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `user_hash`='%s' AND (`status`='UNCONFIRMED' OR `status`='CONFIRMED') LIMIT 1",
array($hash), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Ok, he want's to confirm now so we load some data
// And send him right away the confirmation mail
sendEmail($userid, '{--GUEST_THANX_CONFIRM--}', $message);
- // Maybe he got "referaled"?
- if (($refid > 0) && ($refid != $userid)) {
- // Select the referal userid
+ // Maybe he got "referraled"?
+ if ((isValidUserId($refid)) && ($refid != $userid)) {
+ // Select the referral userid
if (fetchUserData($refid)) {
// Update ref counter...
- updateReferalCounter($refid);
+ updateReferralCounter($refid);
// If version matches add ref bonus to refid's account
if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (isBonusRallyeActive())) {
array(bigintval($refid)), __FILE__, __LINE__);
// Subtract points from system
- handleBonusPoints(getConfig('bonus_ref'));
+ handleBonusPoints(getConfig('bonus_ref'), $refid);
} // END - if
- // Add one-time referal bonus over referal system or directly
- initReferalSystem();
- addPointsThroughReferalSystem('referal_bonus', $refid, getPointsRef(), bigintval($userid));
+ // Add one-time referral bonus over referral system or directly
+ initReferralSystem();
+ addPointsThroughReferralSystem('referral_bonus', $refid, getPointsRef(), bigintval($userid));
} // END - if
} // END - if
if (isExtensionActive('rallye')) {
// Add user to rallye (or not?)
- addUserToReferalRallye(bigintval($userid));
+ addUserToReferralRallye(bigintval($userid));
} // END - if
// Account confirmed!
}
// Template call-back function for list_user admin function
-function doTemplateAdminListUserTitle ($template, $dummy = false) {
+function doTemplateAdminListUserTitle ($template, $clear = false) {
// Init title with "all accounts"
$code = '{--ADMIN_LIST_ALL_ACCOUNTS--}';
- // Do we have a 'status' or 'mode' set?
- if (isGetRequestParameterSet('status')) {
+ // Do we have a 'status' or 'do' set?
+ if (isGetRequestElementSet('status')) {
// Set title according to the 'status'
- $code = sprintf("{--ADMIN_LIST_STATUS_%s_ACCOUNTS--}", strtoupper(getRequestParameter('status')));
- } elseif (isGetRequestParameterSet('mode')) {
- // Set title according to the "mode"
- $code = sprintf("{--ADMIN_LIST_MODE_%s_ACCOUNTS--}", strtoupper(getRequestParameter('mode')));
+ $code = sprintf("{--ADMIN_LIST_STATUS_%s_ACCOUNTS--}", strtoupper(getRequestElement('status')));
+ } elseif (isGetRequestElementSet('do')) {
+ // Set title according to 'do'
+ $code = sprintf("{--ADMIN_LIST_DO_%s_ACCOUNTS--}", strtoupper(getRequestElement('do')));
}
// Return the code
return $code;
}
+// Template call-back function for displaying "username"
+function doTemplateDisplayUsername ($template, $clear = false, $userid = NULL) {
+ // Is a userid set?
+ if (!isValidUserId($userid)) {
+ // Please don't call this without a valid userid
+ debug_report_bug(__FUNCTION__, __LINE__, 'template=' . $template . ',clear=' . intval($clear) . ',userid[' . gettype($userid) . ']=' . intval($userid) . ' - Invalid userid provided.');
+ } // END - if
+
+ // Do we have cache?
+ if (!isset($GLOBALS[__FUNCTION__][$userid])) {
+ // Generate code
+ $GLOBALS[__FUNCTION__][$userid] = $userid . ' ({%user,nickname,fixEmptyContentToDashes=' . $userid . '%})';
+ } // END - if
+
+ // Return cache
+ return $GLOBALS[__FUNCTION__][$userid];
+}
+
// [EOF]
?>