Several fixes for extension handling
authorRoland Häder <roland@mxchange.org>
Tue, 16 Dec 2008 21:14:54 +0000 (21:14 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 16 Dec 2008 21:14:54 +0000 (21:14 +0000)
13 files changed:
inc/databases.php
inc/db/lib.php
inc/extensions/ext-cache.php
inc/extensions/ext-theme.php
inc/filters.php
inc/libs/task_functions.php
inc/libs/theme_functions.php
inc/loader/load_cache-them.php
inc/modules/admin/what-theme_edit.php
inc/modules/guest/action-themes.php
inc/modules/member/action-themes.php
inc/mysql-connect.php
inc/stylesheet.php

index ba9e76e..39abdce 100644 (file)
@@ -114,7 +114,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // Current SVN revision
-define('CURR_SVN_REVISION', "636");
+define('CURR_SVN_REVISION', "637");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index 7578d60..4384bfe 100644 (file)
@@ -51,5 +51,8 @@ if ((file_exists($INC)) && (is_readable($INC))) {
        die("Cannot load database abstraction layer! R.I.P.");
 }
 
+// Remove this globally used variable
+unset($INC);
+
 //
 ?>
index 867bf66..d55b2af 100644 (file)
@@ -62,13 +62,13 @@ case "remove": // Do stuff when removing extension
        $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_admin_menu` WHERE what='config_cache' OR what='cache_stats' LIMIT 2";
 
        // Unregister all filters
-       UNREGISTER_FILTER('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE');
-       UNREGISTER_FILTER('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE');
-       UNREGISTER_FILTER('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE');
-       UNREGISTER_FILTER('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE');
+       UNREGISTER_FILTER('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', true);
+       UNREGISTER_FILTER('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', true);
+       UNREGISTER_FILTER('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', true);
+       UNREGISTER_FILTER('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true);
        UNREGISTER_FILTER('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE');
-       UNREGISTER_FILTER('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE');
-       UNREGISTER_FILTER('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE');
+       UNREGISTER_FILTER('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true);
+       UNREGISTER_FILTER('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', true);
        break;
 
 case "activate": // Do stuff when admin activates this extension
@@ -211,13 +211,13 @@ case "update": // Update an extension
 
        case "0.2.1": // SQL queries for v0.2.1
                // Register the new filter
-               REGISTER_FILTER('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE');
-               REGISTER_FILTER('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE');
-               REGISTER_FILTER('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE');
-               REGISTER_FILTER('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE');
-               REGISTER_FILTER('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE');
-               REGISTER_FILTER('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE');
-               REGISTER_FILTER('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE');
+               REGISTER_FILTER('extension_update', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true);
+               REGISTER_FILTER('post_extension_installed', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true);
+               REGISTER_FILTER('post_extension_run_sql', 'CACHE_DESTROY_ON_EXT_CHANGE', false, true);
+               REGISTER_FILTER('post_admin_added', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true);
+               REGISTER_FILTER('post_admin_edited', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true);
+               REGISTER_FILTER('post_admin_deleted', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true);
+               REGISTER_FILTER('post_admin_reset_pass', 'CACHE_DESTROY_ON_ADMIN_CHANGE', false, true);
 
                // Update notes (these will be set as task text!)
                $UPDATE_NOTES = "Filter hinzugef&uuml;gt f&uuml;r Erweiterungsmanagement.";
index 39d74b1..1a95e55 100644 (file)
@@ -54,7 +54,7 @@ case "register": // Do stuff when installation is running (modules.php?module=ad
 
 case "remove": // Do stuff when removing extension
        // Drop theme table
-       $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_themes";
+       $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_themes`";
 
        // Delete admin menu
        $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_admin_menu` WHERE `action`='theme' LIMIT 4";
@@ -62,7 +62,7 @@ case "remove": // Do stuff when removing extension
        // Delete guest menu entries
        $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_guest_menu` WHERE action='themes' LIMIT 1";
 
-       // Delete/update member menu entries
+       // Delete member menu entries
        $SQLs[] = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_member_menu` WHERE action='themes' OR `what`='themes' LIMIT 2";
        break;
 
@@ -110,24 +110,23 @@ case "update": // Update an extension
                break;
 
        case "0.0.7": // SQL queries for v0.0.7
-               $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_themes ADD theme_name VARCHAR(255) NOT NULL DEFAULT ''";
-
                // Update notes (these will be set as task text!)
-               $UPDATE_NOTES = "Designname (von Menschen lesbar) hinzugef&uuml;gt.";
+               $UPDATE_NOTES = "Ung&uuml;ltiges Update.";
                break;
 
        case "0.0.8": // SQL queries for v0.0.8
                // Theme table
-               $SQLs[] = "DROP TABLE IF EXISTS "._MYSQL_PREFIX."_themes";
-               $SQLs[] = "CREATE TABLE "._MYSQL_PREFIX."_themes (
+               $SQLs[] = "DROP TABLE IF EXISTS `"._MYSQL_PREFIX."_themes`";
+               $SQLs[] = "CREATE TABLE `"._MYSQL_PREFIX."_themes` (
 id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 theme_path VARCHAR(255) NOT NULL DEFAULT '',
+theme_name VARCHAR(255) NOT NULL DEFAULT '',
 theme_active ENUM('Y','N') NOT NULL DEFAULT 'N',
 theme_ver VARCHAR(255) NOT NULL DEFAULT '0.0',
-PRIMARY KEY(`id`),
-UNIQUE KEY(`theme_path`),
-INDEX(`theme_active`),
-) TYPE=MyISAM";
+PRIMARY KEY (`id`),
+UNIQUE KEY (`theme_path`),
+INDEX (`theme_active`)
+) TYPE=MyISAM COMMENT='Themes'";
 
                // Admin menu
                $SQLs[] = "INSERT INTO `"._MYSQL_PREFIX."_admin_menu` (`action`,`what`,`title`,`descr`,`sort`) VALUES ('theme', NULL, 'Themes','Verwalten Sie hier alle Designs (Themes) Ihres Mailtausch-Scriptes.', 8)";
index 33c5922..b750c4a 100644 (file)
@@ -92,14 +92,14 @@ ORDER BY `filter_id` ASC", __FILE__, __LINE__);
 }
 
 // "Registers" a new filter function
-function REGISTER_FILTER ($filterName, $filterFunction, $silentAbort = true) {
+function REGISTER_FILTER ($filterName, $filterFunction, $silentAbort = true, $force = false) {
        global $filters;
 
        // Extend the filter function name
        $filterFunction = sprintf("FILTER_%s", strtoupper($filterFunction));
 
        // Is that filter already there?
-       if (isset($filters[$filterName][$filterFunction])) {
+       if ((isset($filters[$filterName][$filterFunction])) && (!$force)) {
                // Then abort here
                if (!$silentAbort) {
                        ADD_FATAL(sprintf(FILTER_FAILED_ALREADY_ADDED, $filterFunction, $filterName));
@@ -121,11 +121,14 @@ function REGISTER_FILTER ($filterName, $filterFunction, $silentAbort = true) {
 }
 
 // "Unregisters" a filter from the given chain
-function UNREGISTER_FILTER ($filterName, $filterFunction) {
+function UNREGISTER_FILTER ($filterName, $filterFunction, $force = false) {
        global $filters;
 
+       // Extend the filter function name
+       $filterFunction = sprintf("FILTER_%s", strtoupper($filterFunction));
+
        // Is that filter there?
-       if (!isset($filters[$filterName][$filterFunction])) {
+       if ((!isset($filters[$filterName][$filterFunction])) && (!$force)) {
                // Not found, so abort here
                ADD_FATAL(sprintf(FILTER_FAILED_NOT_REMOVED, $filterFunction, $filterName));
                return false;
index 978b87b..76d794d 100644 (file)
@@ -485,13 +485,13 @@ ORDER BY beg_points DESC, userid";
 
        if (EXT_IS_ACTIVE("theme")) {
                // List all themes
-               $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_themes ORDER BY id";
+               $SQLs[]   = "SELECT id FROM `"._MYSQL_PREFIX."_themes` ORDER BY id";
                $WHATs[]  = "theme_edit";
                $DESCRs[] = TASK_ADMIN_LIST_THEME_ALL;
                $TITLEs[] = TASK_ADMIN_LIST_THEME_ALL_TITLE;
 
                // List active themes
-               $SQLs[]   = "SELECT id FROM "._MYSQL_PREFIX."_themes WHERE theme_active='Y' ORDER BY id";
+               $SQLs[]   = "SELECT id FROM `"._MYSQL_PREFIX."_themes` WHERE theme_active='Y' ORDER BY id";
                $WHATs[]  = "theme_edit";
                $DESCRs[] = TASK_ADMIN_LIST_THEME_ACTIVE;
                $TITLEs[] = TASK_ADMIN_LIST_THEME_ACTIVE_TITLE;
index 5adb09e..6fbcd98 100644 (file)
@@ -157,7 +157,7 @@ function THEME_GET_VERSION ($name) {
                if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
        } elseif (GET_EXT_VERSION("cache") != "0.1.8") {
                // Load version from database
-               $result = SQL_QUERY_ESC("SELECT theme_ver FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT theme_ver FROM `"._MYSQL_PREFIX."_themes` WHERE theme_path='%s' LIMIT 1",
                        array($name), __FILE__, __LINE__);
 
                // Entry found?
@@ -196,7 +196,7 @@ function THEME_GET_ID ($name) {
                if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
        } elseif (GET_EXT_VERSION("cache") != "0.1.8") {
                // Check if current theme is already imported or not
-               $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT id FROM `"._MYSQL_PREFIX."_themes` WHERE theme_path='%s' LIMIT 1",
                        array($name), __FILE__, __LINE__);
 
                // Entry found?
@@ -241,7 +241,7 @@ function THEME_IS_ACTIVE ($name) {
                if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
        } elseif (GET_EXT_VERSION("cache") != "0.1.8") {
                // Check if current theme is already imported or not
-               $result = SQL_QUERY_ESC("SELECT theme_active FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' AND theme_active='Y' LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT theme_active FROM `"._MYSQL_PREFIX."_themes` WHERE theme_path='%s' AND theme_active='Y' LIMIT 1",
                        array($name), __FILE__, __LINE__);
 
                // Is the theme active and installed?
@@ -277,7 +277,7 @@ function GET_CURR_THEME_NAME () {
                if (isset($_CONFIG['cache_hits'])) { $_CONFIG['cache_hits']++; } else { $_CONFIG['cache_hits'] = 1; }
        } elseif (GET_EXT_VERSION("cache") != "0.1.8") {
                // Check if current theme is already imported or not
-               $result = SQL_QUERY_ESC("SELECT theme_name FROM "._MYSQL_PREFIX."_themes WHERE theme_path='%s' AND theme_active='Y' LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT theme_name FROM `"._MYSQL_PREFIX."_themes` WHERE theme_path='%s' AND theme_active='Y' LIMIT 1",
                        array($name), __FILE__, __LINE__);
 
                // Load theme name
index a92039f..9f09a15 100644 (file)
@@ -69,9 +69,9 @@ if (($cacheInstance->loadCacheFile("themes")) && ($cacheInstance->extensionVersi
 
        // Load all themes and their data
        if (GET_EXT_VERSION("theme") >= "0.0.7") {
-               $result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver, theme_name FROM "._MYSQL_PREFIX."_themes ORDER BY id", __FILE__, __LINE__);
+               $result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver, theme_name FROM `"._MYSQL_PREFIX."_themes` ORDER BY id", __FILE__, __LINE__);
        } else {
-               $result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver FROM "._MYSQL_PREFIX."_themes ORDER BY id", __FILE__, __LINE__);
+               $result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver FROM `"._MYSQL_PREFIX."_themes` ORDER BY id", __FILE__, __LINE__);
        }
        while ($data = SQL_FETCHARRAY($result)) {
                // Add row to cache file
index 7a90246..f5de9a8 100644 (file)
@@ -54,14 +54,14 @@ if ($SEL > 0) {
                if (isset($_POST['status'])) {
                        // Change status
                        if ($_POST['active'][$id] == "Y") {
-                               $SQL = "UPDATE "._MYSQL_PREFIX."_themes SET theme_active='N' WHERE id='".$id."' LIMIT 1";
+                               $SQL = "UPDATE `"._MYSQL_PREFIX."_themes` SET theme_active='N' WHERE id='".$id."' LIMIT 1";
                        } else {
-                               $SQL = "UPDATE "._MYSQL_PREFIX."_themes SET theme_active='Y' WHERE id='".$id."' LIMIT 1";
+                               $SQL = "UPDATE `"._MYSQL_PREFIX."_themes` SET theme_active='Y' WHERE id='".$id."' LIMIT 1";
                        }
                        $OUT = ADMIN_THEMES_UPDATED;
                } elseif (isset($_POST['del'])) {
                        // Delete themes
-                       $SQL = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_themes WHERE id='".$id."' LIMIT 1";
+                       $SQL = "DELETE LOW_PRIORITY FROM `"._MYSQL_PREFIX."_themes` WHERE id='".$id."' LIMIT 1";
                        $OUT = ADMIN_THEMES_DELETED;
                }
 
@@ -98,7 +98,7 @@ $THEME_MODE = "test";
 
 // Generate output lines for the template
 $OUT = ""; $SW = 2;
-$result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver, theme_name FROM "._MYSQL_PREFIX."_themes ORDER BY theme_path", __FILE__, __LINE__);
+$result = SQL_QUERY("SELECT id, theme_path, theme_active, theme_ver, theme_name FROM `"._MYSQL_PREFIX."_themes` ORDER BY theme_path", __FILE__, __LINE__);
 if (SQL_NUMROWS($result) > 0)
 {
        while(list($id, $unix, $active, $ver, $name) = SQL_FETCHROW($result))
index e0b248c..8bbac22 100644 (file)
@@ -46,7 +46,7 @@ if (defined('__THEME_SELECTION_CONTENT')) return false;
 // Load all active designs (or all if admin)
 $whereStatement = ""; $OUT = "";
 if (!IS_ADMIN()) $whereStatement = " WHERE theme_active='Y'";
-$result_themes = SQL_QUERY("SELECT theme_path FROM "._MYSQL_PREFIX."_themes".$whereStatement, __FILE__, __LINE__);
+$result_themes = SQL_QUERY("SELECT theme_path FROM `"._MYSQL_PREFIX."_themes`".$whereStatement, __FILE__, __LINE__);
 $num_themes = SQL_NUMROWS($result_themes);
 
 if ($num_themes > 1) {
index 3b39557..c06b4d9 100644 (file)
@@ -48,7 +48,7 @@ if (defined('__THEME_SELECTION_CONTENT')) return false;
 // Load all active designs (or all if admin)
 $whereStatement = ""; $OUT = "";
 if (!IS_ADMIN()) $whereStatement = " WHERE theme_active='Y'";
-$result_themes = SQL_QUERY("SELECT theme_path FROM "._MYSQL_PREFIX."_themes".$whereStatement, __FILE__, __LINE__);
+$result_themes = SQL_QUERY("SELECT theme_path FROM `"._MYSQL_PREFIX."_themes`".$whereStatement, __FILE__, __LINE__);
 $num_themes = SQL_NUMROWS($result_themes);
 
 if ($num_themes > 1) {
index f52848a..b81ae59 100644 (file)
@@ -151,6 +151,12 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT
                                // Run daily reset
                                require_once(PATH."inc/check-reset.php");
 
+                               // Create missing configuration file
+                               if (!function_exists('GET_CURR_THEME')) {
+                                       // Load dummy theme functions
+                                       require_once(PATH."inc/theme-dummy.php");
+                               } // END - if
+
                                // Load admin include file if he is admin
                                if (IS_ADMIN()) {
                                        // Administrative functions
@@ -255,6 +261,12 @@ if ((!isBooleanConstantAndTrue('mxchange_installing')) && (isBooleanConstantAndT
        require_once(PATH."inc/databases.php");
        require_once(PATH."inc/session.php");
 
+       // Create missing configuration file
+       if (!function_exists('GET_CURR_THEME')) {
+               // Load dummy theme functions
+               require_once(PATH."inc/theme-dummy.php");
+       } // END - if
+
        // Check if we are in installation routine
        $installPhp = basename($_SERVER['PHP_SELF']);
        if (($installPhp != "install.php") && ($CSS != "1") && ($CSS != -1)) {
index 4d7c214..a8e5748 100644 (file)
@@ -56,12 +56,6 @@ if (($CSS == "1") || ($_CONFIG['css_php'] == "DIRECT")) {
                foreach ($EXT_CSS_FILES as $value) $STYLES[] = $value;
        } // END - if
 
-       // Create missing configuration file
-       if (!function_exists('GET_CURR_THEME')) {
-               // Load dummy theme functions
-               require_once(PATH."inc/theme-dummy.php");
-       } // END - if
-
        // Output inclusion lines
        foreach ($STYLES as $value) {
                // Only include found CSS files (to reduce 404 requests)