More fixes from profi-concept for extension loading, guest/member menu and smaller...
[mailer.git] / inc / load_extensions.php
index 8d69d37d79da508a1975e1a91517c32bedacd45d..e7d7e0b9003cff8fa6f04f65c7041bcee1d1e2db 100644 (file)
@@ -36,7 +36,8 @@ if (!defined('__SECURITY')) {
        $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
        require($INC);
 }
-//
+
+// Init variables
 global $EXT_CSS_FILES;
 $EXT_CSS_FILES = array();
 $ADD = "";
@@ -69,12 +70,20 @@ if (EXT_IS_ACTIVE("cache")) {
        }
 
        // Do not recreate cache file when it's switched off!
-       if (($cacheMode == "init") && ($_CONFIG['cache_exts'] == "N")) $cacheMode = "skip";
+
+       // If we need to init the cache init it now
+       if ($cacheMode == "init") {
+               // Init cache file
+               $cacheInstance->cache_init("EXTENSIONS");
+
+               if ($_CONFIG['cache_exts'] == "N") $cacheMode = "skip";
+       } // END - if
 } else {
        // Cache extension not active
        $cacheMode = "no";
 }
 
+// Load cache?
 if ($cacheMode == "load") {
        // Init include array
        $EXT_POOL = array();
@@ -166,8 +175,9 @@ if ($cacheMode == "load") {
        // Remove array
        unset($EXT_POOL);
 } else {
-       // If current user is not admin load only activated extensions
-       // The admin shall use every available extension for testing purposes
+       // If current user is not admin load only activated extensions. But load
+       // them all if we are going to init the cache files. The admin shall use
+       // every available extension for testing purposes.
        if ((!IS_ADMIN()) && ($cacheMode != "init")) $ADD = " WHERE ext_active='Y'";
 
        if (GET_EXT_VERSION("sql_patches") >= "0.0.6") {
@@ -176,7 +186,7 @@ if ($cacheMode == "load") {
 FROM "._MYSQL_PREFIX."_extensions".$ADD."
 ORDER BY ext_name", __FILE__, __LINE__);
        } else {
-               // Old obsulete query string
+               // Old obsolete query string
                $res_ext_crt = SQL_QUERY("SELECT id, ext_name, ext_lang_file, ext_name, ext_active, ext_version
 FROM "._MYSQL_PREFIX."_extensions".$ADD."
 ORDER BY ext_name", __FILE__, __LINE__);
@@ -187,13 +197,10 @@ ORDER BY ext_name", __FILE__, __LINE__);
 $DEL = array();
 
 // At least one found?
-if ((SQL_NUMROWS($res_ext_crt) > 0) && (($cacheMode == "init") || ($cacheMode == "no")) && ($CSS != "1") && ($CSS != "-1")) {
+if ((SQL_NUMROWS($res_ext_crt) > 0) && ((($cacheMode == "init") && ($CSS != "1") && ($CSS != "-1")) || ($cacheMode == "no"))) {
        // Load theme management
        require_once(PATH."inc/theme-manager.php");
 
-       // If we need to init the cache init it now
-       if ($cacheMode == "init") $cacheInstance->cache_init("EXTENSIONS");
-
        // Extensions are registered so we load them
        while (list($EXT_ID, $name, $lang, $css, $active, $version) = SQL_FETCHROW($res_ext_crt)) {
                // Get menu entry