From 5fc7cb9d73815d9d766caffa798e6dd115d9da41 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 29 Jul 2011 00:14:49 +0000 Subject: [PATCH] Wrapper getTurboRates() introduced --- inc/libs/bonus_functions.php | 16 ++++++++++++++-- inc/modules/admin/what-config_bonus.php | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index 7236987cad..dd62ec7e56 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -82,7 +82,7 @@ function addTurboBonus ($mid, $userid, $type) { $points = getConfig('turbo_bonus'); } else { // Anything else so let's explode all entered rank points - $test = explode(';', getConfig('turbo_rates')); + $test = explode(';', getTurboRates()); if (!empty($test[$rank - 2])) { // Level found $points = $test[$rank - 2]; @@ -123,7 +123,7 @@ function addBonusRanks ($data, $type, $userid) { $GLOBALS['ranking_content']['rankings'] = ''; // How many ranks do we have? - $ranks = count(explode(';', getConfig('turbo_rates'))) + 1; + $ranks = count(explode(';', getTurboRates())) + 1; // Load current user's data $result = SQL_QUERY_ESC("SELECT `level`,`points`,`timemark` FROM `{?_MYSQL_PREFIX?}_bonus_turbo` WHERE `%s`=%s AND `userid`=%s LIMIT 1", @@ -339,5 +339,17 @@ function getBonusRanks () { return $GLOBALS[__FUNCTION__]; } +// Getter for turbo_rates +function getTurboRates () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('turbo_rates'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // [EOF] ?> diff --git a/inc/modules/admin/what-config_bonus.php b/inc/modules/admin/what-config_bonus.php index fe4e8b8138..143885c699 100644 --- a/inc/modules/admin/what-config_bonus.php +++ b/inc/modules/admin/what-config_bonus.php @@ -74,10 +74,10 @@ if (isFormSent()) { $content['bonus_userid'] = addMemberSelectionBox(getBonusUserid(), false, true, true, 'bonus_userid'); // Initialize array for the points list - $RANKS = explode(';', getConfig('turbo_rates')); + $RANKS = explode(';', getTurboRates()); // Automatically calculate bonus points for ranks 2 and 3 when not set - if (getConfig('turbo_rates') == '') $RANKS = array(round(getConfig('turbo_bonus') / 2), round(getConfig('turbo_bonus') / 4)); + if (getTurboRates() == '') $RANKS = array(round(getConfig('turbo_bonus') / 2), round(getConfig('turbo_bonus') / 4)); // Generate list $OUT = '
    '; -- 2.39.5