Lots of changes to get closer to having save as draft working. Please, keep working...
authorthomppj <thomppj@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 29 Oct 2001 04:33:47 +0000 (04:33 +0000)
committerthomppj <thomppj@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 29 Oct 2001 04:33:47 +0000 (04:33 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1640 7612ce4b-ef26-0410-bec9-ea0150e637f0

12 files changed:
config/conf.pl
functions/imap_general.php
functions/imap_mailbox.php
functions/imap_messages.php
functions/mailbox_display.php
src/compose.php
src/draft_actions.php
src/left_main.php
src/load_prefs.php
src/options_folder.php
src/read_body.php
src/validate.php

index 2295f560300bf3527247d460938b83034e0907d7..4360f04703ef784ac4544b515ba2e1c8e6f31001 100755 (executable)
@@ -315,20 +315,22 @@ while (($command ne "q") && ($command ne "Q")) {
       print "R   Return to Main Menu\n";
    } elsif ($menu == 3) {
       print $WHT."Folder Defaults\n".$NRM;
-      print "1.  Default Folder Prefix      : $WHT$default_folder_prefix$NRM\n";
-      print "2.  Show Folder Prefix Option  : $WHT$show_prefix_option$NRM\n";
-      print "3.  Trash Folder               : $WHT$trash_folder$NRM\n";
-      print "4.  Sent Folder                : $WHT$sent_folder$NRM\n";
-      print "5.  By default, move to trash  : $WHT$default_move_to_trash$NRM\n";
-      print "6.  By default, move to sent   : $WHT$default_move_to_sent$NRM\n";
-      print "7.  List Special Folders First : $WHT$list_special_folders_first$NRM\n";
-      print "8.  Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
-      print "9.  Auto Expunge               : $WHT$auto_expunge$NRM\n";
-      print "10. Default Sub. of INBOX      : $WHT$default_sub_of_inbox$NRM\n";
-      print "11. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
-      print "12. Default Unseen Notify      : $WHT$default_unseen_notify$NRM\n";
-      print "13. Default Unseen Type        : $WHT$default_unseen_type$NRM\n";
-         print "14. Auto create Sent and Trash : $WHT$auto_create_special$NRM\n";
+      print "1.  Default Folder Prefix       : $WHT$default_folder_prefix$NRM\n";
+      print "2.  Show Folder Prefix Option   : $WHT$show_prefix_option$NRM\n";
+      print "3.  Trash Folder                : $WHT$trash_folder$NRM\n";
+      print "4.  Sent Folder                 : $WHT$sent_folder$NRM\n";
+      print "5.  Drafts Folder               : $WHT$draft_folder$NRM\n";
+      print "6.  By default, move to trash   : $WHT$default_move_to_trash$NRM\n";
+      print "7.  By default, move to sent    : $WHT$default_move_to_sent$NRM\n";
+      print "8.  By default, save as draft   : $WHT$default_save_as_draft$NRM\n";
+      print "9.  List Special Folders First  : $WHT$list_special_folders_first$NRM\n";
+      print "10. Show Special Folders Color  : $WHT$use_special_folder_color$NRM\n";
+      print "11. Auto Expunge                : $WHT$auto_expunge$NRM\n";
+      print "12. Default Sub. of INBOX       : $WHT$default_sub_of_inbox$NRM\n";
+      print "13. Show 'Contain Sub.' Option  : $WHT$show_contain_subfolders_option$NRM\n";
+      print "14. Default Unseen Notify       : $WHT$default_unseen_notify$NRM\n";
+      print "15. Default Unseen Type         : $WHT$default_unseen_type$NRM\n";
+      print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
       print "\n";
       print "R   Return to Main Menu\n";
    } elsif ($menu == 4) {
@@ -459,32 +461,34 @@ while (($command ne "q") && ($command ne "Q")) {
          elsif ($command == 4) { $signout_page  = command4 (); }
         elsif ($command == 5) { $squirrelmail_default_language = command5(); }
       } elsif ($menu == 2) {
-         if    ($command == 1)  { $domain             = command11 (); }
-         elsif ($command == 2)  { $imapServerAddress  = command12 (); }
-         elsif ($command == 3)  { $imapPort           = command13 (); }
-         elsif ($command == 4)  { $useSendmail        = command14 (); }
-         elsif ($command == 5)  { $sendmail_path      = command15 (); }
-         elsif ($command == 6)  { $smtpServerAddress  = command16 (); }
-         elsif ($command == 7)  { $smtpPort           = command17 (); }
-         elsif ($command == 8)  { $use_authenticated_smtp   = command18 (); }
-         elsif ($command == 9)  { $imap_server_type   = command19 (); }
-         elsif ($command == 10) { $invert_time        = command110 (); }
-         elsif ($command == 11) { $optional_delimiter = command111 (); }
+         if    ($command == 1)  { $domain                 = command11 (); }
+         elsif ($command == 2)  { $imapServerAddress      = command12 (); }
+         elsif ($command == 3)  { $imapPort               = command13 (); }
+         elsif ($command == 4)  { $useSendmail            = command14 (); }
+         elsif ($command == 5)  { $sendmail_path          = command15 (); }
+         elsif ($command == 6)  { $smtpServerAddress      = command16 (); }
+         elsif ($command == 7)  { $smtpPort               = command17 (); }
+         elsif ($command == 8)  { $use_authenticated_smtp = command18 (); }
+         elsif ($command == 9)  { $imap_server_type       = command19 (); }
+         elsif ($command == 10) { $invert_time            = command110 (); }
+         elsif ($command == 11) { $optional_delimiter     = command111 (); }
       } elsif ($menu == 3) {
-         if    ($command == 1) { $default_folder_prefix          = command21 (); }
-         elsif ($command == 2) { $show_prefix_option             = command22 (); }
-         elsif ($command == 3) { $trash_folder                   = command23 (); }
-         elsif ($command == 4) { $sent_folder                    = command24 (); }
-         elsif ($command == 5) { $default_move_to_trash          = command25 (); }
-         elsif ($command == 6) { $default_move_to_sent           = command26 (); }
-         elsif ($command == 7) { $list_special_folders_first     = command27 (); }
-         elsif ($command == 8) { $use_special_folder_color       = command28 (); }
-         elsif ($command == 9) { $auto_expunge                   = command29 (); }
-         elsif ($command == 10){ $default_sub_of_inbox           = command210(); }
-         elsif ($command == 11){ $show_contain_subfolders_option = command211(); }
-         elsif ($command == 12){ $default_unseen_notify          = command212(); }
-         elsif ($command == 13){ $default_unseen_type            = command213(); }
-         elsif ($command == 14){ $auto_create_special            = command214(); }
+         if    ($command == 1)  { $default_folder_prefix          = command21 (); }
+         elsif ($command == 2)  { $show_prefix_option             = command22 (); }
+         elsif ($command == 3)  { $trash_folder                   = command23a (); }
+         elsif ($command == 4)  { $sent_folder                    = command23b (); }
+         elsif ($command == 5)  { $draft_folder                   = command23c (); }
+         elsif ($command == 6)  { $default_move_to_trash          = command24a (); }
+         elsif ($command == 7)  { $default_move_to_sent           = command24b (); }
+         elsif ($command == 8)  { $default_save_as_draft          = command24c (); }
+         elsif ($command == 9)  { $list_special_folders_first     = command27 (); }
+         elsif ($command == 10) { $use_special_folder_color       = command28 (); }
+         elsif ($command == 11) { $auto_expunge                   = command29 (); }
+         elsif ($command == 12) { $default_sub_of_inbox           = command210(); }
+         elsif ($command == 13) { $show_contain_subfolders_option = command211(); }
+         elsif ($command == 14) { $default_unseen_notify          = command212(); }
+         elsif ($command == 15) { $default_unseen_type            = command213(); }
+         elsif ($command == 16) { $auto_create_special            = command214(); }
       } elsif ($menu == 4) {
          if    ($command == 1) { $default_charset          = command31 (); }
          elsif ($command == 2) { $data_dir                 = command33 (); }
@@ -897,7 +901,7 @@ sub command22 {
 }
 
 # Trash Folder 
-sub command23 {
+sub command23a {
    print "You can now specify where the default trash folder is located.\n";
    print "On servers where you do not want this, you can set it to anything\n";
    print "and set option 7 to false.\n";
@@ -919,7 +923,7 @@ sub command23 {
 }
 
 # Sent Folder 
-sub command24 {
+sub command23b {
    print "This is where messages that are sent will be stored.  SquirrelMail\n";
    print "by default puts a copy of all outgoing messages in this folder.\n";
    print "\n";
@@ -939,8 +943,30 @@ sub command24 {
    return $new_sent_folder;
 }
 
+# Draft Folder 
+sub command23c {
+   print "You can now specify where the default draft folder is located.\n";
+   print "On servers where you do not want this, you can set it to anything\n";
+   print "and set option 9 to false.\n";
+   print "\n";
+   print "This is relative to where the rest of your email is kept.  You do\n";
+   print "not need to worry about their mail directory.  If this folder\n";
+   print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
+   print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
+   print "\n";
+
+   print "[$WHT$draft_folder$NRM]: $WHT";
+   $new_draft_folder = <STDIN>;
+   if ($new_draft_folder eq "\n") {
+      $new_draft_folder = $draft_folder;
+   } else {
+      $new_draft_folder =~ s/[\r|\n]//g;
+   }
+   return $new_draft_folder;
+}
+
 # default move to trash 
-sub command25 {
+sub command24a {
    print "By default, should messages get moved to the trash folder?  You\n";
    print "can specify the default trash folder in option 3.  If this is set\n";
    print "to false, messages will get deleted immediately without moving\n";
@@ -965,7 +991,7 @@ sub command25 {
 }
 
 # default move to sent 
-sub command26 {
+sub command24b {
    print "By default, should messages get moved to the sent folder?  You\n";
    print "can specify the default sent folder in option 4.  If this is set\n";
    print "to false, messages will get sent an no copy will be made.\n";
@@ -988,6 +1014,30 @@ sub command26 {
    return $default_move_to_sent;
 }
 
+# default save as draft
+sub command24c {
+   print "By default, should the save to draft option be shown? You can\n";
+   print "specify the default drafts folder in option 5. If this is set\n";
+   print "to false, users will not be shown the save to draft option.\n";
+   print "\n";
+   print "Drafts folder is currently: $draft_folder\n";
+   print "\n";
+   
+   if ($default_move_to_draft eq "true") {
+      $default_value = "y";
+   } else {
+      $default_value = "n";
+   }
+   print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
+   $new_show = <STDIN>;
+   if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
+      $default_save_as_draft = "true";
+   } else {
+      $default_save_as_draft = "false";
+   }
+   return $default_save_as_draft;
+}
+
 # List special folders first 
 sub command27 {
    print "SquirrelMail has what we call 'special folders' that are not\n";
@@ -1148,9 +1198,10 @@ sub command213 {
 
 # Auto create special folders
 sub command214 {
-   print "Would you like the Sent and Trash folders to be created automatically for\n";
-   print "you when a user loggs in?  If the user accidentally deletes their special\n";
-   print "folders, this option will automatically create it again for them.\n";
+   print "Would you like the Sent, Trash, and Drafts folders to be created\n";
+   print "automatically print for you when a user logs in?  If the user\n";
+   print "accidentally deletes their special folders, this option will\n";
+   print "automatically create it again for them.\n";
    print "\n";
    
    if ($auto_create_special eq "true") {
@@ -1652,8 +1703,10 @@ sub save_data {
    
    print FILE "\n";
 
-   print FILE "\tglobal \$default_folder_prefix, \$trash_folder, \$sent_folder;\n";
-   print FILE "\tglobal \$default_move_to_trash, \$default_move_to_sent;\n";
+   print FILE "\tglobal \$default_folder_prefix;\n";
+   print FILE "\tglobal \$trash_folder, \$default_move_to_trash;\n";
+   print FILE "\tglobal \$sent_folder, \$default_move_to_sent;\n";
+   print FILE "\tglobal \$draft_folder, \$default_save_to_draft;\n";
    print FILE "\tglobal \$show_prefix_option, \$list_special_folders_first;\n";
    print FILE "\tglobal \$use_special_folder_color, \$auto_expunge, \$default_sub_of_inbox;\n";
    print FILE "\tglobal \$show_contain_subfolders_option, \$default_unseen_notify;\n";
@@ -1661,8 +1714,10 @@ sub save_data {
    print FILE "\t\$default_folder_prefix            = \"$default_folder_prefix\";\n";
    print FILE "\t\$trash_folder                     = \"$trash_folder\";\n";
    print FILE "\t\$sent_folder                      = \"$sent_folder\";\n";
+   print FILE "\t\$draft_folder                     = \"$draft_folder\";\n";
    print FILE "\t\$default_move_to_trash            =  $default_move_to_trash;\n";
    print FILE "\t\$default_move_to_sent             =  $default_move_to_sent;\n";
+   print FILE "\t\$default_save_as_draft            =  $default_save_as_draft;\n";
    print FILE "\t\$show_prefix_option               =  $show_prefix_option;\n";
    print FILE "\t\$list_special_folders_first       =  $list_special_folders_first;\n";
    print FILE "\t\$use_special_folder_color         =  $use_special_folder_color;\n";
@@ -1765,17 +1820,19 @@ sub set_defaults {
 
       print "\n";
       if ($server eq "cyrus") { 
-                       $default_folder_prefix = "INBOX";
+                       $default_folder_prefix = "";
                        $trash_folder = "INBOX.Trash";
                        $sent_folder = "INBOX.Sent";
+                       $draft_folder = "INBOX.Drafts";
                        $show_prefix_option = false;
                        $default_sub_of_inbox = true;
                        $show_contain_subfolders_option = false;
                        $imap_server_type = "cyrus";
 
-         print "         default_folder_prefix = INBOX\n";
+         print "         default_folder_prefix = none\n";
          print "                  trash_folder = INBOX.Trash\n";
          print "                   sent_folder = INBOX.Sent\n";
+         print "                  draft_folder = INBOX.Drafts\n";
          print "            show_prefix_option = false\n";
          print "          default_sub_of_inbox = true\n";
          print "show_contain_subfolders_option = false\n";
@@ -1786,6 +1843,7 @@ sub set_defaults {
                        $default_folder_prefix = "mail/";
                        $trash_folder = "Trash";
                        $sent_folder = "Sent";
+                       $draft_folder = "Drafts";
                        $show_prefix_option = true;
                        $default_sub_of_inbox = false;
                        $show_contain_subfolders_option = true;
@@ -1794,6 +1852,7 @@ sub set_defaults {
          print "         default_folder_prefix = mail/\n";
          print "                  trash_folder = Trash\n";
          print "                   sent_folder = Sent\n";
+         print "                  draft_folder = Drafts\n";
          print "            show_prefix_option = true\n";
          print "          default_sub_of_inbox = false\n";
          print "show_contain_subfolders_option = true\n";
@@ -1805,6 +1864,7 @@ sub set_defaults {
                        $default_sub_of_inbox = true;
                        $trash_folder = "INBOX/Deleted Items";
                        $sent_folder = "INBOX/Sent Items";
+                       $drafts_folder = "INBOX/Drafts";
                        $show_prefix_option = false;
                        $show_contain_subfolders_option = false;
                        $imap_server_type = "exchange";
@@ -1813,6 +1873,7 @@ sub set_defaults {
          print "           default_sub_of_inbox = true\n";
          print "                   trash_folder = \"INBOX/Deleted Items\"\n";
          print "                    sent_folder = \"INBOX/Sent Items\"\n";
+         print "                   draft_folder = \"INBOX/Drafts\"\n";
          print "             show_prefix_option = false\n";
          print " show_contain_subfolders_option = false\n";
          print "               imap_server_type = exchange\n";
index 09543e740060c0d6c190f6a1920cdf08d6e753bc..674896fbb40f8307886169e96963b92229cde955 100755 (executable)
@@ -32,7 +32,7 @@ $imap_general_debug = false;
    function sqimap_read_data_list ($imap_stream, $pre, $handle_errors,
                                    &$response, &$message) {
       global $color, $squirrelmail_language;
-global $imap_general_debug;
+      global $imap_general_debug;
 
       $read = '';
       $resultlist = array();
@@ -49,11 +49,13 @@ global $imap_general_debug;
             $size = $regs[1];
          } else if (ereg("^\\* [0-9]+ FETCH", $read, $regs)) {
             // Sizeless response, probably single-line
-// For debugging purposes
-if ($imap_general_debug) {
-    echo "<small><tt><font color=\"#CC0000\">$read</font></tt></small><br>\n";
-    flush();
-}
+
+            // For debugging purposes
+            if ($imap_general_debug) {
+                echo "<small><tt><font color=\"#CC0000\">$read</font></tt></small><br>\n";
+                flush();
+            }
+
             $size = 0;
             $data[] = $read;
             $read = fgets($imap_stream, 9096);
@@ -64,11 +66,13 @@ if ($imap_general_debug) {
             while (strpos($read, "\n") === false) {
                $read .= fgets($imap_stream, 9096);
             }
-// For debugging purposes
-if ($imap_general_debug) {
-    echo "<small><tt><font color=\"#CC0000\">$read</font></tt></small><br>\n";
-    flush();
-}
+
+            // For debugging purposes
+            if ($imap_general_debug) {
+                echo "<small><tt><font color=\"#CC0000\">$read</font></tt></small><br>\n";
+                flush();
+            }
+
             // If we know the size, no need to look at the end parameters
             if ($size > 0) {
                if ($total_size == $size) {
@@ -109,10 +113,8 @@ if ($imap_general_debug) {
       $response = $regs[1];
       $message = trim($regs[2]);
       
-if ($imap_general_debug) echo '--<br>';
-
-      if ($handle_errors == false)
-          return $resultlist;
+      if ($imap_general_debug) { echo '--<br>'; }
+      if ($handle_errors == false) { return $resultlist; }
      
       if ($response == 'NO') {
          // ignore this error from m$ exchange, it is not fatal (aka bug)
index 9aa7825680b062360144007a08be56124c438fda..420d8ca45a87fbdcfd2950c2360c99942c16c105 100755 (executable)
     ******************************************************************************/
    function sqimap_mailbox_list ($imap_stream) {
       global $data_dir, $username, $list_special_folders_first;
-      global $trash_folder, $sent_folder;
-      global $move_to_trash, $move_to_sent, $folder_prefix;
+      global $folder_prefix, $trash_folder, $sent_folder, $draft_folder;
+      global $move_to_trash, $move_to_sent, $save_as_draft;
 
       $inbox_in_list = false;
       $inbox_subscribed = false;
             $inbox_in_list = true;
       }
                 
-      /** Just in case they're not subscribed to their inbox, we'll get it 
-          for them anyway **/
+      /**
+       * Just in case they're not subscribed to their inbox,
+       * we'll get it for them anyway
+       */
       if ($inbox_subscribed == false || $inbox_in_list == false) {
          fputs ($imap_stream, sqimap_session_id() . " LIST \"\" \"INBOX\"\r\n");
          $inbox_ary = sqimap_read_data ($imap_stream, sqimap_session_id(), true, $response, $message);
 
       $boxes = sqimap_mailbox_parse ($sorted_list_ary, $sorted_lsub_ary, $dm);
 
-
       /** Now, lets sort for special folders **/
-
       $boxesnew = Array();
 
-      // Find INBOX
+      /* Find INBOX */
       for ($i = 0; $i < count($boxes); $i++) {
          if (strtolower($boxes[$i]["unformatted"]) == "inbox") {
             $boxesnew[] = $boxes[$i];
          }
       }
 
+      /* List special folders and their subfolders, if requested. */
       if ($list_special_folders_first == true) {
-
-         // Then list special folders and their subfolders
+         /* First list the trash folder. */
          for ($i = 0 ; $i < count($boxes) ; $i++) {
             if ($move_to_trash &&
-                eregi('^' . quotemeta($trash_folder) . '(' .
-                quotemeta($dm) . '.*)?$', $boxes[$i]["unformatted"])) {
+                   eregi('^' . quotemeta($trash_folder) . '(' .
+                     quotemeta($dm) . '.*)?$', $boxes[$i]['unformatted'])) {
                $boxesnew[] = $boxes[$i];
                $used[$i] = true;
             }
-            elseif ($move_to_sent &&
-                eregi('^' . quotemeta($sent_folder) . '(' .
-                quotemeta($dm) . '.*)?$', $boxes[$i]["unformatted"])) {
+         }
+
+         /* Then list the sent folder. */
+         for ($i = 0 ; $i < count($boxes) ; $i++) {
+            if ($move_to_sent &&
+                  eregi('^' . quotemeta($sent_folder) . '(' .
+                    quotemeta($dm) . '.*)?$', $boxes[$i]['unformatted'])) {
                $boxesnew[] = $boxes[$i];
                $used[$i] = true;
             }
          }
 
-         // Put INBOX.* folders ahead of the rest
+         /* Lastly, list the list the draft folder. */
+         for ($i = 0 ; $i < count($boxes) ; $i++) {
+            if ($save_as_draft &&
+                  eregi('^' . quotemeta($draft_folder) . '(' .
+                    quotemeta($dm) . '.*)?$', $boxes[$i]['unformatted'])) {
+               $boxesnew[] = $boxes[$i];
+               $used[$i] = true;
+            }
+         }
+
+         /* Put INBOX.* folders ahead of the rest. */
          for ($i = 0; $i < count($boxes); $i++) {
             if (eregi('^inbox\\.', $boxes[$i]["unformatted"]) &&
                 (!isset($used[$i]) || $used[$i] == false)) {
                $used[$i] = true;
             }
          }
-
       }
 
       // Rest of the folders
       return $boxes;
    }
    
-?>
\ No newline at end of file
+?>
index 70d9b08dbcd13afdb1e650e31a5dc8e47e5258ba..4cef81eb67270c6d481b225aee68c9f3c3858b46 100755 (executable)
       $read_list = array();
       $sizes_list = array();
 
-      /* We need to return the data in the same order as the caller supplied
-         in $msg_list, but IMAP servers are free to return responses in
-         whatever order they wish... So we need to re-sort manually */
-
+      /**
+       * We need to return the data in the same order as the caller supplied
+       * in $msg_list, but IMAP servers are free to return responses in
+       * whatever order they wish... So we need to re-sort manually
+       */
       for ($i = 0; $i < sizeof($msg_list); $i++) {
          $id2index[$msg_list[$i]] = $i;
       }
       fputs ($imap_stream, $query);
       $readin_list = sqimap_read_data_list($imap_stream, $sid, true, $response, $message);
 
-
       foreach ($readin_list as $r) {
          if (!eregi("^\\* ([0-9]+) FETCH", $r[0], $regs)) {
             set_up_language($squirrelmail_language);
          $size = $regs[1];
          
          $header = new small_header;
-         if ($issent == true)
-            $header->from = (trim($to) != '')? $to : _("(only Cc/Bcc)");
-         else   
+         if ($issent == true) {
+            $header->from = (trim($to) != '' ? $to : '(' ._("No To Address") . ')');
+         } else {
             $header->from = $from;
+         }
 
          $header->date = $date;
          $header->subject = $subject;
index 09c354b9042a6642d4d57a71cf599a98e6d66ab4..53ff3087a4b2aa1a8070d0f46272dec2b1bc64e0 100644 (file)
        return;
    define('mailbox_display_php', true);
 
-   define( 'PG_SEL_MAX', 10 );         // Default value for page_selector_max
+   define('PG_SEL_MAX', 10);  /* Default value for page_selector_max. */
 
    function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $startMessage, $where, $what) {
       global $checkall;
       global $color, $msgs, $msort;
-      global $sent_folder;
+      global $sent_folder, $draft_folder;
       global $message_highlight_list;
       global $index_order;
 
@@ -33,7 +33,6 @@
             $color_string = $color[12];
           }
       }
-
       $msg = $msgs[$key];
 
       $senderName = sqimap_find_displayable_name($msg['FROM']);
       }
       $urlMailbox = urlencode($mailbox);
       $subject = processSubject($msg['SUBJECT']);
-
       echo "<TR>\n";
 
-      if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true)
-      {
+      if (isset($msg['FLAG_FLAGGED']) && ($msg['FLAG_FLAGGED'] == true)) {
          $flag = "<font color=$color[2]>";
          $flag_end = '</font>';
-      }
-      else
-      {
+      } else {
          $flag = '';
          $flag_end = '';
       }
-      if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false)
-      {
+      if (!isset($msg['FLAG_SEEN']) || ($msg['FLAG_SEEN'] == false)) {
          $bold = '<b>';
          $bold_end = '</b>';
-      }
-      else
-      {
+      } else {
          $bold = '';
          $bold_end = '';
       }
-      if ($mailbox == $sent_folder)
-      {
+
+      if (($mailbox == $sent_folder) || ($mailbox == $draft_folder)) {
          $italic = '<i>';
          $italic_end = '</i>';
-      }
-      else
-      {
+      } else {
          $italic = '';
          $italic_end = '';
       }
-      if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED'])
-      {
+
+      if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
          $fontstr = "<font color=\"$color[9]\">";
          $fontstr_end = '</font>';
-      }
-      else
-      {
+      } else {
          $fontstr = '';
          $fontstr_end = '';
       }
          }
       }
 
-      if (!isset($hlt_color))
-         $hlt_color = $color_string;
+      if (!isset($hlt_color)) {
+          $hlt_color = $color_string;
+      }
 
       if ($where && $what) {
          $search_stuff = '&where='.urlencode($where).'&what='.urlencode($what);
       }
 
-      if ($checkall == 1)
-         $checked = ' checked';
-      else
-         $checked = '';
+      $checked = ($checkall == 1 ?' checked' : '');
 
       for ($i=1; $i <= count($index_order); $i++) {
          switch ($index_order[$i]) {
-            case 1: # checkbox
+            case 1: /* checkbox */
                echo "   <td bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."$checked></TD>\n";
                break;
-            case 2: # from
+            case 2: /* from */
                echo "   <td bgcolor=$hlt_color>$italic$bold$flag$fontstr$senderName$fontstr_end$flag_end$bold_end$italic_end</td>\n";
                break;
-            case 3: # date
+            case 3: /* date */
                echo "   <td nowrap bgcolor=$hlt_color><center>$bold$flag$fontstr".$msg["DATE_STRING"]."$fontstr_end$flag_end$bold_end</center></td>\n";
                break;
-            case 4: # subject
+            case 4: /* subject */
                echo "   <td bgcolor=$hlt_color>$bold";
                    if (! isset($search_stuff)) { $search_stuff = ''; }
                echo "<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$startMessage&show_more=0$search_stuff\"";
                }
                echo ">$flag$subject$flag_end</a>$bold_end</td>\n";
                break;
-            case 5: # flags
+            case 5: /* flags */
                $stuff = false;
                echo "   <td bgcolor=$hlt_color align=center nowrap><b><small>\n";
                if (isset($msg['FLAG_ANSWERED']) &&
                if (!$stuff) echo "&nbsp;\n";
                echo "</small></b></td>\n";
                break;
-            case 6: # size
+            case 6: /* size */
                echo "   <td bgcolor=$hlt_color>$bold$fontstr".show_readable_size($msg['SIZE'])."$fontstr_end$bold_end</td>\n";
                break;
          }
       }
-
-
       echo "</tr>\n";
    }
 
    /**
-    ** This function loops through a group of messages in the mailbox and shows them
-    **/
-   function showMessagesForMailbox($imapConnection, $mailbox, $numMessages, $startMessage, $sort, $color,$show_num, $use_cache) {
+    * This function loops through a group of messages in the mailbox
+    * and shows them to the user.
+    */
+   function showMessagesForMailbox
+        ($imapConnection, $mailbox, $numMessages, $startMessage,
+         $sort, $color,$show_num, $use_cache) {
       global $msgs, $msort;
-      global $sent_folder;
+      global $sent_folder, $draft_folder;
       global $message_highlight_list;
       global $auto_expunge;
 
-      if ($auto_expunge == true) sqimap_mailbox_expunge($imapConnection, $mailbox, false);
+      /* If autoexpunge is turned on, then do it now. */
+      if ($auto_expunge == true) {
+          sqimap_mailbox_expunge($imapConnection, $mailbox, false);
+      }
       sqimap_mailbox_select($imapConnection, $mailbox);
 
-      $issent = ($mailbox == $sent_folder);
+      $issent = (($mailbox == $sent_folder) || ($mailbox == $draft_folder));
       if (!$use_cache) {
-         // if it's sorted
+         /* If it is sorted... */
          if ($numMessages >= 1) {
             if ($sort < 6) {
                $id = range(1, $numMessages);
 
                if ($endMessage < $startMessage) {
                   $startMessage = $startMessage - $show_num;
-                  if ($startMessage < 1)
-                     $startMessage = 1;
+                  if ($startMessage < 1) {
+                      $startMessage = 1;
+                  }
                }
 
                $real_startMessage = $numMessages - $startMessage + 1;
                $real_endMessage = $numMessages - $startMessage - $show_num + 2;
-               if ($real_endMessage <= 0)
-                  $real_endMessage = 1;
+               if ($real_endMessage <= 0) {
+                   $real_endMessage = 1;
+               }
                $id = array_reverse(range($real_endMessage, $real_startMessage));
             }
 
 
          $j = 0;
          if ($sort == 6) {
-            $end = $startMessage + $show_num - 1;
-            if ($numMessages < $show_num)
-                $end_loop = $numMessages;
-            elseif ($end > $numMessages)
-            $end_loop = $numMessages - $startMessage + 1;
-        else
-                $end_loop = $show_num;
+             $end = $startMessage + $show_num - 1;
+             if ($numMessages < $show_num) {
+                 $end_loop = $numMessages;
+             } else if ($end > $numMessages) {
+                 $end_loop = $numMessages - $startMessage + 1;
+             } else {
+                 $end_loop = $show_num;
+             }
          } else {
             $end = $numMessages;
             $end_loop = $end;
          }
+
          while ($j < $end_loop) {
             if (isset($date[$j])) {
                 $date[$j] = ereg_replace('  ', ' ', $date[$j]);
             $num = 0;
             while ($num < count($flags[$j])) {
                if ($flags[$j][$num] == 'Deleted') {
-                  $messages[$j]['FLAG_DELETED'] = true;
-               }
-               elseif ($flags[$j][$num] == 'Answered') {
-                  $messages[$j]['FLAG_ANSWERED'] = true;
-               }
-               elseif ($flags[$j][$num] == 'Seen') {
-                  $messages[$j]['FLAG_SEEN'] = true;
-               }
-               elseif ($flags[$j][$num] == 'Flagged') {
-                  $messages[$j]['FLAG_FLAGGED'] = true;
+                   $messages[$j]['FLAG_DELETED'] = true;
+               } else if ($flags[$j][$num] == 'Answered') {
+                   $messages[$j]['FLAG_ANSWERED'] = true;
+               } else if ($flags[$j][$num] == 'Seen') {
+                   $messages[$j]['FLAG_SEEN'] = true;
+               } else if ($flags[$j][$num] == 'Flagged') {
+                   $messages[$j]['FLAG_FLAGGED'] = true;
                }
                $num++;
             }
          /* Only ignore messages flagged as deleted if we are using a
           * trash folder or auto_expunge */
          if (((isset($move_to_trash) && $move_to_trash)
-              || (isset($auto_expunge) && $auto_expunge)) && $sort != 6)
-         {
+              || (isset($auto_expunge) && $auto_expunge)) && $sort != 6) {
+
             /** Find and remove the ones that are deleted */
             $i = 0;
             $j = 0;
+
             while ($j < $numMessages) {
                if (isset($messages[$j]['FLAG_DELETED']) && $messages[$j]['FLAG_DELETED'] == true) {
                   $j++;
             }
             $numMessages = $i;
          } else {
-            if (! isset($messages))
-                $messages = array();
-            $msgs = $messages;
+             if (!isset($messages)) {
+                 $messages = array();
+             }
+             $msgs = $messages;
          }
       }
 
          session_register('msort');
       }
       displayMessageArray($imapConnection, $numMessages, $startMessage, $msgs, $msort, $mailbox, $sort, $color,$show_num);
-     session_register('msgs');
+      session_register('msgs');
    }
 
-   // generic function to convert the msgs array into an HTML table
+   /******************************************************************/
+   /* Generic function to convert the msgs array into an HTML table. */
+   /******************************************************************/
    function displayMessageArray($imapConnection, $numMessages, $startMessage, &$msgs, $msort, $mailbox, $sort, $color,$show_num) {
       global $folder_prefix, $sent_folder;
       global $imapServerAddress, $data_dir, $username, $use_mailbox_cache;
       global $index_order, $real_endMessage, $real_startMessage, $checkall;
 
-      // if cache isn't already set, do it now
-      if (!session_is_registered('msgs'))
-         session_register('msgs');
-      if (!session_is_registered('msort'))
-         session_register('msort');
+      /* If cache isn't already set, do it now. */
+      if (!session_is_registered('msgs')) { session_register('msgs'); }
+      if (!session_is_registered('msort')) { session_register('msort'); }
 
       if ($startMessage + ($show_num - 1) < $numMessages) {
          $endMessage = $startMessage + ($show_num-1);
 
       if ($endMessage < $startMessage) {
          $startMessage = $startMessage - $show_num;
-         if ($startMessage < 1)
-            $startMessage = 1;
+         if ($startMessage < 1) { $startMessage = 1; }
       }
 
       $nextGroup = $startMessage + $show_num;
       if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) {
          $lMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") . '</A>';
          $rMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
-      }
-      elseif (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
+      } else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) {
          $lMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") . '</A>';
          $rMore = "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
-      }
-      elseif (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
+      } else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) {
          $lMore = "<FONT COLOR=\"$color[9]\">"._("Previous") . '</FONT>';
          $rMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
       }
-      if( $lMore <> '' )
-        $lMore .= ' | ';
+      if ($lMore <> '') {
+          $lMore .= ' | ';
+      }
 
-      // Page selector block. Following code computes page links.
+      /* Page selector block. Following code computes page links. */
       $mMore = '';
-      if( !getPref($data_dir, $username, 'page_selector') &&
-          $numMessages > $show_num ) {
-        $j = intval( $numMessages / $show_num );  // Max pages
-        $k = max( 1, $j / getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX ) );
-        if( $numMessages % $show_num <> 0 )
-                $j++;
-        $startMessage = min( $startMessage, $numMessages );
-        $p = intval( $startMessage / $show_num ) + 1;
-        $i = 1;
-        while( $i < $p ) {
+      if (!getPref($data_dir, $username, 'page_selector')
+             && ($numMessages > $show_num)) {
+         $j = intval( $numMessages / $show_num );  // Max pages
+         $k = max( 1, $j / getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX ) );
+         if ($numMessages % $show_num <> 0 ) {
+             $j++;
+         }
+         $startMessage = min( $startMessage, $numMessages );
+         $p = intval( $startMessage / $show_num ) + 1;
+         $i = 1;
+         while( $i < $p ) {
             $pg = intval( $i );
             $start = ( ($pg-1) * $show_num ) + 1;
             $mMore .= "<a href=\"right_main.php?use_mailbox_cache=$use_mailbox_cache&startMessage=$start" .
                     "&mailbox=$urlMailbox\" TARGET=\"right\">$pg</a> ";
-            $i+=$k;
-        }
-        $mMore .= "<b>$p</b> ";
-        $i += $k;
-        while( $i <= $j ) {
+            $i += $k;
+         }
+         $mMore .= "<b>$p</b> ";
+         $i += $k;
+         while( $i <= $j ) {
             $pg = intval( $i );
             $start = ( ($pg-1) * $show_num ) + 1;
             $mMore .= "<a href=\"right_main.php?use_mailbox_cache=$use_mailbox_cache&startMessage=$start" .
                     "&mailbox=$urlMailbox\" TARGET=\"right\">$pg</a> ";
             $i+=$k;
-        }
-        $mMore .= ' | ';
+         }
+         $mMore .= ' | ';
       }
 
       if (! isset($msg))
             $startMessage = 1;
          }
       }
-
       $endVar = $endMessage + 1;
 
       // loop through and display the info for each message.
     * $Message is a message that is centered on top of the list
     * $More is a second line that is left aligned
     */
-   function mail_message_listing_beginning($imapConnection, $moveURL,
-       $mailbox = '', $sort = -1, $Message = '', $More = '', $startMessage = 1)
-   {
+   function mail_message_listing_beginning
+        ($imapConnection, $moveURL, $mailbox = '', $sort = -1,
+         $Message = '', $More = '', $startMessage = 1) {
       global $color, $index_order, $auto_expunge, $move_to_trash;
-      global $checkall, $sent_folder;
+      global $checkall, $sent_folder, $draft_folder;
       $urlMailbox = urlencode($mailbox);
 
       /** This is the beginning of the message list table.  It wraps around all messages */
       echo "         <SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"" . _("Move") . "\"></SMALL>\n";
       echo "      </TD>\n";
       echo "      <TD ALIGN=RIGHT NOWRAP>&nbsp;&nbsp;&nbsp;\n";
-      if (! $auto_expunge) {
+      if (!$auto_expunge) {
          echo '         <INPUT TYPE=SUBMIT NAME="expungeButton" VALUE="'. _("Expunge") .'">&nbsp;'. _("mailbox") ."&nbsp;\n";
       }
-
       echo "         <INPUT TYPE=SUBMIT NAME=\"markRead\" VALUE=\"". _("Read")."\">\n";
       echo "         <INPUT TYPE=SUBMIT NAME=\"markUnread\" VALUE=\"". _("Unread")."\">\n";
       echo "         <INPUT TYPE=SUBMIT VALUE=\"". _("Delete") . "\">&nbsp;\n";
-
       echo "      </TD>\n";
       echo "   </TR>\n";
       echo "</TABLE>\n";
       do_hook('mailbox_form_before');
       echo '</TD></TR>';
 
-
       echo "<TR><TD BGCOLOR=\"$color[0]\">";
       echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=";
       if ($GLOBALS['alt_index_colors']) {
       echo " BGCOLOR=\"$color[0]\">";
       echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
 
-      // Print the headers
+      /* Print the headers. */
       for ($i=1; $i <= count($index_order); $i++) {
          switch ($index_order[$i]) {
-            case 1: # checkbox
-            case 5: # flags
+            case 1: /* checkbox */
+            case 5: /* flags */
                echo '   <TD WIDTH="1%"><B>&nbsp;</B></TD>';
                break;
 
-            case 2: # from
-               if ($mailbox == $sent_folder)
+            case 2: /* from */
+               if (($mailbox == $sent_folder)
+                     || ($mailbox == $draft_folder)) {
                   echo '   <TD WIDTH="25%"><B>'. _("To") .'</B>';
-               else
-                    echo '   <TD WIDTH="25%"><B>'. _("From") .'</B>';
+               } else {
+                   echo '   <TD WIDTH="25%"><B>'. _("From") .'</B>';
+               }
+
            ShowSortButton($sort, $mailbox, 2, 3);
                echo "</TD>\n";
                break;
 
-            case 3: # date
+            case 3: /* date */
                echo '   <TD NOWRAP WIDTH="5%"><B>'. _("Date") .'</B>';
                ShowSortButton($sort, $mailbox, 0, 1);
                echo "</TD>\n";
                break;
 
-            case 4: # subject
+            case 4: /* subject */
                echo '   <TD><B>'. _("Subject") .'</B> ';
                ShowSortButton($sort, $mailbox, 4, 5);
                echo "</TD>\n";
                break;
 
-            case 6: # size
+            case 6: /* size */
                echo '   <TD WIDTH="5%"><b>' . _("Size")."</b></TD>\n";
                break;
          }
       echo "</TR>\n";
    }
 
-/* ----------------------------------------------------------------------- */
-
+   /*******************************************************************/
+   /* This function shows the sort button. Isn't this a good comment? */
+   /*******************************************************************/
    function ShowSortButton($sort, $mailbox, $Up, $Down) {
+      /* Figure out which image we want to use. */
       if ($sort != $Up && $sort != $Down) {
          $img = 'sort_none.gif';
          $which = $Up;
          $img = 'down_pointer.gif';
          $which = 6;
       }
+
+      /* Now that we have everything figured out, show the actual button. */
       echo ' <a href="right_main.php?newsort=' . $which .
            '&startMessage=1&mailbox=' . urlencode($mailbox) .
            '"><IMG SRC="../images/' . $img .
            '" BORDER=0 WIDTH=12 HEIGHT=10></a>';
    }
 
-   function ShowSelectAllLink($startMessage, $sort)
-   {
+   function ShowSelectAllLink($startMessage, $sort) {
        global $checkall, $PHP_SELF, $what, $where, $mailbox;
 
        ?>&nbsp;
index af1a2bde9cddb4eb8de36075b772f1632e9e19a7..f008aee0b042c2593df37c53ff1c0d94db8a2bd8 100644 (file)
@@ -1,18 +1,19 @@
 <?php
    /**
-    ** compose.php
-    **
-    **  Copyright (c) 1999-2000 The SquirrelMail development team
-    **  Licensed under the GNU GPL. For full terms see the file COPYING.
-    **
-    ** This code sends a mail.
-    **
-    ** There are 3 modes of operation:
-    **  - Start new mail
-    **  - Add an attachment
-    **  - Send mail
-    **
-    ** $Id$
+    * compose.php
+    *
+    * Copyright (c) 1999-2000 The SquirrelMail development team
+    * Licensed under the GNU GPL. For full terms see the file COPYING.
+    *
+    * This code sends a mail.
+    *
+    * There are 4 modes of operation:
+    *    - Start new mail
+    *    - Add an attachment
+    *    - Send mail
+    *    - Save As Draft
+    *  
+    * $Id$
     **/
 
    require_once('../src/validate.php');
       do_hook("compose_form");
           echo ">\n";
 
-      if ( isset($draft_id))
+      if (isset($draft_id)) {
          echo "<input type=\"hidden\" name=\"delete_draft\" value=\"$draft_id\">\n";
+      }
 
       echo "<TABLE WIDTH=\"100%\" ALIGN=center CELLSPACING=0 BORDER=0>\n";
 
       }
       echo "\n    <INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">\n";
 
-      if ($save_as_draft == true)
-         echo "<input type=\"submit\" name =\"draft\" value=\"Save Draft\">\n";
-
+      if ($save_as_draft) {
+          echo "<input type=\"submit\" name =\"draft\" value=\"Save Draft\">\n";
+      }
 
       do_hook("compose_button_row");
 
 
    if (isset($draft)) {
       require_once ('../src/draft_actions.php');
-      if(! saveMessagetoDraft($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $$reply_id)) {
+      if (!saveMessageAsDraft($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id)) {
          showInputForm();
          exit();
       } else {
-         Header("Location: right_main.php?mailbox=$draft_folder&sort=$sort&startMessage=1&note=Draft%20Email%20Saved");
+         $draft_message = _("Draft Email Saved");
+         Header("Location: right_main.php?mailbox=$draft_folder&sort=$sort&startMessage=1&note=$draft_message");
          exit();
       }
    }
index 5dad298d5b47b7ef19be143e095a3608c7554841..0a91cf0ec21b7510e3d37b836a73d2f1d6340f74 100644 (file)
@@ -16,21 +16,19 @@ require_once ('../src/validate.php');
          $to = expandAddrs(parseAddrs($t));
          $cc = expandAddrs(parseAddrs($c));
          $bcc = expandAddrs(parseAddrs($b));
-         if (isset($identity) && $identity != 'default')
-         {
+         if (isset($identity) && ($identity != 'default')) {
             $reply_to = getPref($data_dir, $username, 'reply_to' . $identity);
             $from = getPref($data_dir, $username, 'full_name' . $identity);
             $from_addr = getPref($data_dir, $username, 'email_address' . $identity);
-         }
-         else
-         {
+         } else {
             $reply_to = getPref($data_dir, $username, 'reply_to');
             $from = getPref($data_dir, $username, 'full_name');
             $from_addr = getPref($data_dir, $username, 'email_address');
          }
 
-         if ($from_addr == '')
+         if ($from_addr == '') {
             $from_addr = $popuser.'@'.$domain;
+         }
 
          $to_list = getLineOfAddrs($to);
          $cc_list = getLineOfAddrs($cc);
@@ -38,10 +36,11 @@ require_once ('../src/validate.php');
 
          /* Encoding 8-bit characters and making from line */
          $subject = encodeHeader($subject);
-         if ($from == '')
+         if ($from == '') {
             $from = "<$from_addr>";
-         else
+         } else {
             $from = '"' . encodeHeader($from) . "\" <$from_addr>";
+         }
 
          /* This creates an RFC 822 date */
          $date = date("D, j M Y H:i:s ", mktime()) . timezone();
@@ -51,10 +50,11 @@ require_once ('../src/validate.php');
          $message_id .= time() . '.squirrel@' . $SERVER_NAME .'>';
 
          /* Make an RFC822 Received: line */
-         if (isset($REMOTE_HOST))
+         if (isset($REMOTE_HOST)) {
             $received_from = "$REMOTE_HOST ([$REMOTE_ADDR])";
-         else
+         } else {
             $received_from = $REMOTE_ADDR;
+         }
 
          if (isset($HTTP_VIA) || isset ($HTTP_X_FORWARDED_FOR)) {
             if ($HTTP_X_FORWARDED_FOR == '')
@@ -102,7 +102,7 @@ require_once ('../src/validate.php');
 
          $header .= "X-Mailer: SquirrelMail (version $version)\r\n"; // Identify SquirrelMail
 
-         // Do the MIME-stuff
+         /* Do the MIME-stuff */
          $header .= "MIME-Version: 1.0\r\n";
 
          if (isMultipart()) {
@@ -127,7 +127,7 @@ require_once ('../src/validate.php');
       return $headerlength;
    }
 
-   function saveMessagetoDraft($t, $c, $b, $subject, $body, $reply_id) {
+   function saveMessageAsDraft($t, $c, $b, $subject, $body, $reply_id) {
       global $useSendmail, $msg_id, $is_reply, $mailbox, $onetimepad;
       global $data_dir, $username, $domain, $key, $version, $sent_folder, $imapServerAddress, $imapPort;
       global $draft_folder;
@@ -137,7 +137,6 @@ require_once ('../src/validate.php');
 
       $body = ereg_replace("\n\\.", "\n..", $body);
       $body = ereg_replace("^\\.", "..", $body);
-
       $body = ereg_replace("\n", "\r\n", $body);
 
       $fp = fopen("/dev/null", a);
index f0699bfe4ea8bcdf21f1e9368ad5f06ff4ef462e..f7c81b25e2652b62c9b47d20d5eac99adc0f9c7a 100644 (file)
@@ -24,7 +24,9 @@
    
     displayHtmlHeader();
 
-   if ($auto_create_special && ! isset($auto_create_done)) {
+    /* If requested and not yet complete, attempt to autocreate folders. */
+    if ($auto_create_special && ! isset($auto_create_done)) {
+          /* Autocreate the sent folder, if needed. */
          if (isset ($sent_folder) && $sent_folder != 'none') {
                 if (!sqimap_mailbox_exists ($imapConnection, $sent_folder)) {
                        sqimap_mailbox_create ($imapConnection, $sent_folder, '');
                    sqimap_subscribe($imapConnection, $sent_folder);
                 }
          }
+
+          /* Autocreate the trash folder, if needed. */
          if (isset ($trash_folder) && $trash_folder != 'none') {
                 if (!sqimap_mailbox_exists ($imapConnection, $trash_folder)) {
                        sqimap_mailbox_create ($imapConnection, $trash_folder, '');
                 } else if (! sqimap_mailbox_is_subscribed($imapConnection, $trash_folder)) {
                    sqimap_subscribe($imapConnection, $trash_folder);
                 }
+          }
+
+          /* Autocreate the drafts folder, if needed. */
           if (isset ($draft_folder) && $draft_folder != 'none') {
                  if (!sqimap_mailbox_exists ($imapConnection, $draft_folder)) {
                         sqimap_mailbox_create ($imapConnection, $draft_folder, '');
@@ -45,7 +52,8 @@
                     sqimap_subscribe($imapConnection, $draft_folder);
                  }
           }
-     }
+
+          /* Let the world know that autocreation is complete! Hurrah! */
          $auto_create_done = true;
          session_register('auto_create_done');
    }
@@ -55,6 +63,7 @@
       global $color, $move_to_sent, $move_to_trash;
       global $unseen_notify, $unseen_type, $collapse_folders;
       global $draft_folder, $save_as_draft;
+      global $use_special_folder_color;
 
       $real_box = $box_array['unformatted'];
       $mailbox = str_replace('&nbsp;','',$box_array['formatted']);
       }
       
       $special_color = false;
-      if ((strtolower($real_box) == 'inbox') ||
-          (($real_box == $trash_folder) && ($move_to_trash)) ||
-          (($real_box == $sent_folder) && ($move_to_sent)) ||
-          (($real_box == $draft_folder) && ($save_as_draft)))
-          $special_color = true;
+      if ($use_special_folder_color) {
+          if ((strtolower($real_box) == 'inbox')
+                || (($real_box == $trash_folder) && ($move_to_trash))
+                || (($real_box == $sent_folder) && ($move_to_sent))
+                || (($real_box == $draft_folder) && ($save_as_draft))) {
+              $special_color = true;
+          }
+      }
          
       /* Start off with a blank line. */
       $line = '';
       return ($line);
    }
 
+   /**********************************/
+   /* END OF FUNCTION - BACK TO MAIN */
+   /**********************************/
+
     if (isset($left_refresh) && ($left_refresh != 'None') && ($left_refresh != '')) {
         echo "<META HTTP-EQUIV=\"Expires\" CONTENT=\"Thu, 01 Dec 1994 16:00:00 GMT\">\n";
         echo "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"; 
index b73a39c35e648697eb2cecfe0874a836a8faec53..7938a8b9ccf77ac3256e700ba3dc821bad1f83e7 100644 (file)
 <?php
-   /**
-    **  load_prefs.php
-    **
-    **  Copyright (c) 1999-2000 The SquirrelMail development team
-    **  Licensed under the GNU GPL. For full terms see the file COPYING.
-    **
-    **  Loads preferences from the $username.pref file used by almost
-    **  every other script in the source directory and alswhere.
-    **
-    **  $Id$
-    **/
-
-   require_once('../src/validate.php');
-
-   // ----------------------------------------------------------
-   // Following code should be removed in the next foo_once step
-   if (defined('load_prefs_php'))
-       return;
-   define('load_prefs_php', true);
-   // ----------------------------------------------------------
-
-   global $theme, $chosen_theme, $color;
-   if (! isset($theme))
-      $theme = array();
-   if (! isset($color))
-      $color = array();
-   require_once('../functions/prefs.php');
-   require_once('../functions/plugin.php');
+    /**
+     * load_prefs.php
+     *
+     * Copyright (c) 1999-2001 The SquirrelMail Development Team
+     * Licensed under the GNU GPL. For full terms see the file COPYING.
+     *
+     * Loads preferences from the $username.pref file used by almost
+     * every other script in the source directory and alswhere.
+     *
+     * $Id$
+     **/
+
+    require_once('../src/validate.php');
+
+    /**************************************************************/
+    /* Following code should be removed in the next foo_once step
+    if (defined('load_prefs_php')) { return; }
+    define('load_prefs_php', true);
+    /**************************************************************/
+
+    global $theme, $chosen_theme, $color;
+    if (! isset($theme)) { $theme = array(); }
+    if (! isset($color)) { $color = array(); }
+    require_once('../functions/prefs.php');
+    require_once('../functions/plugin.php');
       
-   if (!isset($username))
-       $username = '';
-   checkForPrefs($data_dir, $username);
-
-   $chosen_theme = getPref($data_dir, $username, "chosen_theme");
-   $in_ary = false;
-   for ($i=0; $i < count($theme); $i++){
-         if ($theme[$i]["PATH"] == $chosen_theme) {
-                $in_ary = true;
-                break;
-         }
-   }
-   
-   if (! $in_ary)
-       $chosen_theme = "";
-
-   if (isset($chosen_theme) && $in_ary && (file_exists($chosen_theme))) {
-      @include_once($chosen_theme);
-   } else {
-      if (isset($theme) && isset($theme[0]) && file_exists($theme[0]["PATH"])) {
-         @include_once($theme[0]["PATH"]);
-      } else {
-          #
-          #  I hard coded the theme as a failsafe if no themes were
-          #  found.  It makes no sense to cause the whole thing to exit
-          #  just because themes were not found.  This is the absolute
-          #  last resort.
-          #
-          $color[0]   = "#DCDCDC"; // (light gray)     TitleBar
-          $color[1]   = "#800000"; // (red)
-          $color[2]   = "#CC0000"; // (light red)      Warning/Error Messages
-          $color[3]   = "#A0B8C8"; // (green-blue)     Left Bar Background
-          $color[4]   = "#FFFFFF"; // (white)          Normal Background
-          $color[5]   = "#FFFFCC"; // (light yellow)   Table Headers
-          $color[6]   = "#000000"; // (black)          Text on left bar
-          $color[7]   = "#0000CC"; // (blue)           Links
-          $color[8]   = "#000000"; // (black)          Normal text
-          $color[9]   = "#ABABAB"; // (mid-gray)       Darker version of #0
-          $color[10]  = "#666666"; // (dark gray)      Darker version of #9
-          $color[11]  = "#770000"; // (dark red)       Special Folders color
-      }
-   }
-
-    if (!defined('download_php')) 
-       session_register("theme_css");
-
-   global $use_javascript_addr_book;
-   $use_javascript_addr_book = getPref($data_dir, $username, 'use_javascript_addr_book', $default_use_javascript_addr_book);
-
-   /** Load the user's sent folder preferences **/
-   global $move_to_sent, $move_to_trash, $save_as_draft;
-   $move_to_sent = getPref($data_dir, $username, 'move_to_sent', $default_move_to_sent);
-
-   /** Load the user's trash folder preferences **/
-   $move_to_trash = getPref($data_dir, $username, 'move_to_trash', $default_move_to_trash);
-
-   /** Load the user's draft folder preferences **/
-   $save_as_draft = getPref($data_dir, $username, 'save_as_draft', TRUE);
-
-   global $unseen_type, $unseen_notify;
-   if ($default_unseen_type == '')
-      $default_unseen_type = 1;
-   $unseen_type = getPref($data_dir, $username, 'unseen_type', $default_unseen_type);
-   if ($default_unseen_notify == '')
-      $default_unseen_notify = 2;
-   $unseen_notify = getPref($data_dir, $username, 'unseen_notify', $default_unseen_notify);
-
-   global $folder_prefix;
-   $folder_prefix = getPref($data_dir, $username, 'folder_prefix', $default_folder_prefix);
-
-   /** Load special folders **/
-   global $trash_folder, $sent_folder, $draft_folder;
-   $new_trash_folder = getPref($data_dir, $username, 'trash_folder');
-   if ( ( $new_trash_folder == '' ) && ( $move_to_trash ) ) {
-      $trash_folder = $folder_prefix . $trash_folder;
-   } else {
-      $trash_folder = $new_trash_folder;
-   }
-
-   /** Load special folders **/
-   $new_sent_folder = getPref($data_dir, $username, 'sent_folder');
-   if ( ( $new_sent_folder == '' ) && ( $move_to_sent ) ) {
-      $sent_folder = $folder_prefix . $sent_folder;
-   } else {
-      $sent_folder = $new_sent_folder;
-   }
-
-  /** Load special folders **/
-   $new_drafts_folder = getPref($data_dir, $username, 'draft_folder');
-   if ( ($new_drafts_folder == '') && ($save_as_draft ) ) {
-      $draft_folder = $folder_prefix . $draft_folder;
-   } else {
-      $draft_folder = $new_drafts_folder;
-   }
-
-   global $show_num, $wrap_at, $left_size;
-   $show_num = getPref($data_dir, $username, 'show_num', 15 );
-
-   $wrap_at = getPref( $data_dir, $username, 'wrap_at', 86 );
-   if ($wrap_at < 15) {
-      $wrap_at = 15;
-   }
-
-   $left_size = getPref($data_dir, $username, 'left_size');
-   if ($left_size == "") {
-      if (isset($default_left_size)) {
-         $left_size = $default_left_size;
-      } else {
-         $left_size = 200;
-      }
-   }
-
-   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 );
-
-   $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_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' );
-   $sort = getPref($data_dir, $username, 'sort', 6 );
-
-   /** Load up the Signature file **/
-   global $signature_abs;
-   if ($use_signature) {
-      $signature_abs = $signature = getSig($data_dir, $username);
-   } else {
-      $signature_abs = getSig($data_dir, $username);
-   }
-
-
-   //  highlightX comes in with the form: name,color,header,value
-   global $message_highlight_list;
-   for ($i=0; $hlt = getPref($data_dir, $username, "highlight$i"); $i++) {
-      $ary = explode(",", $hlt);
-      $message_highlight_list[$i]['name'] = $ary[0];
-      $message_highlight_list[$i]['color'] = $ary[1];
-      $message_highlight_list[$i]['value'] = $ary[2];
-      $message_highlight_list[$i]['match_type'] = $ary[3];
-   }
-
-
-   #index order lets you change the order of the message index
-   global $index_order;
-   $order = getPref($data_dir, $username, 'order1');
-   for ($i=1; $order; $i++) {
-      $index_order[$i] = $order;
-      $order = getPref($data_dir, $username, 'order'.($i+1));
-   }
-   if (!isset($index_order)) {
-      $index_order[1] = 1;
-      $index_order[2] = 2;
-      $index_order[3] = 3;
-      $index_order[4] = 5;
-      $index_order[5] = 4;
-   }
-
-   global $alt_index_colors;
-   $alt_index_colors = getPref($data_dir, $username, 'alt_index_colors', FALSE );
-
-   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' );
-
-   global $collapse_folders, $show_html_default;
-   $collapse_folders = getPref($data_dir, $username, 'collapse_folders');
-
-   // show_html_default is a int value
-   $show_html_default = intval(getPref($data_dir, $username, 'show_html_default'), 1 );
-
-   do_hook("loading_prefs");
-
+    if (!isset($username)) { $username = ''; }
+    checkForPrefs($data_dir, $username);
+
+    $chosen_theme = getPref($data_dir, $username, "chosen_theme");
+    $in_ary = false;
+    for ($i=0; $i < count($theme); $i++){
+        if ($theme[$i]["PATH"] == $chosen_theme) {
+            $in_ary = true;
+            break;
+        }
+    }
+    if (! $in_ary) { $chosen_theme = ""; }
+
+    if (isset($chosen_theme) && $in_ary && (file_exists($chosen_theme))) {
+        @include_once($chosen_theme);
+    } else {
+        if (isset($theme) && isset($theme[0])
+              && file_exists($theme[0]["PATH"])) {
+            @include_once($theme[0]["PATH"]);
+        } else {
+            /**
+             * This theme as a failsafe if no themes were found. It makes
+             * no sense to cause the whole thing to exit just because themes
+             * were not found. This is the absolute last resort.
+             */
+             $color[0]   = "#DCDCDC"; // light gray    TitleBar
+             $color[1]   = "#800000"; // red
+             $color[2]   = "#CC0000"; // light red     Warning/Error Messages
+             $color[3]   = "#A0B8C8"; // green-blue    Left Bar Background
+             $color[4]   = "#FFFFFF"; // white         Normal Background
+             $color[5]   = "#FFFFCC"; // light yellow  Table Headers
+             $color[6]   = "#000000"; // black         Text on left bar
+             $color[7]   = "#0000CC"; // blue          Links
+             $color[8]   = "#000000"; // black         Normal text
+             $color[9]   = "#ABABAB"; // mid-gray      Darker version of #0
+             $color[10]  = "#666666"; // dark gray     Darker version of #9
+             $color[11]  = "#770000"; // dark red      Special Folders color
+        }
+    }
+
+    if (!defined('download_php')) { session_register("theme_css"); }
+
+    global $use_javascript_addr_book;
+    $use_javascript_addr_book = getPref($data_dir, $username, 'use_javascript_addr_book', $default_use_javascript_addr_book);
+
+    /** Declare the global variables for the special folders. */
+    global $move_to_sent, $move_to_trash, $save_as_draft;
+
+    /** Check the default value for save_to_draft. */
+    if (!isset($default_save_as_draft)) { $default_save_as_draft = true; }
+
+    /** Load the user's special folder preferences **/
+    $move_to_sent = getPref($data_dir, $username, 'move_to_sent', $default_move_to_sent);
+    $move_to_trash = getPref($data_dir, $username, 'move_to_trash', $default_move_to_trash);
+    $save_as_draft = getPref($data_dir, $username, 'save_as_draft', $default_save_as_draft);
+
+    global $unseen_type, $unseen_notify;
+    if ($default_unseen_type == '') { $default_unseen_type = 1; }
+    $unseen_type = getPref($data_dir, $username, 'unseen_type', $default_unseen_type);
+    if ($default_unseen_notify == '') { $default_unseen_notify = 2; }
+    $unseen_notify = getPref($data_dir, $username, 'unseen_notify', $default_unseen_notify);
+
+    global $folder_prefix;
+    $folder_prefix = getPref($data_dir, $username, 'folder_prefix', $default_folder_prefix);
+
+    /* Declare global variables for special folders. */
+    global $trash_folder, $sent_folder, $draft_folder;
+
+    /** Load special folder - trash **/
+    $new_trash_folder = getPref($data_dir, $username, 'trash_folder');
+    if (($new_trash_folder == '') && ($move_to_trash)) {
+        $trash_folder = $folder_prefix . $trash_folder;
+    } else {
+        $trash_folder = $new_trash_folder;
+    }
+
+    /** Load special folder - sent **/
+    $new_sent_folder = getPref($data_dir, $username, 'sent_folder');
+    if (($new_sent_folder == '') && ($move_to_sent)) {
+        $sent_folder = $folder_prefix . $sent_folder;
+    } else {
+        $sent_folder = $new_sent_folder;
+    }
+
+    /** Load special folder - draft **/
+    if (!isset($draft_folder)) { $draft_folder = 'none'; }
+    $new_draft_folder = getPref($data_dir, $username, 'draft_folder');
+    if (($new_draft_folder == '') && ($save_as_draft)) {
+        $draft_folder = $folder_prefix . $draft_folder;
+    } else {
+        $draft_folder = $new_draft_folder;
+    }
+
+    global $show_num, $wrap_at, $left_size;
+    $show_num = getPref($data_dir, $username, 'show_num', 15 );
+
+    $wrap_at = getPref( $data_dir, $username, 'wrap_at', 86 );
+    if ($wrap_at < 15) { $wrap_at = 15; }
+
+    $left_size = getPref($data_dir, $username, 'left_size');
+    if ($left_size == "") {
+        if (isset($default_left_size)) {
+            $left_size = $default_left_size;
+        } else {
+            $left_size = 200;
+        }
+    }
+
+    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 );
+
+    $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_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' );
+    $sort = getPref($data_dir, $username, 'sort', 6 );
+
+    /** Load up the Signature file **/
+    global $signature_abs;
+    if ($use_signature) {
+        $signature_abs = $signature = getSig($data_dir, $username);
+    } else {
+        $signature_abs = getSig($data_dir, $username);
+    }
+
+    /* HighlightX comes in with the form: name, color, header, value. */
+    global $message_highlight_list;
+    for ($i=0; $hlt = getPref($data_dir, $username, "highlight$i"); $i++) {
+        $ary = explode(",", $hlt);
+        $message_highlight_list[$i]['name'] = $ary[0];
+        $message_highlight_list[$i]['color'] = $ary[1];
+        $message_highlight_list[$i]['value'] = $ary[2];
+        $message_highlight_list[$i]['match_type'] = $ary[3];
+    }
+
+    /* Index order lets you change the order of the message index */
+    global $index_order;
+    $order = getPref($data_dir, $username, 'order1');
+    for ($i=1; $order; $i++) {
+        $index_order[$i] = $order;
+        $order = getPref($data_dir, $username, 'order'.($i+1));
+    }
+    if (!isset($index_order)) {
+        $index_order[1] = 1;
+        $index_order[2] = 2;
+        $index_order[3] = 3;
+        $index_order[4] = 5;
+        $index_order[5] = 4;
+    }
+
+    global $alt_index_colors;
+    $alt_index_colors = getPref($data_dir, $username, 'alt_index_colors', FALSE );
+
+    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' );
+
+    global $collapse_folders, $show_html_default;
+    $collapse_folders = getPref($data_dir, $username, 'collapse_folders');
+
+    /* show_html_default is a int value. */
+    $show_html_default = intval(getPref($data_dir, $username, 'show_html_default'), 1 );
+
+    do_hook("loading_prefs");
 ?>
index 31f8c2466434fe74eb44ff0011ec7e950f3a1637..f0650600f5cc34927525aa34f7269b1cb335847d 100644 (file)
          </tr>
 <?php }          
 
-   // TRASH FOLDER
+   /* TRASH FOLDER */
    echo '<tr><td nowrap align="right">';
    echo _("Trash Folder:");
    echo '</td><td>';
       echo "<TT><SELECT NAME=trash>\n";
-      if ($move_to_trash == true)
-         echo '<option value="none">' . _("Don't use Trash");
-      else
+      if ($move_to_trash == true) {
+         echo '<option value="none">' . _("Do not use Trash");
+      } else {
          echo '<option value="none" selected>' . _("Do not use Trash");
+      }
  
       for ($i = 0; $i < count($boxes); $i++) {
          $use_folder = true;
    echo '</td></tr>';  
 
 
-   // SENT FOLDER
+   /* SENT FOLDER */
    echo '<tr><td nowrap align="right">';
    echo _("Sent Folder:");
    echo '</td><td>';
       echo '<TT><SELECT NAME="sent">' . "\n";
       if ($move_to_sent == true)
-         echo '<option value="none">' . _("Don't use Sent");
+         echo '<option value="none">' . _("Do not use Sent");
       else
          echo "<option value=none selected>" . _("Do not use Sent");
  
       echo "</SELECT></TT>\n";
    echo '</td></tr>';  
 
-   // Drafts Folder
+   /* Drafts Folder. */
    echo '<tr><td nowrap align="right">';
    echo _("Drafts Folder:");
    echo '</td><td>';
    echo '<TT><SELECT NAME="draft">';
    if ($save_as_draft == true)
-      echo '<option value="none">' . _("Don't use drafts");
+      echo '<option value="none">' . _("Do not use Drafts");
    else
       echo '<option value="none selected">' . _("Do not use Drafts");
 
index 6f7e3c13849a1661d2f7826de80723644c3688d0..8fb431011eefa1a8b91060f766d4bd86349c1a6a 100644 (file)
    do_hook('read_body_top');
    echo '<BR>' .
         '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
-        '   <TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
-        '      <TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
-        '         <TR>' .
-        '            <TD ALIGN="LEFT" WIDTH="33%">' .
-        '               <SMALL>';
+        '   <TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' . "\n" .
+        '      <TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' . "\n" .
+        '         <TR>' . "\n" .
+        '            <TD ALIGN="LEFT" WIDTH="33%">' . "\n" .
+        '               <SMALL>' . "\n";
    if ($where && $what) {
       echo "               <A HREF=\"search.php?where=".urlencode($where)."&what=".urlencode($what)."&mailbox=$urlMailbox\">";
    } else {
    } else {
       echo "               <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=$startMessage\">";
    }
-   echo _("Delete") .
-        '</A>&nbsp;';
+   echo _("Delete") . '</A>&nbsp;';
    if (($mailbox == $draft_folder) && ($save_as_draft)) {
       echo '|&nbsp;';
-      echo "               <A HREF=\"compose.php?mailbox=$mailbox&send_to=$to_string&send_to_cc=$cc_string&send_to_bcc=$
-      echo _("Resume") .
-           '</a>';
+      echo "               <A HREF=\"compose.php?mailbox=$mailbox&send_to=$to_string&send_to_cc=$cc_string&send_to_bcc=\$bcc_string\">";
+      echo _("Resume Draft") . '</a>';
    }
    echo '&nbsp;&nbsp;' .
         '               </SMALL>' .
         '            </TD><TD WIDTH="33%" ALIGN="CENTER">' .
         '               <SMALL>' . "\n";
+
    if ($where && $what) {
    } else {
       if ($currentArrayIndex == -1) {
index 96e2dcf8c73882e735680ef9d18c63d3d81770ea..c74be9c4d9af1dfc8067bd492c319fba2886d58f 100644 (file)
 <?php
-   /**
-    **  validate.php
-    **
-    **  Copyright (c) 1999-2000 The SquirrelMail development team
-    **  Licensed under the GNU GPL. For full terms see the file COPYING.
-    **
-    **  $Id$
-    **/
+    /**
+     * validate.php
+     *
+     * Copyright (c) 1999-2000 The SquirrelMail Development Team
+     * Licensed under the GNU GPL. For full terms see the file COPYING.
+     *
+     * $Id$
+     */
 
-   if (defined ('validate_php'))
-      return; 
-   define ('validate_php', true); 
+    if (defined ('validate_php')) { return; }
+    define ('validate_php', true);
 
-   session_start();
-   require_once('../functions/i18n.php');
-   require_once('../functions/auth.php');
-   
-   is_logged_in();
+    session_start();
+    require_once('../functions/i18n.php');
+    require_once('../functions/auth.php');
 
+    is_logged_in();
 
-   // Remove all slashes for form values
-   if (get_magic_quotes_gpc())
-   {
-       global $REQUEST_METHOD;
-       if ($REQUEST_METHOD == "POST")
-       {
-           global $HTTP_POST_VARS;
-           RemoveSlashes($HTTP_POST_VARS);
-       }
-       elseif ($REQUEST_METHOD == "GET")
-       {
-           global $HTTP_GET_VARS;
-           RemoveSlashes($HTTP_GET_VARS);
-       }
-   }
+    /* Remove all slashes for form values. */
+    if (get_magic_quotes_gpc()) {
+        global $REQUEST_METHOD;
 
-   // Auto-detection
-   //
-   // if $send (the form button's name) contains "\n" as the first char
-   // and the script is compose.php, then trim everything.  Otherwise,
-   // we don't have to worry.
-   //
-   // This is for a RedHat package bug and a Konqueror (pre 2.1.1?) bug
-   global $send, $PHP_SELF;
-   if (isset($send) && substr($send, 0, 1) == "\n" &&
-       substr($PHP_SELF, -12) == '/compose.php')
-   {
-      if ($REQUEST_METHOD == "POST") {
-         global $HTTP_POST_VARS;
-         TrimArray($HTTP_POST_VARS);
-      } else {
-         global $HTTP_GET_VARS;
-         TrimArray($HTTP_GET_VARS);
-      }
-   }
+        if ($REQUEST_METHOD == "POST") {
+            global $HTTP_POST_VARS;
+            RemoveSlashes($HTTP_POST_VARS);
+        } else if ($REQUEST_METHOD == "GET") {
+            global $HTTP_GET_VARS;
+            RemoveSlashes($HTTP_GET_VARS);
+        }
+    }
 
-   //**************************************************************************
-   // Trims every element in the array
-   //**************************************************************************
-   function TrimArray(&$array) {
-      foreach ($array as $k => $v) {
-         global $$k;
-         if (is_array($$k)) {
-            foreach ($$k as $k2 => $v2) {
-              $$k[$k2] = substr($v2, 1);
+    /**
+     * Auto-detection
+     *
+     * if $send (the form button's name) contains "\n" as the first char
+     * and the script is compose.php, then trim everything. Otherwise, we
+     * don't have to worry.
+     *
+     * This is for a RedHat package bug and a Konqueror (pre 2.1.1?) bug
+     */
+    global $send, $PHP_SELF;
+    if (isset($send)
+        && (substr($send, 0, 1) == "\n")
+        && (substr($PHP_SELF, -12) == '/compose.php')) {
+        if ($REQUEST_METHOD == "POST") {
+            global $HTTP_POST_VARS;
+            TrimArray($HTTP_POST_VARS);
+        } else {
+            global $HTTP_GET_VARS;
+            TrimArray($HTTP_GET_VARS);
+        }
+    }
+
+    /************************************/
+    /* Trims every element in the array */
+    /************************************/
+    function TrimArray(&$array) {
+        foreach ($array as $k => $v) {
+            global $$k;
+            if (is_array($$k)) {
+                foreach ($$k as $k2 => $v2) {
+                  $$k[$k2] = substr($v2, 1);
+                }
+            } else {
+                $$k = substr($v, 1);
             }
-         } else {
-            $$k = substr($v, 1);
-         }
-        // Re-assign back to array
-        $array[$k] = $$k;
-      }
-   }
+
+           /* Re-assign back to array. */
+            $array[$k] = $$k;
+        }
+    }
    
    
-   //**************************************************************************
-   // Removes slashes from every element in the array
-   //**************************************************************************
-   function RemoveSlashes(&$array)
-   {
-       foreach ($array as $k => $v)
-       {
-           global $$k;
-           if (is_array($$k))
-           {
-               foreach ($$k as $k2 => $v2)
-               {
-                   $newArray[stripslashes($k2)] = stripslashes($v2);
-               }
-               $$k = $newArray;
-           }
-           else
-           {
-               $$k = stripslashes($v);
-           }
-          // Re-assign back to the array
-          $array[$k] = $$k;
-       }
-   }
+    /***************************************************/
+    /* Removes slashes from every element in the array */
+    /***************************************************/
+    function RemoveSlashes(&$array) {
+        foreach ($array as $k => $v) {
+            global $$k;
+            if (is_array($$k)) {
+                foreach ($$k as $k2 => $v2) {
+                    $newArray[stripslashes($k2)] = stripslashes($v2);
+                }
+                $$k = $newArray;
+            } else {
+                $$k = stripslashes($v);
+            }
+
+           /* Re-assign back to the array. */
+            $array[$k] = $$k;
+        }
+    }
 
-   // Everyone needs stuff from config, and config needs stuff from
-   // strings.php, so include them both here.
-   // Include them down here instead of at the top so that all config
-   // variables overwrite any passed in variables (for security)
-   require_once('../functions/strings.php');
-   require_once('../config/config.php');
-   require_once('../src/load_prefs.php');
-   require_once('../functions/page_header.php');
-   require_once('../functions/prefs.php');
+   /**
+    * Everyone needs stuff from config, and config needs stuff from
+    * strings.php, so include them both here.
+    *
+    * Include them down here instead of at the top so that all config
+    * variables overwrite any passed in variables (for security).
+    */
+    require_once('../functions/strings.php');
+    require_once('../config/config.php');
+    require_once('../src/load_prefs.php');
+    require_once('../functions/page_header.php');
+    require_once('../functions/prefs.php');
 
-   // Set up the language
-   // i18n.php was included by auth.php
-   global $username, $data_dir;
-   set_up_language(getPref($data_dir, $username, 'language'));
+    /* Set up the language (i18n.php was included by auth.php). */
+    global $username, $data_dir;
+    set_up_language(getPref($data_dir, $username, 'language'));
 ?>