// Possible newly installed extension found so we extract extension's name
$ext = strtolower(substr($file, 4, -4)); // Keep always extension names on lower case!!!
- // Check if extension is installed or not
+ // Init variables
$ext_ver = "";
- if ((!is_array($cacheArray['extensions']['ext_version'])) || (empty($cacheArray['extensions']['ext_version'][$ext]))) {
- // Load data from database
- $result = SQL_QUERY_ESC("SELECT id, ext_version FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",
- array($ext), __FILE__, __LINE__);
- } else {
+ $result = false;
+
+ // Check if extension is installed or not
+ if ((is_array($cacheArray['extensions']['ext_version'])) && (isset($cacheArray['extensions']['ext_version'][$ext]))) {
// Load version from cache
if (!empty($cacheArray['extensions']['ext_version'][$ext])) {
// Extension is installed so we can get it's version number
// Disable load from database
$result = false;
+ } elseif (!EXT_IS_ACTIVE("cache")) {
+ // Load data from database
+ $result = SQL_QUERY_ESC("SELECT id, ext_version FROM "._MYSQL_PREFIX."_extensions WHERE ext_name='%s' LIMIT 1",
+ array($ext), __FILE__, __LINE__);
}
// Is the extension not yet installed?
// Generate subject line
$ext_subj = sprintf("[%s:]", $ext);
- // Not installed and do we have created a task for the admin?
- //* DEBUG: */ echo $ext.":".$ext_ver."=";
- $result = SQL_QUERY_ESC("SELECT `id` FROM `"._MYSQL_PREFIX."_task_system` WHERE `subject` LIKE '%s%%' LIMIT 1",
- array($ext_subj), __FILE__, __LINE__);
- //* DEBUG: */ echo SQL_NUMROWS($result)."<br />\n";
- if ((SQL_NUMROWS($result) == 0) && (GET_EXT_VERSION($ext) == "")) {
- // Template file
- $tpl = sprintf("%stemplates/%s/html/ext/ext_%s.tpl",
- PATH,
- GET_LANGUAGE(),
- $ext
- );
-
- // Load text for task
- if ((file_exists($tpl)) && (is_readable($tpl))) {
- // Load extension's own text template (HTML!)
- $MSG = LOAD_TEMPLATE("ext_".$ext, true);
- } else {
- // Load default message
- $MSG = LOAD_EMAIL_TEMPLATE("admin_new_ext","", 0);
- }
-
- // Task not created so it's a brand-new extension which we need to register and create a task for!
- $result_insert = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_task_system (assigned_admin, userid, status, task_type, subject, text, task_created)
-VALUES ('%s', '0', 'NEW', 'EXTENSION', '%s', '%s', UNIX_TIMESTAMP())",
- array(
- GET_ADMIN_ID(get_session('admin_login')),
- $ext_subj,
- addslashes($MSG),
- ), __FILE__, __LINE__, true, false);
- }
-
- // Free memory
- SQL_FREERESULT($result);
+ // Create a task for newly installed extension
+ CREATE_NEW_EXTENSION_TASK(GET_ADMIN_ID(get_session('admin_login')), $ext_subj, $ext);
// We maybe want to install an extension so let's test-drive it...
include(PATH."inc/extensions/".$file);
if (!empty($cacheArray['active_extensions'][$ext])) {
// Maybe we want to keept the current extension active?
- if (($cacheArray['active_extensions'][$ext] == "Y") && (!EXT_IS_ACTIVE($ext, true, true))) {
+ if (($cacheArray['active_extensions'][$ext] == "Y") && (!EXT_IS_ACTIVE($ext))) {
// Reactivate this extension!
$result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_extensions SET ext_active='Y' WHERE ext_name='%s' LIMIT 1",
array($ext), __FILE__, __LINE__);
- EXTENSION_RUN_SQLS(GET_EXT_ID($ext), "activate");
- }
+
+ // Extension has been activated?
+ if (SQL_AFFECTEDROWS() == 1) {
+ // Then run all queries
+ EXTENSION_RUN_SQLS(GET_EXT_ID($ext), "activate");
+ } // END - if
+ } // END - if
}
}
}