]> git.mxchange.org Git - mailer.git/blobdiff - inc/extensions.php
More rewrites of constants and fix for loading mass-included scripts by GET_DIR_AS_AR...
[mailer.git] / inc / extensions.php
index 0f02e6a12485495daa7c172bdd724f66c24f12da..ba65fb3649aec021a10536b64bc80071e3eab821 100644 (file)
@@ -39,7 +39,7 @@ if (!defined('__SECURITY')) {
 
 // Load the extension and maybe found language and function files.
 function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = "", $EXT_VER = "", $dry_run = false, &$SQLs = array()) {
-       global $EXT_LOADED, $_CONFIG, $EXT_VER_HISTORY;
+       global $_CONFIG, $EXT_VER_HISTORY;
        global $INC_POOL, $EXT_UPDATE_DEPENDS, $EXT_DEPRECATED, $UPDATE_NOTES;
        global $EXT_VERSION, $EXT_ALWAYS_ACTIVE;
 
@@ -48,7 +48,7 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = "", $EXT_VER = "", $dry_run
 
        // Is the extension already loaded?
        //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "Loading extension {$ext_name}, mode={$EXT_LOAD_MODE}, ver={$EXT_VER}.");
-       if ((isset($EXT_LOADED['ext'][$ext_name])) && (empty($EXT_LOAD_MODE))) {
+       if ((isset($GLOBALS['ext_loaded']['ext'][$ext_name])) && (empty($EXT_LOAD_MODE))) {
                // Debug message
                DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Extension %s already loaded.", $ext_name));
                return false;
@@ -73,10 +73,10 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = "", $EXT_VER = "", $dry_run
        $langInclude = sprintf("inc/language/%s_%s.php", $ext_name, GET_LANGUAGE());
 
        // Is this include there?
-       if ((FILE_READABLE($langInclude)) && (!isset($EXT_LOADED['lang'][$ext_name]))) {
+       if ((FILE_READABLE($langInclude)) && (!isset($GLOBALS['ext_loaded']['lang'][$ext_name]))) {
                // Then load it
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Language loaded.");
-               $EXT_LOADED['lang'][$ext_name] = true;
+               $GLOBALS['ext_loaded']['lang'][$ext_name] = true;
                LOAD_INC_ONCE($langInclude);
        } // END - if
 
@@ -84,10 +84,10 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = "", $EXT_VER = "", $dry_run
        $funcsInclude = sprintf("inc/libs/%s_functions.php", $ext_name);
 
        // Is this include there?
-       if ((FILE_READABLE($funcsInclude)) && (!isset($EXT_LOADED['funcs'][$ext_name]))) {
+       if ((FILE_READABLE($funcsInclude)) && (!isset($GLOBALS['ext_loaded']['funcs'][$ext_name]))) {
                // Then load it
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Functions loaded.");
-               $EXT_LOADED['funcs'][$ext_name] = true;
+               $GLOBALS['ext_loaded']['funcs'][$ext_name] = true;
                LOAD_INC_ONCE($funcsInclude);
        } // END - if
 
@@ -119,7 +119,7 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = "", $EXT_VER = "", $dry_run
        // Mark it as loaded in normal mode
        if (empty($EXT_LOAD_MODE)) {
                // Mark it now...
-               $EXT_LOADED['ext'][$ext_name] = true;
+               $GLOBALS['ext_loaded']['ext'][$ext_name] = true;
        } // END - if
 
        // All fine!
@@ -256,7 +256,7 @@ function EXTENSION_REGISTER ($ext_name, $task_id, $dry_run = false, $logout = tr
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": LOAD!");
                if ($logout) {
                        // Then redirect to logout
-                       LOAD_URL("modules.php?module=admin&logout=1&".$EXT_LOAD_MODE."=sql_patches");
+                       LOAD_URL("modules.php?module=admin&logout=1&".$EXT_LOAD_MODE."=sql_patches");
                } else {
                        // Add temporary filter
                        REGISTER_FILTER('shutdown', 'REDIRECT_TO_LOGOUT_SQL_PATCHES', true, true);
@@ -313,14 +313,14 @@ function EXTENSION_RUN_SQLS ($ext_id, $load_mode) {
        if (($ext_name == "sql_patches") && (($load_mode == "register") || ($load_mode == "remove"))) {
                // Then redirect to logout
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": LOAD!");
-               LOAD_URL("modules.php?module=admin&logout=1&".$load_mode."=sql_patches");
+               LOAD_URL("modules.php?module=admin&logout=1&".$load_mode."=sql_patches");
        } // END - if
 }
 
 // Check if given extension is active
 function EXT_IS_ACTIVE ($ext_name) {
        // Extensions are all inactive during installation
-       if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing')) || (empty($ext_name))) return false;
+       if ((!isInstalled()) || (isInstalling()) || (empty($ext_name))) return false;
 
        // Not active is the default
        $active = "N";
@@ -333,6 +333,9 @@ function EXT_IS_ACTIVE ($ext_name) {
 
                // Count cache hits
                incrementConfigEntry('cache_hits');
+       } elseif (isset($GLOBALS['ext_loaded'][$ext_name])) {
+               // Extension is loaded!
+               die("LOADED:$ext_name");
        } elseif (($ext_name == "cache") || (GET_EXT_VERSION("cache") == "")) {
                //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "DB! ext_name={$ext_name}");
                // Load from database
@@ -369,7 +372,7 @@ function GET_EXT_VERSION ($ext_name) {
        $ext_ver = false;
 
        // Extensions are all inactive during installation
-       if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing'))) return "";
+       if ((!isInstalled()) || (isInstalling())) return "";
        //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, ": ext_name={$ext_name}");
 
        // Is the cache written?
@@ -380,7 +383,7 @@ function GET_EXT_VERSION ($ext_name) {
 
                // Count cache hits
                incrementConfigEntry('cache_hits');
-       } elseif (!is_object($GLOBALS['cache_instance'])) {
+       } elseif ((!isset($GLOBALS['cache_instance'])) || (!is_object($GLOBALS['cache_instance']))) {
                // Load from database
                $result = SQL_QUERY_ESC("SELECT ext_version FROM `{!_MYSQL_PREFIX!}_extensions` WHERE ext_name='%s' LIMIT 1",
                        array($ext_name), __FILE__, __LINE__);
@@ -756,8 +759,8 @@ function MODULE_HAS_MENU ($mod, $forceDb = false) {
                // Free memory
                SQL_FREERESULT($result);
        } elseif (GET_EXT_VERSION("sql_patches") == "") {
-               // No sql_patches installed, so maybe in admin area?
-               $ret = ((IS_ADMIN()) && ($mod == "admin")); // Then there is a menu!
+               // No sql_patches installed, so maybe in admin area or no admin registered?
+               $ret = (((IS_ADMIN()) || (!isAdminRegistered())) && ($mod == "admin")); // Then there is a menu!
        }
 
        // Return status
@@ -847,5 +850,38 @@ function ADD_EXTENSION_NOTES ($ver, &$UPDATE_NOTES) {
        return $out;
 }
 
+// Getter for CSS files array
+function EXT_GET_CSS_FILES () {
+       // By default no additional CSS files are found
+       $cssFiles = array();
+
+       // Is the array there?
+       if (isset($GLOBALS['css_files'])) {
+               // Then use it
+               $cssFiles = $GLOBALS['css_files'];
+       } // END - if
+
+       // Return array
+       return $cssFiles;
+}
+
+// Init CSS files array
+function EXT_INIT_CSS_FILES () {
+       // Simply init it
+       $GLOBALS['css_files'] = array();
+}
+
+// Add new entry
+function EXT_ADD_CSS_FILE ($file) {
+       // Is the array there?
+       if (!isset($GLOBALS['css_files'])) {
+               // Then auto-init them
+               EXT_INIT_CSS_FILES();
+       } // END - if
+
+       // Add the entry
+       $GLOBALS['css_files'][] = $file;
+}
+
 //
 ?>