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