X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Flibs%2Frefback_functions.php;h=c4b15f74e9f5536eae060235d40ac5e3e916e1e1;hp=cdf60a9fff9c898be6c5c3543b4aef98d98db15d;hb=24dfd21baed6a9a112992bdabf7da96576012bc4;hpb=263a089d8a499e0e26d0af9e7aa7639f88b8ca60 diff --git a/inc/libs/refback_functions.php b/inc/libs/refback_functions.php index cdf60a9fff..c4b15f74e9 100644 --- a/inc/libs/refback_functions.php +++ b/inc/libs/refback_functions.php @@ -14,10 +14,9 @@ * $Date:: $ * * $Tag:: 0.2.1-FINAL $ * * $Author:: $ * - * Needs to be in all Files and every File needs "svn propset * - * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * + * 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 * @@ -51,7 +50,7 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) { $return = $points; // Get all ref levels - $result_refs = SQL_QUERY("SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level` > 0 ORDER BY `level` ASC", + $result_refs = SQL_QUERY('SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level` > 0 ORDER BY `level` ASC', __FUNCTION__, __LINE__); // "Walk" through all level @@ -61,35 +60,35 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) { unset($GLOBALS['ref_level']); // "Walk" through all refids - //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):userid={$userid},ref={$ref},level={$content['level']},points={$points}
"); + //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):userid={$userid},ref={$ref},level={$content['level']},points={$points}
"); foreach (getArrayFromRefbackLevel($userid, $content['level']) as $refid) { // Skip level zero or if both are the same if ($userid == $refid) continue; // Get refback percents $percents = getRefbackPercents($userid, $refid); - //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):userid={$userid},ref={$ref},refid={$refid},points={$points},percents={$percents}
"); + //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):userid={$userid},ref={$ref},refid={$refid},points={$points},percents={$percents}
"); // Some percents given? if ($percents > 0) { - //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):points={$points},perc={$content['percents']},percents={$percents},level={$content['level']}
"); + //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):points={$points},perc={$content['percents']},percents={$percents},level={$content['level']}
"); // Calculate points for refback $refback = $points * ($content['percents'] / 100) * ($percents / 100); // Update refback table ('refid' and 'userid' must be exchanged!) SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_refs` SET `points`=`points`+%s WHERE `userid`=%s AND `refid`=%s LIMIT 1", array($refback, $refid, $userid), __FUNCTION__, __LINE__); - //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):refback={$refback},userid={$userid},refid={$refid} - UPDATE! (".SQL_AFFECTEDROWS().")
"); + //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):refback={$refback},userid={$userid},refid={$refid} - UPDATE! (".SQL_AFFECTEDROWS().")
"); // Add points again, but only directly - //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):refback={$refback}
"); + //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):refback={$refback}
"); addPointsDirectly(sprintf("refback:%s", $refid), $userid, $refback); // Reduce points if refid is found if ($refid == $ref) { // Reduce points here! $return = $points * ($content['percents'] / 100) - $refback; - //* DEBUG: */ print(__FUNCTION__."(".__LINE__."):points={$return} - REDUCED
"); + //* DEBUG: */ print(__FUNCTION__ . '(' . __LINE__."):points={$return} - REDUCED
"); } // END - if } // END - if } // END foreach @@ -109,40 +108,43 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) { // "Getter" for refback percents function getRefbackPercents ($userid, $ref) { //* DEBUG: */ print("----------------------- ".__FUNCTION__." - ENTRY ----------------------------------------------- ".__FUNCTION__." - EXIT ------------------------
"); - return $percents; + return $GLOBALS['refback_percents'][$userid][$ref]; } // "Getter" for userid array which will return only one entry -function getArrayFromRefbackLevel ($rid, $level) { +function getArrayFromRefbackLevel ($refid, $level) { //* DEBUG: */ print("----------------------- ".__FUNCTION__." - ENTRY ----------------------------------------------- ".__FUNCTION__." - EXIT ------------------------
"); return $userIds; } @@ -181,7 +183,7 @@ function updateRefbackTable ($userid) { //* DEBUG: */ print("----------------------- ".__FUNCTION__." - ENTRY ----------------------------------------------- ".__FUNCTION__." - EXIT ------------------------
"); } @@ -288,7 +291,9 @@ function getArrayFromRefbackUserRefs ($userid, $level) { r.refid, r.refback, r.points, - d.status".$add." + d.status".$add.", + d.joined, + d.refid AS level_refid FROM `{?_MYSQL_PREFIX?}_user_refs` AS r LEFT JOIN @@ -302,7 +307,7 @@ ORDER BY array(bigintval($userid), bigintval($level)), __FUNCTION__, __LINE__); // Are there some entries? - if (SQL_NUMROWS($result) > 0) { + if (!SQL_HASZERONUMS($result)) { // Fetch all entries while ($row = SQL_FETCHARRAY($result)) { // Add row @@ -328,7 +333,7 @@ function getArrayFromUserRefbackData ($id) { $id = bigintval($id); // Get entry from database - $result = SQL_QUERY_ESC("SELECT `id`, `refid`, `refback`, `level` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `id`=%s AND `userid`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id`, `userid`, `refid`, `refback`, `level`, `points` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `id`=%s AND `userid`=%s LIMIT 1", array($id, getMemberId()), __FUNCTION__, __LINE__); // Is there an entry? @@ -349,20 +354,20 @@ function getArrayFromUserRefbackData ($id) { function updateMemberRefbackPercents ($id, $percents) { //* DEBUG: */ print("----------------------- ".__FUNCTION__." - ENTRY ----------------------------------------------- ".__FUNCTION__." - EXIT ------------------------
"); return $status; } -// + +// Checks wether refback is enabled +function isRefbackEnabled () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = (getConfig('refback_enabled') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// [EOF] ?>