Fixes for JavaScript in member booking with set limit
authorRoland Häder <roland@mxchange.org>
Mon, 11 Jul 2011 16:02:14 +0000 (16:02 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 11 Jul 2011 16:02:14 +0000 (16:02 +0000)
13 files changed:
.gitattributes
inc/extensions/ext-bonus.php
inc/extensions/ext-surfbar.php
inc/extensions/ext-user.php
inc/filter-functions.php
inc/filter/surfbar_filter.php [new file with mode: 0644]
inc/libs/surfbar_functions.php
inc/modules/member/what-surfbar_book.php
inc/template-functions.php
templates/de/emails/admin/admin_surfbar_url_unlock.tpl
templates/de/html/js/js_surfbar_member_book.tpl
templates/de/html/member/member_surfbar_book_dynamic.tpl
templates/de/html/member/member_surfbar_book_static.tpl

index 0230b49198786a9354e67122013595379e3cf789..8a971b1d325997c1a6d8e08993ca99ee529ef896 100644 (file)
@@ -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
index 1b9114732b40a2413b3c1d92d549ad389f9b3cf6..28dd83f7df9c820552aa59e1d93349fb96a7e438 100644 (file)
@@ -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&uuml;r Bonus-Mails hinzugef&uuml;gt.");
index a79aec359c88f6cdfdf043846ff9f9c90cf52405..edf82b00403c0d918ce7de64bd401d53e31893d3 100644 (file)
@@ -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
index 47ddfe369795c006701c43649113ed0ebbc7bfd1..9f30d00bac3c77277b3db66d99ad3e5d476d6b41 100644 (file)
@@ -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&uuml;ckliefern.");
index 44e4cb04cf55499537f5597ba86fbe34a27038dd..cadab03f460a91d83ff08ca17db5daa1d7ff0be7 100644 (file)
@@ -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 (file)
index 0000000..e2e26f7
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL                                Start: 07/11/2011 *
+ * ===================                          Last change: 07/11/2011 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : surfbar_filter.php                               *
+ * -------------------------------------------------------------------- *
+ * Short description : Filters for ext-surfbar                          *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Filter fuer ext-surfbar                          *
+ * -------------------------------------------------------------------- *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
+ * For more information visit: http://www.mxchange.org                  *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+       die();
+} // END - if
+
+// Filter for changing URL status
+function FILTER_SURFBAR_CHANGE_URL_STATUS ($filterData) {
+       die('<pre>'.print_r($filterData, true).'</pre>');
+       // Return filter data
+       return $filterData;
+}
+
+// [EOF]
+?>
index 739465d07dc436319b0b174fb41042cdf99be7ae..61a901eadecbae88820ea361a6324d5442dce625 100644 (file)
@@ -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;
 }
 
