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