浏览代码

Made the message highlighting much more stable and usable. It has quite
a bit of error correction, and the interface was made easier and more
functional.

Luke Ehresman 25 年之前
父节点
当前提交
257e917384
共有 6 个文件被更改,包括 141 次插入28 次删除
  1. 2 0
      BUG
  2. 1 1
      TODO
  3. 6 4
      functions/imap_mailbox.php
  4. 37 0
      functions/prefs.php
  5. 93 18
      src/msg_highlight.php
  6. 2 5
      src/options.php

+ 2 - 0
BUG

@@ -4,6 +4,8 @@ Known BUGS to be fixed before 0.5pre1:
 
 
 -----------------------SQUASHED------------------------
+--Fixed for 0.5pre1--
+
 --Fixed for 0.4pre2--
 (lme)  Sent and Trash are not set to defaults.
 (lme)  Does not delete folders correctly in UW that end in /

+ 1 - 1
TODO

@@ -4,7 +4,6 @@ Ideas to be implemented
 initials = taken by that person
 
 (pl?)   Importing of address books
-(nre)   Use PHP4 Session management, get rid of cookies
   -     Make it possible to save preferences in MySQL DB or on Filesystem
   -     Configurable headers shown on the message listing, like:  cc, to, etc
   -     Filters
@@ -18,6 +17,7 @@ initials = taken by that person
 (mcp)   Spell checking
   -     Search mailbox(es) for given criteria
 (lme)   Background highlighting messages in list based on header criteria (like pine 4.2x)
+(lme)   Fix conf.pl script and add more error checking so it doesn't throw parse errors
 
 
 Finished:

+ 6 - 4
functions/imap_mailbox.php

@@ -21,10 +21,12 @@
    function sqimap_mailbox_exists ($imap_stream, $mailbox) {
       fputs ($imap_stream, "a001 LIST \"\" \"$mailbox\"\r\n");
       $mbx = sqimap_read_data($imap_stream, "a001", true, $response, $message);
-      if (ereg ("$mailbox", $mbx[0])) {
-         return true;
-      } else {
-         return false;
+      if ($mailbox) {
+         if (ereg ("$mailbox", $mbx[0])) {
+            return true;
+         } else {
+            return false;
+         }
       }
    }
 

+ 37 - 0
functions/prefs.php

@@ -29,6 +29,43 @@
       return "";
    }
 
