Fixes for running SQL queries
[mailer.git] / inc / filters.php
index 82f9dcb27ac6fd26cf9ab596e6a2160eb4e1417c..1355975dd7c81e50fe950f1a26226e73cb33d343 100644 (file)
@@ -211,7 +211,7 @@ function RUN_FILTER ($filterName, $data = null, $silentAbort = true) {
        // Then run all filters
        foreach ($filters[$filterName] as $filterFunction=>$active) {
                // Debug message
-               //* DEBUG: */ echo __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): name={$filterName}, func={$filterFunction}, active={$active}<br />\n";
+               //* DEBUG: */ echo __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): name={$filterName},func={$filterFunction},active={$active}<br />\n";
 
                // Is the filter active?
                if ($active == "Y") {
@@ -319,7 +319,7 @@ function FILTER_FLUSH_FILTERS () {
        } // END - if
 
        // Run the run_sqls filter in non-dry mode
-       RUN_FILTER('run_sqls', false);
+       RUN_FILTER('run_sqls', array('dry_run' => false, 'sqls' => $SQLs));
 }
 
 // Filter for calling the handler for login failtures
@@ -387,36 +387,43 @@ function FILTER_SOLVE_TASK ($data) {
 }
 
 // Filter to load include files
-function FILTER_LOAD_INCLUDES ($INC_POOL) {
+function FILTER_LOAD_INCLUDES ($data) {
        global $CSS;
 
+       // Default is $data as inclusion list
+       $INC_POOL = $data;
+
        // Is it an array?
-       if ((!isset($INC_POOL)) || (!is_array($INC_POOL))) {
+       if ((!isset($data)) || (!is_array($data))) {
                // Then abort here
                DEBUG_LOG(__FILE__, __LINE__, "INC_POOL is no array!");
-               return;
-       } // END - if
+               return $data;
+       } elseif (isset($data['inc_pool'])) {
+               // Use this as new inclusion pool!
+               $INC_POOL = $data['inc_pool'];
+       }
 
        // Check for added include files
        if (count($INC_POOL) > 0) {
                // Loads every include file
-               foreach ($INC_POOL as $fqfn) {
-                       require_once($fqfn);
+               foreach ($INC_POOL as $FQFN) {
+                       require_once($FQFN);
                } // END - foreach
 
                // Reset array
-               $INC_POOL = array();
+               if (isset($data['inc_pool'])) $data['inc_pool'] = array();
        } // END - if
+
+       // Continue with processing
+       return $data;
 }
 
 // Filter for running SQL commands
-function FILTER_RUN_SQLS ($dry_run) {
-       global $SQLs;
-
+function FILTER_RUN_SQLS ($data) {
        // Is the array there?
-       if ((is_array($SQLs)) && (!$dry_run)) {
+       if ((isset($data['sqls'])) && ((!isset($data['dry_run'])) || ($data['dry_run'] == false))) {
                // Run SQL commands
-               foreach ($SQLs as $sql) {
+               foreach ($data['sqls'] as $sql) {
                        $sql = trim($sql);
                        if (!empty($sql)) {
                                // Do we have an "ALTER TABLE" command?
@@ -429,10 +436,7 @@ function FILTER_RUN_SQLS ($dry_run) {
                                }
                        } // END - if
                } // END - foreach
-       } elseif (GET_EXT_VERSION("sql_patches") == "") {
-               // Remove SQLs if extension is not installed
-               $SQLs = array();
-       }
+       } // END - if
 }
 
 // Filter for updating/validating login data