if ((!file_exists($file)) && (!is_readable($file))) return false;
//* DEBUG: */ echo "*".$ext_name."(".count($cacheArray).")<br />";
- // Failed is the default
- $ret = false;
+ // Not active is the default
+ $active = "N";
+
+ // Check cache
if ((!empty($cacheArray['extensions']['ext_active'][$ext_name])) && (!$ignore_cache)) {
// Load from cache
//* DEBUG: */ echo "CACHE!<br />\n";
// Count cache hits
if (isset($_CONFIG['cache_hits'])) $_CONFIG['cache_hits']++;
- } else {
+ } elseif (($ext_name == "cache") || (GET_EXT_VERSION("cache") == "")) {
//* DEBUG: */ echo "DB!<br />\n";
// Load from database
$result = SQL_QUERY_ESC("SELECT ext_active FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",
return false;
}
list($active) = SQL_FETCHROW($result);
+ //* DEBUG: */ echo $ext_name."[DB]: {$active}<br />\n";
SQL_FREERESULT($result);
// Write cache array
$cacheArray['extensions']['ext_active'][$ext_name] = $active;
+ } else {
+ // Extension not active!
+ //* DEBUG: */ echo $ext_name.": Not active!<br />\n";
+ $cacheArray['extensions']['ext_active'][$ext_name] = "N";
}
- // Is this extension activated? (For admins we always have active extensions...)
+ // Create FQFN for extension file
$inc = sprintf("%sinc/extensions/ext-%s.php", PATH, $ext_name);
- // Shorter way
+
+ // Debug message
+ //DEBUG_LOG(__FUNCTION__.": ext_name={$ext_name},active={$active}");
+
+ // Is this extension activated? (For admins we always have active extensions...)
return (
(
- ($active == "Y") || (
- (IS_ADMIN()) &&
- (!$ignore_admin) &&
- (!empty($active))
- )
+ $active == "Y"
) && (
file_exists($inc)
) && (
$ext_subj = "[UPDATE-".$ext."-".$EXT_VERSION.":] ".ADMIN_UPDATE_EXT_SUBJ;
// Create task
- $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE subject='%s' LIMIT 1",
- array($ext_subj), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 0) {
- // Task not created so it's a brand-new extension which we need to register and create a task for!
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_task_system (assigned_admin, userid, status, task_type, subject, text, task_created) VALUES ('%s', '0', 'NEW', 'EXTENSION_UPDATE', '%s', '%s', UNIX_TIMESTAMP())",
- array(GET_ADMIN_ID(get_session('admin_login')), $ext_subj, addslashes($NOTES)), __FILE__, __LINE__);
- }
-
- // Free memory
- SQL_FREERESULT($result);
+ CREATE_EXTENSION_UPDATE_TASK(GET_ADMIN_ID(get_session('admin_login')), $ext_subj, addslashes($NOTES));
// Update extension's version
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_extensions SET ext_version='%s' WHERE ext_name='%s' LIMIT 1",