]> git.mxchange.org Git - mailer.git/commitdiff
Wrapper function for configuration introduced, config entry renamed:
authorquix0r <quix0r@mxchange.org>
Sat, 9 Jul 2011 03:59:51 +0000 (03:59 +0000)
committerquix0r <quix0r@mxchange.org>
Sat, 9 Jul 2011 03:59:51 +0000 (03:59 +0000)
- 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

inc/expression-functions.php
inc/extensions/ext-surfbar.php
inc/libs/surfbar_functions.php
inc/modules/admin/what-config_surfbar.php
inc/modules/member/what-surfbar_book.php
inc/modules/member/what-surfbar_start.php
templates/de/html/admin/admin_config_surfbar.tpl
templates/de/html/member/member_surfbar_book_dynamic.tpl
templates/de/html/member/member_surfbar_book_static.tpl

index a9aa0b5681c3034b9e341a0b355c5259e257b324..a7dcfcac86e9c47f55223b7d473265c81af93659 100644 (file)
@@ -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
index cf297dd85b65f8c71f7ce76ad714fc8b67272da3..a79aec359c88f6cdfdf043846ff9f9c90cf52405 100644 (file)
@@ -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');
index 1a1ff0e53e933154297f31bf66fc5598fda6c668..936a31f61ce43ee4340706b85eff88d7068d4b38 100644 (file)
@@ -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__];
 }
 
 // -----------------------------------------------------------------------------
index a0b77e469c1ada3183b9531c195c26353528f9f6..23ed02aab07052a07daf0580d1b9ccdaeb6d0508 100644 (file)
@@ -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
 
index e428c713c5c4a5907e1e4faaf009344284dea181..f04d0d12a344a0819a37141c87e9469b05ef3910 100644 (file)
@@ -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]
index bf720d7badefb9b699d852abde07724b9cb57056..588f0f2097dcb3982641bf2b4245d9643ff7eda0 100644 (file)
@@ -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');
index b251c1bf019bb6a8669f6c2903ca0aaad46aaeaa..719fed224521bc71fce86e9e4fae7635649482ce 100644 (file)
@@ -98,7 +98,7 @@
                        {--ADMIN_CONFIG_SURFBAR_PAYMENT_MODEL_STATIC--}
                </td>
                <td style="padding-left:5px">
-                       <input type="radio" class="form_field" name="surfbar_pay_model" value="STATIC"$content[surfbar_pay_model_static] />
+                       <input type="radio" class="form_field" name="surfbar_payment_model" value="STATIC"$content[surfbar_payment_model_static] />
                </td>
        </tr>
        <tr>
                        {--ADMIN_CONFIG_SURFBAR_PAYMENT_MODEL_DYNAMIC--}
                </td>
                <td class="bottom" style="padding-left:5px">
-                       <input type="radio" class="form_field" name="surfbar_pay_model" value="DYNAMIC"$content[surfbar_pay_model_dynamic] />
+                       <input type="radio" class="form_field" name="surfbar_payment_model" value="DYNAMIC"$content[surfbar_payment_model_dynamic] />
                </td>
        </tr>
        <tr>
index 544f89309604f8d8571567bc5c0410759f2869f7..b1ea15e9efe0a6659a311ef710d595019895fd27 100644 (file)
@@ -21,9 +21,9 @@
        <div class="member_input" style="padding-top:5px;padding-bottom:5px">
                <div class="para">
                        Jeder Seiten-Aufruf durch andere Mitglieder kostet Ihnen mindestens
-                       <strong>{%pipe,translateComma=$content[costs]%} {?POINTS?}</strong>.
+                       <strong>{%pipe,SURFBAR_DETERMINE_COSTS,translateComma=true%} {?POINTS?}</strong>.
                        Surfen Sie mit der Surfbar erhalten Sie mindestens
-                       <strong>{%pipe,translateComma=$content[reward]%} {?POINTS?}</strong>
+                       <strong>{%pipe,SURFBAR_DETERMINE_REWARD,translateComma=true%} {?POINTS?}</strong>
                        auf Ihr Konto gutgeschrieben.
                </div>
                <div class="para">
index e988a2f5a2e57225c7b1027fea041e82e24babe3..56ef07c1b32e1975c3bd148ad5a2c5b8137161ad 100644 (file)
 
        <div class="member_input" style="padding-top:5px;padding-bottom:5px">
                Jeder Seiten-Aufruf durch andere Mitglieder kostet Ihnen <span
-                class="surfbar_points">$content[costs] {?POINTS?}</span>. Surfen Sie mit
-               der Surfbar erhalten Sie <span class="surfbar_points">$content[reward]
+                class="surfbar_points">{%pipe,SURFBAR_DETERMINE_COSTS,translateComma=true%}{?POINTS?}</span>. Surfen Sie mit
+               der Surfbar erhalten Sie <span class="surfbar_points">{%pipe,SURFBAR_DETERMINE_REWARD,translateComma=true%}
                {?POINTS?}</span> auf Ihr Konto gutgeschrieben.<br />
                <br />
-               Sie haben bereits <strong>$content[curr_order]</strong> von maximal
-               <strong>$content[max_order]</strong> erlaubten URLs gebucht.
+               Sie haben bereits <strong>{%pipe,SURFBAR_GET_TOTAL_USER_URLS,translateComma%}</strong> von maximal
+               <strong>{%config,translateComma=surfbar_max_order%}</strong> erlaubten URLs gebucht.
        </div>
 
        <div class="table_header top" style="padding-top:5px;padding-bottom:5px">