]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions.php
Heavy improvements to caching system. Now, if cache is installed the system relays...
[mailer.git] / inc / extensions.php
index 711a3d163966b7e40f4f43ed01e9d723bec4b04a..970e0a71ad57cabdcc4a61aa4d0ba088b98ba384 100644 (file)
@@ -308,8 +308,10 @@ function EXT_IS_ACTIVE ($ext_name, $ignore_admin = false, $ignore_cache = false)
        if ((!file_exists($file)) && (!is_readable($file))) return false;
        //* DEBUG: */ echo "*".$ext_name."(".count($cacheArray).")<br />";
 
-       // Failed is the default
-       $ret = false;
+       // Not active is the default
+       $active = "N";
+
+       // Check cache
        if ((!empty($cacheArray['extensions']['ext_active'][$ext_name])) && (!$ignore_cache)) {
                // Load from cache
                //* DEBUG: */ echo "CACHE!<br />\n";
@@ -317,7 +319,7 @@ function EXT_IS_ACTIVE ($ext_name, $ignore_admin = false, $ignore_cache = false)
 
                // Count cache hits
                if (isset($_CONFIG['cache_hits'])) $_CONFIG['cache_hits']++;
-       } else {
+       } elseif (($ext_name == "cache") || (GET_EXT_VERSION("cache") == "")) {
                //* DEBUG: */ echo "DB!<br />\n";
                // Load from database
                $result = SQL_QUERY_ESC("SELECT ext_active FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",
@@ -327,22 +329,27 @@ function EXT_IS_ACTIVE ($ext_name, $ignore_admin = false, $ignore_cache = false)
                        return false;
                }
                list($active) = SQL_FETCHROW($result);
+               //* DEBUG: */ echo $ext_name."[DB]: {$active}<br />\n";
                SQL_FREERESULT($result);
 
                // Write cache array
                $cacheArray['extensions']['ext_active'][$ext_name] = $active;
+       } else {
+               // Extension not active!
+               //* DEBUG: */ echo $ext_name.": Not active!<br />\n";
+               $cacheArray['extensions']['ext_active'][$ext_name] = "N";
        }
 
-       // Is this extension activated? (For admins we always have active extensions...)
+       // Create FQFN for extension file
        $inc = sprintf("%sinc/extensions/ext-%s.php", PATH, $ext_name);
-       // Shorter way
+
+       // Debug message
+       //DEBUG_LOG(__FUNCTION__.": ext_name={$ext_name},active={$active}");
+
+       // Is this extension activated? (For admins we always have active extensions...)
        return (
                (
-                       ($active == "Y") || (
-                               (IS_ADMIN()) &&
-                               (!$ignore_admin) &&
-                               (!empty($active))
-                       )
+                       $active == "Y"
                ) && (
                        file_exists($inc)
                ) && (
@@ -464,16 +471,7 @@ function EXTENSION_UPDATE($file, $ext, $EXT_VER, $dry_run=false)
                        $ext_subj = "[UPDATE-".$ext."-".$EXT_VERSION.":] ".ADMIN_UPDATE_EXT_SUBJ;
 
                        // Create task
-                       $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE subject='%s' LIMIT 1",
-                        array($ext_subj), __FILE__, __LINE__);
-                       if (SQL_NUMROWS($result) == 0) {
-                               // Task not created so it's a brand-new extension which we need to register and create a task for!
-                               $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_task_system (assigned_admin, userid, status, task_type, subject, text, task_created) VALUES ('%s', '0', 'NEW', 'EXTENSION_UPDATE', '%s', '%s', UNIX_TIMESTAMP())",
-                                array(GET_ADMIN_ID(get_session('admin_login')), $ext_subj, addslashes($NOTES)), __FILE__, __LINE__);
-                       }
-
-                       // Free memory
-                       SQL_FREERESULT($result);
+                       CREATE_EXTENSION_UPDATE_TASK(GET_ADMIN_ID(get_session('admin_login')), $ext_subj, addslashes($NOTES));
 
                        // Update extension's version
                        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_extensions SET ext_version='%s' WHERE ext_name='%s' LIMIT 1",