/**
* options_display.php
*
- * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Copyright (c) 1999-2004 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* Displays all optinos about display preferences
*
- * $Id$
+ * @version $Id$
* @package squirrelmail
*/
define('SMOPT_GRP_MAILBOX', 1);
define('SMOPT_GRP_MESSAGE', 2);
+// 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");
+ }
+ }
+ }
+}
+
/**
* This function builds an array with all the information about
* the options available to the user, and returns it. The options
* @return array all option information
*/
function load_optpage_data_display() {
- global $theme, $language, $languages, $js_autodetect_results,
+ global $theme, $language, $languages, $js_autodetect_results, $javascript_setting,
$compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
- $optmode, $show_alternative_names, $available_languages;
+ $optmode, $show_alternative_names, $available_languages, $use_icons;
/* Build a simple array into which we will build options. */
$optgrps = array();
);
$css_values = array( 'none' => _("Default" ) );
- $handle=opendir('../themes/css/');
- while ($file = readdir($handle) ) {
- if ( substr( $file, -4 ) == '.css' ) {
- $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
+
+ if (is_readable(SM_PATH . 'themes/css') && is_dir(SM_PATH . 'themes/css')) {
+ $handle=opendir(SM_PATH . 'themes/css');
+ while ($file = readdir($handle) ) {
+ if ( substr( $file, -4 ) == '.css' ) {
+ $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
+ }
}
+ closedir($handle);
}
- closedir($handle);
if ( count( $css_values ) > 1 ) {
'refresh' => SMOPT_REFRESH_ALL,
'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
SMPREF_JS_ON => _("Always"),
- SMPREF_JS_OFF => _("Never"))
+ SMPREF_JS_OFF => _("Never")),
+ 'save' => 'save_option_javascript_autodetect',
+ 'script' => 'onclick="document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\';"'
);
-
- if ($optmode != 'submit')
- $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\'';
- else
- $onLoadScript = '';
-
$optvals[SMOPT_GRP_GENERAL][] = array(
'name' => 'js_autodetect_results',
'caption' => '',
'type' => SMOPT_TYPE_HIDDEN,
- 'refresh' => SMOPT_REFRESH_NONE,
+ 'refresh' => SMOPT_REFRESH_NONE
//'post_script' => $js_autodetect_script,
- 'save' => 'save_option_javascript_autodetect'
);
/*** Load the General Options into the array ***/
'refresh' => SMOPT_REFRESH_NONE
);
+ if ($use_icons) {
+ global $icon_themes, $icon_theme;
+ $temp = array();
+ for ($count = 0; $count < sizeof($icon_themes); $count++) {
+ $temp[$count] = $icon_themes[$count]['NAME'];
+ if ($icon_theme == $icon_themes[$count]['PATH'])
+ $value = $count;
+ }
+ if (sizeof($icon_themes) > 0) {
+ $optvals[SMOPT_GRP_MAILBOX][] = array(
+ 'name' => 'icon_theme',
+ 'caption' => _("Message Flags Icon Theme"),
+ 'type' => SMOPT_TYPE_STRLIST,
+ 'refresh' => SMOPT_REFRESH_NONE,
+ 'posvals' => $temp,
+ 'initial_value' => $value,
+ 'save' => 'icon_theme_save'
+ );
+ }
+ }
+
+ $optvals[SMOPT_GRP_MAILBOX][] = array(
+ 'name' => 'show_flag_buttons',
+ 'caption' => _("Show Flag / Unflag Buttons"),
+ 'type' => SMOPT_TYPE_BOOLEAN,
+ 'refresh' => SMOPT_REFRESH_NONE
+ );
+
$optvals[SMOPT_GRP_MAILBOX][] = array(
'name' => 'page_selector',
'caption' => _("Enable Page Selector"),
'refresh' => SMOPT_REFRESH_NONE
);
+ $optvals[SMOPT_GRP_MESSAGE][] = array(
+ 'name' => 'body_quote',
+ 'caption' => _("Prefix for Original Message when Replying"),
+ 'type' => SMOPT_TYPE_STRING,
+ 'refresh' => SMOPT_REFRESH_NONE,
+ 'size' => SMOPT_SIZE_TINY,
+ 'save' => 'save_option_reply_prefix'
+ );
+
$optvals[SMOPT_GRP_MESSAGE][] = array(
'name' => 'reply_focus',
'caption' => _("Cursor Position when Replying"),
/* Assemble all this together and return it as our result. */
$result = array(
'grps' => $optgrps,
- 'vals' => $optvals,
- 'xtra' => $onLoadScript
+ 'vals' => $optvals
);
return ($result);
}
* This function saves the javascript detection option.
*/
function save_option_javascript_autodetect($option) {
+ global $data_dir, $username;
+
+ save_option($option);
+ checkForJavascript(TRUE);
+}
+
+/**
+ * This function saves the user's icon theme setting
+ */
+function icon_theme_save($option) {
+
+ global $icon_themes, $data_dir, $username;
+
+
+ // Don't assume the new value is there, double check
+ // and only save if found
+ //
+ if (isset($icon_themes[$option->new_value]['PATH']))
+ setPref($data_dir, $username, 'icon_theme', $icon_themes[$option->new_value]['PATH']);
+ else
+ setPref($data_dir, $username, 'icon_theme', 'none');
+
+}
+
+/**
+ * This function saves the reply prefix (body_quote) character(s)
+ */
+function save_option_reply_prefix($option) {
global $data_dir, $username, $new_javascript_setting;
- /* Set javascript either on or off. */
- if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
- if ($option->new_value == SMPREF_JS_ON) {
- setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
- } else {
- setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
- }
- } else {
- setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
- }
+ // save as "NONE" if it was blanked out
+ //
+ if (empty($option->new_value)) $option->new_value = 'NONE';
+
+
+ // Save the option like normal.
+ //
+ save_option($option);
+
}
?>