fixed comp_in_new handling
[squirrelmail.git] / src / options.php
index 1d5e8fcc1f5d4276f21daee012d1ed6dfd5f6e7d..3fd806955fb5aa5957cbced7c5b1e6c7c736fbd0 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * options.php
  *
- * Copyright (c) 1999-2001 The Squirrelmail Development Team
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * Displays the options page. Pulls from proper user preference files
@@ -17,18 +17,7 @@ require_once('../functions/display_messages.php');
 require_once('../functions/imap.php');
 require_once('../functions/array.php');
 require_once('../functions/options.php');
-
-/* Set the base uri. */
-ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
-$base_uri = $regs[1];
-
-/* First and foremost, deal with language stuff. */
-if (isset($language)) {
-    setcookie('squirrelmail_language', $language, time()+2592000, $base_uri);
-    $squirrelmail_language = $language;
-} else {
-    $language = getPref($data_dir, $username, 'language');
-}
+require_once('../functions/strings.php');
 
 /*********************************/
 /*** Build the resultant page. ***/
@@ -74,6 +63,51 @@ function process_optionmode_link($optpage) {
    /* There will be something here, later. */
 }
 
+
+/**
+ * This function prints out an option page row.
+ */
+function print_optionpages_row($leftopt, $rightopt = false) {
+    global $color;
+
+    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=\"49%\">" .
+                        '<A HREF="' . $leftopt['url'] . '">' . $leftopt['name'] . '</A>'.
+                     '</TD>'.
+                     "<TD VALIGN=TOP BGCOLOR=\"$color[4]\" WIDTH=\"2%\">&nbsp;</TD>";
+    if ($rightopt) {
+        echo         "<TD VALIGN=top BGCOLOR=\"$color[9]\" WIDTH=\"49%\">" .
+                        '<A HREF="' . $rightopt['url'] . '">' . $rightopt['name'] . '</A>' .
+                     '</TD>';
+    } else {
+        echo         "<TD VALIGN=top BGCOLOR=\"$color[4]\" WIDTH=\"49%\">&nbsp;</TD>";
+    }
+
+    echo          '</TR>' .
+                  '<TR>' .
+                     "<TD VALIGN=top BGCOLOR=\"$color[0]\" WIDTH=\"49%\">" .
+                        $leftopt['desc'] .
+                     '</TD>' .
+                     "<TD VALIGN=top BGCOLOR=\"$color[4]\" WIDTH=\"2%\">&nbsp;</TD>";
+    if ($rightopt) {
+        echo         "<TD VALIGN=top BGCOLOR=\"$color[0]\" WIDTH=\"49%\">" .
+                        $rightopt['desc'] .
+                     '</TD>';
+    } else {
+        echo         "<TD VALIGN=top BGCOLOR=\"$color[4]\" WIDTH=\"49%\">&nbsp;</TD>";
+    }
+    
+    echo          '</TR>' . 
+               '</TABLE>' .
+            '</TD></TR>' .
+         "</TABLE>\n";
+}
+
+/* ---------------------------- main ---------------------------- */
+
 /* Make sure we have an Option Page set. Default to main. */
 if (!isset($optpage)) {
     $optpage = 'main';
@@ -84,9 +118,9 @@ if (!isset($optmode)) {
     $optmode = SMOPT_MODE_DISPLAY;
 }
 
-/*************************************************************/
-/*** First, set the load information for each option page. ***/
-/*************************************************************/
+/*
+ * First, set the load information for each option page.   
+ */
 
 /* Initialize load information variables. */
 $optpage_name = '';
@@ -166,23 +200,19 @@ if (isset($optpage_name) && ($optpage_name != '')) {
     $optpage_title .= " - $optpage_name";
 }
 
-?>
-
-<BR>
-<TABLE BGCOLOR="<?php echo $color[0] ?>" WIDTH="95%" ALIGN="CENTER" CELLPADDING="2" CELLSPACING="0" BORDER="0">
-<TR><TD ALIGN="CENTER">
-    <B><?php echo $optpage_title; ?></B><BR>
-    <TABLE WIDTH="100%" BORDER="0" CELLPADDING="5" CELLSPACING="0">
-    <TR><TD BGCOLOR="<?php echo $color[4] ?>" ALIGN="CENTER">
-
-<?php
+echo '<BR>' .
+     "<TABLE BGCOLOR=\"$color[0]\" WIDTH=\"95%\" ALIGN=\"CENTER\" CELLPADDING=\"2\" CELLSPACING=\"0\" BORDER=\"0\">\n".
+    '<TR><TD ALIGN="CENTER">'.
+    "<B>$optpage_title</B><BR>\n".
+    '<TABLE WIDTH="100%" BORDER="0" CELLPADDING="5" CELLSPACING="0">'.
+    "<TR><TD BGCOLOR=\"$color[4]\" ALIGN=\"CENTER\">\n";
 
 /*******************************************************************/
 /* DO OLD SAVING OF SUBMITTED OPTIONS. THIS WILL BE REMOVED LATER. */
 /*******************************************************************/
 
 /* If in submit mode, select a save hook name and run it. */
-if ($optmode == SMOPT_MODE_SUBMIT)      {
+if ($optmode == SMOPT_MODE_SUBMIT) {
     /* Select a save hook name. */
     switch ($optpage) {
         case SMOPT_PAGE_PERSONAL:
@@ -227,14 +257,18 @@ if ($optpage == SMOPT_PAGE_MAIN) {
     /* First, display the results of a submission, if needed. */
     /**********************************************************/
     if ($optmode == SMOPT_MODE_SUBMIT) {
+        if (!isset($frame_top)) {
+            $frame_top = '_top';
+        }
         /* Display a message indicating a successful save. */
         echo '<B>' . _("Successfully Saved Options") . ": $optpage_name</B><BR>\n";
 
         /* If $max_refresh != SMOPT_REFRESH_NONE, provide a refresh link. */
-        if ($max_refresh == SMOPT_REFRESH_FOLDERLIST) {
+        if ( !isset( $max_refresh ) ) {
+        } else if ($max_refresh == SMOPT_REFRESH_FOLDERLIST) {
             echo '<A HREF="../src/left_main.php" TARGET="left">' . _("Refresh Folder List") . '</A><BR>';
         } else if ($max_refresh) {
-            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="' . $frame_top . '">' . _("Refresh Page") . '</A><BR>';
         }
     }
     /******************************************/
@@ -278,7 +312,7 @@ if ($optpage == SMOPT_PAGE_MAIN) {
     $optpage_blocks[] = array(
         'name' => _("Index Order"),
         'url'  => 'options_order.php',
-        'desc' => _("The order of the message index can be rearanged and changed to contain the headers in any order you want."),
+        'desc' => _("The order of the message index can be rearranged and changed to contain the headers in any order you want."),
         'js'   => false
     );
 
@@ -305,7 +339,7 @@ if ($optpage == SMOPT_PAGE_MAIN) {
     $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\">";
+                   "<TABLE BGCOLOR=\"$color[4]\" WIDTH=\"100%\" CELLPADDING=\"3\" CELLSPACING=\"0\" BORDER=\"0\"><TR><TD>";
     foreach ($optpage_blocks as $next_optpage) {
         if ($first_optpage == false) {
             $first_optpage = $next_optpage;
@@ -319,7 +353,7 @@ if ($optpage == SMOPT_PAGE_MAIN) {
         print_optionpages_row($first_optpage);
     }
 
-    echo "</TABLE></TD></TR></TABLE>\n";
+    echo "</TD></TR></TABLE></TD></TR></TABLE>\n";
 
     do_hook('options_link_and_description');
 
@@ -329,9 +363,9 @@ if ($optpage == SMOPT_PAGE_MAIN) {
 /*************************************************************************/
 } else {
     echo '<FORM NAME="f" ACTION="options.php" METHOD="POST"><BR>' . "\n"
-       . '<TABLE WIDTH="100%" CELLPADDING=2 CELLSPACING=0 BORDER=0>' . "\n"
        . create_optpage_element($optpage)
-       . create_optmode_element(SMOPT_MODE_SUBMIT);
+       . create_optmode_element(SMOPT_MODE_SUBMIT)
+       . '<TABLE WIDTH="100%" CELLPADDING=2 CELLSPACING=0 BORDER=0>' . "\n";
 
     /* Output the option groups for this page. */
     print_option_groups($optpage_data['options']);
@@ -384,76 +418,10 @@ if ($optpage == SMOPT_PAGE_MAIN) {
     }
 }
 
-?>
-    </TD></TR>
-    </TABLE>
-
-</TD></TR>
-</TABLE>
-
-</BODY></HTML>
-
-<?php
-
-    /*******************************************************************/
-    /* Please be warned. The code below this point sucks. This is just */
-    /* my first implementation to make the option rows work for both   */
-    /* Javascript and non-Javascript option chunks.                    */
-    /*                                                                 */
-    /* Please, someone make these better for me. All three functions   */
-    /* below REALLY do close to the same thing.                        */
-    /*                                                                 */
-    /* This code would be GREATLY improved by a templating system.     */
-    /* Don't try to implement that now, however. That will come later. */
-    /*******************************************************************/
-
-    /*******************************************************************/
-    /* Actually, now that I think about it, don't do anything with     */
-    /* this code yet. There is ACTUALLY supposed to be a difference    */
-    /* between the three functions that write the option rows. I just  */
-    /* have not yet gotten to integrating that yet.                    */
-    /*******************************************************************/
-
-    /**
-     * This function prints out an option page row.
-     */
-    function print_optionpages_row($leftopt, $rightopt = false) {
-        global $color;
-
-        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>";
-        }
-
-        echo          '</TR>' .
-                      '<TR>' .
-                         "<TD VALIGN=top BGCOLOR=\"$color[0]\" WIDTH=\"50%\">" .
-                            $leftopt['desc'] .
-                         '</TD>' .
-                         "<TD VALIGN=top BGCOLOR=\"$color[4]\">&nbsp;</TD>";
-        if ($rightopt) {
-            echo         "<TD VALIGN=top BGCOLOR=\"$color[0]\" WIDTH=\"50%\">" .
-                            $rightopt['desc'] .
-                         '</TD>';
-        } else {
-            echo         "<TD VALIGN=top BGCOLOR=\"$color[4]\" WIDTH=\"50%\">&nbsp;</TD>";
-        }
-        
-        echo          '</TR>' .
-                   '</TABLE>' .
-                '</TD></TR>' .
-             "</TABLE>\n";
-    }
+echo        '</TD></TR>' .
+        '</TABLE>'.
+        '</TD></TR>'.
+     '</TABLE>' .
+     '</BODY></HTML>';
 
 ?>