X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fextensions.php;h=9d2c0a44184b7fb6932aca4acb3dfab530ec9497;hp=8be7feba1048bd7e43f14930d50f0c56961e8636;hb=4913351e083ec29bfd7d98710e6a9da6c92bd648;hpb=798cdd57a6c0e5879e3ad5d9a76900ed27e1d9e0;ds=sidebyside diff --git a/inc/extensions.php b/inc/extensions.php index 8be7feba10..9d2c0a4418 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? @@ -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");