index 9846af2bd1989559de4c7318dbcde2fc1139aa5f..bf1e88ce19b5630e17a65a9f8ead249dc4f9ad55 100644 (file)
@@ -66,6 +66,7 @@ if (!SURFBAR_IF_USER_BOOK_MORE_URLS()) {
        $message = '{--MEMBER_SURFBAR_URL_NOT_ADDED--}';
 
        // Register the new URL
+       die(postRequestParameter('limit').'=<pre>'.print_r($_POST,true).'</pre>');
        $insertId = SURFBAR_MEMBER_ADD_URL(postRequestParameter('url'), postRequestParameter('limit'));
 
        // Was this fine?
index 611d1b107d2dd3e5fcb23887555645f6272ea73b..4280695bdb50a2dea032859caaa2f98b63e66343 100644 (file)
@@ -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 = '<!-- Template ' . $template . ' - Start //-->' . $GLOBALS['tpl_content'][$template] . '<!-- Template ' . $template . ' - End //-->';
                                $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
index d991f5cd25dd179c8feceb57de59721af133f033..2c8da915a8a2c9802f0a7de4d75adfaf60f3906a 100644 (file)
@@ -1,6 +1,6 @@
 Hallo Administrator,
 
-Ein Administrator hat soeben eine URL in der Surfbar hinzugef&uuml;gt bzw. freigegeben.
+ein Administrator hat soeben eine URL in der Surfbar hinzugef&uuml;gt bzw. freigegeben.
 
 Hier sind alle Daten aus der Mail:
 ------------------------------------------
index 7f742fc7834f05fd30992804d0b5ec9c1b4377c9..c6fa3c746622cdcf40492ad8ad2d4865a51f4358 100644 (file)
@@ -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();
index b1ea15e9efe0a6659a311ef710d595019895fd27..a71ab240f531a189d60f1f577463d05de75094cb 100644 (file)
@@ -1,4 +1,4 @@
-<form accept-charset="UTF-8" id="book" action="{%url=modules.php?module=login&amp;what=surfbar_book%}" method="post" onsubmit="return SubmitForm()" onreset="return ResetForm()">
+<form accept-charset="UTF-8" id="book" action="{%url=modules.php?module=login&amp;what=surfbar_book%}" method="post" onsubmit="return submitForm()" onreset="return resetForm()">
 <div class="table dashed" style="width:600px;margin-top:10px">
        <div class="table_header bottom" style="padding-top:5px;padding-bottom:5px">
                <strong>URL in Surfbar buchen - Dynamisch:</strong>
 
        <div class="member_input" style="padding-top:5px;padding-bottom:5px">
                Soll die Anzahl Aufrufe begrenzt werden?<br />
-               <input type="radio" id="limited_no" onfocus="return FocusLimitedNo()" name="limited" value="N" checked="checked" /> {--NO--}
-               <input type="radio" id="limited_yes" onfocus="return FocusLimitedYes()" name="limited" value="Y" /> {--YES--}
+               <input type="radio" id="limited_no" onclick="return focusLimitedNo()" name="limited" value="N" checked="checked" /> {--NO--}
+               <input type="radio" id="limited_yes" onclick="return focusLimitedYes()" name="limited" value="Y" /> {--YES--}
        </div>
 
        <div class="member_input bottom" style="padding-top:5px;padding-bottom:5px">
-               Aufrufe begrenzen auf: <input type="text" class="form_field" id="limit" name="limit" size="7" maxlength="20" value="-" />
+               Aufrufe begrenzen auf: <input type="text" onchange="return changeLimited()" onclick="return focusLimit()" onblur="return blurLimit()" class="form_field" id="limit" name="limit" size="7" maxlength="20" value="-" />
        </div>
 
        <div class="member_input" style="padding-top:5px;padding-bottom:5px">
index 56ef07c1b32e1975c3bd148ad5a2c5b8137161ad..33e90b141e45bd0684f8ab28e62aee3999a8ea15 100644 (file)
 
        <div class="member_input" style="padding-top:5px;padding-bottom:5px">
                Soll die Anzahl Aufrufe begrenzt werden?<br />
-               <input type="radio" id="limited_no" onfocus="return FocusLimitedNo()" name="limited" value="N" checked="checked" /> {--NO--}
-               <input type="radio" id="limited_yes" onfocus="return FocusLimitedYes()" name="limited" value="Y" /> {--YES--}
+               <input type="radio" id="limited_no" onclick="return focusLimitedNo()" name="limited" value="N" checked="checked" /> {--NO--}
+               <input type="radio" id="limited_yes" onclick="return focusLimitedYes()" name="limited" value="Y" /> {--YES--}
        </div>
 
        <div class="member_input bottom" style="padding-top:5px;padding-bottom:5px">
-               Aufrufe begrenzen auf: <input type="text" class="form_field" id="limit" name="limit" size="7" maxlength="20" value="-" />
+               Aufrufe begrenzen auf: <input type="text" class="form_field" onchange="return changeLimited()" onclick="return focusLimit()" onblur="return blurLimit()" id="limit" name="limit" size="7" maxlength="20" value="-" />
        </div>
 
        <div class="member_input" style="padding-top:5px;padding-bottom:5px">