X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Flibs%2Frefback_functions.php;h=dcc7740a3244afb061737da102f605f83035465e;hb=cb22480488263dac67caa6f5b6476421527900ad;hp=300ee3aacdfc7eb13745a1d3165566d6816e0a09;hpb=486544503c2e517dc5c399308fdf43c8e35ff102;p=mailer.git diff --git a/inc/libs/refback_functions.php b/inc/libs/refback_functions.php index 300ee3aacd..dcc7740a32 100644 --- a/inc/libs/refback_functions.php +++ b/inc/libs/refback_functions.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2011 by Mailer Developer Team * + * Copyright (c) 2009 - 2012 by Mailer Developer Team * * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -50,7 +50,7 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) { $return = $ref_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 @@ -98,7 +98,7 @@ LIMIT 1', // Something must have been updated if (SQL_HASZEROAFFECTED()) { // Please report this bug - debug_report_bug(__FUNCTION__, __LINE__, 'Nothing has been updated in user_refs,userid=' . $userid . ',refid=' . convertNullToZero($refid) . ',refbackPoints=' . $refbackPoints); + reportBug(__FUNCTION__, __LINE__, 'Nothing has been updated in user_refs,userid=' . $userid . ',refid=' . convertNullToZero($refid) . ',refbackPoints=' . $refbackPoints); } // END - if // Add points again, but only directly @@ -136,9 +136,9 @@ LIMIT 1', */ function getRefbackPercents ($userid, $refid) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ' - ENTERED!'); - if ((!isValidUserId($userid)) || (!isValidUserId($refid))) { + if ((!isValidId($userid)) || (!isValidId($refid))) { // userid and/or refid is invalid - debug_report_bug(__FUNCTION__, __LINE__, 'userid=' . convertNullToZero($userid) . ', refid=' . convertNullToZero($refid) . ' - Both must be > 0'); + reportBug(__FUNCTION__, __LINE__, 'userid=' . convertNullToZero($userid) . ', refid=' . convertNullToZero($refid) . ' - Both must be > 0'); } elseif ($userid == $refid) { // Skip identical ids return 0; @@ -160,7 +160,7 @@ function getRefbackPercents ($userid, $refid) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ',percents=' . $GLOBALS['refback_percents'][$userid][$refid]); } else { // Please report all findings - debug_report_bug(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ' - No entry found. :-('); + reportBug(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ' - No entry found. :-('); } // Free result @@ -196,7 +196,7 @@ ORDER BY // Add all while ($content = SQL_FETCHARRAY($result)) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . convertNullToZero($refid) . ',level=' . $level . ',userid=' . $content['userid']); - $userIds[] = $content['userid']; + array_push($userIds, $content['userid']); } // END - while } // END - if @@ -274,7 +274,7 @@ function getArrayFromUserRefbackData ($id) { $id = bigintval($id); // Get entry from database - $result = SQL_QUERY_ESC("SELECT `id`,`userid`,`refid`,`refback_percents`,`level`,`refback_points` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `id`=%s AND `userid`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `id`, `userid`, `refid`, `refback_percents`, `level`, `refback_points` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `id`=%s AND `userid`=%s LIMIT 1", array($id, getMemberId()), __FUNCTION__, __LINE__); // Is there an entry? @@ -342,7 +342,7 @@ function updateMemberRefbackPercents ($id, $percents, $note) { // Prepare email content $content['refback_percents'] = $percents; - $content['refback_note'] = $note; + $content['refback_notice'] = $note; // Load member email template $mail = loadEmailTemplate('member_refback', $content, $content['refid']); @@ -354,19 +354,59 @@ function updateMemberRefbackPercents ($id, $percents, $note) { sendAdminNotification('{--ADMIN_REFBACK_SUBJECT--}', 'admin_refback', $content, $content['refid']); // All fine! - $status['ok'] = true; + $status['ok'] = TRUE; // Return status array //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'id=' . $id . ',percents=' . $percents . ' - EXIT!'); return $status; } -// Checks wether refback is enabled +// ---------------------------------------------------------------------------- +// Wrapper functions for configuration entries +// ---------------------------------------------------------------------------- + +// Getter for refback_enabled +function getRefbackEnabled () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('refback_enabled'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Checks whether refback is enabled function isRefbackEnabled () { - // Do we have cache? + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = (getRefbackEnabled() == 'Y'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Getter for refback_max_perc +function getRefbackMaxPerc () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('refback_max_perc'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Getter for refback_min_perc +function getRefbackMinPerc () { + // Is there cache? if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS[__FUNCTION__] = (getConfig('refback_enabled') == 'Y'); + $GLOBALS[__FUNCTION__] = getConfig('refback_min_perc'); } // END - if // Return cache