7fbca45b4c54343f9825c245c5ab7125e777570c
[squirrelmail.git] / src / msg_highlight.php
1 <?php
2 session_start();
3
4 if (!isset($config_php))
5 include("../config/config.php");
6 if (!isset($strings_php))
7 include("../functions/strings.php");
8 if (!isset($page_header_php))
9 include("../functions/page_header.php");
10 if (!isset($i18n_php))
11 include("../functions/i18n.php");
12
13
14 if ($action == "delete" && isset($id)) {
15 removePref($data_dir, $username, "highlight$id");
16 } else if ($action == "save") {
17 if (!$id) $id = 0;
18 $name = ereg_replace(",", " ", $name);
19 if ($color_type == 1) $newcolor = $newcolor_choose;
20 else $newcolor = $newcolor_input;
21
22 $newcolor = ereg_replace(",", "", $newcolor);
23 $newcolor = ereg_replace("#", "", $newcolor);
24 $newcolor = "$newcolor";
25 $value = ereg_replace(",", " ", $value);
26 setPref($data_dir, $username, "highlight$id", $name.",".$newcolor.",".$value.",".$match_type);
27 $message_highlight_list[$id]["name"] = $name;
28 $message_highlight_list[$id]["color"] = $newcolor;
29 $message_highlight_list[$id]["value"] = $value;
30 $message_highlight_list[$id]["match_type"] = $match_type;
31 }
32 include("../src/load_prefs.php");
33 displayPageHeader($color, "None");
34 echo "<br><center><b>" . _("Message Highlighting") . "</b> - [<a href=\"msg_highlight.php?action=add\">" . _("New") . "</a>]</center><br>\n";
35 if (count($message_highlight_list) >= 1) {
36 echo "<table border=0 cellpadding=3 cellspacing=0 align=center width=80%>\n";
37 for ($i=0; $i < count($message_highlight_list); $i++) {
38 echo "<tr>\n";
39 echo " <td width=1% bgcolor=" . $color[4] . ">\n";
40 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";
41 echo " </td>";
42 echo " <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n";
43 echo " " . $message_highlight_list[$i]["name"];
44 echo " </td>\n";
45 echo " <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n";
46 echo " ".$message_highlight_list[$i]["match_type"]." = " . $message_highlight_list[$i]["value"];
47 echo " </td>\n";
48 echo "</tr>\n";
49 }
50 echo "</table>\n";
51 echo "<br>\n";
52 } else {
53 echo "<center>" . _("No highlighting is defined") . "</center><br>\n";
54 echo "<br>\n";
55 }
56 if ($action == "edit" || $action == "add") {
57 if (!isset($id)) $id = count($message_highlight_list);
58
59 $color_list[0] = "4444aa";
60 $color_list[1] = "44aa44";
61 $color_list[2] = "aaaa44";
62 $color_list[3] = "44aaaa";
63 $color_list[4] = "aa44aa";
64 $color_list[5] = "aaaaff";
65 $color_list[6] = "aaffaa";
66 $color_list[7] = "ffffaa";
67 $color_list[8] = "aaffff";
68 $color_list[9] = "ffaaff";
69 $color_list[10] = "aaaaaa";
70 $color_list[11] = "bfbfbf";
71 $color_list[12] = "dfdfdf";
72 $color_list[13] = "ffffff";
73
74 for ($i=0; $i < 14; $i++) {
75 if ($color_list[$i] == $message_highlight_list[$id]["color"]) {
76 $selected_choose = " checked";
77 ${"selected".$i} = " selected";
78 continue;
79 }
80 }
81 if (!$message_highlight_list[$id]["color"])
82 $selected_choose = " checked";
83 else if (!$selected_choose)
84 $selected_input = " checked";
85
86 echo "<form action=\"msg_highlight.php\">\n";
87 echo "<input type=\"hidden\" value=\"save\" name=\"action\">\n";
88 echo "<input type=\"hidden\" value=\"$id\" name=\"id\">\n";
89 echo "<table width=80% align=center cellpadding=2 cellspacing=0 border=0>\n";
90 echo " <tr>\n";
91 echo " <td align=right width=40%>\n";
92 echo _("Identifying name") . ":";
93 echo " </td>\n";
94 echo " <td width=60%>\n";
95 echo " <input type=\"text\" value=\"".$message_highlight_list[$id]["name"]."\" name=\"name\">";
96 echo " </td>\n";
97 echo " </tr>\n";
98 echo " <tr><td><br><br></td></tr>\n";
99 echo " <tr>\n";
100 echo " <td align=right width=40%>\n";
101 echo _("Color") . ":";
102 echo " </td>\n";
103 echo " <td width=60%>\n";
104 echo " <input type=\"radio\" name=color_type value=1$selected_choose> &nbsp;<select name=newcolor_choose>\n";
105 echo " <option value=\"$color_list[0]\"$selected0>" . _("Dark Blue") . "\n";
106 echo " <option value=\"$color_list[1]\"$selected1>" . _("Dark Green") . "\n";
107 echo " <option value=\"$color_list[2]\"$selected2>" . _("Dark Yellow") . "\n";
108 echo " <option value=\"$color_list[3]\"$selected3>" . _("Dark Cyan") . "\n";
109 echo " <option value=\"$color_list[4]\"$selected4>" . _("Dark Magenta") . "\n";
110 echo " <option value=\"$color_list[5]\"$selected5>" . _("Light Blue") . "\n";
111 echo " <option value=\"$color_list[6]\"$selected6>" . _("Light Green") . "\n";
112 echo " <option value=\"$color_list[7]\"$selected7>" . _("Light Yellow") . "\n";
113 echo " <option value=\"$color_list[8]\"$selected8>" . _("Light Cyan") . "\n";
114 echo " <option value=\"$color_list[9]\"$selected9>" . _("Light Magenta") . "\n";
115 echo " <option value=\"$color_list[10]\"$selected10>" . _("Dark Gray") . "\n";
116 echo " <option value=\"$color_list[11]\"$selected11>" . _("Medium Gray") . "\n";
117 echo " <option value=\"$color_list[12]\"$selected12>" . _("Light Gray") . "\n";
118 echo " <option value=\"$color_list[13]\"$selected13>" . _("White") . "\n";
119 echo " </select><br>\n";
120 echo " <input type=\"radio\" name=color_type value=2$selected_input> &nbsp;". _("Other:") ."<input type=\"text\" value=\"";
121 if ($selected_input) echo $message_highlight_list[$id]["color"];
122 echo "\" name=\"newcolor_input\" size=7> "._("Ex: 63aa7f")."<br>\n";
123 echo " </td>\n";
124 echo " </tr>\n";
125 echo " <tr><td><br><br></td></tr>\n";
126 echo " <tr>\n";
127 echo " <td align=right width=40%>\n";
128 echo _("Match") . ":";
129 echo " </td>\n";
130 echo " <td width=60%>\n";
131 echo " <select name=match_type>\n";
132 if ($message_highlight_list[$id]["match_type"] == "from") echo " <option value=\"from\" selected>From\n";
133 else echo " <option value=\"from\">From\n";
134 if ($message_highlight_list[$id]["match_type"] == "to") echo " <option value=\"to\" selected>To\n";
135 else echo " <option value=\"to\">To\n";
136 if ($message_highlight_list[$id]["match_type"] == "subject") echo " <option value=\"subject\" selected>Subject\n";
137 else echo " <option value=\"subject\">Subject\n";
138 echo " </select>\n";
139 echo " <input type=\"text\" value=\"".$message_highlight_list[$id]["value"]."\" name=\"value\">";
140 echo " </td>\n";
141 echo " </tr>\n";
142 echo "</table>\n";
143 echo "<center><input type=\"submit\" value=\"" . _("Submit") . "\"></center>\n";
144 echo "</form>\n";
145 }
146 echo "</BODY></HTML>";
147 ?>