From: Roland Häder Date: Sun, 25 Nov 2012 13:34:45 +0000 (+0000) Subject: Introduced more wrappers X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b941cf55d76e1349c7e9c29e116fbf708664a06b;p=mailer.git Introduced more wrappers --- diff --git a/inc/daily/daily_100_bonus.php b/inc/daily/daily_100_bonus.php index 59f5c9b0d4..6d7c5c05ca 100644 --- a/inc/daily/daily_100_bonus.php +++ b/inc/daily/daily_100_bonus.php @@ -86,7 +86,7 @@ if (!SQL_HASZERONUMS($result_bonus)) { } // END - while // Handle bonus points - handleBonusPoints(getConfig('bonus_stats'), $content['userid']); + handleBonusPoints(getBonusStats(), $content['userid']); } // END - if // Free memory diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index a9175e22d9..cdd11a792d 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -285,7 +285,7 @@ function isBonusRallyeActive () { // Is there cache? if (!isset($GLOBALS['bonus_rallye_active'])) { // Just determine it - $GLOBALS['bonus_rallye_active'] = (getConfig('bonus_active') == 'Y'); + $GLOBALS['bonus_rallye_active'] = (getBonusActive() == 'Y'); } // END - if // Return cache @@ -297,7 +297,7 @@ function isBonusNewMemberNotifyEnabled () { // Is there cache? if (!isset($GLOBALS['bonus_new_member_notify_active'])) { // Just determine it - $GLOBALS['bonus_new_member_notify_active'] = (getConfig('bonus_new_member_notify') == 'Y'); + $GLOBALS['bonus_new_member_notify_active'] = (getBonusNewMemberNotify() == 'Y'); } // END - if // Return cache @@ -388,5 +388,113 @@ function getBonusUserid () { return $GLOBALS[__FUNCTION__]; } +// Getter for bonus_active +function getBonusActive () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('bonus_active'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Getter for bonus_notify_points +function getBonusNotifyPoints () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('bonus_notify_points'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Getter for bonus_new_member_notify +function getBonusNewMemberNotify () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('bonus_new_member_notify'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Getter for bonus_stats +function getBonusStats () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('bonus_stats'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Getter for bonus_order +function getBonusOrder () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('bonus_order'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Getter for bonus_lines +function getBonusLines () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('bonus_lines'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Getter for bonus_include_own +function getBonusIncludeOwn () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('bonus_include_own'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Getter for bonus_disable_notify +function getBonusDisableNotify () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('bonus_disable_notify'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// Getter for bonus_enable_notify +function getBonusEnableNotify () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('bonus_enable_notify'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // [EOF] ?> diff --git a/inc/libs/holiday_functions.php b/inc/libs/holiday_functions.php index 40f9e68cbe..8b5c02d711 100644 --- a/inc/libs/holiday_functions.php +++ b/inc/libs/holiday_functions.php @@ -104,5 +104,21 @@ LIMIT 1", SQL_FREERESULT($result_stop); } +// ---------------------------------------------------------------------------- +// Wrapper functions for configuration entries +// ---------------------------------------------------------------------------- + +// Getter for user_alpha +function getHolidayLock () { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('holiday_lock'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + // [EOF] ?> diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index 64e03f1a5c..255ad5ce4c 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -339,7 +339,7 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p } // END - if // Is the timeout reached? - if ($probe >= getConfig('login_timeout')) { + if ($probe >= getLoginTimeout()) { // Add login bonus to user's account $add = ',`login_bonus`=`login_bonus`+{?login_bonus?}'; $GLOBALS['bonus_payed'] = TRUE; @@ -625,7 +625,7 @@ LIMIT 1", array(bigintval($refid)), __FILE__, __LINE__); // Subtract points from system - handleBonusPoints(getConfig('bonus_ref'), $refid); + handleBonusPoints(getBonusRef(), $refid); } // END - if // Add one-time referral bonus over referral system or directly diff --git a/inc/mails/bonus_mails.php b/inc/mails/bonus_mails.php index 2493a25e59..ef465e5c1c 100644 --- a/inc/mails/bonus_mails.php +++ b/inc/mails/bonus_mails.php @@ -52,9 +52,9 @@ $sql = ''; $mode = ''; // Shall I sent activation or deactivation mail? $sql = "SELECT `userid`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE (`bonus_rallye_enable_notify` "; -switch (getConfig('bonus_active')) { +switch (getBonusActive()) { case 'Y': // Active rallye is activated - if (getConfig('bonus_enable_notify') == 'Y') { + if (getBonusEnableNotify() == 'Y') { // Okay, let's check for member accounts $sql .= '= 0 OR (`bonus_rallye_enable_notify` > 0 AND `bonus_rallye_enable_notify` < `bonus_rallye_disable_notify`)'; $mode = 'enable'; @@ -65,7 +65,7 @@ switch (getConfig('bonus_active')) { break; case 'N': // Active rallye is deactivated - if (getConfig('bonus_disable_notify') == 'Y') { + if (getBonusDisableNotify() == 'Y') { // Okay, let's check for member accounts $sql .= ' > 0 AND `bonus_rallye_disable_notify` < `bonus_rallye_enable_notify`'; $mode = 'disable'; @@ -81,7 +81,7 @@ if (!empty($sql)) { $sql .= ')' . runFilterChain('user_exclusion_sql', " AND `status`='CONFIRMED'") . ' ORDER BY `last_online` ASC'; // Normal notification mails or bonus mails? - $sentBonusMails = ((getConfig('bonus_notify_points') > 0) && ($mode == 'enable') && (isExtensionActive('bonus'))); + $sentBonusMails = ((getBonusNotifyPoints() > 0) && ($mode == 'enable') && (isExtensionActive('bonus'))); // Load message body for bonus mails $message = loadEmailTemplate('bonus_enable_notify_body', '', '{PER}userid{PER}'); @@ -125,7 +125,7 @@ LIMIT 1", $url = 'modules.php?module=index&what=login'; // Insert mail - addBonusMailToQueue('{--MEMBER_BONUS_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message, $receiver, getConfig('bonus_notify_points'), getConfig('bonus_notify_wait'), $url, 0, 'normal', SQL_NUMROWS($result_main)); + addBonusMailToQueue('{--MEMBER_BONUS_RALLYE_' . strtoupper($mode) . '_SUBJECT--}', $message, $receiver, getBonusNotifyPoints(), getConfig('bonus_notify_wait'), $url, 0, 'normal', SQL_NUMROWS($result_main)); } // END - if } // END - if diff --git a/inc/modules/admin/what-unlock_emails.php b/inc/modules/admin/what-unlock_emails.php index 76bc73be56..a9145f11b7 100644 --- a/inc/modules/admin/what-unlock_emails.php +++ b/inc/modules/admin/what-unlock_emails.php @@ -105,7 +105,7 @@ LIMIT 1', array(bigintval($content['sender'])), __FILE__, __LINE__); // Subtract bonus points from system - handleBonusPoints(getConfig('bonus_order'), $content['sender']); + handleBonusPoints(getBonusOrder(), $content['sender']); } // END - if // Load email template diff --git a/inc/modules/guest/what-top10.php b/inc/modules/guest/what-top10.php index 190bfd144d..e6e836228f 100644 --- a/inc/modules/guest/what-top10.php +++ b/inc/modules/guest/what-top10.php @@ -81,9 +81,9 @@ while ($content = SQL_FETCHARRAY($result)) { $count++; } // END - while -if ($count < getConfig('top10_max')) { +if ($count < getTop10Max()) { // Add more "blank" rows - for ($i = $count; $i <= getConfig('top10_max'); $i++) { + for ($i = $count; $i <= getTop10Max(); $i++) { // Prepare data for template $content = array( 'index' => $i @@ -135,9 +135,9 @@ while ($content = SQL_FETCHARRAY($result)) { $count++; } // END - while -if ($count < getConfig('top10_max')) { +if ($count < getTop10Max()) { // Add more "blank" rows - for ($i = $count; $i <= getConfig('top10_max'); $i++) { + for ($i = $count; $i <= getTop10Max(); $i++) { // Prepare data for template $content = array( 'index' => $i @@ -193,9 +193,9 @@ while ($content = SQL_FETCHARRAY($result)) { $count++; } // END - while -if ($count < getConfig('top10_max')) { +if ($count < getTop10Max()) { // Add more "blank" rows - for ($i = $count; $i <= getConfig('top10_max'); $i++) { + for ($i = $count; $i <= getTop10Max(); $i++) { // Prepare data for template $content = array( 'index' => $i diff --git a/inc/modules/member/what-holiday.php b/inc/modules/member/what-holiday.php index e1b6872cff..95e3f651d5 100644 --- a/inc/modules/member/what-holiday.php +++ b/inc/modules/member/what-holiday.php @@ -84,12 +84,12 @@ if ((SQL_NUMROWS($result1) == 1) || (SQL_NUMROWS($result2) == 1)) { if (empty($content['timestamp'])) $content['timestamp'] = '0'; if (empty($content['timestamp_ordered'])) $content['timestamp_ordered'] = '0'; - if ((($content['timestamp'] + getConfig('holiday_lock')) > time()) || (($content['timestamp_ordered'] + getConfig('holiday_lock')) > time())) { + if ((($content['timestamp'] + getHolidayLock()) > time()) || (($content['timestamp_ordered'] + getHolidayLock()) > time())) { // Mail order is to close away! unsetPostRequestElement('ok'); unsetPostRequestElement('stop'); - if (($content['timestamp'] + getConfig('holiday_lock')) > time()) { + if (($content['timestamp'] + getHolidayLock()) > time()) { // Mail found in pool $stamp = $content['timestamp']; } else { @@ -120,7 +120,12 @@ if (isFormSent()) { } else { // Everything went okay so let's store his request and send mails SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_holidays` (`userid`, `holiday_start`, `holiday_end`, `comments`) VALUES ('%s','%s','%s','%s')", - array(getMemberId(), $START, $content['holiday_end'], postRequestElement('comments')), __FILE__, __LINE__); + array( + getMemberId(), + $START, + $content['holiday_end'], + postRequestElement('comments') + ), __FILE__, __LINE__); // Activate holiday system SQL_QUERY_ESC("UPDATE @@ -174,7 +179,7 @@ LIMIT 1", array(getMemberId()), __FILE__, __LINE__); // Merge arrays $content = merge_array($content, SQL_FETCHARRAY($result)); - if (($content['holiday_active'] == 'Y') && (($content['holiday_activated'] + getConfig('holiday_lock')) < time())) { + if (($content['holiday_active'] == 'Y') && (($content['holiday_activated'] + getHolidayLock()) < time())) { // Load data $result2 = SQL_QUERY_ESC("SELECT `holiday_start`, @@ -251,7 +256,7 @@ LIMIT 1", array(getMemberId()), __FILE__, __LINE__); SQL_FREERESULT($result); // Check for lock - if (($content['holiday_activated'] + getConfig('holiday_lock')) < time()) { + if (($content['holiday_activated'] + getHolidayLock()) < time()) { // User can deactivate his holiday request switch ($content['holiday_active']) { case 'Y': // Display deactivation form diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 2e500b1617..3d3e6ebc9b 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -2498,6 +2498,18 @@ function getApServerName () { return $GLOBALS[__FUNCTION__]; } +// Getter for 'index_delay' +function getIndexDelay () { + // Is the cache entry set? + if (!isset($GLOBALS[__FUNCTION__])) { + // No, so determine it + $GLOBALS[__FUNCTION__] = getConfig('index_delay'); + } // END - if + + // Return cached entry + return $GLOBALS[__FUNCTION__]; +} + // Checks whether 'ap_server_name' is 'Y' function isApServerNameEnabled () { // Is the cache entry set? diff --git a/index.php b/index.php index f0683ecff1..7b7d2f15f4 100644 --- a/index.php +++ b/index.php @@ -67,7 +67,7 @@ if ((isExtensionInstalledAndNewer('sql_patches', '0.8.3')) && (isDisplayHomeInIn ////////////////////////////////////////////////// // Check for cookies -if ((isSessionVariableSet('visited')) || (getConfig('index_delay') > -1)) { +if ((isSessionVariableSet('visited')) || (getIndexDelay() > -1)) { // Set content type setContentType('text/html'); @@ -87,9 +87,9 @@ if ((isSessionVariableSet('visited')) || (getConfig('index_delay') > -1)) { loadTemplate('index'); // Shall I insert an automated forward? - if (getConfig('index_delay') > 0) { + if (getIndexDelay() > 0) { // This will be a JavaScript-redirect! - $content['delay'] = (getConfig('index_delay') * 1000 + 500); + $content['delay'] = (getIndexDelay() * 1000 + 500); $content['module'] = 'index'; // Load template diff --git a/mailid_top.php b/mailid_top.php index 87db810c76..11b984d145 100644 --- a/mailid_top.php +++ b/mailid_top.php @@ -282,7 +282,7 @@ if ((isValidUserId($userId)) && (($mailId > 0) || ($bonusId > 0)) && (!ifFatalEr // Is an active-rallye running and this is not a notification mail? if ((isBonusRallyeActive()) && ($data['is_notify'] != 'Y')) { // Shall I exclude the webmaster's own userid from the active-rallye? - if ((((getBonusUserid() == $userId) && (getConfig('bonus_include_own') == 'Y')) || (getBonusUserid() != $userId)) && (getDefRefid() != $userId)) { + if ((((getBonusUserid() == $userId) && (getBonusIncludeOwn() == 'Y')) || (getBonusUserid() != $userId)) && (getDefRefid() != $userId)) { // Add points and remember ranking are done in this function.... addTurboBonus($urlId, $userId, $type);