From: quix0r Date: Sat, 9 Jul 2011 03:59:51 +0000 (+0000) Subject: Wrapper function for configuration introduced, config entry renamed: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9808a406e8cf98dab0e6ba8682e913405aaf77ba;p=mailer.git Wrapper function for configuration introduced, config entry renamed: - Wrapper function getSurfbarPaymentModel() introduced for ext-surfbar which encapsulates surfbar_payment_model (old name: surfbar_pay_model) - In same extension, more code has been rewritten to use EL code --- diff --git a/inc/expression-functions.php b/inc/expression-functions.php index a9aa0b5681..a7dcfcac86 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -192,8 +192,11 @@ function doExpressionPipe ($data) { if ((empty($data['value'])) && ($data['value'] != '0')) { // No value is set $replacer = '{DQUOTE} . ' . $data['extra_func2'] . '(' . $data['extra_func'] . '(' . $data['callback'] . '())) . {DQUOTE}'; + } elseif (isXmlTypeBool($data['value'])) { + // Boolean value detected + $replacer = '{DQUOTE} . ' . $data['extra_func2'] . '(' . $data['extra_func'] . '(' . $data['callback'] . '(' . $data['value'] . '))) . {DQUOTE}'; } else { - // Some value is set + // Some string/integer value is set $replacer = '{DQUOTE} . ' . $data['extra_func2'] . '(' . $data['extra_func'] . '(' . $data['callback'] . "('" . $data['value'] . "'))) . {DQUOTE}"; } } // END - if diff --git a/inc/extensions/ext-surfbar.php b/inc/extensions/ext-surfbar.php index cf297dd85b..a79aec359c 100644 --- a/inc/extensions/ext-surfbar.php +++ b/inc/extensions/ext-surfbar.php @@ -146,7 +146,7 @@ UNIQUE KEY `status_action` (`actions_status`,`actions_action`)", addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_actions` (`actions_status`,`actions_action`,`actions_new_status`) VALUES ('MIGRATED','BOOKNOW','PENDING')"); // Config entries - addConfigAddSql('surfbar_pay_model', "ENUM('STATIC','DYNAMIC') NOT NULL DEFAULT 'STATIC'"); + addConfigAddSql('surfbar_payment_model', "ENUM('STATIC','DYNAMIC') NOT NULL DEFAULT 'STATIC'"); addConfigAddSql('surfbar_static_reward', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 0.25000'); addConfigAddSql('surfbar_static_costs', 'FLOAT(20,5) UNSIGNED NOT NULL DEFAULT 1.00000'); addConfigAddSql('surfbar_static_time', 'SMALLINT(6) UNSIGNED NOT NULL DEFAULT 60'); diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 1a1ff0e53e..936a31f61c 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -785,14 +785,14 @@ function translateMemberSurfbarActionToSubmit ($action) { } // Determine reward -function SURFBAR_DETERMINE_REWARD ($onlyMin=false) { +function SURFBAR_DETERMINE_REWARD ($onlyMin = false) { // Static values are default $reward = getConfig('surfbar_static_reward'); // Do we have static or dynamic? - if (getConfig('surfbar_pay_model') == 'DYNAMIC') { + if (getSurfbarPaymentModel() == 'DYNAMIC') { // "Calculate" dynamic reward - if ($onlyMin) { + if ($onlyMin === true) { $reward += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE(); } else { $reward += SURFBAR_CALCULATE_DYNAMIC_ADD(); @@ -809,7 +809,7 @@ function SURFBAR_DETERMINE_COSTS ($onlyMin=false) { $costs = getConfig('surfbar_static_costs'); // Do we have static or dynamic? - if (getConfig('surfbar_pay_model') == 'DYNAMIC') { + if (getSurfbarPaymentModel() == 'DYNAMIC') { // "Calculate" dynamic costs if ($onlyMin) { $costs += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE(); @@ -835,7 +835,7 @@ function SURFBAR_CALCULATE_DYNAMIC_ADD () { // Determine right template name function SURFBAR_DETERMINE_TEMPLATE_NAME() { // Default is the frameset - $templateName = "surfbar_frameset"; + $templateName = 'surfbar_frameset'; // Any frame set? ;-) if (isGetRequestParameterSet('frame')) { @@ -860,26 +860,26 @@ function SURFBAR_CHECK_RELOAD_FULL () { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Fixed surf lock is '.getConfig('surfbar_static_lock') . '', false); // Do we have dynamic model? - if (getConfig('surfbar_pay_model') == 'DYNAMIC') { + if (getSurfbarPaymentModel() == 'DYNAMIC') { // "Calculate" dynamic lock $GLOBALS['surfbar_cache']['surf_lock'] += SURFBAR_CALCULATE_DYNAMIC_ADD(); } // END - if // Ask the database $result = SQL_QUERY_ESC("SELECT - COUNT(l.locks_id) AS cnt + COUNT(l.`locks_id`) AS `cnt` FROM `{?_MYSQL_PREFIX?}_surfbar_locks` AS l INNER JOIN `{?_MYSQL_PREFIX?}_surfbar_urls` AS u ON - u.url_id=l.locks_url_id + u.`url_id`=l.`locks_url_id` WHERE - l.locks_userid=%s AND - (UNIX_TIMESTAMP() - ".SURFBAR_GET_SURF_LOCK().") < UNIX_TIMESTAMP(l.locks_last_surfed) AND + l.`locks_userid`=%s AND + (UNIX_TIMESTAMP() - {%pipe,SURFBAR_GET_SURF_LOCK%}) < UNIX_TIMESTAMP(l.`locks_last_surfed`) AND ( - ((UNIX_TIMESTAMP(l.locks_last_surfed) - u.url_fixed_reload) < 0 AND u.url_fixed_reload > 0) OR - u.url_fixed_reload = '0' + ((UNIX_TIMESTAMP(l.`locks_last_surfed`) - u.`url_fixed_reload`) < 0 AND u.`url_fixed_reload` > 0) OR + u.`url_fixed_reload` = 0 ) LIMIT 1", array(getMemberId()), __FUNCTION__, __LINE__ @@ -953,7 +953,7 @@ LIMIT 1", // Check wether the user is allowed to book more URLs function SURFBAR_IF_USER_BOOK_MORE_URLS ($userid = '0') { // Is this admin and userid is zero or does the user has some URLs left to book? - return ((($userid == '0') && (isAdmin())) || (SURFBAR_GET_TOTAL_USER_URLS($userid, '', array('REJECTED')) < getConfig('surfbar_max_order'))); + return ((($userid == '0') && (isAdmin())) || (SURFBAR_GET_TOTAL_USER_URLS($userid, '', array('REJECTED')) < getSurfbarMaxOrder())); } // Get total amount of URLs of given status for current user @@ -964,7 +964,7 @@ function SURFBAR_GET_TOTAL_USER_URLS ($userid = '0', $status = '', $exclude = '' $userid = getMemberId(); } elseif ($userid == '0') { // Error! - return (getConfig('surfbar_max_order') + 1); + return (getSurfbarMaxOrder() + 1); } // Default is all URLs @@ -1065,7 +1065,7 @@ function SURFBAR_PAY_POINTS () { // Remove it from the URL owner //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS().'', false); if (isValidUserId(SURFBAR_GET_USERID())) { - subtractPoints(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS()); + subtractPoints(sprintf("surfbar_%s", getSurfbarPaymentModel()), SURFBAR_GET_USERID(), SURFBAR_GET_COSTS()); } // END - if //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getMemberId().',reward='.SURFBAR_GET_REWARD().'', false); @@ -1073,7 +1073,7 @@ function SURFBAR_PAY_POINTS () { unset($GLOBALS['ref_level']); // Book it to the user - addPointsThroughReferalSystem(sprintf("surfbar_%s", getConfig('surfbar_pay_model')), getMemberId(), SURFBAR_GET_REWARD()); + addPointsThroughReferalSystem(sprintf("surfbar_%s", getSurfbarPaymentModel()), getMemberId(), SURFBAR_GET_REWARD()); } // Updates the statistics of current URL/userid @@ -1295,7 +1295,7 @@ function SURFBAR_DETERMINE_WAIT_TIME () { $time = getConfig('surfbar_static_time'); // Which payment model do we have? - if (getConfig('surfbar_pay_model') == 'DYNAMIC') { + if (getSurfbarPaymentModel() == 'DYNAMIC') { // "Calculate" dynamic time $time += SURFBAR_CALCULATE_DYNAMIC_ADD(); } // END - if @@ -1745,7 +1745,7 @@ LIMIT 1", //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'BASE/STATIC - reward='.SURFBAR_GET_REWARD().'|costs='.SURFBAR_GET_COSTS().'', false); // Only in dynamic model add the dynamic bonus! - if (getConfig('surfbar_pay_model') == 'DYNAMIC') { + if (getSurfbarPaymentModel() == 'DYNAMIC') { // Calculate dynamic reward/costs and add it $GLOBALS['surfbar_cache']['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD(); $GLOBALS['surfbar_cache']['costs'] += SURFBAR_CALCULATE_DYNAMIC_ADD(); @@ -1771,49 +1771,61 @@ LIMIT 1", // "Getter" for surfbar_dynamic_percent function getSurfbarDynamicPercent () { // Do we have cache? - if (!isset($GLOBALS['surfbar_dynamic_percent'])) { + if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS['surfbar_dynamic_percent'] = getConfig('surfbar_dynamic_percent'); + $GLOBALS[__FUNCTION__] = getConfig('surfbar_dynamic_percent'); } // END - if // Return cache - return $GLOBALS['surfbar_dynamic_percent']; + return $GLOBALS[__FUNCTION__]; } // "Getter" for surfbar_static_reward function getSurfbarStaticReward () { // Do we have cache? - if (!isset($GLOBALS['surfbar_static_reward'])) { + if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS['surfbar_static_reward'] = getConfig('surfbar_static_reward'); + $GLOBALS[__FUNCTION__] = getConfig('surfbar_static_reward'); } // END - if // Return cache - return $GLOBALS['surfbar_static_reward']; + return $GLOBALS[__FUNCTION__]; } // "Getter" for surfbar_static_time function getSurfbarStaticTime () { // Do we have cache? - if (!isset($GLOBALS['surfbar_static_time'])) { + if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS['surfbar_static_time'] = getConfig('surfbar_static_time'); + $GLOBALS[__FUNCTION__] = getConfig('surfbar_static_time'); } // END - if // Return cache - return $GLOBALS['surfbar_static_time']; + return $GLOBALS[__FUNCTION__]; } // "Getter" for surfbar_max_order function getSurfbarMaxOrder () { // Do we have cache? - if (!isset($GLOBALS['surfbar_max_order'])) { + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getConfig('surfbar_max_order'); + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__]; +} + +// "Getter" for surfbar_payment_model +function getSurfbarPaymentModel () { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { // Determine it - $GLOBALS['surfbar_max_order'] = getConfig('surfbar_max_order'); + $GLOBALS[__FUNCTION__] = getConfig('surfbar_payment_model'); } // END - if // Return cache - return $GLOBALS['surfbar_max_order']; + return $GLOBALS[__FUNCTION__]; } // ----------------------------------------------------------------------------- diff --git a/inc/modules/admin/what-config_surfbar.php b/inc/modules/admin/what-config_surfbar.php index a0b77e469c..23ed02aab0 100644 --- a/inc/modules/admin/what-config_surfbar.php +++ b/inc/modules/admin/what-config_surfbar.php @@ -70,12 +70,12 @@ if (isFormSent()) { } // END - foreach // Even some more... - foreach (array('surfbar_pay_model_static','surfbar_pay_model_dynamic','surfbar_pause_mode_internal','surfbar_pause_mode_external','surfbar_notification_mode_instant','surfbar_notification_mode_reset') as $entry) { + foreach (array('surfbar_payment_model_static','surfbar_payment_model_dynamic','surfbar_pause_mode_internal','surfbar_pause_mode_external','surfbar_notification_mode_instant','surfbar_notification_mode_reset') as $entry) { $content[$entry] = ''; } // END - foreach // Prepare selections - foreach (array('surfbar_pay_model','surfbar_pause_mode','surfbar_notification_mode') as $entry) { + foreach (array('surfbar_payment_model','surfbar_pause_mode','surfbar_notification_mode') as $entry) { $content[$entry . '_' . strtolower(getConfig($entry))] = ' checked="checked"'; } // END - foreach diff --git a/inc/modules/member/what-surfbar_book.php b/inc/modules/member/what-surfbar_book.php index e428c713c5..f04d0d12a3 100644 --- a/inc/modules/member/what-surfbar_book.php +++ b/inc/modules/member/what-surfbar_book.php @@ -77,14 +77,8 @@ if (!SURFBAR_IF_USER_BOOK_MORE_URLS()) { // Load message template displayMessage($message); } else { - // Prepare some content - $content = array( - 'reward' => SURFBAR_DETERMINE_REWARD(true), - 'costs' => SURFBAR_DETERMINE_COSTS(true), - ); - // Load surfbar order form - loadTemplate(sprintf("member_surfbar_book_%s", strtolower(getConfig('surfbar_pay_model'))), false, $content); + loadTemplate(sprintf("member_surfbar_book_%s", strtolower(getSurfbarPaymentModel()))); } // [EOF] diff --git a/inc/modules/member/what-surfbar_start.php b/inc/modules/member/what-surfbar_start.php index bf720d7bad..588f0f2097 100644 --- a/inc/modules/member/what-surfbar_start.php +++ b/inc/modules/member/what-surfbar_start.php @@ -56,7 +56,7 @@ $content = array( ); // In dynamic mode we need some more data -if (getConfig('surfbar_pay_model') == 'DYNAMIC') { +if (getSurfbarPaymentModel() == 'DYNAMIC') { // Prepare content for dynamic surfbar $content = array( 'surfbar_total_urls' => SURFBAR_GET_TOTAL_URLS('ACTIVE', 0), @@ -64,7 +64,7 @@ if (getConfig('surfbar_pay_model') == 'DYNAMIC') { } // END - if // Load the template -loadTemplate('member_surfbar_start_' . strtolower(getConfig('surfbar_pay_model')), false, $content); +loadTemplate('member_surfbar_start_' . strtolower(getSurfbarPaymentModel()), false, $content); // Load surfbar link template loadTemplate('member_surfbar_link'); diff --git a/templates/de/html/admin/admin_config_surfbar.tpl b/templates/de/html/admin/admin_config_surfbar.tpl index b251c1bf01..719fed2245 100644 --- a/templates/de/html/admin/admin_config_surfbar.tpl +++ b/templates/de/html/admin/admin_config_surfbar.tpl @@ -98,7 +98,7 @@ {--ADMIN_CONFIG_SURFBAR_PAYMENT_MODEL_STATIC--} - + @@ -106,7 +106,7 @@ {--ADMIN_CONFIG_SURFBAR_PAYMENT_MODEL_DYNAMIC--} - + diff --git a/templates/de/html/member/member_surfbar_book_dynamic.tpl b/templates/de/html/member/member_surfbar_book_dynamic.tpl index 544f893096..b1ea15e9ef 100644 --- a/templates/de/html/member/member_surfbar_book_dynamic.tpl +++ b/templates/de/html/member/member_surfbar_book_dynamic.tpl @@ -21,9 +21,9 @@
Jeder Seiten-Aufruf durch andere Mitglieder kostet Ihnen mindestens - {%pipe,translateComma=$content[costs]%} {?POINTS?}. + {%pipe,SURFBAR_DETERMINE_COSTS,translateComma=true%} {?POINTS?}. Surfen Sie mit der Surfbar erhalten Sie mindestens - {%pipe,translateComma=$content[reward]%} {?POINTS?} + {%pipe,SURFBAR_DETERMINE_REWARD,translateComma=true%} {?POINTS?} auf Ihr Konto gutgeschrieben.
diff --git a/templates/de/html/member/member_surfbar_book_static.tpl b/templates/de/html/member/member_surfbar_book_static.tpl index e988a2f5a2..56ef07c1b3 100644 --- a/templates/de/html/member/member_surfbar_book_static.tpl +++ b/templates/de/html/member/member_surfbar_book_static.tpl @@ -20,12 +20,12 @@
Jeder Seiten-Aufruf durch andere Mitglieder kostet Ihnen $content[costs] {?POINTS?}. Surfen Sie mit - der Surfbar erhalten Sie $content[reward] + class="surfbar_points">{%pipe,SURFBAR_DETERMINE_COSTS,translateComma=true%}{?POINTS?}. Surfen Sie mit + der Surfbar erhalten Sie {%pipe,SURFBAR_DETERMINE_REWARD,translateComma=true%} {?POINTS?} auf Ihr Konto gutgeschrieben.

- Sie haben bereits $content[curr_order] von maximal - $content[max_order] erlaubten URLs gebucht. + Sie haben bereits {%pipe,SURFBAR_GET_TOTAL_USER_URLS,translateComma%} von maximal + {%config,translateComma=surfbar_max_order%} erlaubten URLs gebucht.