]> git.mxchange.org Git - mailer.git/blobdiff - inc/filter-functions.php
Asserts + TODO added
[mailer.git] / inc / filter-functions.php
index e217428394c3dbff7dbf7b47bc02d19f1bd35640..f60544c24efde8321a941cc8ce1882d97d75a557 100644 (file)
@@ -193,9 +193,6 @@ ORDER BY
        // Remove extension
        registerFilter(__FUNCTION__, __LINE__, 'extension_remove', 'REMOVE_EXTENSION');
 
-       // Exclude some users
-       registerFilter(__FUNCTION__, __LINE__, 'exclude_users', 'HTML_INCLUDE_USERS');
-
        // Handling of fatal errors
        registerFilter(__FUNCTION__, __LINE__, 'handle_fatal_errors', 'HANDLE_FATAL_ERRORS');
 
@@ -237,7 +234,7 @@ function registerFilter ($file, $line, $filterName, $filterFunction, $silentAbor
                // In installation phase we always want to abort
                if (($silentAbort === FALSE) || (isInstaller())) {
                        // Add fatal message
-                       reportBug(__FUNCTION__, __LINE__, sprintf("Filter chain %s has already filter function %s registered! file=%s,L=%s,force=%d", $filterName, $filterFunction, basename($file), $line, intval($force)));
+                       reportBug(__FUNCTION__, __LINE__, sprintf('Filter chain %s has already filter function %s registered! file=%s,L=%s,force=%d', $filterName, $filterFunction, basename($file), $line, intval($force)));
                } // END - if
 
                // Abort here
@@ -249,7 +246,7 @@ function registerFilter ($file, $line, $filterName, $filterFunction, $silentAbor
                // Is the function there?
                if (!function_exists($filterFunction)) {
                        // Then abort here
-                       logDebugMessage(__FUNCTION__, __LINE__, sprintf("Filter function %s could not be added to filter chain %s. file=%s,L=%s,force=%d", $filterFunction, $filterName, basename($file), $line, intval($force)));
+                       logDebugMessage(__FUNCTION__, __LINE__, sprintf('Filter function %s could not be added to filter chain %s. file=%s,L=%s,force=%d', $filterFunction, $filterName, basename($file), $line, intval($force)));
                        return FALSE;
                } // END - if
 
@@ -314,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) {
@@ -434,7 +431,27 @@ 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'
+// @TODO Add a filter chain here? E.g.: 'filter_chain_interrupted'
+function interruptFilterChain () {
+       // Make sure that interrupted filter chains are not interrupted twice
+       assert((!isset($GLOBALS['filter_chain_interrupted'])) || ($GLOBALS['filter_chain_interrupted'] === FALSE));
+
+       // Set it
+       $GLOBALS['filter_chain_interrupted'] = TRUE;
+}
+
+// Continues the filter chain by disabling flag 'filter_chain_aborted'
+// @TODO Add a filter chain here? E.g.: 'filter_chain_continued'
+function continueFilterChain () {
+       // Make sure that continued filter chains are not continued twice
+       assert((!isset($GLOBALS['filter_chain_interrupted'])) || ($GLOBALS['filter_chain_interrupted'] === TRUE));
+
+       // Set it
+       $GLOBALS['filter_chain_interrupted'] = FALSE;
 }
 
 // [EOF]