]> git.mxchange.org Git - mailer.git/commitdiff
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 4e19d0980aa78d2ba0a3b655a6eb8f27897c585d..dc97d8ec41393402a6c01c6688394ea1b9273ef4 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 edba5885bf2ccb67ab02a6e8d7537aea44fed770..26a846a66c29a4a4388859d9e5b812b2f263caa9 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 b731596c3e60affb68fb4b5376bc79574c2c79de..cca6b078e1cdb57f0c417104d576a2033b92416e 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 a961dde09be96a372f4fbe85fccb28e836d7a3ff..7b32e11122084ee152c2d6cd644df603b332bc8c 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 a96e34080b94a8cae6e57bf67b8d9dbd3306a48a..b160adff37ffcf1795e8b26cf4094848ac78bcae 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 517797ef8a2917fd9177c1580f1cb16030b4c08b..2bd3e5713eaccda3822ca2d33440482295ad167d 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 e36364535b02ac6ffae506969afb63b9ffb913ea..53b5a43b8c66aa5ebaf568ef84c5361fb05629db 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