| 1 | <?php |
| 2 | /** |
| 3 | ** options_highlight.php |
| 4 | ** |
| 5 | ** Copyright (c) 1999-2000 The SquirrelMail development team |
| 6 | ** Licensed under the GNU GPL. For full terms see the file COPYING. |
| 7 | ** |
| 8 | ** Displays message highlighting options |
| 9 | ** |
| 10 | **/ |
| 11 | |
| 12 | session_start(); |
| 13 | |
| 14 | if (!isset($config_php)) |
| 15 | include("../config/config.php"); |
| 16 | if (!isset($strings_php)) |
| 17 | include("../functions/strings.php"); |
| 18 | if (!isset($page_header_php)) |
| 19 | include("../functions/page_header.php"); |
| 20 | if (!isset($display_messages_php)) |
| 21 | include("../functions/display_messages.php"); |
| 22 | if (!isset($imap_php)) |
| 23 | include("../functions/imap.php"); |
| 24 | if (!isset($array_php)) |
| 25 | include("../functions/array.php"); |
| 26 | if (!isset($i18n_php)) |
| 27 | include("../functions/i18n.php"); |
| 28 | |
| 29 | |
| 30 | if ($action == "delete" && isset($id)) { |
| 31 | removePref($data_dir, $username, "highlight$id"); |
| 32 | } else if ($action == "save") { |
| 33 | if (!$id) $id = 0; |
| 34 | $name = ereg_replace(",", " ", $name); |
| 35 | if ($color_type == 1) $newcolor = $newcolor_choose; |
| 36 | else $newcolor = $newcolor_input; |
| 37 | |
| 38 | $newcolor = ereg_replace(",", "", $newcolor); |
| 39 | $newcolor = ereg_replace("#", "", $newcolor); |
| 40 | $newcolor = "$newcolor"; |
| 41 | $value = ereg_replace(",", " ", $value); |
| 42 | setPref($data_dir, $username, "highlight$id", $name.",".$newcolor.",".$value.",".$match_type); |
| 43 | $message_highlight_list[$id]["name"] = $name; |
| 44 | $message_highlight_list[$id]["color"] = $newcolor; |
| 45 | $message_highlight_list[$id]["value"] = $value; |
| 46 | $message_highlight_list[$id]["match_type"] = $match_type; |
| 47 | } |
| 48 | include("../src/load_prefs.php"); |
| 49 | displayPageHeader($color, "None"); |
| 50 | ?> |
| 51 | <br> |
| 52 | <table width=95% align=center border=0 cellpadding=2 cellspacing=0><tr><td bgcolor="<? echo $color[0] ?>"> |
| 53 | <center><b><? echo _("Options") . " - " . _("Message Highlighting"); ?></b></center> |
| 54 | </td></tr></table> |
| 55 | |
| 56 | <? |
| 57 | echo "<br><center>[<a href=\"options_highlight.php?action=add\">" . _("New") . "</a>]"; |
| 58 | echo " - [<a href=\"options.php\">"._("Done")."</a>]</center><br>\n"; |
| 59 | if (count($message_highlight_list) >= 1) { |
| 60 | echo "<table border=0 cellpadding=3 cellspacing=0 align=center width=80%>\n"; |
| 61 | for ($i=0; $i < count($message_highlight_list); $i++) { |
| 62 | echo "<tr>\n"; |
| 63 | echo " <td width=1% bgcolor=" . $color[4] . ">\n"; |
| 64 | echo "<nobr><small>[<a href=\"options_highlight.php?action=edit&id=$i\">" . _("Edit") . "</a>] [<a href=\"options_highlight.php?action=delete&id=$i\">"._("Delete")."</a>]</small></nobr>\n"; |
| 65 | echo " </td>"; |
| 66 | echo " <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n"; |
| 67 | echo " " . $message_highlight_list[$i]["name"]; |
| 68 | echo " </td>\n"; |
| 69 | echo " <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n"; |
| 70 | echo " ".$message_highlight_list[$i]["match_type"]." = " . $message_highlight_list[$i]["value"]; |
| 71 | echo " </td>\n"; |
| 72 | echo "</tr>\n"; |
| 73 | } |
| 74 | echo "</table>\n"; |
| 75 | echo "<br>\n"; |
| 76 | } else { |
| 77 | echo "<center>" . _("No highlighting is defined") . "</center><br>\n"; |
| 78 | echo "<br>\n"; |
| 79 | } |
| 80 | if ($action == "edit" || $action == "add") { |
| 81 | if (!isset($id)) $id = count($message_highlight_list); |
| 82 | |
| 83 | $color_list[0] = "4444aa"; |
| 84 | $color_list[1] = "44aa44"; |
| 85 | $color_list[2] = "aaaa44"; |
| 86 | $color_list[3] = "44aaaa"; |
| 87 | $color_list[4] = "aa44aa"; |
| 88 | $color_list[5] = "aaaaff"; |
| 89 | $color_list[6] = "aaffaa"; |
| 90 | $color_list[7] = "ffffaa"; |
| 91 | $color_list[8] = "aaffff"; |
| 92 | $color_list[9] = "ffaaff"; |
| 93 | $color_list[10] = "aaaaaa"; |
| 94 | $color_list[11] = "bfbfbf"; |
| 95 | $color_list[12] = "dfdfdf"; |
| 96 | $color_list[13] = "ffffff"; |
| 97 | for ($i=0; $i < 14; $i++) { |
| 98 | if ($color_list[$i] == $message_highlight_list[$id]["color"]) { |
| 99 | $selected_choose = " checked"; |
| 100 | ${"selected".$i} = " selected"; |
| 101 | continue; |
| 102 | } |
| 103 | } |
| 104 | if (!$message_highlight_list[$id]["color"]) |
| 105 | $selected_choose = " checked"; |
| 106 | else if (!$selected_choose) |
| 107 | $selected_input = " checked"; |
| 108 | |
| 109 | echo "<form action=\"options_highlight.php\">\n"; |
| 110 | echo "<input type=\"hidden\" value=\"save\" name=\"action\">\n"; |
| 111 | echo "<input type=\"hidden\" value=\"$id\" name=\"id\">\n"; |
| 112 | echo "<table width=80% align=center cellpadding=3 cellspacing=0 border=0>\n"; |
| 113 | echo " <tr bgcolor=\"$color[0]\">\n"; |
| 114 | echo " <td align=right width=25%><b>\n"; |
| 115 | echo _("Identifying name") . ":"; |
| 116 | echo " </b></td>\n"; |
| 117 | echo " <td width=75%>\n"; |
| 118 | echo " <input type=\"text\" value=\"".$message_highlight_list[$id]["name"]."\" name=\"name\">"; |
| 119 | echo " </td>\n"; |
| 120 | echo " </tr>\n"; |
| 121 | echo " <tr><td><small><small> </small></small></td></tr>\n"; |
| 122 | echo " <tr bgcolor=\"$color[0]\">\n"; |
| 123 | echo " <td align=right width=25%><b>\n"; |
| 124 | echo _("Color") . ":"; |
| 125 | echo " </b></td>\n"; |
| 126 | echo " <td width=75%>\n"; |
| 127 | echo " <input type=\"radio\" name=color_type value=1$selected_choose> <select name=newcolor_choose>\n"; |
| 128 | echo " <option value=\"$color_list[0]\"$selected0>" . _("Dark Blue") . "\n"; |
| 129 | echo " <option value=\"$color_list[1]\"$selected1>" . _("Dark Green") . "\n"; |
| 130 | echo " <option value=\"$color_list[2]\"$selected2>" . _("Dark Yellow") . "\n"; |
| 131 | echo " <option value=\"$color_list[3]\"$selected3>" . _("Dark Cyan") . "\n"; |
| 132 | echo " <option value=\"$color_list[4]\"$selected4>" . _("Dark Magenta") . "\n"; |
| 133 | echo " <option value=\"$color_list[5]\"$selected5>" . _("Light Blue") . "\n"; |
| 134 | echo " <option value=\"$color_list[6]\"$selected6>" . _("Light Green") . "\n"; |
| 135 | echo " <option value=\"$color_list[7]\"$selected7>" . _("Light Yellow") . "\n"; |
| 136 | echo " <option value=\"$color_list[8]\"$selected8>" . _("Light Cyan") . "\n"; |
| 137 | echo " <option value=\"$color_list[9]\"$selected9>" . _("Light Magenta") . "\n"; |
| 138 | echo " <option value=\"$color_list[10]\"$selected10>" . _("Dark Gray") . "\n"; |
| 139 | echo " <option value=\"$color_list[11]\"$selected11>" . _("Medium Gray") . "\n"; |
| 140 | echo " <option value=\"$color_list[12]\"$selected12>" . _("Light Gray") . "\n"; |
| 141 | echo " <option value=\"$color_list[13]\"$selected13>" . _("White") . "\n"; |
| 142 | echo " </select><br>\n"; |
| 143 | echo " <input type=\"radio\" name=color_type value=2$selected_input> ". _("Other:") ."<input type=\"text\" value=\""; |
| 144 | if ($selected_input) echo $message_highlight_list[$id]["color"]; |
| 145 | echo "\" name=\"newcolor_input\" size=7> "._("Ex: 63aa7f")."<br>\n"; |
| 146 | echo " </td>\n"; |
| 147 | echo " </tr>\n"; |
| 148 | echo " <tr><td><small><small> </small></small></td></tr>\n"; |
| 149 | echo " <tr bgcolor=\"$color[0]\">\n"; |
| 150 | echo " <td align=right width=25%><b>\n"; |
| 151 | echo _("Match") . ":"; |
| 152 | echo " </b></td>\n"; |
| 153 | echo " <td width=75%>\n"; |
| 154 | echo " <select name=match_type>\n"; |
| 155 | if ($message_highlight_list[$id]["match_type"] == "from") echo " <option value=\"from\" selected>From\n"; |
| 156 | else echo " <option value=\"from\">From\n"; |
| 157 | if ($message_highlight_list[$id]["match_type"] == "to") echo " <option value=\"to\" selected>To\n"; |
| 158 | else echo " <option value=\"to\">To\n"; |
| 159 | if ($message_highlight_list[$id]["match_type"] == "cc") echo " <option value=\"cc\" selected>Cc\n"; |
| 160 | else echo " <option value=\"cc\">Cc\n"; |
| 161 | if ($message_highlight_list[$id]["match_type"] == "to_cc") echo " <option value=\"to_cc\" selected>To or Cc\n"; |
| 162 | else echo " <option value=\"to_cc\">To or Cc\n"; |
| 163 | if ($message_highlight_list[$id]["match_type"] == "subject") echo " <option value=\"subject\" selected>Subject\n"; |
| 164 | else echo " <option value=\"subject\">Subject\n"; |
| 165 | echo " </select>\n"; |
| 166 | echo " <nobr><input type=\"text\" value=\"".$message_highlight_list[$id]["value"]."\" name=\"value\"> ("; |
| 167 | echo _("Regular Expression"); |
| 168 | echo ")\n <nobr></td>\n"; |
| 169 | echo " </tr>\n"; |
| 170 | echo "</table>\n"; |
| 171 | echo "<center><input type=\"submit\" value=\"" . _("Submit") . "\"></center>\n"; |
| 172 | echo "</form>\n"; |
| 173 | } |
| 174 | ?> |
| 175 | </body></html> |