}
//
-function EXTENSION_REGISTER ($ext_name, $id, $dry_run=false)
-{
+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();
// 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();
+
+ // 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;
+
// Generate file name
$file = sprintf("%sinc/extensions/ext-%s.php", PATH, $ext_name);
$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);
- // 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",
// 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;
// Finally restore previous SQLs
$SQLs = $SQLs2; unset($SQLs2);
- $EXT_LANG_PREFIX = $LANG_BCK;
} else {
// Does not depend on an other extension
$test = true;
// 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?
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
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();
}
// 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");
// 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