]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions.php
Cache class rewritten to better convention
[mailer.git] / inc / extensions.php
index c4d7a8e0b133555bdd20787d448e372afc3892de..ed6f43c50386877ce402900c253d32e7e7d4e8db 100644 (file)
@@ -38,22 +38,25 @@ if (!defined('__SECURITY')) {
 }
 
 //
-function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false)
-{
+function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) {
        global $NOTES, $_CONFIG, $INC_POOL, $cacheInstance;
 
+       // This shall never do a non-admin user!
+       if (!IS_ADMIN()) return false;
+
+       // Is this extension already installed?
+       if (EXT_IS_ACTIVE($ext_name)) return false;
+
        // We want to register an extension and registration status is by default "failed" (= false)
        $EXT_LOAD_MODE = "register"; $ret = false; $SQLs = array();
        $INC_POOL = array();
 
-       // This shall never do a non-admin user!
-       if (!IS_ADMIN()) return false;
+       // By default the language prefix is the extension's name
+       // @TODO: Do we really need this one anymore? Can't we just take $ext_name and done?
+       $EXT_LANG_PREFIX = $ext_name;
 
        // By default we have no failtures
-       $EXT_REPORTS_FAILURE = true;
-
-       // Is this extension already installed?
-       if (EXT_IS_ACTIVE($ext_name)) return false;
+       $EXT_REPORTS_FAILURE = false;
 
        // Generate file name
        $file = sprintf("%sinc/extensions/ext-%s.php", PATH, $ext_name);
@@ -116,7 +119,7 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false)
                                // If versions mismatch update extension first
                                $ext_ver = GET_EXT_VERSION($EXT_UPDATE_DEPENDS);
 
-                               // Extension version set?
+                               // Extension version set? If empty the extension is not registered
                                if (empty($ext_ver)) {
                                        // Extension not registered so far so first load task's ID...
                                        $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE task_type='EXTENSION' AND subject LIKE '[%s:]%%' LIMIT 1",
@@ -169,7 +172,7 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false)
                $EXT_LOAD_MODE = "register";
 
                // Remains true if extension registration reports no failtures
-               $test = ($test && !$EXT_REPORTS_FAILTURE);
+               $test = ($test && !$EXT_REPORTS_FAILURE);
 
                // Does everthing before wents ok?
                if ($test) {
@@ -197,9 +200,9 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false)
                                if ((EXT_IS_ACTIVE("cache")) || (GET_EXT_VERSION("cache") != "")) {
                                        //* DEBUG: */ echo __LINE__.": DESTROY!<br />\n";
                                        // Remove cache files
-                                       if ($cacheInstance->cache_file("extensions", true)) $cacheInstance->cache_destroy();
-                                       if ($cacheInstance->cache_file("mod_reg", true))    $cacheInstance->cache_destroy();
-                                       if ($cacheInstance->cache_file("config", true))     $cacheInstance->cache_destroy();
+                                       if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
+                                       if ($cacheInstance->loadCacheFile("mod_reg"))          $cacheInstance->destroyCacheFile();
+                                       if ($cacheInstance->loadCacheFile("config"))           $cacheInstance->destroyCacheFile();
                                } // END - if
 
                                // Check for added include files
@@ -334,9 +337,9 @@ function EXTENSION_RUN_SQLS($id, $EXT_LOAD_MODE) {
        if (((EXT_IS_ACTIVE("cache")) || (GET_EXT_VERSION("cache") != "")) && (((SQL_AFFECTEDROWS() == 1)) || ($sqlRan === true) || ($EXT_LOAD_MODE == "activate") || ($EXT_LOAD_MODE == "deactivate"))) {
                //* DEBUG: */ echo __LINE__.": DESTROY!<br />\n";
                // Remove cache files
-               if ($cacheInstance->cache_file("extensions", true)) $cacheInstance->cache_destroy();
-               if ($cacheInstance->cache_file("mod_reg", true))    $cacheInstance->cache_destroy();
-               if ($cacheInstance->cache_file("config", true))     $cacheInstance->cache_destroy();
+               if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("mod_reg"))    $cacheInstance->destroyCacheFile();
+               if ($cacheInstance->loadCacheFile("config"))     $cacheInstance->destroyCacheFile();
 
                // @TODO This causes the whole (!) menu cache being purged
                CACHE_PURGE_ADMIN_MENU();
@@ -387,7 +390,7 @@ function EXT_IS_ACTIVE ($ext_name) {
        }
 
        // Debug message
-       //DEBUG_LOG(__FUNCTION__, __LINE__, " ext_name={$ext_name},active={$active}");
+       //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, " ext_name={$ext_name},active={$active}");
 
        // Is this extension activated? (For admins we always have active extensions...)
        return ($active == "Y");
@@ -533,9 +536,9 @@ function EXTENSION_UPDATE($file, $ext, $EXT_VER, $dry_run=false)
 
                        // Update cache
                        if (EXT_IS_ACTIVE("cache")) {
-                               if ($cacheInstance->cache_file("extensions", true) == true) $cacheInstance->cache_destroy();
-                               if ($cacheInstance->cache_file("config", true) == true)     $cacheInstance->cache_destroy();
-                               if ($cacheInstance->cache_file("mod_reg", true) == true)    $cacheInstance->cache_destroy();
+                               if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
+                               if ($cacheInstance->loadCacheFile("config")) $cacheInstance->destroyCacheFile();
+                               if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
                        } // END - if
 
                        // Remove array