From fd87494d30afbfc69dafcaaaec43e287be4bc22c Mon Sep 17 00:00:00 2001 From: thomppj Date: Sun, 11 Nov 2001 01:42:15 +0000 Subject: [PATCH] More options updated changes. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1720 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/constants.php | 6 +++-- functions/options.php | 22 ++++++++++++++++ src/load_prefs.php | 25 +++++++++++------- src/options.php | 31 ++++------------------- src/options_display.php | 56 +++++++++++++++++++++++++---------------- 5 files changed, 82 insertions(+), 58 deletions(-) diff --git a/functions/constants.php b/functions/constants.php index 15756f8c..a762b703 100644 --- a/functions/constants.php +++ b/functions/constants.php @@ -17,9 +17,9 @@ /**************************************************************/ /* Define constants for javascript settings. */ + define('SMPREF_JS_OFF', 0); define('SMPREF_JS_ON', 1); - define('SMPREF_JS_OFF', 2); - define('SMPREF_JS_AUTODETECT', 3); + define('SMPREF_JS_AUTODETECT', 2); define('SMPREF_LOC_TOP', 'top'); define('SMPREF_LOC_BETWEEN', 'between'); @@ -27,6 +27,8 @@ define('SMPREF_LOC_LEFT', ''); define('SMPREF_LOC_RIGHT', 'right'); + define('SMPREF_NO', 0); + define('SMPREF_YES', 1); define('SMPREF_NONE', 'none'); do_hook("loading_constants"); diff --git a/functions/options.php b/functions/options.php index e5eeefff..72674ca4 100644 --- a/functions/options.php +++ b/functions/options.php @@ -158,6 +158,28 @@ class SquirrelOption { } function createWidget_Boolean() { + /* Do the whole current value thing. */ + if ($this->value != SMPREF_NO) { + $yes_chk = ' CHECKED'; + $no_chk = ''; + } else { + $yes_chk = ''; + $no_chk = ' CHECKED'; + } + + /* Build the yes choice. */ + $yes_option = ' " + . _("Yes"); + + /* Build the no choice. */ + $no_option = ' " + . _("No"); + + /* Build and return the combined "boolean widget". */ + $result = "$yes_option    $no_option"; + return ($result); } function createWidget_Hidden() { diff --git a/src/load_prefs.php b/src/load_prefs.php index b55a4b30..55ebfc07 100644 --- a/src/load_prefs.php +++ b/src/load_prefs.php @@ -133,19 +133,19 @@ global $editor_size, $use_signature, $prefix_sig; $editor_size = getPref($data_dir, $username, "editor_size", 76 ); - $use_signature = getPref($data_dir, $username, 'use_signature', FALSE ); + $use_signature = getPref($data_dir, $username, 'use_signature', SMPREF_OFF ); $prefix_sig = getPref($data_dir, $username, "prefix_sig"); /* Load preferences for reply citation style. */ global $reply_citation_style, $reply_citation_start, $reply_citation_end; - $reply_citation_style = getPref($data_dir, $username, 'reply_citation_style', 'none' ); + $reply_citation_style = getPref($data_dir, $username, 'reply_citation_style', SMPREF_NONE ); $reply_citation_start = getPref($data_dir, $username, 'reply_citation_start'); $reply_citation_end = getPref($data_dir, $username, 'reply_citation_end'); global $left_refresh, $sort; - $left_refresh = getPref($data_dir, $username, 'left_refresh', 'None' ); + $left_refresh = getPref($data_dir, $username, 'left_refresh', SMPREF_NONE ); $sort = getPref($data_dir, $username, 'sort', 6 ); /** Load up the Signature file **/ @@ -182,17 +182,24 @@ } global $alt_index_colors; - $alt_index_colors = getPref($data_dir, $username, 'alt_index_colors', FALSE ); + $alt_index_colors = getPref($data_dir, $username, 'alt_index_colors', SMPREF_ON ); global $location_of_bar, $location_of_buttons; - $location_of_bar = getPref($data_dir, $username, 'location_of_bar', 'left'); - $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons', 'between' ); + $location_of_bar = getPref($data_dir, $username, 'location_of_bar', SMPREF_LOC_LEFT); + $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons', SMPREF_LOC_BETWEEN); global $collapse_folders, $show_html_default; - $collapse_folders = getPref($data_dir, $username, 'collapse_folders'); + $collapse_folders = getPref($data_dir, $username, 'collapse_folders', SMPREF_ON); /* show_html_default is a int value. */ - $show_html_default = intval(getPref($data_dir, $username, 'show_html_default', 1 ) ); + $show_html_default = intval(getPref($data_dir, $username, 'show_html_default', SMPREF_ON)); + + global $include_self_reply_all; + $include_self_reply_all = getPref($data_dir, $username, 'include_self_reply_all', SMPREF_ON); + + global $page_selector, $page_selector_max; + $page_selector = getPref($data_dir, $username, 'page_selector', SMPREF_ON); + $page_selector_max = getPref($data_dir, $username, 'page_selector_max', 10); /* SqClock now in the core */ global $date_format, $hour_format, $username, $data_dir; @@ -202,7 +209,7 @@ /* Load the javascript settings. */ global $javascript_setting, $javascript_on; $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); - $javascript_on = getPref($data_dir, $username, 'javascript_on', true); + $javascript_on = getPref($data_dir, $username, 'javascript_on', SMPREF_ON); do_hook("loading_prefs"); ?> diff --git a/src/options.php b/src/options.php index aa6b2c0d..8b78c491 100644 --- a/src/options.php +++ b/src/options.php @@ -90,32 +90,11 @@ setPref($data_dir, $username, 'location_of_bar', $new_location_of_bar); setPref($data_dir, $username, 'left_size', $new_left_size); setPref($data_dir, $username, 'left_refresh', $new_left_refresh); - - if (isset($altIndexColors) && $altIndexColors == 1) { - setPref($data_dir, $username, 'alt_index_colors', 1); - } else { - setPref($data_dir, $username, 'alt_index_colors', 0); - } - - setPref($data_dir, $username, 'show_html_default', ($showhtmldefault?1:0) ); - - if (isset($includeselfreplyall)) { - setPref($data_dir, $username, 'include_self_reply_all', 1); - } else { - removePref($data_dir, $username, 'include_self_reply_all'); - } - - if (isset($pageselectormax)) { - setPref($data_dir, $username, 'page_selector_max', $pageselectormax); - } else { - removePref($data_dir, $username, 'page_selector_max', 0 ); - } - - if (isset($pageselector)) { - removePref($data_dir, $username, 'page_selector'); - } else { - setPref($data_dir, $username, 'page_selector', 1); - } + setPref($data_dir, $username, 'alt_index_colors', $new_alt_index_colors); + setPref($data_dir, $username, 'show_html_default', $new_show_html_default); + setPref($data_dir, $username, 'include_self_reply_all', $new_include_self_reply_all); + setPref($data_dir, $username, 'page_selector', $new_page_selector); + setPref($data_dir, $username, 'page_selector_max', $new_page_selector_max); $js_autodetect_results = (isset($new_js_autodetect_results) ? $new_js_autodetect_results : SMPREF_JS_OFF); if ($new_javascript_setting == SMPREF_JS_AUTODETECT) { diff --git a/src/options_display.php b/src/options_display.php index f0aede33..6189c0f7 100644 --- a/src/options_display.php +++ b/src/options_display.php @@ -161,6 +161,41 @@ 'posvals' => $left_refresh_values ); + $optvals[] = array( + 'name' => 'alt_index_colors', + 'caption' => _("Use Alternating Row Colors"), + 'type' => SMOPT_TYPE_BOOLEAN, + 'refresh' => SMOPT_REFRESH_NONE + ); + + $optvals[] = array( + 'name' => 'show_html_default', + 'caption' => _("Show HTML Version by Default"), + 'type' => SMOPT_TYPE_BOOLEAN, + 'refresh' => SMOPT_REFRESH_NONE + ); + + $optvals[] = array( + 'name' => 'include_self_reply_all', + 'caption' => _("Include Self in Reply All"), + 'type' => SMOPT_TYPE_BOOLEAN, + 'refresh' => SMOPT_REFRESH_NONE + ); + + $optvals[] = array( + 'name' => 'page_selector', + 'caption' => _("Use Page Selector"), + 'type' => SMOPT_TYPE_BOOLEAN, + 'refresh' => SMOPT_REFRESH_NONE + ); + + $optvals[] = array( + 'name' => 'page_selector_max', + 'caption' => _("Maximum Number of Pages to Show"), + 'type' => SMOPT_TYPE_INTEGER, + 'refresh' => SMOPT_REFRESH_NONE + ); + /* Build all these values into an array of SquirrelOptions objects. */ $options = createOptionArray($optvals); @@ -179,27 +214,6 @@ /*** NOT YET CONVERTED TO OPTION OBJECTS ***/ - OptionRadio( _("Use alternating row colors?"), - 'altIndexColors', - array( 1 => _("Yes"), - 0 => _("No") ), - $alt_index_colors ); - OptionCheck( _("Show HTML version by default"), - 'showhtmldefault', - $show_html_default, - _("Yes, show me the HTML version of a mail message, if it is available.") ); - OptionCheck( _("Include Self"), - 'includeselfreplyall', - getPref($data_dir, $username, 'include_self_reply_all', FALSE ), - _("Don't remove me from the CC addresses when I use \"Reply All\"") ); - $psw = getPref($data_dir, $username, 'page_selector_max', 10 ); - OptionCheck( _("Page Selector"), - 'pageselector', - !getPref($data_dir, $username, 'page_selector', FALSE ), - _("Show page selector") . - "  " . - _("pages max") ); - echo '
'; do_hook('options_display_inside'); OptionSubmit( 'submit_display' ); -- 2.25.1