//* 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 ((isValidId($refid)) && ($refid != $userid) && ($sendNotify === TRUE)) {
// Calculate the referral's points and percents
$percentsReferral = getReferralLevelPercents($GLOBALS['ref_level'] + 1);
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'points=' . $points . ',refid(var|data)=' . convertNullToZero($refid) . '|' . convertNullToZero(getUserData('refid')) . ',userid=' . $userid . ',paymentMethod=' . $paymentMethod . ',subject=' . $subject . ',ref_level=' . $GLOBALS['ref_level']);
if (($paymentMethod == 'REFERRAL') && (isValidId(getUserData('refid'))) && ($points > 0) && (getUserData('refid') != $userid)) {
// Is _ref there?
- if (substr($subject, -4, 4) == '_ref') {
+ if (ifSubjectHasReferralSuffix($subject)) {
// Then remove it, no double _ref suffix!
$subject = substr($subject, 0, -4);
} // END - if
// Then let's credit him here...
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'subject=' . $subject . ',userid=' . $userid . ',refid=' . convertNullToZero(getUserData('refid')) . ',points=' . $points . ',ref_points=' . $ref_points . ',added[' . gettype($added) . ']=' . intval($added) . ',ref_level=' . $GLOBALS['ref_level'] . ' - ADVANCE!');
- $added = ($added && addPointsThroughReferralSystem(sprintf("%s_ref:%s", $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, getFetchedUserData('userid', getUserData('refid'), 'refid')));
+ $added = ($added && addPointsThroughReferralSystem(sprintf('%s_ref:%s', $subject, $GLOBALS['ref_level']), getUserData('refid'), $points, getFetchedUserData('userid', getUserData('refid'), 'refid')));
} // END - if
} // END - if
} // END - if
// Fetch all entries
while ($row = sqlFetchArray($result)) {
// Init click rate with zero
- $row['click_rate'] = '0';
-
- // Is at least one mail received?
- if ($row['emails_received'] > 0) {
- // Calculate click rate
- $row['click_rate'] = ($row['mails_confirmed'] / $row['emails_received'] * 100);
- } // END - if
+ $row['click_rate'] = calculatePercentageRate($row['mails_confirmed'], $row['emails_received']);
// Activity is 'active' by default because if ext-autopurge is not installed
$row['activity'] = '{--MEMBER_ACTIVITY_ACTIVE--}';
} // END - if
// Now checkout the entry in database table
- $result = sqlQueryEscaped("SELECT `id`, `subject`, `column_name`, `locked_mode`, `payment_method`, `notify_recipient` FROM `{?_MYSQL_PREFIX?}_points_data` WHERE `subject`='%s' LIMIT 1",
- array($subject), __FUNCTION__, __LINE__);
+ $result = sqlQueryEscaped("SELECT
+ `id`,
+ `subject`,
+ `column_name`,
+ `locked_mode`,
+ `payment_method`,
+ `notify_recipient`
+FROM
+ `{?_MYSQL_PREFIX?}_points_data`
+WHERE
+ `subject`='%s'
+LIMIT 1",
+ array(
+ $subject
+ ), __FUNCTION__, __LINE__
+ );
// Is there an entry?
if (sqlNumRows($result) == 1) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',count()=' . count($GLOBALS['referral_refid'][$userid]));
// If no entries are there, skip this whole step
- if (count($GLOBALS['referral_refid'][$userid]) == 0) {
+ if (!isFilledArray($GLOBALS['referral_refid'][$userid])) {
// No entries found
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - ABORTING...');
return;
// Checks if 'refid' is valid
function isReferralIdValid () {
- return ((isset($GLOBALS['__refid'])) && (getReferralId() !== NULL) && (getReferralId() > 0));
+ return ((isset($GLOBALS['__refid'])) && (isValidId(getReferralId())));
}
// Getter for referral id