Introduced interruptFilterChain() and continueFilterChain(). Please DO ALWAYS use...
authorRoland Häder <roland@mxchange.org>
Wed, 31 Jul 2013 01:58:02 +0000 (01:58 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 31 Jul 2013 01:58:02 +0000 (01:58 +0000)
inc/filter-functions.php
inc/filter/blacklist_filter.php
inc/filter/forced_filter.php
inc/filter/order_filter.php
inc/filter/register_filter.php
inc/filter/surfbar_filter.php
inc/filter/wernis_filter.php

index 4e19d09..dc97d8e 100644 (file)
@@ -311,8 +311,8 @@ function runFilterChain ($filterName, $filterData = NULL) {
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'filterName=' . $filterName . ',count()=' . count($GLOBALS['cache_array']['filter']['chains'][$filterName]));
        $returnValue = $filterData;
 
-       // Remove any existing flag(s)
-       unset($GLOBALS['filter_chain_aborted']);
+       // Continue filter chain is default
+       continueFilterChain();
 
        // Then run all filters
        foreach ($GLOBALS['cache_array']['filter']['chains'][$filterName] as $filterFunction => $active) {
@@ -431,7 +431,19 @@ function loadExtensionFilters ($ext_name) {
 // Checks whether the filter chain has been aborted
 function isFilterChainAborted () {
        // Determine it
-       return ((isset($GLOBALS['filter_chain_aborted'])) && ($GLOBALS['filter_chain_aborted'] === TRUE));
+       return ((isset($GLOBALS['filter_chain_interrupted'])) && ($GLOBALS['filter_chain_interrupted'] === TRUE));
+}
+
+// Interrupts the filter chain by enabling flag 'filter_chain_aborted'
+function interruptFilterChain () {
+       // Set it
+       $GLOBALS['filter_chain_interrupted'] = TRUE;
+}
+
+// Continues the filter chain by disabling flag 'filter_chain_aborted'
+function continueFilterChain () {
+       // Set it
+       $GLOBALS['filter_chain_interrupted'] = FALSE;
 }
 
 // [EOF]
index edba588..26a846a 100644 (file)
@@ -81,7 +81,7 @@ function FILTER_CHECK_URL_BLACKLISTED ($filterData) {
        if ((isUrlBlacklistEnabled()) && (isUrlBlacklisted($filterData['url']))) {
                // Create redirect-URL
                $filterData['redirect'] = 'modules.php?module=login&amp;what=order&amp;code=' . getCode('BLIST_URL') . '&amp;blist=' . $GLOBALS['blacklist_data'][$filterData['url']]['timestamp'];
-               $GLOBALS['filter_chain_aborted'] = TRUE;
+               interruptFilterChain();
 
                // Set data for next filter chain
                $filterData['init_done']   = FALSE;
index b731596..cca6b07 100644 (file)
@@ -110,11 +110,11 @@ function FILTER_FORCED_CHANGE_CAMPAIGN_VALIDATE_DATA ($filterData) {
        if ((!is_string($filterData['new_status'])) || (empty($filterData['new_status']))) {
                // Abort here, not fine
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newStatus[' . gettype($filterData['new_status']) . ']=' . $filterData['new_status'] . ' - EXIT!');
-               $GLOBALS['filter_chain_aborted'] = FALSE;
+               interruptFilterChain();
        } elseif ($filterData['data']['forced_campaign_status'] != $filterData['prev_status']) {
                // Status is not like prevStatus
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $filterData['data']['forced_campaign_status'] . '!=' . $filterData['prev_status'] . ' - EXIT!');
-               $GLOBALS['filter_chain_aborted'] = FALSE;
+               continueFilterChain();
        } // END - if
 
        // Return filter data
index a961dde..7b32e11 100644 (file)
@@ -136,7 +136,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_SUBJECT ($filterData) {
                if ((isInStringIgnoreCase('https://', $filterData['subject'])) || (isInStringIgnoreCase('http://', $filterData['subject'])) || (isInStringIgnoreCase('www', $filterData['subject']))) {
                        // URL in subject found
                        $filterData['redirect'] = 'modules.php?module=login&amp;what=order&amp;code=' . getCode('SUBJECT_URL');
-                       $GLOBALS['filter_chain_aborted'] = TRUE;
+                       interruptFilterChain();
                } // END - if
        } // END - if
 
@@ -154,7 +154,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_TEXT ($filterData) {
                if ((isInStringIgnoreCase('https://', $filterData['text'])) || (isInStringIgnoreCase('http://', $filterData['text'])) || (isInStringIgnoreCase('www', $filterData['text']))) {
                        // URL found
                        $filterData['redirect'] = 'modules.php?module=login&amp;what=order&amp;code=' . getCode('URL_FOUND');
-                       $GLOBALS['filter_chain_aborted'] = TRUE;
+                       interruptFilterChain();
                } // END - if
 
                // Remove new-line and carriage-return characters
@@ -164,7 +164,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_TEXT ($filterData) {
                if (strlen($TEST) > getMaxTextLength()) {
                        // Text is too long!
                        $filterData['redirect'] = 'modules.php?module=login&amp;what=order&amp;code=' . getCode('OVERLENGTH');
-                       $GLOBALS['filter_chain_aborted'] = TRUE;
+                       interruptFilterChain();
                } // END - if
        } // END - if
 
@@ -181,7 +181,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_TYPE ($filterData) {
        if ((!isset($filterData['mail_type'])) || ($filterData['mail_type'] < 1)) {
                // Not correctly set
                $filterData['redirect'] = 'modules.php?module=login&amp;what=order&amp;code=' . getCode('NO_MAIL_TYPE');
-               $GLOBALS['filter_chain_aborted'] = TRUE;
+               interruptFilterChain();
        } // END - if
 
        // Return the data for next filter
@@ -197,7 +197,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_URL ($filterData) {
        if (!isUrlValid($filterData['url'])) {
                // URL is invalid!
                $filterData['redirect'] = 'modules.php?module=login&amp;what=order&amp;code=' . getCode('INVALID_URL');
-               $GLOBALS['filter_chain_aborted'] = TRUE;
+               interruptFilterChain();
        } // END - if
 
        // Return the data for next filter
@@ -213,7 +213,7 @@ function FILTER_MAIL_ORDER_GENERIC_CHECK_RECEIVER ($filterData) {
        if (($filterData['receiver'] < getOrderMin()) && (!isAdmin())) {
                // Less than allowed receivers entered!
                $filterData['redirect'] = 'modules.php?module=login&amp;what=order&amp;code=' . getCode('MORE_RECEIVERS3');
-               $GLOBALS['filter_chain_aborted'] = TRUE;
+               interruptFilterChain();
        } // END - if
 
        // Return the data for next filter
index a96e340..b160adf 100644 (file)
@@ -126,6 +126,9 @@ function FILTER_GENERIC_USER_REGISTRATION ($filterData) {
        if ((isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'register')) {
                // Run it
                $filterData['status'] = doGenericUserRegistration();
+
+               // Interrupt filter chain
+               interruptFilterChain();
        } // END - if
 
        // Return it
@@ -143,6 +146,9 @@ function FILTER_GENERIC_USER_REGISTRATION_CHECK () {
        if ((isFormSent()) && (isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'register')) {
                // Check form
                $isFormSent = isRegistrationDataComplete();
+
+               // Interrupt filter chain
+               interruptFilterChain();
        } // END - if
 
        // Return it
@@ -158,6 +164,9 @@ function FILTER_GENERIC_USER_REGISTRATION_DONE () {
        if ((isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'register')) {
                // Run it
                displayMessage('{--REGISTRATION_DONE--}');
+
+               // Interrupt filter chain
+               interruptFilterChain();
        } // END - if
 
        // Return NULL
@@ -186,6 +195,9 @@ function FILTER_GENERIC_USER_REGISTRATION_FORM () {
        if (((isGetRequestElementSet('registration_provider')) && (getRequestElement('registration_provider') == 'register')) || (getDefaultRegistrationProvider() == 'register')) {
                // Display generic form
                doDisplayGenericUserRegistrationForm();
+
+               // Interrupt filter chain
+               interruptFilterChain();
        } // END - if
 
        // Return NULL
index 517797e..2bd3e57 100644 (file)
@@ -73,11 +73,11 @@ function FILTER_SURFBAR_CHANGE_URL_VALIDATE_DATA ($filterData) {
        if ((!is_string($filterData['new_status'])) || (empty($filterData['new_status']))) {
                // Abort here, but fine!
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'newStatus[' . gettype($filterData['new_status']) . ']=' . $filterData['new_status'] . ' - EXIT!');
-               $GLOBALS['filter_chain_aborted'] = TRUE;
+               interruptFilterChain();
        } elseif ($filterData['data'][$filterData['url_id']]['url_status'] != $filterData['prev_status']) {
                // Status is not like prevStatus
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $filterData['data'][$filterData['url_id']]['url_status'] . '!=' . $filterData['prev_status'] . ' - EXIT!');
-               $GLOBALS['filter_chain_aborted'] = FALSE;
+               continueFilterChain();
        } // END - if
 
        // Return filter data
index e363645..53b5a43 100644 (file)
@@ -48,6 +48,9 @@ function FILTER_WERNIS_USER_REGISTRATION ($filterData) {
        if ((isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'wernis')) {
                // Run it
                $filterData['status'] = doWernisUserRegistration();
+
+               // Interrupt filter chain
+               interruptFilterChain();
        } // END - if
 
        // Return it
@@ -63,6 +66,9 @@ function FILTER_WERNIS_USER_REGISTRATION_DONE () {
        // Is generic user registration selected?
        if ((isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'wernis')) {
                // Run it
+
+               // Interrupt filter chain
+               interruptFilterChain();
        } // END - if
 
        // Return it
@@ -78,6 +84,9 @@ function FILTER_WERNIS_USER_REGISTRATION_FAILED () {
        // Is generic user registration selected?
        if ((isPostRequestElementSet('registration_provider')) && (postRequestElement('registration_provider') == 'wernis')) {
                // Run it
+
+               // Interrupt filter chain
+               interruptFilterChain();
        } // END - if
 
        // Return it
@@ -93,6 +102,9 @@ function FILTER_WERNIS_USER_REGISTRATION_FORM () {
        // Is generic user registration selected?
        if (((isGetRequestElementSet('registration_provider')) && (gettRequestElement('registration_provider') == 'wernis')) || (getDefaultRegistrationProvider() == 'wernis')) {
                // Run it
+
+               // Interrupt filter chain
+               interruptFilterChain();
        } // END - if
 
        // Return it