From: stevetruckstuff Date: Mon, 2 Oct 2006 21:22:59 +0000 (+0000) Subject: Minor modifications to handle moving of icon themes to conf.pl X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=1e7218745fd9a5d248bc896661b0d44fc23bcde5;ds=sidebyside Minor modifications to handle moving of icon themes to conf.pl git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11816 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/include/load_prefs.php b/include/load_prefs.php index d35b088c..8a68404d 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -57,6 +57,7 @@ $chosen_theme_path = empty($chosen_theme) ? $chosen_theme_path = 'u_'.$user_themes[$user_theme_default]['PATH'] : $chosen_theme; +// Make sure the chosen theme is a legitimate one. // need to adjust $chosen_theme path with SM_PATH $chosen_theme_path = preg_replace("/(\.\.\/){1,}/", SM_PATH, $chosen_theme_path); $k = 0; @@ -102,8 +103,24 @@ if (isset($chosen_theme) && $found_theme && (file_exists($chosen_theme))) { } */ + // user's icon theme, if using icons -$icon_theme = getPref($data_dir, $username, 'icon_theme', 'images/themes/xp/' ); +$icon_theme = getPref($data_dir, $username, 'icon_theme'); +$default_icon_theme = $icon_themes[$icon_theme_def]['PATH']; +$found_theme = false; + +// Make sure the chosen icon theme is a legitimate one. +// need to adjust $icon_theme path with SM_PATH +$icon_theme = preg_replace("/(\.\.\/){1,}/", SM_PATH, $icon_theme); +$k = 0; +while (!$found_theme && $k < count($icon_themes)) { + if ($icon_themes[$k]['PATH'] == $icon_theme) + $found_theme = true; + $k++; +} +if (!$found_theme) { + $icon_theme = $default_icon_theme; +} /* * NOTE: The $icon_theme_path var should contain the path to the icon diff --git a/include/options/display.php b/include/options/display.php index b88a2dbf..caa1ab9f 100644 --- a/include/options/display.php +++ b/include/options/display.php @@ -16,27 +16,6 @@ define('SMOPT_GRP_GENERAL', 0); define('SMOPT_GRP_MAILBOX', 1); define('SMOPT_GRP_MESSAGE', 2); -/** - * Icon themes and user CSS themes should probably both be moved to conf.pl - * - * TODO: move to conf.pl - **/ -// load icon themes if in use -global $use_icons; -if ($use_icons) { - global $icon_themes; - $dirName = SM_PATH . 'images/themes'; - if (is_readable($dirName) && is_dir($dirName)) { - $d = dir($dirName); - while($dir = $d->read()) { - if ($dir != "." && $dir != "..") { - if (is_dir($dirName."/".$dir) && file_exists("$dirName/$dir/theme.php")) - include("$dirName/$dir/theme.php"); - } - } - } -} - global $use_iframe; if (! isset($use_iframe)) $use_iframe=false; @@ -56,8 +35,9 @@ if (! isset($use_iframe)) $use_iframe=false; function load_optpage_data_display() { global $theme, $fontsets, $language, $languages,$aTemplateSet, $default_use_mdn, $squirrelmail_language, $allow_thread_sort, - $show_alternative_names, $use_icons, $use_iframe, $sTemplateID, - $oTemplate, $user_themes, $chosen_theme; + $show_alternative_names, $use_iframe, $use_icons, + $sTemplateID, $oTemplate, + $user_themes, $chosen_theme; /* Build a simple array into which we will build options. */ $optgrps = array(); diff --git a/templates/util_global.php b/templates/util_global.php index b2eee612..9ef9e040 100644 --- a/templates/util_global.php +++ b/templates/util_global.php @@ -61,7 +61,7 @@ function getIcon($icon_theme_path, $icon_name, $text_icon, $alt_text='', $w=NULL * @since 1.5.2 */ function getIconPath ($icon_theme_path, $icon_name) { - global $icon_theme_def; + global $default_icon_theme; if (is_null($icon_theme_path)) return NULL; @@ -71,8 +71,8 @@ function getIconPath ($icon_theme_path, $icon_name) { return $icon_theme_path . $icon_name; // Icon not found, check for the admin-specified default - } elseif (!is_null($icon_theme_def) && is_file($icon_theme_def . $icon_name)) { - return $icon_theme_def . $icon_name; + } elseif (!is_null($default_icon_theme) && is_file($default_icon_theme . $icon_name)) { + return $default_icon_theme . $icon_name; // Icon not found, return the SQM default icon } elseif (is_file(SM_PATH . 'images/themes/default/'.$icon_name)) {