function initReferralSystem () {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referral system initialized!');
$GLOBALS['ref_level'] = NULL;
- $GLOBALS['ref_system'] = true;
+ $GLOBALS['ref_system'] = TRUE;
}
// Getter fro ref level percents
if ((isset($GLOBALS['cache_array']['refdepths']['level'])) && (isExtensionActive('cache'))) {
// First look for level
$key = array_search($level, $GLOBALS['cache_array']['refdepths']['level']);
- if ($key !== false) {
+ if ($key !== FALSE) {
// Entry found
$data['percents'] = $GLOBALS['cache_array']['refdepths']['percents'][$key];
function addPointsThroughReferralSystem ($subject, $userid, $points, $refid = NULL) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',points=' . $points . ',refid=' . convertNullToZero($refid) . ' - ENTERED!');
// By default nothing has been added
- $added = false;
+ $added = FALSE;
// Determine payment method and notification
$paymentMethod = strtoupper(getPaymentMethodFromSubject($subject));
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',refid=' . $refid . ',paymentMethod=' . $paymentMethod . ',sendNotify=' . intval($sendNotify) . ',isLocked=' . intval($isLocked));
// Send "referral confirmed" mails out?
- if ((isValidUserid($refid)) && ($refid != $userid) && ($sendNotify === true)) {
+ if ((isValidUserid($refid)) && ($refid != $userid) && ($sendNotify === TRUE)) {
// Calculate the referral's points and percents
$percentsReferral = getReferralLevelPercents($GLOBALS['ref_level'] + 1);
} // END - if
// Points updated, maybe I shall send him an email?
- if (($sendNotify === true) && ($isLocked === false)) {
+ if (($sendNotify === TRUE) && ($isLocked === FALSE)) {
// "Explode" subject
$subjectArray = explode(':', $subject);
$subjectUserid = (isset($subjectArray[1])) ? $subjectArray[1] : '0';
'userid' => $userid,
'points' => $points,
'points_mode' => 'sub',
+ 'column' => 'used_points',
'added' => (!SQL_HASZEROAFFECTED())
);
$refs = array();
// Get refs from database
- $result = SQL_QUERY_ESC("SELECT
- ur.`id`, ur.`refid`, ud.`status`, ud.`last_online`, ud.`mails_confirmed`, ud.`emails_received`
+ $result = SQL_QUERY_ESC('SELECT
+ ur.`id`,
+ ur.`refid`,
+ ud.`status`,
+ ud.`last_online`,
+ ud.`mails_confirmed`,
+ ud.`emails_received`,
+ ud.`subid`
FROM
`{?_MYSQL_PREFIX?}_user_refs` AS `ur`
LEFT JOIN
ur.`userid`=%s AND
ur.`level`=%s
ORDER BY
- ur.`refid` ASC",
+ ur.`refid` ASC',
array(
bigintval($userid),
bigintval($level)
$columnName = $pointsData['column_name'];
// Are the points locked?
- if (($isLocked === true) && ($pointsData['locked_mode'] == 'LOCKED')) {
+ if (($isLocked === TRUE) && ($pointsData['locked_mode'] == 'LOCKED')) {
// Locked points, so prefix it
$columnName = 'locked_' . $pointsData['column_name'];
} // END - if
} // END - foreach
} // END - foreach
} // END - foreach
- //die('<pre>'.print_r($GLOBALS['referral_refid'][$userid],true).'</pre>');
+ //die('<pre>'.print_r($GLOBALS['referral_refid'][$userid],TRUE).'</pre>');
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - EXIT!');
}
// Prepare SQL
$SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_user_refs` (`userid`, `level`, `refid`) VALUES ';
- $executeSql = false;
+ $executeSql = FALSE;
// Now walk through the array, first levels
foreach ($GLOBALS['referral_refid'][$userid] as $level => $levelArray) {
$SQL .= '(' . $userid . ',' . $level . ',' . $refid . '),';
// Some has been added, so execute the query
- $executeSql = true;
+ $executeSql = TRUE;
} // END - if
} // END - foreach
} // END - foreach
// And run it
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',SQL=' . $SQL);
- if ($executeSql === true) {
+ if ($executeSql === TRUE) {
SQL_QUERY($SQL, __FUNCTION__, __LINE__);
} // END - if
return getReferralId();
} elseif ((!isHtmlOutputMode()) && (basename($_SERVER['PHP_SELF']) != 'ref.php')) {
// Skip this in non-html-mode and outside ref.php
- return false;
+ return FALSE;
}
// Check if refid is set
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using default refid (' . getDefRefid() . ')');
setReferralId(getDefRefid());
} else {
- // No default id when sql_patches is not installed or none set
+ // No default id when ext-sql_patches is not installed or none set
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using NULL as refid');
setReferralId(NULL);
}
// Set cookie when default refid > 0
if ((!isSessionVariableSet('refid')) || (!isValidUserId(getReferralId())) || ((!isValidUserId(getSession('refid'))) && (isExtensionInstalledAndNewer('sql_patches', '0.1.2')) && (isValidUserId(getDefRefid())))) {
// Default is not found
- $found = false;
+ $found = FALSE;
// Is there nickname or userid set?
if ((isExtensionActive('nickname')) && (isNicknameUsed(getReferralId()))) {
$found = fetchUserData(getReferralId(), 'nickname');
// If we found it, use the userid as referral id
- if ($found === true) {
+ if ($found === TRUE) {
// Set the userid as 'refid'
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using refid from user account by nickname (' . getUserData('userid') . ')');
setReferralId(getUserData('userid'));
}
// Is the record valid?
- if ((($found === false) || (!isUserDataValid())) && (isExtensionInstalledAndNewer('sql_patches', '0.1.2'))) {
+ if ((($found === FALSE) || (!isUserDataValid())) && (isExtensionInstalledAndNewer('sql_patches', '0.1.2'))) {
// No, then reset referral id
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using default refid (' . getDefRefid() . ')');
setReferralId(getDefRefid());