X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Freferral-functions.php;h=4747f3123ca83ce23ba7fa660bb946af0cbc9cc2;hb=150ed402878985508f10f4e06d25831e0fb3a1f8;hp=72e53b622ad549c90d10772476317f4b7ef67af6;hpb=f2b603aed42bfdf7a94611d7bae71fe3a1048890;p=mailer.git diff --git a/inc/referral-functions.php b/inc/referral-functions.php index 72e53b622a..4747f3123c 100644 --- a/inc/referral-functions.php +++ b/inc/referral-functions.php @@ -10,11 +10,6 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Alle zum Referral-System gehoerenden Funktionen * * -------------------------------------------------------------------- * - * $Revision:: $ * - * $Date:: $ * - * $Tag:: 0.2.1-FINAL $ * - * $Author:: $ * - * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * * Copyright (c) 2009 - 2013 by Mailer Developer Team * * For more information visit: http://mxchange.org * @@ -200,7 +195,7 @@ function addPointsThroughReferralSystem ($subject, $userid, $points, $refid = NU //* 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); @@ -279,14 +274,14 @@ function addPointsThroughReferralSystem ($subject, $userid, $points, $refid = NU //* 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 @@ -423,13 +418,7 @@ ORDER BY // 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--}'; @@ -482,8 +471,22 @@ function getPointsDataArrayFromSubject ($subject) { } // 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) { @@ -682,7 +685,7 @@ function flushReferralTableToDatabase ($userid) { //* 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; @@ -799,8 +802,8 @@ function setReferralId ($refid) { } // Checks if 'refid' is valid -function isReferralIdValid () { - return ((isset($GLOBALS['__refid'])) && (getReferralId() !== NULL) && (getReferralId() > 0)); +function isValidReferralId () { + return ((isset($GLOBALS['__refid'])) && (isValidId(getReferralId()))); } // Getter for referral id @@ -811,7 +814,7 @@ function getReferralId () { // Determines referral id and sets it function determineReferralId () { // Is it already detected? - if (isReferralIdValid()) { + if (isValidReferralId()) { // Do not determine it, just return it return getReferralId(); } elseif ((!isHtmlOutputMode()) && (basename($_SERVER['PHP_SELF']) != 'ref.php')) { @@ -820,7 +823,7 @@ function determineReferralId () { } // Check if refid is set - if (isReferralIdValid()) { + if (isValidReferralId()) { // This is fine... //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using refid from GLOBALS (' . getReferralId() . ')'); } elseif (isPostRequestElementSet('refid')) { @@ -889,7 +892,7 @@ function determineReferralId () { // Set cookie //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Saving refid to session (' . getReferralId() . ') #1'); setSession('refid', getReferralId()); - } elseif ((!isReferralIdValid()) || (!fetchUserData(getReferralId()))) { + } elseif ((!isValidReferralId()) || (!fetchUserData(getReferralId()))) { // Not valid! //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Not valid referral id (' . getReferralId() . '), setting NULL in session'); setReferralId(NULL);