Quellcode durchsuchen

made message highlighting be more flexible. You can now highlight messages
based upon "from", "to", or "subject".

Luke Ehresman vor 25 Jahren
Ursprung
Commit
2c69920d1e
5 geänderte Dateien mit 31 neuen und 17 gelöschten Zeilen
  1. 12 12
      functions/imap_messages.php
  2. 3 1
      functions/mailbox_display.php
  3. 1 0
      src/load_prefs.php
  4. 14 3
      src/msg_highlight.php
  5. 1 1
      src/options.php

+ 12 - 12
functions/imap_messages.php

@@ -41,7 +41,7 @@
     **  Returns some general header information -- FROM, DATE, and SUBJECT
     ******************************************************************************/
 	class small_header {
-		var $from, $subject, $date;
+		var $from, $subject, $date, $to;
 	}
 	 
    function sqimap_get_small_header ($imap_stream, $id, $sent) {
@@ -52,16 +52,12 @@
       $from = _("Unknown Sender");
 		$g = 0;
       for ($i = 0; $i < count($read); $i++) {
-			if ($sent == true) {
-         	if (eregi ("^to:", $read[$i])) {
-            	$from = sqimap_find_displayable_name(substr($read[$i], 3));
-				}	
-			} else { 
-         	if (eregi ("^from:", $read[$i])) {
-            	$from = sqimap_find_displayable_name(substr($read[$i], 5));
-				}	
-			}
-
+         if (eregi ("^to:", $read[$i])) {
+            $to = sqimap_find_displayable_name(substr($read[$i], 3));
+			}	
+         if (eregi ("^from:", $read[$i])) {
+            $from = sqimap_find_displayable_name(substr($read[$i], 5));
+			}	
          if (eregi ("^date:", $read[$i])) {
             $date = substr($read[$i], 5);
          } else if (eregi ("^subject:", $read[$i])) {
@@ -72,9 +68,13 @@
 		}	
 
 		$header = new small_header;
-		$header->from = $from;
+      if ($sent == true)
+         $header->from = $to;
+      else   
+		   $header->from = $from;
 		$header->date = $date;
 		$header->subject = $subject;
+      $header->to = $to;
 
 		return $header;
    }

+ 3 - 1
functions/mailbox_display.php

@@ -27,7 +27,7 @@
 		if ($mailbox == $sent_folder) { $italic = "<i>"; $italic_end = "</i>"; }
       
       for ($i=0; $i < count($message_highlight_list); $i++) {
-         if (eregi($message_highlight_list[$i]["value"],$msg["FROM"])) {
+         if (eregi($message_highlight_list[$i]["value"],$msg[strtoupper($message_highlight_list[$i]["match_type"])])) {
             $hlt_color = $message_highlight_list[$i]["color"];
             continue;
          }   
@@ -64,6 +64,7 @@
 					$from[$q] = $hdr->from;
 					$date[$q] = $hdr->date;
 					$subject[$q] = $hdr->subject;
+               $to[$q] = $hdr->to;
 
                $flags[$q] = sqimap_get_flags ($imapConnection, $q+1);
             }
@@ -79,6 +80,7 @@
             $messages[$j]["ID"] = $j+1;
             $messages[$j]["FROM"] = decodeHeader($from[$j]);
             $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]);
+            $messages[$j]["TO"] = decodeHeader($to[$j]);
    
             $num = 0;
             while ($num < count($flags[$j])) {

+ 1 - 0
src/load_prefs.php

@@ -107,5 +107,6 @@
       $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];
    }
 ?>

+ 14 - 3
src/msg_highlight.php

@@ -23,10 +23,11 @@
       $newcolor = ereg_replace("#", "", $newcolor);
       $newcolor = "$newcolor";
       $value = ereg_replace(",", " ", $value);
-      setPref($data_dir, $username, "highlight$id", $name.",".$newcolor.",".$value);
+      setPref($data_dir, $username, "highlight$id", $name.",".$newcolor.",".$value.",".$match_type);
       $message_highlight_list[$id]["name"] = $name;
       $message_highlight_list[$id]["color"] = $newcolor;
       $message_highlight_list[$id]["value"] = $value;
+      $message_highlight_list[$id]["match_type"] = $match_type;
    }
    include("../src/load_prefs.php");
    displayPageHeader($color, "None");
@@ -42,7 +43,7 @@
          echo "      " . $message_highlight_list[$i]["name"];
          echo "   </td>\n";
          echo "   <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n";
-         echo "      " . $message_highlight_list[$i]["value"];
+         echo "      ".$message_highlight_list[$i]["match_type"]." = " . $message_highlight_list[$i]["value"];
          echo "   </td>\n";
          echo "</tr>\n";
       }
@@ -77,7 +78,9 @@
             continue;
          }
       }
-      if (!$selected_choose)
+      if (!$message_highlight_list[$id]["color"])
+         $selected_choose = " checked";
+      else if (!$selected_choose)   
          $selected_input = " checked";
       
       echo "<form action=\"msg_highlight.php\">\n";
@@ -125,6 +128,14 @@
       echo _("Match") . ":";
       echo "      </td>\n";
       echo "      <td width=60%>\n";
+      echo "         <select name=match_type>\n";
+      if ($message_highlight_list[$id]["match_type"] == "from")    echo "            <option value=\"from\" selected>From\n"; 
+      else                                                         echo "            <option value=\"from\">From\n"; 
+      if ($message_highlight_list[$id]["match_type"] == "to")      echo "            <option value=\"to\" selected>To\n"; 
+      else                                                         echo "            <option value=\"to\">To\n"; 
+      if ($message_highlight_list[$id]["match_type"] == "subject") echo "            <option value=\"subject\" selected>Subject\n"; 
+      else                                                         echo "            <option value=\"subject\">Subject\n"; 
+      echo "         </select>\n";
       echo "         <input type=\"text\" value=\"".$message_highlight_list[$id]["value"]."\" name=\"value\">";
       echo "      </td>\n";
       echo "   </tr>\n";

+ 1 - 1
src/options.php

@@ -414,7 +414,7 @@
          echo "      " . $message_highlight_list[$i]["name"];
          echo "   </td>\n";
          echo "   <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n";
-         echo "      " . $message_highlight_list[$i]["value"];
+         echo "      ".$message_highlight_list[$i]["match_type"]." = " . $message_highlight_list[$i]["value"];
          echo "   </td>\n";
          echo "</tr>\n";
       }