Refback will be payed now (user cannot setup currently)
[mailer.git] / inc / extensions.php
index 3973f4132afb746d5403111617ac69ccaf6819dc..1851e5d4a851379affe3c2b345b75e45dc8f53c6 100644 (file)
@@ -186,10 +186,13 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false)
                                        foreach ($INC_POOL as $inc) {
                                                require_once($inc);
                                        } // END - foreach
+
+                                       // Remove array
+                                       unset($INC_POOL);
                                } // END - if
 
                                // Register extension
-                               $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_extensions (ext_name, ext_lang_file, ext_active, ext_version) VALUES ('%s', '%s', '%s', '%s')",
+                               $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_extensions (ext_name, ext_lang_file, ext_active, ext_version) VALUES ('%s','%s','%s','%s')",
                                 array($ext_name, $EXT_LANG_PREFIX, $EXT_ALWAYS_ACTIVE, $EXT_VERSION), __FILE__, __LINE__);
 
                                // Update task management
@@ -239,7 +242,7 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false)
 }
 //
 function EXTENSION_RUN_SQLS($id, $EXT_LOAD_MODE) {
-       global $cacheInstance;
+       global $cacheInstance, $_CONFIG;
        $SQLs = array();
 
        // By default no SQL has been executed
@@ -398,7 +401,12 @@ function GET_EXT_VERSION ($ext_name) {
 function EXTENSION_UPDATE($file, $ext, $EXT_VER, $dry_run=false)
 {
        // This shall never do a non-admin user!
-       global $cacheInstance, $_CONFIG, $NOTES; $SQLs = array();
+       global $cacheInstance, $_CONFIG, $NOTES;
+
+       // Init arrays
+       $SQLs = array(); $INC_POOL = array();
+
+       // Only admins are allowed to update extensions
        if ((!IS_ADMIN()) || (empty($ext))) return false;
 
        // Load extension in update mode
@@ -452,9 +460,16 @@ function EXTENSION_UPDATE($file, $ext, $EXT_VER, $dry_run=false)
                                }
                        }
 
+                       // In real-mode execute any existing includes
+                       if ((!$dry_run) && (count($INC_POOL) > 0)) {
+                               // Include all files
+                               foreach ($INC_POOL as $fqfn) {
+                                       require_once($fqfn);
+                               } // END - foreach
+                       } // END - if
+
                        // Run SQLs
-                       if ((is_array($SQLs)) && (!$dry_run))
-                       {
+                       if ((is_array($SQLs)) && (!$dry_run)) {
                                // Run SQL commands
                                foreach ($SQLs as $sql)
                                {
@@ -616,5 +631,6 @@ function EXT_VERSION_IS_OLDER ($ext_name, $ext_ver) {
        // Now compare both and return the result
        return ($currVersion < $ext_ver);
 }
+
 //
 ?>