-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__);
- } 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__);
- }
-
- // 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)) {
- $CSS = "---";
- if (GET_EXT_VERSION("sql_patches") >= "0.0.6") $CSS = TRANSLATE_YESNO($css);
-
- // Prepare data for the row template
- $content = array(
- 'sw' => $SW,
- 'id' => $id,
- 'name' => $name,
- 'active' => TRANSLATE_YESNO($active),
- 'act_val' => $active,
- 'lang' => $lang,
- 'css' => $CSS,
- 'ver' => $ver,
- );
-
- // Load row template and switch color
- $OUT .= LOAD_TEMPLATE("admin_extensions_row", true, $content);
- $SW = 3 - $SW;
- }
-
- // Free memory
- SQL_FREERESULT($result);
-
- // Remember rows in constant for the template
- define('__EXT_ROWS', $OUT);
-
- // Load template
- LOAD_TEMPLATE("admin_extensions");
- } else {
- // No extensions are registered
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NO_EXTENSION_REGISTERED."</FONT>");
- }
- // Link for checking for new or updated extensions
- OUTPUT_HTML("<br /><A href=\"".URL."/modules.php?module=admin&what=extensions&do=search\">".ADMIN_SEARCH_NEW_EXTENSIONS."</A>");
- break;
-
-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__);
- $task_found = SQL_NUMROWS($result);
-
- // Free result
- SQL_FREERESULT($result);
-
- // Is the ID number valid and the task was found?
- 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__);
- list($subj) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
-
- // Disable cache update by default
- $cacheInstance_UPDATE = "0";
- if (!empty($subj)) {
- // 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();
- }
- } 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);
- } else {
- // Motify the admin that we have a problem here...
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_REG_FAILED_404);
- }