- 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
if ((empty($data['value'])) && ($data['value'] != '0')) {
// No value is set
$replacer = '{DQUOTE} . ' . $data['extra_func2'] . '(' . $data['extra_func'] . '(' . $data['callback'] . '())) . {DQUOTE}';
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}';
+ // Some string/integer value is set
$replacer = '{DQUOTE} . ' . $data['extra_func2'] . '(' . $data['extra_func'] . '(' . $data['callback'] . "('" . $data['value'] . "'))) . {DQUOTE}";
}
} // END - if
$replacer = '{DQUOTE} . ' . $data['extra_func2'] . '(' . $data['extra_func'] . '(' . $data['callback'] . "('" . $data['value'] . "'))) . {DQUOTE}";
}
} // END - if
addExtensionSql("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_actions` (`actions_status`,`actions_action`,`actions_new_status`) VALUES ('MIGRATED','BOOKNOW','PENDING')");
// Config entries
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');
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');
-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?
// 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
// "Calculate" dynamic reward
+ if ($onlyMin === true) {
$reward += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE();
} else {
$reward += SURFBAR_CALCULATE_DYNAMIC_ADD();
$reward += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE();
} else {
$reward += SURFBAR_CALCULATE_DYNAMIC_ADD();
$costs = getConfig('surfbar_static_costs');
// Do we have static or dynamic?
$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();
// "Calculate" dynamic costs
if ($onlyMin) {
$costs += SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE();
// Determine right template name
function SURFBAR_DETERMINE_TEMPLATE_NAME() {
// Default is the frameset
// 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')) {
// Any frame set? ;-)
if (isGetRequestParameterSet('frame')) {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Fixed surf lock is '.getConfig('surfbar_static_lock') . '', false);
// Do we have dynamic model?
//* 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
// "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
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`
- 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__
)
LIMIT 1",
array(getMemberId()), __FUNCTION__, __LINE__
// 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?
// 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
}
// Get total amount of URLs of given status for current user
$userid = getMemberId();
} elseif ($userid == '0') {
// Error!
$userid = getMemberId();
} elseif ($userid == '0') {
// Error!
- return (getConfig('surfbar_max_order') + 1);
+ return (getSurfbarMaxOrder() + 1);
// Remove it from the URL owner
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.SURFBAR_GET_USERID().',costs='.SURFBAR_GET_COSTS().'', false);
if (isValidUserId(SURFBAR_GET_USERID())) {
// 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);
} // END - if
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid='.getMemberId().',reward='.SURFBAR_GET_REWARD().'', false);
unset($GLOBALS['ref_level']);
// Book it to the user
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
}
// Updates the statistics of current URL/userid
$time = getConfig('surfbar_static_time');
// Which payment model do we have?
$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
// "Calculate" dynamic time
$time += SURFBAR_CALCULATE_DYNAMIC_ADD();
} // END - if
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'BASE/STATIC - reward='.SURFBAR_GET_REWARD().'|costs='.SURFBAR_GET_COSTS().'', false);
// Only in dynamic model add the dynamic bonus!
//* 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();
// Calculate dynamic reward/costs and add it
$GLOBALS['surfbar_cache']['reward'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
$GLOBALS['surfbar_cache']['costs'] += SURFBAR_CALCULATE_DYNAMIC_ADD();
// "Getter" for surfbar_dynamic_percent
function getSurfbarDynamicPercent () {
// Do we have cache?
// "Getter" for surfbar_dynamic_percent
function getSurfbarDynamicPercent () {
// Do we have cache?
- if (!isset($GLOBALS['surfbar_dynamic_percent'])) {
+ if (!isset($GLOBALS[__FUNCTION__])) {
- $GLOBALS['surfbar_dynamic_percent'] = getConfig('surfbar_dynamic_percent');
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_dynamic_percent');
} // END - if
// Return cache
} // END - if
// Return cache
- return $GLOBALS['surfbar_dynamic_percent'];
+ return $GLOBALS[__FUNCTION__];
}
// "Getter" for surfbar_static_reward
function getSurfbarStaticReward () {
// Do we have cache?
}
// "Getter" for surfbar_static_reward
function getSurfbarStaticReward () {
// Do we have cache?
- if (!isset($GLOBALS['surfbar_static_reward'])) {
+ if (!isset($GLOBALS[__FUNCTION__])) {
- $GLOBALS['surfbar_static_reward'] = getConfig('surfbar_static_reward');
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_static_reward');
} // END - if
// Return cache
} // END - if
// Return cache
- return $GLOBALS['surfbar_static_reward'];
+ return $GLOBALS[__FUNCTION__];
}
// "Getter" for surfbar_static_time
function getSurfbarStaticTime () {
// Do we have cache?
}
// "Getter" for surfbar_static_time
function getSurfbarStaticTime () {
// Do we have cache?
- if (!isset($GLOBALS['surfbar_static_time'])) {
+ if (!isset($GLOBALS[__FUNCTION__])) {
- $GLOBALS['surfbar_static_time'] = getConfig('surfbar_static_time');
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_static_time');
} // END - if
// Return cache
} // END - if
// Return cache
- return $GLOBALS['surfbar_static_time'];
+ return $GLOBALS[__FUNCTION__];
}
// "Getter" for surfbar_max_order
function getSurfbarMaxOrder () {
// Do we have cache?
}
// "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__])) {
- $GLOBALS['surfbar_max_order'] = getConfig('surfbar_max_order');
+ $GLOBALS[__FUNCTION__] = getConfig('surfbar_payment_model');
} // END - if
// Return cache
} // END - if
// Return cache
- return $GLOBALS['surfbar_max_order'];
+ return $GLOBALS[__FUNCTION__];
}
// -----------------------------------------------------------------------------
}
// -----------------------------------------------------------------------------
} // END - foreach
// Even some more...
} // 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
$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
$content[$entry . '_' . strtolower(getConfig($entry))] = ' checked="checked"';
} // END - foreach
// Load message template
displayMessage($message);
} else {
// 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
// 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())));
);
// In dynamic mode we need some more data
);
// 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),
// Prepare content for dynamic surfbar
$content = array(
'surfbar_total_urls' => SURFBAR_GET_TOTAL_URLS('ACTIVE', 0),
} // END - if
// Load the template
} // 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');
// Load surfbar link template
loadTemplate('member_surfbar_link');
{--ADMIN_CONFIG_SURFBAR_PAYMENT_MODEL_STATIC--}
</td>
<td style="padding-left:5px">
{--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] />
{--ADMIN_CONFIG_SURFBAR_PAYMENT_MODEL_DYNAMIC--}
</td>
<td class="bottom" style="padding-left:5px">
{--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] />
<div class="member_input" style="padding-top:5px;padding-bottom:5px">
<div class="para">
Jeder Seiten-Aufruf durch andere Mitglieder kostet Ihnen mindestens
<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
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">
auf Ihr Konto gutgeschrieben.
</div>
<div class="para">
<div class="member_input" style="padding-top:5px;padding-bottom:5px">
Jeder Seiten-Aufruf durch andere Mitglieder kostet Ihnen <span
<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 />
{?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">
</div>
<div class="table_header top" style="padding-top:5px;padding-bottom:5px">