From f7b1b3b1779c3665bc943b2dec65182e8c536e69 Mon Sep 17 00:00:00 2001 From: thomppj Date: Mon, 29 Oct 2001 04:33:47 +0000 Subject: [PATCH] Lots of changes to get closer to having save as draft working. Please, keep working hard on this!!! git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1640 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- config/conf.pl | 161 +++++++++----- functions/imap_general.php | 32 +-- functions/imap_mailbox.php | 47 ++-- functions/imap_messages.php | 17 +- functions/mailbox_display.php | 248 ++++++++++----------- src/compose.php | 41 ++-- src/draft_actions.php | 25 +-- src/left_main.php | 30 ++- src/load_prefs.php | 407 +++++++++++++++++----------------- src/options_folder.php | 17 +- src/read_body.php | 19 +- src/validate.php | 201 ++++++++--------- 12 files changed, 659 insertions(+), 586 deletions(-) diff --git a/config/conf.pl b/config/conf.pl index 2295f560..4360f047 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -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 = ; + 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 = ; + 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"; diff --git a/functions/imap_general.php b/functions/imap_general.php index 09543e74..674896fb 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -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 "$read
\n"; - flush(); -} + + // For debugging purposes + if ($imap_general_debug) { + echo "$read
\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 "$read
\n"; - flush(); -} + + // For debugging purposes + if ($imap_general_debug) { + echo "$read
\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 '--
'; - - if ($handle_errors == false) - return $resultlist; + if ($imap_general_debug) { echo '--
'; } + if ($handle_errors == false) { return $resultlist; } if ($response == 'NO') { // ignore this error from m$ exchange, it is not fatal (aka bug) diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 9aa78256..420d8ca4 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -207,8 +207,8 @@ ******************************************************************************/ 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; @@ -281,8 +281,10 @@ $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); @@ -300,12 +302,10 @@ $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]; @@ -314,25 +314,39 @@ } } + /* 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)) { @@ -340,7 +354,6 @@ $used[$i] = true; } } - } // Rest of the folders @@ -451,4 +464,4 @@ return $boxes; } -?> \ No newline at end of file +?> diff --git a/functions/imap_messages.php b/functions/imap_messages.php index 70d9b08d..4cef81eb 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -96,10 +96,11 @@ $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; } @@ -108,7 +109,6 @@ 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); @@ -213,10 +213,11 @@ $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; diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 09c354b9..53ff3087 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -13,12 +13,12 @@ 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']); @@ -46,46 +45,35 @@ } $urlMailbox = urlencode($mailbox); $subject = processSubject($msg['SUBJECT']); - echo "\n"; - if (isset($msg['FLAG_FLAGGED']) && $msg['FLAG_FLAGGED'] == true) - { + if (isset($msg['FLAG_FLAGGED']) && ($msg['FLAG_FLAGGED'] == true)) { $flag = ""; $flag_end = ''; - } - else - { + } else { $flag = ''; $flag_end = ''; } - if (!isset($msg['FLAG_SEEN']) || $msg['FLAG_SEEN'] == false) - { + if (!isset($msg['FLAG_SEEN']) || ($msg['FLAG_SEEN'] == false)) { $bold = ''; $bold_end = ''; - } - else - { + } else { $bold = ''; $bold_end = ''; } - if ($mailbox == $sent_folder) - { + + if (($mailbox == $sent_folder) || ($mailbox == $draft_folder)) { $italic = ''; $italic_end = ''; - } - else - { + } else { $italic = ''; $italic_end = ''; } - if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) - { + + if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) { $fontstr = ""; $fontstr_end = ''; - } - else - { + } else { $fontstr = ''; $fontstr_end = ''; } @@ -104,30 +92,28 @@ } } - 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 " \n"; break; - case 2: # from + case 2: /* from */ echo " $italic$bold$flag$fontstr$senderName$fontstr_end$flag_end$bold_end$italic_end\n"; break; - case 3: # date + case 3: /* date */ echo "
$bold$flag$fontstr".$msg["DATE_STRING"]."$fontstr_end$flag_end$bold_end
\n"; break; - case 4: # subject + case 4: /* subject */ echo " $bold"; if (! isset($search_stuff)) { $search_stuff = ''; } echo "$flag$subject$flag_end$bold_end\n"; break; - case 5: # flags + case 5: /* flags */ $stuff = false; echo " \n"; if (isset($msg['FLAG_ANSWERED']) && @@ -170,31 +156,35 @@ if (!$stuff) echo " \n"; echo "\n"; break; - case 6: # size + case 6: /* size */ echo " $bold$fontstr".show_readable_size($msg['SIZE'])."$fontstr_end$bold_end\n"; break; } } - - echo "\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); @@ -208,14 +198,16 @@ 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)); } @@ -235,17 +227,19 @@ $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]); @@ -278,16 +272,13 @@ $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++; } @@ -297,11 +288,12 @@ /* 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++; @@ -314,9 +306,10 @@ } $numMessages = $i; } else { - if (! isset($messages)) - $messages = array(); - $msgs = $messages; + if (!isset($messages)) { + $messages = array(); + } + $msgs = $messages; } } @@ -347,20 +340,20 @@ 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); @@ -370,8 +363,7 @@ if ($endMessage < $startMessage) { $startMessage = $startMessage - $show_num; - if ($startMessage < 1) - $startMessage = 1; + if ($startMessage < 1) { $startMessage = 1; } } $nextGroup = $startMessage + $show_num; @@ -397,46 +389,46 @@ if (($nextGroup <= $numMessages) && ($prevGroup >= 0)) { $lMore = "". _("Previous") . ''; $rMore = "". _("Next") ."\n"; - } - elseif (($nextGroup > $numMessages) && ($prevGroup >= 0)) { + } else if (($nextGroup > $numMessages) && ($prevGroup >= 0)) { $lMore = "". _("Previous") . ''; $rMore = ""._("Next")."\n"; - } - elseif (($nextGroup <= $numMessages) && ($prevGroup < 0)) { + } else if (($nextGroup <= $numMessages) && ($prevGroup < 0)) { $lMore = ""._("Previous") . ''; $rMore = "". _("Next") ."\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 .= "$pg "; - $i+=$k; - } - $mMore .= "$p "; - $i += $k; - while( $i <= $j ) { + $i += $k; + } + $mMore .= "$p "; + $i += $k; + while( $i <= $j ) { $pg = intval( $i ); $start = ( ($pg-1) * $show_num ) + 1; $mMore .= "$pg "; $i+=$k; - } - $mMore .= ' | '; + } + $mMore .= ' | '; } if (! isset($msg)) @@ -456,7 +448,6 @@ $startMessage = 1; } } - $endVar = $endMessage + 1; // loop through and display the info for each message. @@ -512,11 +503,11 @@ * $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 */ @@ -562,21 +553,18 @@ echo " \n"; echo " \n"; echo "    \n"; - if (! $auto_expunge) { + if (!$auto_expunge) { echo '  '. _("mailbox") ." \n"; } - echo " \n"; echo " \n"; echo "  \n"; - echo " \n"; echo " \n"; echo "\n"; do_hook('mailbox_form_before'); echo ''; - echo ""; echo ""; echo ""; - // 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 ' '; break; - case 2: # from - if ($mailbox == $sent_folder) + case 2: /* from */ + if (($mailbox == $sent_folder) + || ($mailbox == $draft_folder)) { echo ' \n"; break; - case 3: # date + case 3: /* date */ echo ' \n"; break; - case 4: # subject + case 4: /* subject */ echo ' \n"; break; - case 6: # size + case 6: /* size */ echo ' \n"; break; } @@ -624,9 +615,11 @@ echo "\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; @@ -637,14 +630,15 @@ $img = 'down_pointer.gif'; $which = 6; } + + /* Now that we have everything figured out, show the actual button. */ echo ' '; } - function ShowSelectAllLink($startMessage, $sort) - { + function ShowSelectAllLink($startMessage, $sort) { global $checkall, $PHP_SELF, $what, $where, $mailbox; ?>  diff --git a/src/compose.php b/src/compose.php index af1a2bde..f008aee0 100644 --- a/src/compose.php +++ b/src/compose.php @@ -1,18 +1,19 @@ \n"; - if ( isset($draft_id)) + if (isset($draft_id)) { echo "\n"; + } echo "
 '. _("To") .''; - else - echo ' '. _("From") .''; + } else { + echo ' '. _("From") .''; + } + ShowSortButton($sort, $mailbox, 2, 3); echo "'. _("Date") .''; ShowSortButton($sort, $mailbox, 0, 1); echo "'. _("Subject") .' '; ShowSortButton($sort, $mailbox, 4, 5); echo "' . _("Size")."
\n"; @@ -382,9 +384,9 @@ } echo "\n \n"; - if ($save_as_draft == true) - echo "\n"; - + if ($save_as_draft) { + echo "\n"; + } do_hook("compose_button_row"); @@ -438,11 +440,12 @@ 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¬e=Draft%20Email%20Saved"); + $draft_message = _("Draft Email Saved"); + Header("Location: right_main.php?mailbox=$draft_folder&sort=$sort&startMessage=1¬e=$draft_message"); exit(); } } diff --git a/src/draft_actions.php b/src/draft_actions.php index 5dad298d..0a91cf0e 100644 --- a/src/draft_actions.php +++ b/src/draft_actions.php @@ -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); diff --git a/src/left_main.php b/src/left_main.php index f0699bfe..f7c81b25 100644 --- a/src/left_main.php +++ b/src/left_main.php @@ -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, ''); @@ -32,12 +34,17 @@ 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(' ','',$box_array['formatted']); @@ -81,11 +90,14 @@ } $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 = ''; @@ -127,6 +139,10 @@ return ($line); } + /**********************************/ + /* END OF FUNCTION - BACK TO MAIN */ + /**********************************/ + if (isset($left_refresh) && ($left_refresh != 'None') && ($left_refresh != '')) { echo "\n"; echo "\n"; diff --git a/src/load_prefs.php b/src/load_prefs.php index b73a39c3..7938a8b9 100644 --- a/src/load_prefs.php +++ b/src/load_prefs.php @@ -1,212 +1,201 @@ diff --git a/src/options_folder.php b/src/options_folder.php index 31f8c246..f0650600 100644 --- a/src/options_folder.php +++ b/src/options_folder.php @@ -48,15 +48,16 @@ '; - // SENT FOLDER + /* SENT FOLDER */ echo ''; - // Drafts Folder + /* Drafts Folder. */ echo '
'; echo _("Trash Folder:"); echo ''; echo "
'; echo _("Sent Folder:"); echo ''; echo '\n"; echo '
'; echo _("Drafts Folder:"); echo ''; echo '' . "\n" . - '
' . - ' ' . - ' ' . - '
' . - ' '; + '
' . "\n" . + ' ' . "\n" . + ' ' . "\n" . + '
' . "\n" . + ' ' . "\n"; if ($where && $what) { echo " "; } else { @@ -323,18 +323,17 @@ } else { echo " "; } - echo _("Delete") . - ' '; + echo _("Delete") . ' '; if (($mailbox == $draft_folder) && ($save_as_draft)) { echo '| '; - echo " '; + echo " "; + echo _("Resume Draft") . ''; } echo '  ' . ' ' . ' ' . ' ' . "\n"; + if ($where && $what) { } else { if ($currentArrayIndex == -1) { diff --git a/src/validate.php b/src/validate.php index 96e2dcf8..c74be9c4 100644 --- a/src/validate.php +++ b/src/validate.php @@ -1,116 +1,111 @@ $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')); ?> -- 2.25.1