- // Disable cache update by default
- $cache_update = 0;
- if (!empty($subj)) {
- // Extract extension's name from subject...
- $ext_name = trim(substr($subj, 1, strpos($subj, ":") - 1));
-
- // Test the extension for deprecation
- LOAD_EXTENSION($ext_name, "test");
-
- // Is the extension deprecated?
- if (EXT_GET_DEPRECATED() == "N") {
- // ... so we can finally register and load it in registration mode
- if (REGISTER_EXTENSION($ext_name, $ext_id)) {
- // Extension was found and successfully registered
- LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_EXTENSION_REGISTERED'));
-
- // Show next link
- if (EXT_IS_ACTIVE("task")) {
- LOAD_TEMPLATE("admin_next_link", false, array(
- 'url' => "modules.php?module=admin&what=list_task",
- 'title' => getMessage('ADMIN_EXT_REGISTER_NEXT_LINK')
- ));
+ // Is the ID number valid and the task was found?
+ if (($ext_id > 0) && ($task_found == 1)) {
+ // ID is valid so begin with registration, we first want to it's real name from task management (subject column)
+ $result = SQL_QUERY_ESC("SELECT `subject` FROM `{?_MYSQL_PREFIX?}_task_system` WHERE `id`=%s LIMIT 1",
+ array(bigintval($ext_id)), __FILE__, __LINE__);
+ list($subj) = SQL_FETCHROW($result);
+ SQL_FREERESULT($result);
+
+ // Disable cache update by default
+ $cache_update = 0;
+ if (!empty($subj)) {
+ // Extract extension's name from subject...
+ $ext_name = trim(substr($subj, 1, strpos($subj, ':') - 1));
+
+ // Test the extension for deprecation
+ loadExtension($ext_name, 'test');
+
+ // Is the extension deprecated?
+ if (!isExtensionDeprecated()) {
+ // ... so we can finally register and load it in registration mode
+ if (registerExtension($ext_name, $ext_id)) {
+ // Errors?
+ if (getTotalFatalErrors() == 0) {
+ // Extension was found and successfully registered
+ loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_EXTENSION_REGISTERED'), $ext_name));
+
+ // Show next link
+ if (isExtensionActive('task')) {
+ loadTemplate('admin_next_link', false, array(
+ 'url' => 'modules.php?module=admin&what=list_task',
+ 'title' => getMessage('ADMIN_EXT_REGISTER_NEXT_LINK')
+ ));
+ } else {
+ loadTemplate('admin_next_link', false, array(
+ 'url' => 'modules.php?module=admin',
+ 'title' => getMessage('ADMIN_EXT_REGISTER_NEXT_LINK')
+ ));
+ }
+ } else {
+ // Errors detected!
+ loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_EXTENSION_NOT_REGISTERED'), $ext_name));
+ }
+
+ // Do we need to update cache file?
+ // @TODO Rewrite this to a filter
+ if (isExtensionActive('cache')) {
+ // Remove cache file (will be auto-created again!)
+ if ($GLOBALS['cache_instance']->loadCacheFile('config')) $GLOBALS['cache_instance']->removeCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile('extension')) $GLOBALS['cache_instance']->removeCacheFile();
+ if ($GLOBALS['cache_instance']->loadCacheFile('modules')) $GLOBALS['cache_instance']->removeCacheFile();
+ } // END - if
+ } elseif (getExtensionVersion($ext_name) != '') {
+ // Notify the admin that we have a problem here...
+ loadTemplate('admin_settings_saved', false, getMessage('ADMIN_REG_FAILED_ALREADY'));