Philippe - let's make sure we make this work for BOTH netscape and IE. I will install...
[squirrelmail.git] / src / options.php
index 1c3067147bd6ea3c3b61479d2ca6ec10713d89dc..4724989957e2ec809a1889d5ccc28e6e6f3acb68 100644 (file)
 ?>
 
 <br>
-<table bgcolor="<?php echo $color[0] ?>" width="95%" align="center" cellpadding="2" cellspacing="0" border="0">
-<tr><td align="center">
+<TABLE BGCOLOR="<?php echo $color[0] ?>" WIDTH="95%" align="center" CELLPADDING="2" CELLSPACING="0" BORDER="0">
+<TR><TD align="center">
     <b><?php echo _("Options") ?></b><br>
 
-    <table width="100%" border="0" cellpadding="5" cellspacing="0">
-    <tr><td bgcolor="<?php echo $color[4] ?>" align="center">
+    <TABLE WIDTH="100%" BORDER="0" CELLPADDING="5" CELLSPACING="0">
+    <TR><TD BGCOLOR="<?php echo $color[4] ?>" align="center">
 
 <?php
     if (isset($submit_personal)) {
         /* Save personal information. */
-        if (isset($full_name)) {
-           setPref($data_dir, $username, 'full_name', $full_name);
-        }
-        if (isset($email_address)) {
-           setPref($data_dir, $username, 'email_address', $email_address);
-        }
-        if (isset($reply_to)) {
-           setPref($data_dir, $username, 'reply_to', $reply_to);
-        }
+        setPref($data_dir, $username, 'full_name', $new_full_name);
+        setPref($data_dir, $username, 'email_address', $new_email_address);
+        setPref($data_dir, $username, 'reply_to', $new_reply_to);
         setPref($data_dir, $username, 'reply_citation_style', $new_reply_citation_style);
         setPref($data_dir, $username, 'reply_citation_start', $new_reply_citation_start);
         setPref($data_dir, $username, 'reply_citation_end', $new_reply_citation_end);
-        if (! isset($usesignature))
-            $usesignature = 0;
-        setPref($data_dir, $username, 'use_signature', $usesignature);  
-        if (! isset($prefixsig)) {
-            $prefixsig = 0;
-        }
-        setPref($data_dir, $username, 'prefix_sig', $prefixsig);
-        if (isset($signature_edit)) {
-            setSig($data_dir, $username, $signature_edit);
-        }
+        setPref($data_dir, $username, 'use_signature', $new_use_signature);
+        setPref($data_dir, $username, 'prefix_sig', $new_prefix_sig);
+        setSig($data_dir, $username, $new_signature_abs);
       
         do_hook('options_personal_save');
       
         echo '<br><b>'._("Successfully saved personal information!").'</b><br>';
     } else if (isset($submit_display)) {
-        // Do checking to make sure $chosentheme is in the array
-        $in_ary = false;
+        /* Do checking to make sure $new_theme is in the array. */
+        $theme_in_array = false;
         for ($i=0; $i < count($theme); $i++) {
-            if ($theme[$i]['PATH'] == $chosentheme) {
-                $in_ary = true;
+            if ($theme[$i]['PATH'] == $new_chosen_theme) {
+                $theme_in_array = true;
                 break;
             }
         }
-        if (! $in_ary) {
-            $chosentheme = '';
+        if (!$theme_in_array) {
+            $new_chosen_theme = '';
         }
    
         /* Save display preferences. */
-        setPref($data_dir, $username, 'chosen_theme', $chosentheme);
-        setPref($data_dir, $username, 'language', $language);
-        setPref($data_dir, $username, 'use_javascript_addr_book', $javascript_abook);
-        setPref($data_dir, $username, 'show_num', $shownum);
-        setPref($data_dir, $username, 'wrap_at', $wrapat);
-        setPref($data_dir, $username, 'editor_size', $editorsize);
-        setPref($data_dir, $username, 'left_refresh', $leftrefresh);
-        setPref($data_dir, $username, 'location_of_bar', $folder_new_location);
-        setPref($data_dir, $username, 'location_of_buttons', $button_new_location);
-        setPref($data_dir, $username, 'left_size', $leftsize);
-
-        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');
+        setPref($data_dir, $username, 'chosen_theme', $new_chosen_theme);
+        setPref($data_dir, $username, 'language', $new_language);
+        setPref($data_dir, $username, 'use_javascript_addr_book', $new_use_javascript_addr_book);
+        setPref($data_dir, $username, 'javascript_setting', $new_javascript_setting);
+        setPref($data_dir, $username, 'show_num', $new_show_num);
+        setPref($data_dir, $username, 'wrap_at', $new_wrap_at);
+        setPref($data_dir, $username, 'editor_size', $new_editor_size);
+        setPref($data_dir, $username, 'location_of_buttons', $new_location_of_buttons);
+        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);
+        setPref($data_dir, $username, 'show_xmailer_default', $new_show_xmailer_default);
+        setPref($data_dir, $username, 'attachment_common_show_images', $new_attachment_common_show_images);
+        setPref($data_dir, $username, 'pf_subtle_link', $new_pf_subtle_link);
+        setPref($data_dir, $username, 'pf_cleandisplay', $new_pf_cleandisplay);
+
+        $js_autodetect_results = (isset($new_js_autodetect_results) ? $new_js_autodetect_results : SMPREF_JS_OFF);
+        if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
+            if ($js_autodetect_results == 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, 'page_selector', 1);
+            setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
         }
 
         do_hook('options_display_save');
 
         echo '<br><b>'._("Successfully saved display preferences!").'</b><br>';
-        echo '<a href="../src/webmail.php?right_frame=options.php" target=_top>' . _("Refresh Page") . '</a><br>';
+        echo '<A HREF="../src/webmail.php?right_frame=options.php" target=_top>' . _("Refresh Page") . '</A><br>';
     } else if (isset($submit_folder)) { 
-        /* Save folder preferences. */
-        if ($trash != 'none') {
-            setPref($data_dir, $username, 'move_to_trash', true);
-           setPref($data_dir, $username, 'trash_folder', $trash);
+        /* Save trash folder preferences. */
+        if ($new_trash_folder != SMPREF_NONE) {
+            setPref($data_dir, $username, 'move_to_trash', SMPREF_ON);
+            setPref($data_dir, $username, 'trash_folder', $new_trash_folder);
         } else {
-            setPref($data_dir, $username, 'move_to_trash', '0');
-            setPref($data_dir, $username, 'trash_folder', 'none');
+            setPref($data_dir, $username, 'move_to_trash', SMPREF_OFF);
+            setPref($data_dir, $username, 'trash_folder', SMPREF_NONE);
         }
-        if ($sent != 'none') {
-            setPref($data_dir, $username, 'move_to_sent', true);
-            setPref($data_dir, $username, 'sent_folder', $sent);
+
+        /* Save sent folder preferences. */
+        if ($new_sent_folder != SMPREF_NONE) {
+            setPref($data_dir, $username, 'move_to_sent', SMPREF_ON);
+            setPref($data_dir, $username, 'sent_folder', $new_sent_folder);
         } else {
-            setPref($data_dir, $username, 'move_to_sent', '0');
-            setPref($data_dir, $username, 'sent_folder', 'none');
+            setPref($data_dir, $username, 'move_to_sent', SMPREF_OFF);
+            setPref($data_dir, $username, 'sent_folder', SMPREF_NONE);
         }
-        if ($draft != 'none') {
-            setPref($data_dir, $username, 'save_as_draft', true);
-            setPref($data_dir, $username, 'draft_folder', $draft);
+
+        /* Save draft folder preferences. */
+        if ($new_draft_folder != SMPREF_NONE) {
+            setPref($data_dir, $username, 'save_as_draft', SMPREF_ON);
+            setPref($data_dir, $username, 'draft_folder', $new_draft_folder);
         } else {
-            setPref($data_dir, $username, 'save_as_draft', '0');
-            setPref($data_dir, $username, 'draft_folder', 'none');
+            setPref($data_dir, $username, 'save_as_draft', SMPREF_OFF);
+            setPref($data_dir, $username, 'draft_folder', SMPREF_NONE);
         }
+
+        /* Save folder prefix preferences. */
         if (isset($folderprefix)) {
             setPref($data_dir, $username, 'folder_prefix', $folderprefix);
         } else {
             setPref($data_dir, $username, 'folder_prefix', '');
         }
-        setPref($data_dir, $username, 'unseen_notify', $unseennotify);
-        setPref($data_dir, $username, 'unseen_type', $unseentype);
-        if (isset($collapsefolders))
-             setPref($data_dir, $username, 'collapse_folders', $collapsefolders);
-        else
-             removePref($data_dir, $username, 'collapse_folders');
-        setPref($data_dir, $username, 'date_format', $dateformat);
-        setPref($data_dir, $username, 'hour_format', $hourformat);
+
+        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);
+        setPref($data_dir, $username, 'unseen_notify', $new_unseen_notify);
+        setPref($data_dir, $username, 'unseen_type', $new_unseen_type);
+        setPref($data_dir, $username, 'collapse_folders', $new_collapse_folders);
+        setPref($data_dir, $username, 'date_format', $new_date_format);
+        setPref($data_dir, $username, 'hour_format', $new_hour_format);
+
         do_hook('options_folders_save');
         echo '<br><b>'._("Successfully saved folder preferences!").'</b><br>';
-        echo '<a href="../src/left_main.php" target=left>' . _("Refresh Folder List") . '</a><br>';
+        echo '<A HREF="../src/left_main.php" target=left>' . _("Refresh Folder List") . '</A><br>';
     } else {
         do_hook('options_save');
     }
     /*****************************************************/
     /* Let's sort Javascript Option Pages to the bottom. */
     /*****************************************************/
+    $js_optionpages = array();
+    $reg_optionpages = array();
     foreach ($optionpages as $optpage) {
-        if ($optpage['js']) {
+        if (!$optpage['js']) {
+            $reg_optionpages[] = $optpage;
+        } else if ($javascript_on == SMPREF_JS_ON) {
             $js_optionpages[] = $optpage;
-        } else {
-            $nojs_optionpages[] = $optpage;
         }
     }
-    $optionpages = array_merge($nojs_optionpages, $js_optionpages);
+    $optionpages = array_merge($reg_optionpages, $js_optionpages);
 
     /********************************************/
     /* Now, print out each option page section. */
     /********************************************/
     $first_optpage = false;
+    echo "<TABLE BGCOLOR=\"$color[4]\" WIDTH=\"100%\" CELLPADDING=0 CELLSPACING=\"5\" BORDER=\"0\">" .
+                '<TR><TD VALIGN="TOP">' .
+                   "<TABLE BGCOLOR=\"$color[4]\" WIDTH=\"100%\" CELLPADDING=\"3\" CELLSPACING=\"0\" BORDER=\"0\">";
     foreach ($optionpages as $next_optpage) {
         if ($first_optpage == false) {
             $first_optpage = $next_optpage;
         print_optionpages_row($first_optpage);
     }
 
+    echo '</TABLE>' .
+                '</TD></TR>' .
+             "</TABLE>\n";
+
     do_hook('options_link_and_description');
 
 ?>
-    </td></tr>
-    </table>
+    </TD></TR>
+    </TABLE>
 
-</td></tr>
-</table>
+</TD></TR>
+</TABLE>
 
 </body></html>
 
     /*******************************************************************/
 
     /**
-     * This function prints out an option page row. All it actually
-     * does is call the three functions below.
+     * This function prints out an option page row.
      */
     function print_optionpages_row($leftopt, $rightopt = false) {
-        if ($rightopt == false) {
-            if ($leftopt['js']) {
-                print_optionpages_row_fulljs($leftopt);
-            } else {
-                print_optionpages_row_nojs($leftopt);
-            }
-        } else {
-            if ($leftopt['js']) {
-                if ($rightopt['js']) {
-                    print_optionpages_row_fulljs($leftopt, $rightopt);
-                } else {
-                    print_optionpages_row_partjs($leftopt, $rightopt);
-                }
-            } else {
-                print_optionpages_row_nojs($leftopt, $rightopt);
-            }
-        }
-    }
-
-    /**
-     * This function prints out an option page row: in which the left
-     *   Left:  options for functionality that do not require javascript
-     *   Right: options for functionality that do not require javascript
-     */
-    function print_optionpages_row_nojs($leftopt, $rightopt = false) {
         global $color;
-?>
-<table bgcolor="<?php echo $color[4] ?>" width="100%" cellpadding="0" cellspacing="5" border="0">
-   <tr><td valign=top>
-      <table width="100%" cellpadding="3" cellspacing="0" border="0">
-         <tr>
-            <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%">
-               <a href="<?php echo $leftopt['url'] ?>"><?php echo $leftopt['name'] ?></a>
-            </td>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
-<?php if ($rightopt != false) { ?>
-            <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%">
-               <a href="<?php echo $rightopt['url'] ?>"><?php echo $rightopt['name'] ?></a>
-            </td>
-<?php } else { ?>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>" width="50%">&nbsp;</td>
-<?php } ?>
-         </tr>
-         <tr>
-            <td valign="top" bgcolor="<?php echo $color[0] ?>">
-               <?php echo $leftopt['desc'] ?>
-            </td>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
-<?php if ($rightopt != false) { ?>
-            <td valign="top" bgcolor="<?php echo $color[0] ?>">
-               <?php echo $rightopt['desc'] ?>
-            </td>
-<?php } else { ?>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
-<?php } ?>
-         </tr>
-      </table>
-   </td></tr>
-</table>
-<?php
-    }
 
-    /**
-     * This function prints out an option page row: in which the left
-     *   Left:  options for functionality that does not require javascript
-     *   Right: options for functionality that are javascript only
-     */
-    function print_optionpages_row_partjs($leftopt, $rightopt = false) {
-        global $color;
-?>
-<table bgcolor="<?php echo $color[4] ?>" width="100%" cellpadding="0" cellspacing="5" border="0">
-   <tr><td valign=top>
-      <table width="100%" cellpadding="3" cellspacing="0" border="0">
-         <tr>
-            <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%">
-               <a href="<?php echo $leftopt['url'] ?>"><?php echo $leftopt['name'] ?></a>
-            </td>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
-<?php if ($rightopt != false) { ?>
-            <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%">
-               <a href="<?php echo $rightopt['url'] ?>"><?php echo $rightopt['name'] ?></a>
-            </td>
-<?php } else { ?>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>" width="50%">&nbsp;</td>
-<?php } ?>
-         </tr>
-         <tr>
-            <td valign="top" bgcolor="<?php echo $color[0] ?>">
-               <?php echo $leftopt['desc'] ?>
-            </td>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
-<?php if ($rightopt != false) { ?>
-            <td valign="top" bgcolor="<?php echo $color[0] ?>">
-               <?php echo $rightopt['desc'] ?>
-            </td>
-<?php } else { ?>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
-<?php } ?>
-         </tr>
-      </table>
-   </td></tr>
-</table>
-<?php
-    }
+        echo "<TABLE BGCOLOR=\"$color[4]\" WIDTH=\"100%\" CELLPADDING=0 CELLSPACING=5 BORDER=0>" .
+                '<TR><TD VALIGN="TOP">' .
+                   '<TABLE WIDTH="100%" CELLPADDING="3" CELLSPACING="0" BORDER="0">' .
+                      '<TR>' .
+                         "<TD VALIGN=TOP BGCOLOR=\"$color[9]\" WIDTH=\"50%\">" .
+                            '<A HREF="' . $leftopt['url'] . '">' . $leftopt['name'] . '</A>'.
+                         '</TD>'.
+                         "<TD VALIGN=TOP BGCOLOR=\"$color[4]\">&nbsp;</TD>";
+        if ($rightopt) {
+            echo         "<TD VALIGN=top BGCOLOR=\"$color[9]\" WIDTH=\"50%\">" .
+                            '<A HREF="' . $rightopt['url'] . '">' . $rightopt['name'] . '</A>' .
+                         '</TD>';
+        } else {
+            echo         "<TD VALIGN=top BGCOLOR=\"$color[4]\" WIDTH=\"50%\">&nbsp;</TD>";
+        }
 
-    /**
-     * This function prints out an option page row: in which the left
-     *   Left:  options for functionality that are javascript only
-     *   Right: options for functionality that are javascript only
-     */
-    function print_optionpages_row_fulljs($leftopt, $rightopt = false) {
-        global $color;
-?>
-<table bgcolor="<?php echo $color[4] ?>" width="100%" cellpadding="0" cellspacing="5" border="0">
-   <tr><td valign=top>
-      <table width="100%" cellpadding="3" cellspacing="0" border="0">
-         <tr>
-            <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%">
-               <a href="<?php echo $leftopt['url'] ?>"><?php echo $leftopt['name'] ?></a>
-            </td>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
-<?php if ($rightopt != false) { ?>
-            <td valign="top" bgcolor="<?php echo $color[9] ?>" width="50%">
-               <a href="<?php echo $rightopt['url'] ?>"><?php echo $rightopt['name'] ?></a>
-            </td>
-<?php } else { ?>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>" width="50%">&nbsp;</td>
-<?php } ?>
-         </tr>
-         <tr>
-            <td valign="top" bgcolor="<?php echo $color[0] ?>">
-               <?php echo $leftopt['desc'] ?>
-            </td>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
-<?php if ($rightopt != false) { ?>
-            <td valign="top" bgcolor="<?php echo $color[0] ?>">
-               <?php echo $rightopt['desc'] ?>
-            </td>
-<?php } else { ?>
-            <td valign="top" bgcolor="<?php echo $color[4] ?>">&nbsp;</td>
-<?php } ?>
-         </tr>
-      </table>
-   </td></tr>
-</table>
-<?php
+        echo          '</TR>' .
+                      '<TR>' .
+                         "<TD VALIGN=top BGCOLOR=\"$color[0]\">" .
+                            $leftopt['desc'] .
+                         '</TD>' .
+                         "<TD VALIGN=top BGCOLOR=\"$color[4]\">&nbsp;</TD>";
+        if ($rightopt) {
+            echo         "<TD VALIGN=top BGCOLOR=\"$color[0]\">" .
+                            $rightopt['desc'] .
+                         '</TD>';
+        } else {
+            echo "<TD VALIGN=top BGCOLOR=\"$color[4]\">&nbsp;</TD>";
+        }
+        
+        echo          '</TR>' .
+                   '</TABLE>' .
+                '</TD></TR>' .
+             "</TABLE>\n";
     }
 
 ?>