X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fextensions.php;h=cfe82ae48efecd04076eb52701b78d3633ef19c8;hb=aa27f7442553d0a8341e5611d70b8e4521bbce03;hp=0b75f56d259428dd8b3a5e2562a2f051db948bea;hpb=7f104f6fe558bb56b4205241435a2357c2feece1;p=mailer.git diff --git a/inc/extensions.php b/inc/extensions.php index 0b75f56d25..cfe82ae48e 100644 --- a/inc/extensions.php +++ b/inc/extensions.php @@ -41,6 +41,7 @@ if (!defined('__SECURITY')) { function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) { global $NOTES, $_CONFIG, $INC_POOL, $cacheInstance; + // 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(); @@ -48,6 +49,13 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) // 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 = false; + // Is this extension already installed? if (EXT_IS_ACTIVE($ext_name)) return false; @@ -89,20 +97,25 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) $SQLs = array(); $test = false; - // Backup language as well - $LANG_BCK = $EXT_LANG_PREFIX; - $EXT_ALWAYS_ACTIVE = "N"; - // Load required extension also in update mode $file = sprintf("%sinc/extensions/ext-%s.php", PATH, $EXT_UPDATE_DEPENDS); // Check for required file if (FILE_READABLE($file)) { - // File exists so let's load it + // Bacup version number $VER_BACKUP = $EXT_VERSION; + + // Backup language as well + $LANG_BCK = $EXT_LANG_PREFIX; + + // Save the Parrent $EXT_ALWAYS_ACTIVE for later! + $EXT_ALWAYS_ACTIVE_PARRENT = $EXT_ALWAYS_ACTIVE; + + // Set EXT_ALWAYS_ACTIVE for update $EXT_ALWAYS_ACTIVE = "N"; + + // File exists so let's load it require($file); - $EXT_VERSION = $VER_BACKUP; // If versions mismatch update extension first $ext_ver = GET_EXT_VERSION($EXT_UPDATE_DEPENDS); @@ -134,6 +147,15 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) // Nothing to register / update before... $test = true; } + + // Restore version number + $EXT_VERSION = $VER_BACKUP; + + // Restore language back + $EXT_LANG_PREFIX = $LANG_BCK; + + // Restore $EXT_ALWAYS_ACTIVE with the value from parrent + $EXT_ALWAYS_ACTIVE = $EXT_ALWAYS_ACTIVE_PARRENT; } else { // Required file for update does not exists! $test = true; @@ -142,7 +164,6 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) // Finally restore previous SQLs $SQLs = $SQLs2; unset($SQLs2); - $EXT_LANG_PREFIX = $LANG_BCK; } else { // Does not depend on an other extension $test = true; @@ -151,6 +172,9 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) // Switch back to register mode $EXT_LOAD_MODE = "register"; + // Remains true if extension registration reports no failtures + $test = ($test && !$EXT_REPORTS_FAILURE); + // Does everthing before wents ok? if ($test) { // "Dry-run-mode" activated? @@ -178,8 +202,8 @@ function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false) //* DEBUG: */ echo __LINE__.": DESTROY!
\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->cache_file("mod_reg")) $cacheInstance->cache_destroy(); + if ($cacheInstance->cache_file("config")) $cacheInstance->cache_destroy(); } // END - if // Check for added include files @@ -315,8 +339,8 @@ function EXTENSION_RUN_SQLS($id, $EXT_LOAD_MODE) { //* DEBUG: */ echo __LINE__.": DESTROY!
\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->cache_file("mod_reg")) $cacheInstance->cache_destroy(); + if ($cacheInstance->cache_file("config")) $cacheInstance->cache_destroy(); // @TODO This causes the whole (!) menu cache being purged CACHE_PURGE_ADMIN_MENU(); @@ -367,7 +391,7 @@ function EXT_IS_ACTIVE ($ext_name) { } // Debug message - //DEBUG_LOG(__FUNCTION__.": 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"); @@ -513,9 +537,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->cache_file("extensions", true)) $cacheInstance->cache_destroy(); + if ($cacheInstance->cache_file("config")) $cacheInstance->cache_destroy(); + if ($cacheInstance->cache_file("mod_reg")) $cacheInstance->cache_destroy(); } // END - if // Remove array @@ -583,7 +607,7 @@ function GET_EXT_NAME ($id) { $ret = $cacheArray['extensions']['ext_name'][$id]; // Count cache hits - $_CONFIG['cache_hits']++; + if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database $result = SQL_QUERY_ESC("SELECT ext_name FROM "._MYSQL_PREFIX."_extensions WHERE id=%s LIMIT 1", @@ -602,7 +626,7 @@ function GET_EXT_ID($name) { $ret = $cacheArray['extensions']['ext_id'][$name]; // Count cache hits - $_CONFIG['cache_hits']++; + if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; } } elseif (!EXT_IS_ACTIVE("cache")) { // Load from database $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",