ehh, hmm: include -> require
[squirrelmail.git] / src / options.php
index 91503a708f0a7796bb4ffaf79ae63c944486ac80..dad4282779dd1ed622c1355ce8aa1c1ee8884b97 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,10 +17,11 @@ require_once('../functions/display_messages.php');
 require_once('../functions/imap.php');
 require_once('../functions/array.php');
 require_once('../functions/options.php');
+require_once('../functions/strings.php');
 
 /* Set the base uri. */
 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
-$base_uri = $regs[1];   
+$base_uri = $regs[1];
 
 /* First and foremost, deal with language stuff. */
 if (isset($language)) {
@@ -97,31 +98,36 @@ $optpage_loader = '';
 switch ($optpage) {
     case SMOPT_PAGE_MAIN: break;
     case SMOPT_PAGE_PERSONAL:
-        $optpage_name   = _("Personal Information");
-        $optpage_file   = 'options_personal.php';
-        $optpage_loader = 'load_optpage_data_personal';
+        $optpage_name     = _("Personal Information");
+        $optpage_file     = '../src/options_personal.php';
+        $optpage_loader   = 'load_optpage_data_personal';
+        $optpage_loadhook = 'optpage_loadhook_personal';
         break;
     case SMOPT_PAGE_DISPLAY:
         $optpage_name   = _("Display Preferences");
-        $optpage_file   = 'options_display.php';
+        $optpage_file   = '../src/options_display.php';
         $optpage_loader = 'load_optpage_data_display';
+        $optpage_loadhook = 'optpage_loadhook_display';
         break;
     case SMOPT_PAGE_HIGHLIGHT:
         $optpage_name   = _("Message Highlighting");
-        $optpage_file   = 'options_highlight.php';
+        $optpage_file   = '../src/options_highlight.php';
         $optpage_loader = 'load_optpage_data_highlight';
+        $optpage_loadhook = 'optpage_loadhook_highlight';
         break;
     case SMOPT_PAGE_FOLDER:
         $optpage_name   = _("Folder Preferences");
-        $optpage_file   = 'options_folder.php';
+        $optpage_file   = '../src/options_folder.php';
         $optpage_loader = 'load_optpage_data_folder';
+        $optpage_loadhook = 'optpage_loadhook_folder';
         break;
     case SMOPT_PAGE_ORDER:
         $optpage_name = _("Index Order");
-        $optpage_file = 'options_order.php';
+        $optpage_file = '../src/options_order.php';
         $optpage_loader = 'load_optpage_data_order';
+        $optpage_loadhook = 'optpage_loadhook_order';
         break;
-    default: do_hook('set_optpage_loadinfo');
+    default: do_hook('optpage_set_loadinfo');
 }
 
 /**********************************************************/
@@ -135,6 +141,7 @@ if ($optpage != SMOPT_PAGE_MAIN) {
     /* Assemble the data for this option page. */
     $optpage_data = array();
     $optpage_data = $optpage_loader();
+    do_hook($optpage_loadhook);
     $optpage_data['options'] =
         create_option_groups($optpage_data['grps'], $optpage_data['vals']);
 }
@@ -143,15 +150,16 @@ if ($optpage != SMOPT_PAGE_MAIN) {
 /*** Next, process anything that needs to be processed. ***/
 /***********************************************************/
 
-switch ($optmode) {
-    case SMOPT_MODE_SUBMIT:
-        $max_refresh = process_optionmode_submit($optpage, $optpage_data);
-        break;
-    case SMOPT_MODE_LINK:
-        $max_refresh = process_optionmode_link($optpage, $optpage_data);
-        break;
+if ( isset( $optpage_data ) ) {
+    switch ($optmode) {
+        case SMOPT_MODE_SUBMIT:
+            $max_refresh = process_optionmode_submit($optpage, $optpage_data);
+            break;
+        case SMOPT_MODE_LINK:
+            $max_refresh = process_optionmode_link($optpage, $optpage_data);
+            break;
+    }
 }
-
 /*** MOVE THIS DISPLAY CODE DOWN EVENTUALLY!!! ***/
 
 $optpage_title = _("Options");
@@ -187,7 +195,8 @@ if ($optmode == SMOPT_MODE_SUBMIT)   {
         case SMOPT_PAGE_FOLDER:
             $save_hook_name = 'options_folder_save';
             break;
-        default: $save_hook_name = 'options_save';
+        default: 
+            $save_hook_name = 'options_save';
             break;
     }
 
@@ -270,7 +279,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
     );
 
@@ -297,7 +306,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;
@@ -311,7 +320,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');
 
@@ -321,16 +330,13 @@ 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']);
 
-    /*** FIXME: CURRENTLY, THIS NEXT SWITCH STATEMENT DOES NOT TAKE
-     *** INTO ACCOUNT FOR PLUGINS. NEED TO FIX IT. ***/
     /* Set the inside_hook_name and submit_name. */
     switch ($optpage) {
         case SMOPT_PAGE_PERSONAL:
@@ -345,12 +351,12 @@ if ($optpage == SMOPT_PAGE_MAIN) {
             break;
         case SMOPT_PAGE_HIGHLIGHT:
             $inside_hook_name = 'options_highlight_inside';
-            $bottom_hook_name = 'options_display_bottom';
+            $bottom_hook_name = 'options_highlight_bottom';
             $submit_name = 'submit_highlight';
             break;
         case SMOPT_PAGE_FOLDER:
             $inside_hook_name = 'options_folder_inside';
-            $bottom_hook_name = 'options_display_bottom';
+            $bottom_hook_name = 'options_folder_bottom';
             $submit_name = 'submit_folder';
             break;
         case SMOPT_PAGE_ORDER:
@@ -431,7 +437,7 @@ if ($optpage == SMOPT_PAGE_MAIN) {
             echo         "<TD VALIGN=top BGCOLOR=\"$color[4]\" WIDTH=\"50%\">&nbsp;</TD>";
         }
 
-        echo          '</TR>' .
+        echo          '</TR>' . "\n" .
                       '<TR>' .
                          "<TD VALIGN=top BGCOLOR=\"$color[0]\" WIDTH=\"50%\">" .
                             $leftopt['desc'] .
@@ -445,7 +451,7 @@ if ($optpage == SMOPT_PAGE_MAIN) {
             echo         "<TD VALIGN=top BGCOLOR=\"$color[4]\" WIDTH=\"50%\">&nbsp;</TD>";
         }
         
-        echo          '</TR>' .
+        echo          '</TR>' . "\n" .
                    '</TABLE>' .
                 '</TD></TR>' .
              "</TABLE>\n";