X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-extensions.php;h=196bd01558baa4d0384bf310b79577f469755ce2;hp=e81f62f2496d6fe7260927dcd692c78eb4b044ce;hb=3b85bd5030ad591b0c5cb038ca534a7b50e1b319;hpb=61b77b466ed51b55406cce2671c6ad3991b350a9 diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php index e81f62f249..196bd01558 100644 --- a/inc/modules/admin/what-extensions.php +++ b/inc/modules/admin/what-extensions.php @@ -38,7 +38,7 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) { } // Add description as navigation point -ADD_DESCR("admin", basename(__FILE__)); +ADD_DESCR("admin", __FILE__); global $cacheInstance, $cacheArray, $cacheMode; @@ -164,17 +164,18 @@ if (!empty($_GET['reg_ext'])) { $ext_name = GET_EXT_NAME($id); $ext_ver = GET_EXT_VERSION($ext_name); - // Free the result - SQL_FREERESULT($result); - if ($_CONFIG['verbose_sql']) { // Load SQL commands in remove mode $EXT_LOAD_MODE = "remove"; + $EXT_ALWAYS_ACTIVE = "N"; $file = sprintf("%sinc/extensions/ext-%s.php", PATH, $ext_name); - include($file); + if (FILE_READABLE($file)) { + // Load file + include($file); - // Generate extra table with loaded SQL commands - $VERBOSE_OUT = EXTENSION_VERBOSE_TABLE($SQLs); + // Generate extra table with loaded SQL commands + $VERBOSE_OUT = EXTENSION_VERBOSE_TABLE($SQLs); + } } // END - if // Prepare data for the row template @@ -227,36 +228,35 @@ 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_lang_file, ext_active, ext_has_css, ext_version - FROM "._MYSQL_PREFIX."_extensions - ".$where." - ORDER BY ext_name", __FILE__, __LINE__); + $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_lang_file, ext_active, id, ext_version - FROM "._MYSQL_PREFIX."_extensions - ".$where." - ORDER BY ext_name", __FILE__, __LINE__); + $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__); } // Are there some entries? 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 @@ -280,7 +280,7 @@ case "overview": // List all registered extensions 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 @@ -290,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); @@ -300,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->cache_file("config" , true)) $cacheInstance->cache_destroy(); - if ($cacheInstance->cache_file("extensions", true)) $cacheInstance->cache_destroy(); - if ($cacheInstance->cache_file("mod_reg" , true)) $cacheInstance->cache_destroy(); - } // 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 = "test"; + 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