Added code for priority.
authorullgren <ullgren@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 4 Nov 2001 11:57:08 +0000 (11:57 +0000)
committerullgren <ullgren@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 4 Nov 2001 11:57:08 +0000 (11:57 +0000)
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
functions/mailbox_display.php
functions/mime.php
functions/smtp.php
src/compose.php
src/read_body.php

index a3b81d98c489279feb163a7f5b44c5170799829f..8cbf6ae2ef44fe9b28f718d132b89f361994e39d 100755 (executable)
                 $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++;
          }
index c43e14aa67ff4a34e71d7e11ac67f59f32e1f925..361373da78b7930e63380aa3c73333a8c8c4bee8 100644 (file)
@@ -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;
 
                   echo "A\n";
                   $stuff = true;
                }
-               if (ereg('(5)',substr($msg['PRIORITY'],0,1))) {
-                  echo "<font color=$color[8]>v</font>\n";
-                  $stuff = true;
-               }
                if ($msg['TYPE0'] == 'multipart') {
                   echo "+\n";
                   $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']) {
                   echo "<font color=\"$color[1]\">D</font>\n";
index 90e32a90a727b51ef2f4399ef95655e61cfd9a06..cfb9e9d9706255e6b60aa6094b59aa1e01a601e2 100644 (file)
@@ -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 {
index 3bd9d4d20572dfc1a941e40e23b01d20b2bd8a34..153f15e530699a5ff52e6342cd8b90ba5d6de68e 100644 (file)
       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();
 
             $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
         
       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;
+   }
+?>
index 8c5fc0ac4459316adac529b5353cd5dc8bee979f..176acee74b4265d1b72db1dba4b388205ccc1bcf 100644 (file)
          $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);
    }
 
    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";
       if ($use_javascript_addr_book) {
       if ($save_as_draft) {
           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");
 
    // 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);
 
          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();
          }
index c987954b7c397e56d4d5ae6294b4991268ac86ea..421a44896c7ac8dc0f9bd70207d10f3472fa1fdf 100644 (file)
          }
       }
    }
+
+   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));
            '         </TD>' . "\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");
    echo '</TABLE>' .
         '   </TD></TR>' .