Removed sort from url query because we store sort in the session and in case
[squirrelmail.git] / include / options / display.php
index ac209ce831c42113eac2bda067fa3bd3a6e30db5..0753c943ef2865d919857ea667d276f16db3bf76 100644 (file)
@@ -3,12 +3,12 @@
 /**
  * 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
  */
 
@@ -22,11 +22,13 @@ global $use_icons;
 if ($use_icons) {
     global $icon_themes;
     $dirName = SM_PATH . 'images/themes';
-    $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");
+    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");
+            }
         }
     }
 }
@@ -45,7 +47,7 @@ if ($use_icons) {
  * @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, $use_icons;
 
@@ -78,13 +80,16 @@ function load_optpage_data_display() {
     );
  
     $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 ) {
     
@@ -151,22 +156,17 @@ function load_optpage_data_display() {
         '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 ***/
@@ -188,7 +188,6 @@ function load_optpage_data_display() {
         'refresh' => SMOPT_REFRESH_NONE
     );
 
-echo "use icons? $use_icons<br>";
     if ($use_icons) {
         global $icon_themes, $icon_theme;
         $temp = array();
@@ -197,17 +196,26 @@ echo "use icons? $use_icons<br>";
             if ($icon_theme == $icon_themes[$count]['PATH'])
                 $value = $count;
         }
-        $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'
-        );
+        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"),
@@ -391,6 +399,15 @@ echo "use icons? $use_icons<br>";
         '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"),
@@ -432,8 +449,7 @@ echo "use icons? $use_icons<br>";
     /* Assemble all this together and return it as our result. */
     $result = array(
         'grps' => $optgrps,
-        'vals' => $optvals,
-        'xtra' => $onLoadScript
+        'vals' => $optvals
     );
     return ($result);
 }
@@ -470,18 +486,10 @@ function save_option_theme($option) {
  * This function saves the javascript detection option.
  */
 function save_option_javascript_autodetect($option) {
-    global $data_dir, $username, $new_javascript_setting;
+    global $data_dir, $username;
 
-    /* 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_option($option);
+    checkForJavascript(TRUE);
 }
 
 /** 
@@ -502,4 +510,21 @@ function icon_theme_save($option) {
 
 }
 
+/** 
+ * This function saves the reply prefix (body_quote) character(s)
+ */
+function save_option_reply_prefix($option) {
+    global $data_dir, $username, $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);
+
+}
+
 ?>