Bladeren bron

Added code for priority.
Sysadmins can allow/disallow users to send e-mail messages with priority
using the conf.pl script.

Pontus Ullgren 24 jaren geleden
bovenliggende
commit
87928b66be
6 gewijzigde bestanden met toevoegingen van 81 en 14 verwijderingen
  1. 5 0
      functions/imap_messages.php
  2. 10 7
      functions/mailbox_display.php
  3. 1 0
      functions/mime.php
  4. 27 3
      functions/smtp.php
  5. 16 4
      src/compose.php
  6. 22 0
      src/read_body.php

+ 5 - 0
functions/imap_messages.php

@@ -492,6 +492,11 @@
                 $hdr->date = time();
                 $hdr->date = time();
             $i++;
             $i++;
          }
          }
+	 /** X-PRIORITY **/
+         else if (strtolower(substr($read[$i], 0, 11)) == "x-priority:") {
+            $hdr->priority = trim(substr($read[$i], 11));
+            $i++;
+         }
          else {
          else {
             $i++;
             $i++;
          }
          }

+ 10 - 7
functions/mailbox_display.php

@@ -21,6 +21,7 @@
       global $checkall;
       global $checkall;
       global $color, $msgs, $msort;
       global $color, $msgs, $msort;
       global $sent_folder, $draft_folder;
       global $sent_folder, $draft_folder;
+      global $default_use_priority;
       global $message_highlight_list;
       global $message_highlight_list;
       global $index_order;
       global $index_order;
 
 
@@ -138,17 +139,19 @@
                   echo "A\n";
                   echo "A\n";
                   $stuff = true;
                   $stuff = true;
                }
                }
-               if (ereg('(5)',substr($msg['PRIORITY'],0,1))) {
-                  echo "<font color=$color[8]>v</font>\n";
-                  $stuff = true;
-               }
                if ($msg['TYPE0'] == 'multipart') {
                if ($msg['TYPE0'] == 'multipart') {
                   echo "+\n";
                   echo "+\n";
                   $stuff = true;
                   $stuff = true;
                }
                }
-               if (ereg('(1|2)',substr($msg['PRIORITY'],0,1))) {
-                  echo "<font color=$color[1]>!</font>\n";
-                  $stuff = true;
+	       if ($default_use_priority) {
+                  if (ereg('(1|2)',substr($msg['PRIORITY'],0,1))) {
+                     echo "<font color=$color[1]>!</font>\n";
+                     $stuff = true;
+                  }
+                  if (ereg('(5)',substr($msg['PRIORITY'],0,1))) {
+                     echo "<font color=$color[8]>?</font>\n";
+                     $stuff = true;
+                  }
                }
                }
                if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
                if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
                   echo "<font color=\"$color[1]\">D</font>\n";
                   echo "<font color=\"$color[1]\">D</font>\n";

+ 1 - 0
functions/mime.php

@@ -24,6 +24,7 @@
       var $cc = array(), $bcc = array(), $reply_to = '', $subject = '';
       var $cc = array(), $bcc = array(), $reply_to = '', $subject = '';
       var $id = 0, $mailbox = '', $description = '', $filename = '';
       var $id = 0, $mailbox = '', $description = '', $filename = '';
       var $entity_id = 0, $message_id = 0, $name = '';
       var $entity_id = 0, $message_id = 0, $name = '';
+      // var $priority = "";
    }
    }
 
 
    class message {
    class message {

+ 27 - 3
functions/smtp.php

@@ -569,9 +569,10 @@
       return $err_num;
       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 $useSendmail, $msg_id, $is_reply, $mailbox, $onetimepad;
       global $data_dir, $username, $domain, $key, $version, $sent_folder, $imapServerAddress, $imapPort;
       global $data_dir, $username, $domain, $key, $version, $sent_folder, $imapServerAddress, $imapPort;
+      global $default_use_priority;
       global $more_headers;
       global $more_headers;
       $more_headers = Array();
       $more_headers = Array();
 
 
@@ -593,6 +594,9 @@
             $more_headers['References']  = $hdr->message_id;
             $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
       // In order to remove the problem of users not able to create
       // messages with "." on a blank line, RFC821 has made provision
       // messages with "." on a blank line, RFC821 has made provision
@@ -625,5 +629,25 @@
 	 
 	 
       return $length;
       return $length;
    }
    }
