From 387a99be2a05128c307013cb7ed27628a46c27f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 11 Jul 2011 16:02:14 +0000 Subject: [PATCH] Fixes for JavaScript in member booking with set limit --- .gitattributes | 1 + inc/extensions/ext-bonus.php | 2 +- inc/extensions/ext-surfbar.php | 6 +++ inc/extensions/ext-user.php | 4 +- inc/filter-functions.php | 5 +- inc/filter/surfbar_filter.php | 51 +++++++++++++++++++ inc/libs/surfbar_functions.php | 27 ++++++++-- inc/modules/member/what-surfbar_book.php | 1 + inc/template-functions.php | 5 +- .../emails/admin/admin_surfbar_url_unlock.tpl | 2 +- .../de/html/js/js_surfbar_member_book.tpl | 50 ++++++++++++++---- .../member/member_surfbar_book_dynamic.tpl | 8 +-- .../member/member_surfbar_book_static.tpl | 6 +-- 13 files changed, 141 insertions(+), 27 deletions(-) create mode 100644 inc/filter/surfbar_filter.php diff --git a/.gitattributes b/.gitattributes index 0230b49198..8a971b1d32 100644 --- a/.gitattributes +++ b/.gitattributes @@ -218,6 +218,7 @@ inc/filter/politician_stop_filter.php svneol=native#text/plain inc/filter/rallye_filter.php svneol=native#text/plain inc/filter/register_filter.php svneol=native#text/plain inc/filter/removeip_filter.php svneol=native#text/plain +inc/filter/surfbar_filter.php svneol=native#text/plain inc/filter/theme_filter.php svneol=native#text/plain inc/filter/timezone_filter.php svneol=native#text/plain inc/filter/uberwach_filter.php svneol=native#text/plain diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index 1b9114732b..28dd83f7df 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -603,7 +603,7 @@ ORDER BY case '0.9.5': // SQL queries for v0.9.5 // Register filter - registerFilter('generate_admin_mail_links', 'GENERATE_BONUS_MAIL_LINKS', true, isExtensionDryRun()); + registerFilter('generate_admin_mail_links', 'GENERATE_BONUS_MAIL_LINKS', false, true, isExtensionDryRun()); // Update notes setExtensionUpdateNotes("Filter zum Generieren von Admin-Links für Bonus-Mails hinzugefügt."); diff --git a/inc/extensions/ext-surfbar.php b/inc/extensions/ext-surfbar.php index a79aec359c..edf82b0040 100644 --- a/inc/extensions/ext-surfbar.php +++ b/inc/extensions/ext-surfbar.php @@ -195,6 +195,9 @@ UNIQUE KEY `status_action` (`actions_status`,`actions_action`)", // Register module addModuleSql('surfbar', 'Y', 'Y', 'N', 'N'); + + // Register filter + registerFilter('post_change_surfbar_url_status', 'SURFBAR_CHANGE_URL_STATUS', false, true, isExtensionDryRun()); break; case 'remove': // Do stuff when removing extension @@ -209,6 +212,9 @@ UNIQUE KEY `status_action` (`actions_status`,`actions_action`)", // Unregister module addExtensionSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_mod_reg` WHERE `module`='surfbar' LIMIT 1"); + + // Unregister filter + unregisterFilter(__FUNCTION__, __LINE__, 'post_change_surfbar_url_status', 'SURFBAR_CHANGE_URL_STATUS', true, isExtensionDryRun()); break; case 'activate': // Do stuff when admin activates this extension diff --git a/inc/extensions/ext-user.php b/inc/extensions/ext-user.php index 47ddfe3697..9f30d00bac 100644 --- a/inc/extensions/ext-user.php +++ b/inc/extensions/ext-user.php @@ -427,8 +427,8 @@ INDEX (`userid`)", case '0.3.9': // SQL queries for v0.3.9 // Register new filters for gathering points - registerFilter(__FUNCTION__, __LINE__, 'get_total_points', 'USER_POINTS', true, isExtensionDryRun()); - registerFilter(__FUNCTION__, __LINE__, 'get_own_points', 'USER_POINTS', true, isExtensionDryRun()); + registerFilter('get_total_points', 'USER_POINTS', false, true, isExtensionDryRun()); + registerFilter('get_own_points', 'USER_POINTS', false, true, isExtensionDryRun()); // Update notes (these will be set as task text!) setExtensionUpdateNotes("Filter registriert, die das eigene {?POINTS?}-Guthaben des Mitgliedes zurückliefern."); diff --git a/inc/filter-functions.php b/inc/filter-functions.php index 44e4cb04cf..cadab03f46 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -224,7 +224,10 @@ function registerFilter ($filterName, $filterFunction, $silentAbort = true, $for //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'REGISTER: filterName=' . $filterName . ',filterFunction=' . $filterFunction); $GLOBALS['cache_array']['filter']['chains'][$filterName][$filterFunction] = 'A'; $GLOBALS['cache_array']['filter']['counter'][$filterName][$filterFunction] = '0'; - } // END - if + } elseif (($silentAbort === false) && (!function_exists($filterFunction))) { + // Please report them all! + debug_report_bug(__FUNCTION__, __LINE__, 'filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',silentAbort=false,force=' . intval($force) . ',dry_run=' . intval($dry_run) . ' - NOT FOUND!'); + } //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ENTRY: filterName=' . $filterName . ',filterFunction=' . $filterFunction . ' - EXIT!'); } diff --git a/inc/filter/surfbar_filter.php b/inc/filter/surfbar_filter.php new file mode 100644 index 0000000000..e2e26f7a5d --- /dev/null +++ b/inc/filter/surfbar_filter.php @@ -0,0 +1,51 @@ +'.print_r($filterData, true).''); + // Return filter data + return $filterData; +} + +// [EOF] +?> diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 739465d07d..61a901eade 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -178,6 +178,7 @@ function SURFBAR_MEMBER_ADD_URL ($url, $limit) { } // Register the new URL + die('limit='.$limit); return SURFBAR_REGISTER_URL($url, getMemberId(), 'PENDING', 'reg', array('limit' => $limit)); } @@ -597,10 +598,10 @@ function SURFBAR_REGISTER_URL ($url, $userid, $status = 'PENDING', $addMode = 'r )); // Is limit/reload set? - if (!isset($config['limit'])) { + if (!isset($content['limit'])) { $content['limit'] = '0'; } // END - if - if (!isset($config['reload'])) { + if (!isset($content['reload'])) { $content['reload'] = '0'; } // END - if @@ -1314,6 +1315,7 @@ function SURFBAR_DETERMINE_WAIT_TIME () { // Changes the status of an URL from given to other function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) { + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - ENTERED!'); // Make new status always lower-case $newStatus = strtolower($newStatus); @@ -1326,12 +1328,14 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) // Is the new status set? if ((!is_string($newStatus)) || (empty($newStatus))) { // Abort here, but fine! + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newStatus[' . gettype($newStatus) . ']=' . $newStatus . ' - EXIT!'); return true; } // END - if // Is the status like prevStatus is saying? if ($data[$urlId]['url_status'] != $prevStatus) { // No, then abort here + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $data[$urlId]['url_status'] . '!=' . $prevStatus . ' - EXIT!'); return false; } // END - if @@ -1350,6 +1354,20 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) //} // END - if // ---------- Comment out for debugging/developing member actions! --------- + // Prepare array + $filterData = array( + 'url_id' => $urlId, + 'prev_status' => $prevStatus, + 'new_status' => $newStatus, + 'data' => $data + ); + + // Run post filter chain + $filterData = runFilterChain('post_change_surfbar_url_status', $filterData); + + // Extract data from it again + $data = $filterData['data']; + // Prepare content for notification routines $data[$urlId]['url_userid'] = $data[$urlId]['url_userid']; $data[$urlId]['frametester'] = '{%pipe,generateFrametesterUrl=' . $data[$urlId]['url'] . '%}'; @@ -1363,12 +1381,13 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) } // END - if // Send admin notification - SURFBAR_NOTIFY_ADMIN('url_' . $data[$urlId]['url_status'] . '_' . $newStatus, $data[$urlId]); + SURFBAR_NOTIFY_ADMIN('url_' . strtolower($data[$urlId]['url_status']) . '_' . $newStatus, $data[$urlId]); // Send user notification - SURFBAR_NOTIFY_USER('url_' . $data[$urlId]['url_status'] . '_' . $newStatus, $data[$urlId]); + SURFBAR_NOTIFY_USER('url_' . strtolower($data[$urlId]['url_status']) . '_' . $newStatus, $data[$urlId]); // All done! + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - EXIT!'); return true; } diff --git a/inc/modules/member/what-surfbar_book.php b/inc/modules/member/what-surfbar_book.php index 9846af2bd1..bf1e88ce19 100644 --- a/inc/modules/member/what-surfbar_book.php +++ b/inc/modules/member/what-surfbar_book.php @@ -66,6 +66,7 @@ if (!SURFBAR_IF_USER_BOOK_MORE_URLS()) { $message = '{--MEMBER_SURFBAR_URL_NOT_ADDED--}'; // Register the new URL + die(postRequestParameter('limit').'=
'.print_r($_POST,true).'
'); $insertId = SURFBAR_MEMBER_ADD_URL(postRequestParameter('url'), postRequestParameter('limit')); // Was this fine? diff --git a/inc/template-functions.php b/inc/template-functions.php index 611d1b107d..4280695bdb 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -322,10 +322,13 @@ function loadTemplate ($template, $return = false, $content = array(), $compileC // Prepare eval() command, other output doesn't like entities, maybe $GLOBALS['template_eval'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['tpl_content'][$template]), false, true, true, $compileCode) . '");'; } - } else { + } elseif (isHtmlOutputMode()) { // Add surrounding HTML comments to help finding bugs faster $ret = '' . $GLOBALS['tpl_content'][$template] . ''; $GLOBALS['template_eval'][$template] = '$ret = "' . getColorSwitchCode($template) . compileRawCode(escapeQuotes($ret), false, true, true, $compileCode) . '";'; + } else { + // JavaScript again + $GLOBALS['template_eval'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($GLOBALS['tpl_content'][$template]), false, true, true, $compileCode) . '");'; } // END - if } elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) { // Only admins shall see this warning or when installation mode is active diff --git a/templates/de/emails/admin/admin_surfbar_url_unlock.tpl b/templates/de/emails/admin/admin_surfbar_url_unlock.tpl index d991f5cd25..2c8da915a8 100644 --- a/templates/de/emails/admin/admin_surfbar_url_unlock.tpl +++ b/templates/de/emails/admin/admin_surfbar_url_unlock.tpl @@ -1,6 +1,6 @@ Hallo Administrator, -Ein Administrator hat soeben eine URL in der Surfbar hinzugefügt bzw. freigegeben. +ein Administrator hat soeben eine URL in der Surfbar hinzugefügt bzw. freigegeben. Hier sind alle Daten aus der Mail: ------------------------------------------ diff --git a/templates/de/html/js/js_surfbar_member_book.tpl b/templates/de/html/js/js_surfbar_member_book.tpl index 7f742fc783..c6fa3c7466 100644 --- a/templates/de/html/js/js_surfbar_member_book.tpl +++ b/templates/de/html/js/js_surfbar_member_book.tpl @@ -1,18 +1,23 @@ -var limit = document.getElementById('limit'); -var span = document.getElementById('span_limit'); -var old_limit = 0; +var limit = document.getElementById('limit'); +var span = document.getElementById('span_limit'); +var limited_no = document.getElementById('limited_no'); +var limited_yes = document.getElementById('limited_yes'); -function FocusLimitedNo () { +var old_limit = 0; + +function focusLimitedNo () { if ((limit.value > 0) && (limit.value != '-')) { old_limit = limit.value; } + limited_no.focus(); + limited_yes.blur(); limit.disabled = true; limit.setAttribute('class', 'disabled'); - limit.style.textAlign = 'center'; limit.value = '-'; + return true; } -function FocusLimitedYes () { +function focusLimitedYes () { limit.disabled = false; limit.setAttribute('class', 'form_field'); limit.style.textAlign = 'left'; @@ -22,19 +27,44 @@ function FocusLimitedYes () { limit.value = ''; } limit.focus(); + return true; +} + +function changeLimited () { + if ((limit.value == '') || (limit.value == 0)) { + focusLimitedNo(); + } + return true; +} + +function focusLimit () { + limited_yes.focus(); + limited_no.blur(); + limit.focus(); + if (limit.value == '-') { + limit.value = ''; + } + return true; +} + +function blurLimit () { + if ((limit.value == '') || (limit.value == 0)) { + limit.value = '-'; + } + return true; } -function SubmitForm () { +function submitForm () { if (limit.value == '-') { limit.value = 0; } return true; } -function ResetForm () { +function resetForm () { old_limit = 0; - FocusLimitedNo(); + focusLimitedNo(); return true; } -FocusLimitedNo(); +focusLimitedNo(); diff --git a/templates/de/html/member/member_surfbar_book_dynamic.tpl b/templates/de/html/member/member_surfbar_book_dynamic.tpl index b1ea15e9ef..a71ab240f5 100644 --- a/templates/de/html/member/member_surfbar_book_dynamic.tpl +++ b/templates/de/html/member/member_surfbar_book_dynamic.tpl @@ -1,4 +1,4 @@ -
+
URL in Surfbar buchen - Dynamisch: @@ -10,12 +10,12 @@
Soll die Anzahl Aufrufe begrenzt werden?
- {--NO--} - {--YES--} + {--NO--} + {--YES--}
- Aufrufe begrenzen auf: + Aufrufe begrenzen auf:
diff --git a/templates/de/html/member/member_surfbar_book_static.tpl b/templates/de/html/member/member_surfbar_book_static.tpl index 56ef07c1b3..33e90b141e 100644 --- a/templates/de/html/member/member_surfbar_book_static.tpl +++ b/templates/de/html/member/member_surfbar_book_static.tpl @@ -10,12 +10,12 @@
Soll die Anzahl Aufrufe begrenzt werden?
- {--NO--} - {--YES--} + {--NO--} + {--YES--}
- Aufrufe begrenzen auf: + Aufrufe begrenzen auf:
-- 2.30.2