Automatic deactivation of deprecated extensions added
[mailer.git] / inc / modules / admin / what-extensions.php
index b8a940ff951ca4dc155ca4274fdb5ee4d89d1b2b..d75af2b14c8d7a5f3335d82f919f377ebcad03ca 100644 (file)
@@ -228,13 +228,13 @@ switch ($do) {
 case "overview": // List all registered extensions
        if (GET_EXT_VERSION("sql_patches") >= "0.0.6") {
                // Load extension data with CSS informations
-               $result = SQL_QUERY("SELECT id, ext_name, ext_active, ext_has_css, ext_version
+               $result = SQL_QUERY("SELECT id AS ext_id, ext_name, ext_active, ext_has_css AS ext_css, ext_version
 FROM "._MYSQL_PREFIX."_extensions
 ".$where."
 ORDER BY ext_name", __FILE__, __LINE__);
        } else {
                // Load extension data without CSS informations
-               $result = SQL_QUERY("SELECT id, ext_name, ext_active, id, ext_version
+               $result = SQL_QUERY("SELECT id AS ext_id, ext_name, ext_active, id, ext_version
 FROM "._MYSQL_PREFIX."_extensions
 ".$where."
 ORDER BY ext_name", __FILE__, __LINE__);
@@ -244,20 +244,19 @@ ORDER BY ext_name", __FILE__, __LINE__);
        if (SQL_NUMROWS($result) > 0) {
                // Extensions are registered
                $SW = 2; $OUT = "";
-               while (list($id, $name, $lang, $active, $css, $ver) = SQL_FETCHROW($result)) {
+               while ($content = SQL_FETCHARRAY($result)) {
                        $CSS = "---";
-                       if (GET_EXT_VERSION("sql_patches") >= "0.0.6") $CSS = TRANSLATE_YESNO($css);
+                       if (GET_EXT_VERSION("sql_patches") >= "0.0.6") $CSS = TRANSLATE_YESNO($content['ext_css']);
 
                        // Prepare data for the row template
                        $content = array(
                                'sw'      => $SW,
-                               'id'      => $id,
-                               'name'    => $name,
-                               'active'  => TRANSLATE_YESNO($active),
-                               'act_val' => $active,
-                               'lang'    => $lang,
+                               'id'      => $content['ext_id'],
+                               'name'    => $content['ext_name'],
+                               'active'  => TRANSLATE_YESNO($content['ext_active']),
+                               'act_val' => $content['ext_active'],
                                'css'     => $CSS,
-                               'ver'     => $ver,
+                               'ver'     => $content['ext_version'],
                        );
 
                        // Load row template and switch color
@@ -281,7 +280,7 @@ ORDER BY ext_name", __FILE__, __LINE__);
 
 case "register": // Register new extension
        $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_task_system WHERE assigned_admin='%s' AND task_type='EXTENSION' LIMIT 1",
-        array(bigintval(GET_ADMIN_ID(get_session('admin_login')))), __FILE__, __LINE__);
+               array(bigintval(GET_ADMIN_ID(get_session('admin_login')))), __FILE__, __LINE__);
        $task_found = SQL_NUMROWS($result);
 
        // Free result
@@ -291,7 +290,7 @@ case "register": // Register new extension
        if (($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($id)), __FILE__, __LINE__);
+                       array(bigintval($id)), __FILE__, __LINE__);
                list($subj) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
 
@@ -301,25 +300,35 @@ case "register": // Register new extension
                        // Extract extension's name from subject...
                        $ext_name = trim(substr($subj, 1, strpos($subj, ":") - 1));
 
-                       // ... so we can finally register and load it in registration mode
-                       $status = EXTENSION_REGISTER($ext_name, $id);
-                       if ($status == true) {
-                               // Extension was found and successfully registered
-                               LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_EXTENSION_REGISTERED);
-
-                               // Do we need to update cache file?
-                               if ((EXT_IS_ACTIVE("cache")) && ($cacheMode != "no")) {
-                                       // Remove cache file (will be auto-created again!)
-                                       if ($cacheInstance->loadCacheFile("config")) $cacheInstance->destroyCacheFile();
-                                       if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
-                                       if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
-                               } // END - if
-                       } elseif (GET_EXT_VERSION($ext_name) != "") {
-                               // Motify the admin that we have a problem here...
-                               LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_REG_FAILED_ALREADY);
+                       // Test the extension for deprecation
+                       $EXT_DEPRECATED = "N"; $EXT_LOAD_MODE = "";
+                       include(PATH."inc/extensions/ext-".$ext_name.".php");
+
+                       // Is the extension deprecated?
+                       if ($EXT_DEPRECATED == "N") {
+                               // ... so we can finally register and load it in registration mode
+                               $status = EXTENSION_REGISTER($ext_name, $id);
+                               if ($status == true) {
+                                       // Extension was found and successfully registered
+                                       LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_EXTENSION_REGISTERED);
+
+                                       // Do we need to update cache file?
+                                       if ((EXT_IS_ACTIVE("cache")) && ($cacheMode != "no")) {
+                                               // Remove cache file (will be auto-created again!)
+                                               if ($cacheInstance->loadCacheFile("config")) $cacheInstance->destroyCacheFile();
+                                               if ($cacheInstance->loadCacheFile("extensions", true)) $cacheInstance->destroyCacheFile();
+                                               if ($cacheInstance->loadCacheFile("mod_reg")) $cacheInstance->destroyCacheFile();
+                                       } // END - if
+                               } elseif (GET_EXT_VERSION($ext_name) != "") {
+                                       // Notify the admin that we have a problem here...
+                                       LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_REG_FAILED_ALREADY);
+                               } else {
+                                       // Notify the admin that we have a problem here...
+                                       LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_REG_FAILED_404);
+                               }
                        } else {
                                // Motify the admin that we have a problem here...
-                               LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_REG_FAILED_404);
+                               LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_REG_FAILED_DEPRECATED);
                        }
                } else {
                        // Extension was not found in task management