-   
-?>
+
+   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;
+   }
+?>

+ 16 - 4
src/compose.php

@@ -208,7 +208,8 @@
          $editor_size, $attachments, $subject, $newmail,
          $editor_size, $attachments, $subject, $newmail,
          $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox,
          $use_javascript_addr_book, $send_to_bcc, $reply_id, $mailbox,
          $from_htmladdr_search, $location_of_buttons, $attachment_dir,
          $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);
       $subject = decodeHeader($subject);
       $reply_subj = decodeHeader($reply_subj);
       $reply_subj = decodeHeader($reply_subj);
@@ -376,7 +377,8 @@
    }
    }
 
 
    function showComposeButtonRow() {
    function showComposeButtonRow() {
-      global $use_javascript_addr_book, $save_as_draft;
+      global $use_javascript_addr_book, $save_as_draft, 
+             $default_use_priority, $mailprio;
 
 
       echo "   <TR><td>\n   </td><td>\n";
       echo "   <TR><td>\n   </td><td>\n";
       if ($use_javascript_addr_book) {
       if ($use_javascript_addr_book) {
@@ -393,6 +395,16 @@
       if ($save_as_draft) {
       if ($save_as_draft) {
           echo "<input type=\"submit\" name =\"draft\" value=\"Save Draft\">\n";
           echo "<input type=\"submit\" name =\"draft\" value=\"Save Draft\">\n";
       }
       }
+      if ($default_use_priority) {
+        if(!isset($mailprio)) {
+	  $mailprio = "3";
+	}
+	echo "\n\t". _("Priority") .":<select name=\"mailprio\">".
+	  "\n\t\t<option value=1".($mailprio=="1"?" selected":"").">". _("High") ."</option>".
+	  "\n\t\t<option value=3".($mailprio=="3"?" selected":"").">". _("Normal") ."</option>".
+	  "\n\t\t<option value=5".($mailprio=="5"?" selected":"").">". _("Low")."</option>".
+	  "\n\t</select>";
+      }
 
 
       do_hook("compose_button_row");
       do_hook("compose_button_row");
 
 
@@ -419,7 +431,7 @@
    // True if FAILURE
    // True if FAILURE
    function saveAttachedFiles() {
    function saveAttachedFiles() {
       global $HTTP_POST_FILES, $attachment_dir, $attachments;
       global $HTTP_POST_FILES, $attachment_dir, $attachments;
-
+      
       $localfilename = GenerateRandomString(32, '', 7);
       $localfilename = GenerateRandomString(32, '', 7);
       while (file_exists($attachment_dir . $localfilename))
       while (file_exists($attachment_dir . $localfilename))
           $localfilename = GenerateRandomString(32, '', 7);
           $localfilename = GenerateRandomString(32, '', 7);
@@ -500,7 +512,7 @@
 
 
          do_hook("compose_send");
          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();
             showInputForm();
             exit();
             exit();
          }
          }

+ 22 - 0
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 **/
    /** make sure everything will display in HTML format **/
    $from_name = decodeHeader(htmlspecialchars($message->header->from));
    $from_name = decodeHeader(htmlspecialchars($message->header->from));
    $subject = decodeHeader(htmlspecialchars($message->header->subject));
    $subject = decodeHeader(htmlspecialchars($message->header->subject));
@@ -466,6 +477,17 @@
            '         </TD>' . "\n" .
            '         </TD>' . "\n" .
            '      </TR>' . "\n";
            '      </TR>' . "\n";
    }
    }
+   if ($default_use_priority) {
+      if (isset($priority_string)) {
+	echo "      <TR>\n" .
+	  "         <TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
+	  "            "._("Priority").": \n".
+	  "         </TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>\n" .
+	  "            <B>$priority_string</B>&nbsp;\n" .
+	  "         </TD>" . "\n" .
+	  "      </TR>" . "\n";
+      }
+   }
    do_hook("read_body_header");
    do_hook("read_body_header");
    echo '</TABLE>' .
    echo '</TABLE>' .
         '   </TD></TR>' .
         '   </TD></TR>' .