From 020abcf38274494558650035430a4be32e01d6e6 Mon Sep 17 00:00:00 2001 From: ullgren Date: Sun, 4 Nov 2001 11:57:08 +0000 Subject: [PATCH] Added code for priority. Sysadmins can allow/disallow users to send e-mail messages with priority using the conf.pl script. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1689 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_messages.php | 5 +++++ functions/mailbox_display.php | 17 ++++++++++------- functions/mime.php | 1 + functions/smtp.php | 30 +++++++++++++++++++++++++++--- src/compose.php | 20 ++++++++++++++++---- src/read_body.php | 22 ++++++++++++++++++++++ 6 files changed, 81 insertions(+), 14 deletions(-) diff --git a/functions/imap_messages.php b/functions/imap_messages.php index a3b81d98..8cbf6ae2 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -492,6 +492,11 @@ $hdr->date = time(); $i++; } + /** X-PRIORITY **/ + else if (strtolower(substr($read[$i], 0, 11)) == "x-priority:") { + $hdr->priority = trim(substr($read[$i], 11)); + $i++; + } else { $i++; } diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index c43e14aa..361373da 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -21,6 +21,7 @@ global $checkall; global $color, $msgs, $msort; global $sent_folder, $draft_folder; + global $default_use_priority; global $message_highlight_list; global $index_order; @@ -138,17 +139,19 @@ echo "A\n"; $stuff = true; } - if (ereg('(5)',substr($msg['PRIORITY'],0,1))) { - echo "v\n"; - $stuff = true; - } if ($msg['TYPE0'] == 'multipart') { echo "+\n"; $stuff = true; } - if (ereg('(1|2)',substr($msg['PRIORITY'],0,1))) { - echo "!\n"; - $stuff = true; + if ($default_use_priority) { + if (ereg('(1|2)',substr($msg['PRIORITY'],0,1))) { + echo "!\n"; + $stuff = true; + } + if (ereg('(5)',substr($msg['PRIORITY'],0,1))) { + echo "?\n"; + $stuff = true; + } } if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) { echo "D\n"; diff --git a/functions/mime.php b/functions/mime.php index 90e32a90..cfb9e9d9 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -24,6 +24,7 @@ var $cc = array(), $bcc = array(), $reply_to = '', $subject = ''; var $id = 0, $mailbox = '', $description = '', $filename = ''; var $entity_id = 0, $message_id = 0, $name = ''; + // var $priority = ""; } class message { diff --git a/functions/smtp.php b/functions/smtp.php index 3bd9d4d2..153f15e5 100644 --- a/functions/smtp.php +++ b/functions/smtp.php @@ -569,9 +569,10 @@ return $err_num; } - function sendMessage($t, $c, $b, $subject, $body, $reply_id) { + function sendMessage($t, $c, $b, $subject, $body, $reply_id, $prio = 3) { global $useSendmail, $msg_id, $is_reply, $mailbox, $onetimepad; global $data_dir, $username, $domain, $key, $version, $sent_folder, $imapServerAddress, $imapPort; + global $default_use_priority; global $more_headers; $more_headers = Array(); @@ -593,6 +594,9 @@ $more_headers['References'] = $hdr->message_id; } } + if ($default_use_priority) { + $more_headers = array_merge($more_headers, createPriorityHeaders($prio)); + } // In order to remove the problem of users not able to create // messages with "." on a blank line, RFC821 has made provision @@ -625,5 +629,25 @@ return $length; } - -?> \ No newline at end of file + + function createPriorityHeaders($prio) { + $prio_headers = Array(); + $prio_headers["X-Priority"] = $prio; + + switch($prio) { + case 1: $prio_headers["Importance"] = "High"; + $prio_headers["X-MSMail-Priority"] = "High"; + break; + + case 3: $prio_headers["Importance"] = "Normal"; + $prio_headers["X-MSMail-Priority"] = "Normal"; + break; + + case 5: + $prio_headers["Importance"] = "Low"; + $prio_headers["X-MSMail-Priority"] = "Low"; + break; + } + return $prio_headers; + } +?> diff --git a/src/compose.php b/src/compose.php index 8c5fc0ac..176acee7 100644 --- a/src/compose.php +++ b/src/compose.php @@ -208,7 +208,8 @@ $editor_size, $attachments, $subject, $newmail, $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox, $from_htmladdr_search, $location_of_buttons, $attachment_dir, - $username, $data_dir, $identity, $draft_id, $delete_draft; + $username, $data_dir, $identity, $draft_id, $delete_draft, + $mailprio; $subject = decodeHeader($subject); $reply_subj = decodeHeader($reply_subj); @@ -376,7 +377,8 @@ } function showComposeButtonRow() { - global $use_javascript_addr_book, $save_as_draft; + global $use_javascript_addr_book, $save_as_draft, + $default_use_priority, $mailprio; echo " \n \n"; if ($use_javascript_addr_book) { @@ -393,6 +395,16 @@ if ($save_as_draft) { echo "\n"; } + if ($default_use_priority) { + if(!isset($mailprio)) { + $mailprio = "3"; + } + echo "\n\t". _("Priority") .":"; + } do_hook("compose_button_row"); @@ -419,7 +431,7 @@ // True if FAILURE function saveAttachedFiles() { global $HTTP_POST_FILES, $attachment_dir, $attachments; - + $localfilename = GenerateRandomString(32, '', 7); while (file_exists($attachment_dir . $localfilename)) $localfilename = GenerateRandomString(32, '', 7); @@ -500,7 +512,7 @@ do_hook("compose_send"); - if (! sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id)) { + if (!sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body, $reply_id, $mailprio)) { showInputForm(); exit(); } diff --git a/src/read_body.php b/src/read_body.php index c987954b..421a4489 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -334,6 +334,17 @@ } } } + + if($default_use_priority) { + switch(substr($message->header->priority,0,1)) { + case "1" : $priority_string = _("High"); + break; + case "3" : $priority_string = _("Normal"); + break; + case "5" : $priority_string = _("Low"); + break; + } + } /** make sure everything will display in HTML format **/ $from_name = decodeHeader(htmlspecialchars($message->header->from)); $subject = decodeHeader(htmlspecialchars($message->header->subject)); @@ -466,6 +477,17 @@ ' ' . "\n" . ' ' . "\n"; } + if ($default_use_priority) { + if (isset($priority_string)) { + echo " \n" . + " \n" . + " "._("Priority").": \n". + " \n" . + " $priority_string \n" . + " " . "\n" . + " " . "\n"; + } + } do_hook("read_body_header"); echo '' . ' ' . -- 2.25.1