From: Roland Häder Date: Tue, 6 Oct 2009 20:45:35 +0000 (+0000) Subject: Fixed for loading themes, no longer needed parameters removed X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=af71686cb6c6e59eee9c206b36342f7dd7164c1f Fixed for loading themes, no longer needed parameters removed --- diff --git a/inc/libs/theme_functions.php b/inc/libs/theme_functions.php index 44363a8c7c..eb85579a28 100644 --- a/inc/libs/theme_functions.php +++ b/inc/libs/theme_functions.php @@ -42,12 +42,18 @@ if (!defined('__SECURITY')) { require($INC); } -// Create a selection box with installed and activated themes -function generateThemeSelectionBox ($mod, $act, $wht, $result) { +// Create a selection box with installed and activated themes or all if admin +function generateThemeSelectionBox () { + // Init variables and fill them if set + $what = ''; + $mod = getModule(); + if (isWhatSet()) { + $what = getWhat(); + } // END - if + // Construction URL - $formAction = "{!URL!}/modules.php?module=".$mod; - if (!empty($act)) $formAction .= "&action=".$act; - if (!empty($wht)) $formAction .= "&what=".$wht; + $formAction = "{!URL!}/modules.php?module=" . $mod; + if (!empty($what)) $formAction .= "&what=" . $what; // Initialize array $themesArray = array( @@ -55,10 +61,21 @@ function generateThemeSelectionBox ($mod, $act, $wht, $result) { 'theme_name' => array() // Title ); + // Only activated themes for the user + $add = " WHERE `theme_active`='Y'"; + + // Do we have admin? + if (IS_ADMIN()) $add = ''; + + // Select all themes we want + $result = SQL_QUERY("SELECT `theme_path`, `theme_name` FROM `{!_MYSQL_PREFIX!}_themes`".$add." ORDER BY `theme_name` ASC", __FILE__, __LINE__); + // Load all themes while ($content = SQL_FETCHARRAY($result)) { - // Load it's theme.php file + // Construct relative include file name $INC = sprintf("theme/%s/theme.php", SQL_ESCAPE($content['theme_path'])); + + // Load it's theme.php file if found if (isIncludeReadable($INC)) { // And save all data in array loadInclude($INC); @@ -67,8 +84,8 @@ function generateThemeSelectionBox ($mod, $act, $wht, $result) { } // END - if } // END - while - // Sort whole array by title - array_pk_sort($themesArray, array('theme_name')); + // Free the result + SQL_FREERESULT($result); // Construct selection form for the box template $OUT = ''; diff --git a/inc/modules/guest/action-themes.php b/inc/modules/guest/action-themes.php index 06fba85c3a..1edf21289c 100644 --- a/inc/modules/guest/action-themes.php +++ b/inc/modules/guest/action-themes.php @@ -56,9 +56,7 @@ if (IS_ADMIN()) { if ($num_themes > 1) { // If more than 1 is installed output selection box - $act = ''; - if (isActionSet()) $act = getAction(); - $OUT = generateThemeSelectionBox('index', $act, getWhat(), $result_themes); + $OUT = generateThemeSelectionBox(); } elseif (($num_themes == 1) || ((!IS_ADMIN()) && ($num_themes == 0))) { // If there's only one just output it's name define('__THEME_NAME', getCurrentThemeName()); @@ -68,9 +66,6 @@ if ($num_themes > 1) { $OUT = LOAD_TEMPLATE('admin_settings_saved', true, "
{--ADMIN_NO_THEME_INSTALLED_WARNING--}
"); } -// Free memory -SQL_FREERESULT($result_themes); - // Load final box template LOAD_TEMPLATE('theme_select_box', false, $OUT); diff --git a/inc/modules/member/action-themes.php b/inc/modules/member/action-themes.php index b4cdecf965..86ad7ff2c1 100644 --- a/inc/modules/member/action-themes.php +++ b/inc/modules/member/action-themes.php @@ -58,10 +58,7 @@ if (IS_ADMIN()) { if ($num_themes > 1) { // If more than 1 is installed output selection box - $act = ''; $wht = ''; - if (isActionSet()) $act = getAction(); - if (isWhatSet()) $wht = getWhat(); - $OUT = generateThemeSelectionBox('login', $act, $wht, $result_themes); + $OUT = generateThemeSelectionBox(); } elseif (($num_themes == 1) || ((!IS_ADMIN()) && ($num_themes == 0))) { // If there's only one just output it's name define('__THEME_NAME', getCurrentThemeName()); @@ -71,9 +68,6 @@ if ($num_themes > 1) { $OUT = LOAD_TEMPLATE('admin_settings_saved', true, "
{--ADMIN_NO_THEME_INSTALLED_WARNING--}
"); } -// Free memory -SQL_FREERESULT($result_themes); - // Load final box template LOAD_TEMPLATE('theme_select_box', false, $OUT);