Caching of XML/email templates finished:
[mailer.git] / inc / filters.php
index 2bfb3495874b9c252c5bda4366eac5134bb994ef..634d0f1c00a306d515f5a03686b77aadcdf17b99 100644 (file)
@@ -45,21 +45,17 @@ function FILTER_FLUSH_FILTERS () {
        // Clear all previous SQL queries
        initSqls();
 
-       // Are we installing?
-       if ((isInstallationPhase())) {
-               // Then silently skip this filter
-               return true;
-       } // END - if
-
        // Is a database link here and not in installation mode?
-       if ((!SQL_IS_LINK_UP()) && (!isInstalling())) {
+       if ((!SQL_IS_LINK_UP()) && (!isInstallationPhase())) {
                // Abort here
                reportBug(__FUNCTION__, __LINE__, 'No database link is up. Cannot flush filters.');
-               return false;
-       } // END - if
+       } elseif ((isInstallationPhase()) && (!SQL_IS_LINK_UP())) {
+               // If the link is not up in installation phase, skip flushing filters
+               return;
+       }
 
-       // Is the extension ext-sql_patches updated?
-       if ((!isExtensionInstalled('sql_patches')) || (isExtensionInstalledAndOlder('sql_patches', '0.5.9'))) {
+       // Is the extension ext-sql_patches updated and not in installation phase?
+       if ((!isInstallationPhase()) && ((!isExtensionInstalled('sql_patches')) || (isExtensionInstalledAndOlder('sql_patches', '0.5.9')))) {
                // Log only in debug mode
                if (isDebugModeEnabled()) {
                        logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters, sql_patches might be missing. isExtensionInstalled()=' . intval(isExtensionInstalled('sql_patches')) . ',isExtensionInstalledAndOlder()=' . intval(isExtensionInstalledAndOlder('sql_patches', '0.5.9')));
@@ -275,7 +271,7 @@ function FILTER_RUN_SQLS ($filterData) {
 
                                // Is there still a query left?
                                if (!empty($sql)) {
-                                       // Do we have an "ALTER TABLE" command?
+                                       // Is there an "ALTER TABLE" command?
                                        if (substr(strtolower($sql), 0, 11) == 'alter table') {
                                                // Analyse the alteration command
                                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Alterting table: ' . $sql . ',enable_codes=' . intval($filterData['enable_codes']));
@@ -384,7 +380,7 @@ function FILTER_REMOVE_UPDATES ($filterData) {
        // Simply remove it
        unsetExtensionSqls();
 
-       // Do we need to remove update depency?
+       // Are there update dependencies to remove?
        if (countExtensionUpdateDependencies() > 0) {
                // Then find all updates we shall no longer execute
                foreach (getExtensionUpdateDependencies() as $id => $ext_name) {
@@ -438,7 +434,7 @@ function FILTER_COMPILE_CONFIG ($code, $compiled = false) {
        // Save the uncompiled code
        $uncompiled = $code;
 
-       // Do we have cache?
+       // Is there cache?
        if (!isset($GLOBALS['compiled_config'][$code])) {
                // Compile {?some_var?} to getConfig('some_var')
                preg_match_all('/\{\?(([a-zA-Z0-9-_]+)*)\?\}/', $code, $matches);
@@ -447,7 +443,7 @@ function FILTER_COMPILE_CONFIG ($code, $compiled = false) {
                if ((count($matches) > 0) && (count($matches[0]) > 0)) {
                        // Replace all matches
                        foreach ($matches[0] as $key => $match) {
-                               // Do we have cache?
+                               // Is there cache?
                                if (!isset($GLOBALS['compile_config'][$matches[1][$key]])) {
                                        // Is the config valid?
                                        if (isConfigEntrySet($matches[1][$key])) {
@@ -563,7 +559,7 @@ function FILTER_COMPILE_EXPRESSION_CODE ($filterData) {
                } // END - foreach
        } // END - if
 
-       // Do we have non-HTML mode?
+       // Is there non-HTML mode?
        if (!isHtmlOutputMode()) {
                $filterData = decodeEntities($filterData);
        } // END - if
@@ -881,7 +877,7 @@ function FILTER_COUNT_MODULE () {
 
 // Handles fatal errors
 function FILTER_HANDLE_FATAL_ERRORS () {
-       // Do we have errors to handle and right output mode?
+       // Is there errors to handle and right output mode?
        if ((!ifFatalErrorsDetected()) || (!isHtmlOutputMode())) {
                // Abort executing here
                return false;
@@ -994,13 +990,15 @@ function FILTER_FLUSH_TEMPLATE_CACHE () {
                return;
        } // END - if
 
-       // Do we have cached eval() data?
+       // Is there cached eval() data?
        if ((isset($GLOBALS['template_eval'])) && (count($GLOBALS['template_eval']) > 0)) {
                // Now flush all
-               foreach ($GLOBALS['template_eval'] as $template => $eval) {
-                       // Flush the cache (if not yet found)
-                       flushTemplateCache($template, $eval);
-               } // END - if
+               foreach ($GLOBALS['template_eval'] as $prefix => $templateArray) {
+                       foreach ($templateArray as $template => $eval) {
+                               // Flush the cache (if not yet found)
+                               flushTemplateCache($prefix, $template, $eval);
+                       } // END - foreach
+               } // END - foreach
        } // END - if
 }
 
@@ -1237,5 +1235,17 @@ function FILTER_INIT_SESSION ($filterData) {
        return $filterData;
 }
 
+// Filter for sending "build mail" to admin
+function FILTER_SEND_BUILD_MAIL ($filterData) {
+       // Was one line updated?
+       //if ($filterData['affected'] == 1) {
+               // Then call the proper function
+               call_user_func_array('sendGenericBuildMails', $filterData);
+       //} // END - if
+
+       // Return data
+       return $filterData;
+}
+
 // [EOF]
 ?>