From 44f642f5f0ce75901e1fb73a06f0a5791ba82711 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Mon, 19 Jun 2000 00:57:21 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@546 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- BUG | 2 + TODO | 2 +- functions/imap_mailbox.php | 10 ++-- functions/prefs.php | 37 +++++++++++++ src/msg_highlight.php | 111 +++++++++++++++++++++++++++++++------ src/options.php | 7 +-- 6 files changed, 141 insertions(+), 28 deletions(-) diff --git a/BUG b/BUG index 4bf48417..bb7caf6a 100644 --- a/BUG +++ b/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 / diff --git a/TODO b/TODO index f92da748..dd3981f2 100644 --- a/TODO +++ b/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: diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index c4c9da99..0f5943d2 100755 --- a/functions/imap_mailbox.php +++ b/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; + } } } diff --git a/functions/prefs.php b/functions/prefs.php index f636ec4a..b0a88941 100644 --- a/functions/prefs.php +++ b/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. ") ."
"; + 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"; diff --git a/src/msg_highlight.php b/src/msg_highlight.php index bbcff874..a92bca57 100644 --- a/src/msg_highlight.php +++ b/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 "
\n"; - echo "
" . _("Message Highlighting") . "

\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 "saved"; + $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 "
" . _("Message Highlighting") . " - [" . _("New") . "]

\n"; + if (count($message_highlight_list) >= 1) { + echo "\n"; + for ($i=0; $i < count($message_highlight_list); $i++) { + echo "\n"; + echo " "; + echo " \n"; + echo " \n"; + echo "\n"; + } + echo "
\n"; + echo "[" . _("Edit") . "] ["._("Delete")."]\n"; + echo " \n"; + echo " " . $message_highlight_list[$i]["name"]; + echo " \n"; + echo " " . $message_highlight_list[$i]["value"]; + echo "
\n"; + echo "
\n"; } else { + echo "
" . _("No highlighting is defined") . "

\n"; + echo "
\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 "
\n"; echo "\n"; echo "\n"; - echo "\n"; + echo "
\n"; echo " \n"; - echo " \n"; - echo " \n"; echo " \n"; + echo " \n"; echo " \n"; - echo " \n"; - echo " \n"; echo " \n"; + echo " \n"; echo " \n"; - echo " \n"; - echo " \n"; echo " \n"; echo "
\n"; + echo " \n"; echo _("Identifying name") . ":"; echo " \n"; + echo " \n"; echo " "; echo "


\n"; + echo " \n"; echo _("Color") . ":"; echo " \n"; - echo " "; + echo " \n"; + echo "  
\n"; + echo "  ". _("Other:") ." "._("Ex: 63aa7f")."
\n"; echo "


\n"; + echo " \n"; echo _("Match") . ":"; echo " \n"; + echo " \n"; echo " "; echo "
\n"; echo "
\n"; echo "
\n"; - } + } echo ""; ?> diff --git a/src/options.php b/src/options.php index b8acd1e8..6e7c9aee 100644 --- a/src/options.php +++ b/src/options.php @@ -405,14 +405,11 @@ // MESSAGE HIGHLIGHTING echo "
\n"; - echo "
" . _("Message Highlighting") . " - [" . _("New") . "]

\n"; + echo "
" . _("Message Highlighting") . " - [" . _("Edit") . "]

\n"; if (count($message_highlight_list) >= 1) { - echo "\n"; + echo "
\n"; for ($i=0; $i < count($message_highlight_list); $i++) { echo "\n"; - echo " "; echo " \n"; -- 2.25.1
\n"; - echo "[" . _("Edit") . "] ["._("Delete")."]\n"; - echo " \n"; echo " " . $message_highlight_list[$i]["name"]; echo "