+   function removePref($data_dir, $username, $string) {
+      $filename = "$data_dir$username.pref";
+      $found = false;
+      if (!file_exists($filename)) {
+         echo _("Preference file, ") . "\"$filename\"" . _(", does not exist.  Log out, and log back in to create a default preference file. ") ."<BR>";
+         exit;
+      }
+      $file = fopen($filename, "r");
+
+      for ($i=0; !feof($file); $i++) {
+         $pref[$i] = fgets($file, 1024);
+         if (substr($pref[$i], 0, strpos($pref[$i], "=")) == $string) {
+            $i--;
+         }
+      }
+      fclose($file);
+
+      for ($i=0,$j=0; $i < count($pref); $i++) {
+         if (substr($pref[$i], 0, 9) == "highlight") {
+            $hlt[$j] = substr($pref[$i], strpos($pref[$i], "=")+1);
+            $j++;
+         }
+      }
+
+      $file = fopen($filename, "w");
+      for ($i=0; $i < count($pref); $i++) {
+         if (substr($pref[$i], 0, 9) != "highlight") {
+            fwrite($file, "$pref[$i]", 1024);
+         }   
+      }
+      for ($i=0; $i < count($hlt); $i++) {
+         fwrite($file, "highlight$i=$hlt[$i]");
+      }
+
+      fclose($file);
+   }
+   
    /** sets the pref, $string, to $set_to **/
    function setPref($data_dir, $username, $string, $set_to) {
       $filename = "$data_dir$username.pref";

+ 93 - 18
src/msg_highlight.php

@@ -9,53 +9,128 @@
       include("../functions/page_header.php");
    if (!isset($i18n_php))
       include("../functions/i18n.php");
-   include("../src/load_prefs.php");
-
-   displayPageHeader($color, "None");
 
-   // MESSAGE HIGHLIGHTING
-   echo "<br>\n";
-   echo "<center><b>" . _("Message Highlighting") . "</b></center><br>\n";
 
-
-   if ($action == "save") {
+   if ($action == "delete" && isset($id)) {
+      removePref($data_dir, $username, "highlight$id");
+   } else if ($action == "save") {
       if (!$id) $id = 0;
+      $name = ereg_replace(",", " ", $name);
+      if ($color_type == 1) $newcolor = $newcolor_choose;
+      else $newcolor = $newcolor_input;
+      
+      $newcolor = ereg_replace(",", "", $newcolor);
+      $newcolor = ereg_replace("#", "", $newcolor);
+      $newcolor = "$newcolor";
+      $value = ereg_replace(",", " ", $value);
       setPref($data_dir, $username, "highlight$id", $name.",".$newcolor.",".$value);
-      echo "<a href=\"options.php\">saved</a>";
+      $message_highlight_list[$id]["name"] = $name;
+      $message_highlight_list[$id]["color"] = $newcolor;
+      $message_highlight_list[$id]["value"] = $value;
+   }
+   include("../src/load_prefs.php");
+   displayPageHeader($color, "None");
+   echo "<br><center><b>" . _("Message Highlighting") . "</b> - [<a href=\"msg_highlight.php?action=add\">" . _("New") . "</a>]</center><br>\n";
+   if (count($message_highlight_list) >= 1) {
+      echo "<table border=0 cellpadding=3 cellspacing=0 align=center width=80%>\n";
+      for ($i=0; $i < count($message_highlight_list); $i++) {
+         echo "<tr>\n";
+         echo "   <td width=1% bgcolor=" . $color[4] . ">\n";
+         echo "<nobr><small>[<a href=\"msg_highlight.php?action=edit&id=$i\">" . _("Edit") . "</a>]&nbsp;[<a href=\"msg_highlight.php?action=delete&id=$i\">"._("Delete")."</a>]</small></nobr>\n";
+         echo "   </td>";
+         echo "   <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n";
+         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 "   </td>\n";
+         echo "</tr>\n";
+      }
+      echo "</table>\n";
+      echo "<br>\n";
    } else {
+      echo "<center>" . _("No highlighting is defined") . "</center><br>\n";
+      echo "<br>\n";
+   }
+   if ($action == "edit" || $action == "add") {
       if (!isset($id)) $id = count($message_highlight_list);
+
+      $color_list[0] = "4444aa";
+      $color_list[1] = "44aa44";
+      $color_list[2] = "aaaa44";
+      $color_list[3] = "44aaaa";
+      $color_list[4] = "aa44aa";
+      $color_list[5] = "aaaaff";
+      $color_list[6] = "aaffaa";
+      $color_list[7] = "ffffaa";
+      $color_list[8] = "aaffff";
+      $color_list[9] = "ffaaff";
+      $color_list[10] = "aaaaaa";
+      $color_list[11] = "bfbfbf";
+      $color_list[12] = "dfdfdf";
+      $color_list[13] = "ffffff";
+
+      for ($i=0; $i < 14; $i++) {
+         if ($color_list[$i] == $message_highlight_list[$id]["color"]) {
+            $selected_choose = " checked";
+            ${"selected".$i} = " selected";
+            continue;
+         }
+      }
+      if (!$selected_choose)
+         $selected_input = " checked";
       
       echo "<form action=\"msg_highlight.php\">\n";
       echo "<input type=\"hidden\" value=\"save\" name=\"action\">\n";
       echo "<input type=\"hidden\" value=\"$id\" name=\"id\">\n";
-      echo "<table width=75% cellpadding=2 cellspacing=0 border=0>\n";
+      echo "<table width=80% align=center cellpadding=2 cellspacing=0 border=0>\n";
       echo "   <tr>\n";
-      echo "      <td>\n";
+      echo "      <td align=right width=40%>\n";
       echo _("Identifying name") . ":";
       echo "      </td>\n";
-      echo "      <td>\n";
+      echo "      <td width=60%>\n";
       echo "         <input type=\"text\" value=\"".$message_highlight_list[$id]["name"]."\" name=\"name\">";
       echo "      </td>\n";
       echo "   </tr>\n";
+      echo "   <tr><td><br><br></td></tr>\n";
       echo "   <tr>\n";
-      echo "      <td>\n";
+      echo "      <td align=right width=40%>\n";
       echo _("Color") . ":";
       echo "      </td>\n";
-      echo "      <td>\n";
-      echo "         <input type=\"text\" value=\"".$message_highlight_list[$id]["color"]."\" name=\"newcolor\">";
+      echo "      <td width=60%>\n";
+      echo "         <input type=\"radio\" name=color_type value=1$selected_choose> &nbsp;<select name=newcolor_choose>\n";
+      echo "            <option value=\"$color_list[0]\"$selected0>" . _("Dark Blue") . "\n";
+      echo "            <option value=\"$color_list[1]\"$selected1>" . _("Dark Green") . "\n";
+      echo "            <option value=\"$color_list[2]\"$selected2>" . _("Dark Yellow") . "\n";
+      echo "            <option value=\"$color_list[3]\"$selected3>" . _("Dark Cyan") . "\n";
+      echo "            <option value=\"$color_list[4]\"$selected4>" . _("Dark Magenta") . "\n";
+      echo "            <option value=\"$color_list[5]\"$selected5>" . _("Light Blue") . "\n";
+      echo "            <option value=\"$color_list[6]\"$selected6>" . _("Light Green") . "\n";
+      echo "            <option value=\"$color_list[7]\"$selected7>" . _("Light Yellow") . "\n";
+      echo "            <option value=\"$color_list[8]\"$selected8>" . _("Light Cyan") . "\n";
+      echo "            <option value=\"$color_list[9]\"$selected9>" . _("Light Magenta") . "\n";
+      echo "            <option value=\"$color_list[10]\"$selected10>" . _("Dark Gray") . "\n";
+      echo "            <option value=\"$color_list[11]\"$selected11>" . _("Medium Gray") . "\n";
+      echo "            <option value=\"$color_list[12]\"$selected12>" . _("Light Gray") . "\n";
+      echo "            <option value=\"$color_list[13]\"$selected13>" . _("White") . "\n";
+      echo "         </select><br>\n";
+      echo "         <input type=\"radio\" name=color_type value=2$selected_input> &nbsp;". _("Other:") ."<input type=\"text\" value=\"";
+      if ($selected_input) echo $message_highlight_list[$id]["color"];
+      echo "\" name=\"newcolor_input\" size=7> "._("Ex: 63aa7f")."<br>\n";
       echo "      </td>\n";
       echo "   </tr>\n";
+      echo "   <tr><td><br><br></td></tr>\n";
       echo "   <tr>\n";
-      echo "      <td>\n";
+      echo "      <td align=right width=40%>\n";
       echo _("Match") . ":";
       echo "      </td>\n";
-      echo "      <td>\n";
+      echo "      <td width=60%>\n";
       echo "         <input type=\"text\" value=\"".$message_highlight_list[$id]["value"]."\" name=\"value\">";
       echo "      </td>\n";
       echo "   </tr>\n";
       echo "</table>\n";
       echo "<center><input type=\"submit\" value=\"" . _("Submit") . "\"></center>\n";
       echo "</form>\n";
-   }   
+   }
    echo "</BODY></HTML>";
 ?>

+ 2 - 5
src/options.php

@@ -405,14 +405,11 @@
 
    // MESSAGE HIGHLIGHTING
    echo "<br>\n";
-   echo "<center><b>" . _("Message Highlighting") . "</b> - [<a href=\"msg_highlight.php?method=add\">" . _("New") . "</a>]</center><br>\n";
+   echo "<center><b>" . _("Message Highlighting") . "</b> - [<a href=\"msg_highlight.php\">" . _("Edit") . "</a>]</center><br>\n";
    if (count($message_highlight_list) >= 1) {
-      echo "<table border=0 cellpadding=2 cellspacing=0 align=center width=100%>\n";
+      echo "<table border=0 cellpadding=2 cellspacing=0 align=center width=75%>\n";
       for ($i=0; $i < count($message_highlight_list); $i++) {
          echo "<tr>\n";
-         echo "   <td width=1% bgcolor=" . $color[4] . ">\n";
-         echo "<small>[<a href=\"msg_highlight.php?method=edit&id=$i\">" . _("Edit") . "</a>]&nbsp;["._("Delete")."]</small>\n";
-         echo "   </td>";
          echo "   <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n";
          echo "      " . $message_highlight_list[$i]["name"];
          echo "   </td>\n";