9d157cec |
1 | <?php |
895905c0 |
2 | |
c57b0888 |
3 | /** |
4 | * options_highlight.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
c57b0888 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Displays message highlighting options |
10 | * |
11 | * $Id$ |
12 | */ |
ef870322 |
13 | |
c57b0888 |
14 | require_once('../src/validate.php'); |
15 | require_once('../functions/display_messages.php'); |
16 | require_once('../functions/imap.php'); |
17 | require_once('../functions/array.php'); |
18 | require_once('../functions/plugin.php'); |
9d157cec |
19 | |
c57b0888 |
20 | function oh_opt( $val, $sel, $tit ) { |
d79e01f5 |
21 | echo "<option value=\"$val\""; |
c57b0888 |
22 | if ( $sel ) |
23 | echo 'selected'; |
24 | echo ">$tit</option>\n"; |
25 | } |
e697b6cc |
26 | |
d79e01f5 |
27 | if (! isset($action)) { |
28 | $action = ''; |
29 | } |
30 | if (! isset($message_highlight_list)) { |
31 | $message_highlight_list = array(); |
32 | } |
33 | |
34 | if ($action == 'delete' && isset($theid)) { |
35 | removePref($data_dir, $username, "highlight$theid"); |
36 | header( "Location: $PHP_SELF" ); |
37 | exit; |
38 | } else if ($action == 'save') { |
39 | if (!$theid) $theid = 0; |
40 | $identname = ereg_replace(',', ' ', $identname); |
41 | if ($color_type == 1) $newcolor = $newcolor_choose; |
42 | elseif ($color_type == 2) $newcolor = $newcolor_input; |
43 | else $newcolor = $color_type; |
44 | |
45 | $newcolor = ereg_replace(',', '', $newcolor); |
46 | $newcolor = ereg_replace('#', '', $newcolor); |
47 | $newcolor = ereg_replace('"', '', $newcolor); |
48 | $newcolor = ereg_replace('\'', '', $newcolor); |
49 | $value = ereg_replace(',', ' ', $value); |
50 | |
51 | setPref($data_dir, $username, "highlight$theid", $identname.','.$newcolor.','.$value.','.$match_type); |
52 | $message_highlight_list[$theid]['name'] = $identname; |
53 | $message_highlight_list[$theid]['color'] = $newcolor; |
54 | $message_highlight_list[$theid]['value'] = $value; |
55 | $message_highlight_list[$theid]['match_type'] = $match_type; |
56 | } |
57 | displayPageHeader($color, 'None'); |
c36ed9cf |
58 | ?> |
d79e01f5 |
59 | <br> |
60 | <table width="95%" align="center" border="0" cellpadding="2" cellspacing="0"><tr><td bgcolor="<?php echo $color[0] ?>"> |
61 | <center><b><?php echo _("Options") . ' - ' . _("Message Highlighting"); ?></b></center> |
62 | </td></tr></table> |
c36ed9cf |
63 | |
8442ac08 |
64 | <?php |
d79e01f5 |
65 | echo '<br><center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]'. |
e697b6cc |
66 | ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n"; |
d79e01f5 |
67 | if (count($message_highlight_list) >= 1) { |
68 | echo '<table border="0" cellpadding="3" cellspacing="0" align="center" width="80%">'."\n"; |
69 | for ($i=0; $i < count($message_highlight_list); $i++) { |
e697b6cc |
70 | echo '<tr bgcolor="' . $message_highlight_list[$i]['color'] . '">'. |
d79e01f5 |
71 | "<td width=20% bgcolor=\"$color[4]\" nobr>". |
72 | "<small>[<a href=\"options_highlight.php?action=edit&theid=$i\">". |
73 | _("Edit") . |
74 | '</a>] [<a href="options_highlight.php?action=delete&theid='. |
75 | $i . '">' . _("Delete") . '</a>]</small>'. |
76 | '</td><td>'. |
77 | htmlspecialchars($message_highlight_list[$i]['name']) . |
78 | '</td><td>'. |
79 | $message_highlight_list[$i]['match_type'] . ' = ' . |
80 | htmlspecialchars($message_highlight_list[$i]['value']). |
81 | '</td></tr>'; |
82 | } |
83 | echo "</table>\n". |
84 | "<br>\n"; |
85 | } else { |
86 | echo '<center>' . _("No highlighting is defined") . "</center><br>\n". |
87 | "<br>\n"; |
88 | } |
89 | if ($action == 'edit' || $action == 'add') { |
90 | if (!isset($theid)) |
91 | { |
5b528f70 |
92 | $theid = count($message_highlight_list); |
93 | $message_highlight_list[$theid] = array(); |
d79e01f5 |
94 | } |
95 | |
96 | $color_list[0] = '4444aa'; |
97 | $color_list[1] = '44aa44'; |
98 | $color_list[2] = 'aaaa44'; |
99 | $color_list[3] = '44aaaa'; |
100 | $color_list[4] = 'aa44aa'; |
101 | $color_list[5] = 'aaaaff'; |
102 | $color_list[6] = 'aaffaa'; |
103 | $color_list[7] = 'ffffaa'; |
104 | $color_list[8] = 'aaffff'; |
105 | $color_list[9] = 'ffaaff'; |
106 | $color_list[10] = 'aaaaaa'; |
107 | $color_list[11] = 'bfbfbf'; |
108 | $color_list[12] = 'dfdfdf'; |
109 | $color_list[13] = 'ffffff'; |
110 | |
111 | # helpful color chart from http://www.visibone.com/colorlab/big.html |
112 | $new_color_list["0,0"] = 'cccccc'; |
113 | $new_color_list["0,1"] = '999999'; |
114 | $new_color_list["0,2"] = '666666'; |
115 | $new_color_list["0,3"] = '333333'; |
116 | $new_color_list["0,4"] = '000000'; |
117 | |
118 | # red |
119 | $new_color_list["1,0"] = 'ff0000'; |
120 | $new_color_list["1,1"] = 'cc0000'; |
121 | $new_color_list["1,2"] = '990000'; |
122 | $new_color_list["1,3"] = '660000'; |
123 | $new_color_list["1,4"] = '330000'; |
124 | |
125 | $new_color_list["2,0"] = 'ffcccc'; |
126 | $new_color_list["2,1"] = 'cc9999'; |
127 | $new_color_list["2,2"] = '996666'; |
128 | $new_color_list["2,3"] = '663333'; |
129 | $new_color_list["2,4"] = '330000'; |
130 | |
131 | $new_color_list["3,0"] = 'ffcccc'; |
132 | $new_color_list["3,1"] = 'ff9999'; |
133 | $new_color_list["3,2"] = 'ff6666'; |
134 | $new_color_list["3,3"] = 'ff3333'; |
135 | $new_color_list["3,4"] = 'ff0000'; |
136 | |
137 | # green |
138 | $new_color_list["4,0"] = '00ff00'; |
139 | $new_color_list["4,1"] = '00cc00'; |
140 | $new_color_list["4,2"] = '009900'; |
141 | $new_color_list["4,3"] = '006600'; |
142 | $new_color_list["4,4"] = '003300'; |
143 | |
144 | $new_color_list["5,0"] = 'ccffcc'; |
145 | $new_color_list["5,1"] = '99cc99'; |
146 | $new_color_list["5,2"] = '669966'; |
147 | $new_color_list["5,3"] = '336633'; |
148 | $new_color_list["5,4"] = '003300'; |
149 | |
150 | $new_color_list["6,0"] = 'ccffcc'; |
151 | $new_color_list["6,1"] = '99ff99'; |
152 | $new_color_list["6,2"] = '66ff66'; |
153 | $new_color_list["6,3"] = '33ff33'; |
154 | $new_color_list["6,4"] = '00ff00'; |
155 | |
156 | # blue |
157 | $new_color_list["7,0"] = '0000ff'; |
158 | $new_color_list["7,1"] = '0000cc'; |
159 | $new_color_list["7,2"] = '000099'; |
160 | $new_color_list["7,3"] = '000066'; |
161 | $new_color_list["7,4"] = '000033'; |
162 | |
163 | $new_color_list["8,0"] = 'ccccff'; |
164 | $new_color_list["8,1"] = '9999cc'; |
165 | $new_color_list["8,2"] = '666699'; |
166 | $new_color_list["8,3"] = '333366'; |
167 | $new_color_list["8,4"] = '000033'; |
168 | |
169 | $new_color_list["9,0"] = 'ccccff'; |
170 | $new_color_list["9,1"] = '9999ff'; |
171 | $new_color_list["9,2"] = '6666ff'; |
172 | $new_color_list["9,3"] = '3333ff'; |
173 | $new_color_list["9,4"] = '0000ff'; |
174 | |
175 | # yellow |
176 | $new_color_list["10,0"] = 'ffff00'; |
177 | $new_color_list["10,1"] = 'cccc00'; |
178 | $new_color_list["10,2"] = '999900'; |
179 | $new_color_list["10,3"] = '666600'; |
180 | $new_color_list["10,4"] = '333300'; |
181 | |
182 | $new_color_list["11,0"] = 'ffffcc'; |
183 | $new_color_list["11,1"] = 'cccc99'; |
184 | $new_color_list["11,2"] = '999966'; |
185 | $new_color_list["11,3"] = '666633'; |
186 | $new_color_list["11,4"] = '333300'; |
187 | |
188 | $new_color_list["12,0"] = 'ffffcc'; |
189 | $new_color_list["12,1"] = 'ffff99'; |
190 | $new_color_list["12,2"] = 'ffff66'; |
191 | $new_color_list["12,3"] = 'ffff33'; |
192 | $new_color_list["12,4"] = 'ffff00'; |
193 | |
194 | # cyan |
195 | $new_color_list["13,0"] = '00ffff'; |
196 | $new_color_list["13,1"] = '00cccc'; |
197 | $new_color_list["13,2"] = '009999'; |
198 | $new_color_list["13,3"] = '006666'; |
199 | $new_color_list["13,4"] = '003333'; |
200 | |
201 | $new_color_list["14,0"] = 'ccffff'; |
202 | $new_color_list["14,1"] = '99cccc'; |
203 | $new_color_list["14,2"] = '669999'; |
204 | $new_color_list["14,3"] = '336666'; |
205 | $new_color_list["14,4"] = '003333'; |
206 | |
207 | $new_color_list["15,0"] = 'ccffff'; |
208 | $new_color_list["15,1"] = '99ffff'; |
209 | $new_color_list["15,2"] = '66ffff'; |
210 | $new_color_list["15,3"] = '33ffff'; |
211 | $new_color_list["15,4"] = '00ffff'; |
212 | |
213 | # magenta |
214 | $new_color_list["16,0"] = 'ff00ff'; |
215 | $new_color_list["16,1"] = 'cc00cc'; |
216 | $new_color_list["16,2"] = '990099'; |
217 | $new_color_list["16,3"] = '660066'; |
218 | $new_color_list["16,4"] = '330033'; |
219 | |
220 | $new_color_list["17,0"] = 'ffccff'; |
221 | $new_color_list["17,1"] = 'cc99cc'; |
222 | $new_color_list["17,2"] = '996699'; |
223 | $new_color_list["17,3"] = '663366'; |
224 | $new_color_list["17,4"] = '330033'; |
225 | |
226 | $new_color_list["18,0"] = 'ffccff'; |
227 | $new_color_list["18,1"] = 'ff99ff'; |
228 | $new_color_list["18,2"] = 'ff66ff'; |
229 | $new_color_list["18,3"] = 'ff33ff'; |
230 | $new_color_list["18,4"] = 'ff00ff'; |
231 | |
232 | $selected_input = ''; |
233 | $selected_choose = ''; |
234 | |
235 | for ($i=0; $i < 14; $i++) { |
236 | ${"selected".$i} = ''; |
237 | } |
238 | if (isset($message_highlight_list[$theid]['color'])) { |
239 | for ($i=0; $i < 14; $i++) { |
e1db998a |
240 | if ($color_list[$i] == $message_highlight_list[$theid]['color']) { |
d79e01f5 |
241 | $selected_choose = ' checked'; |
242 | ${"selected".$i} = ' selected'; |
243 | continue; |
cd928157 |
244 | } |
d79e01f5 |
245 | } |
246 | } |
247 | if (!isset($message_highlight_list[$theid]['color'])) |
248 | $selected_choose = ' checked'; |
249 | else if ($selected_choose == '') |
250 | $selected_input = ' checked'; |
251 | |
252 | echo '<form name="f" action="options_highlight.php">' . "\n"; |
253 | echo '<input type="hidden" value="save" name="action">' . "\n"; |
254 | echo '<input type="hidden" value="'.$theid.'" name="theid">' . "\n"; |
255 | echo '<table width="80%" align="center" cellpadding="3" cellspacing="0" border="0">' . "\n"; |
256 | echo " <tr bgcolor=\"$color[0]\">\n"; |
257 | echo " <td align=\"right\" nobr><b>\n"; |
258 | echo _("Identifying name") . ":"; |
259 | echo ' </b></td>' . "\n"; |
260 | echo ' <td>' . "\n"; |
261 | if (isset($message_highlight_list[$theid]['name'])) |
262 | $disp = $message_highlight_list[$theid]['name']; |
263 | else |
264 | $disp = ''; |
265 | $disp = htmlspecialchars($disp); |
266 | echo " <input type=\"text\" value=\"".$disp."\" name=\"identname\">"; |
267 | echo " </td>\n"; |
268 | echo " </tr>\n"; |
269 | echo ' <tr><td><small><small> </small></small></td></tr>' . "\n"; |
270 | echo " <tr bgcolor=\"$color[0]\">\n"; |
271 | echo ' <td align="right"><b>' . "\n"; |
272 | echo _("Color") . ':'; |
273 | echo " </b></td>\n"; |
274 | echo ' <td>' . "\n"; |
275 | echo " <input type=\"radio\" name=color_type value=1$selected_choose> <select name=newcolor_choose>\n"; |
276 | echo " <option value=\"$color_list[0]\"$selected0>" . _("Dark Blue") . "\n"; |
277 | echo " <option value=\"$color_list[1]\"$selected1>" . _("Dark Green") . "\n"; |
278 | echo " <option value=\"$color_list[2]\"$selected2>" . _("Dark Yellow") . "\n"; |
279 | echo " <option value=\"$color_list[3]\"$selected3>" . _("Dark Cyan") . "\n"; |
280 | echo " <option value=\"$color_list[4]\"$selected4>" . _("Dark Magenta") . "\n"; |
281 | echo " <option value=\"$color_list[5]\"$selected5>" . _("Light Blue") . "\n"; |
282 | echo " <option value=\"$color_list[6]\"$selected6>" . _("Light Green") . "\n"; |
283 | echo " <option value=\"$color_list[7]\"$selected7>" . _("Light Yellow") . "\n"; |
284 | echo " <option value=\"$color_list[8]\"$selected8>" . _("Light Cyan") . "\n"; |
285 | echo " <option value=\"$color_list[9]\"$selected9>" . _("Light Magenta") . "\n"; |
286 | echo " <option value=\"$color_list[10]\"$selected10>" . _("Dark Gray") . "\n"; |
287 | echo " <option value=\"$color_list[11]\"$selected11>" . _("Medium Gray") . "\n"; |
288 | echo " <option value=\"$color_list[12]\"$selected12>" . _("Light Gray") . "\n"; |
289 | echo " <option value=\"$color_list[13]\"$selected13>" . _("White") . "\n"; |
290 | echo " </select><br>\n"; |
291 | echo " <input type=\"radio\" name=color_type value=2$selected_input> ". _("Other:") ."<input type=\"text\" value=\""; |
292 | if ($selected_input) echo $message_highlight_list[$theid]["color"]; |
293 | echo '" name="newcolor_input" size="7"> '._("Ex: 63aa7f")."<br>\n"; |
294 | echo " </td>\n"; |
295 | echo " </tr>\n"; |
296 | |
297 | # Show grid of color choices |
298 | echo "<tr bgcolor=$color[0]><td colspan='2'>\n"; |
299 | echo "<table border=0 cellpadding=\"2\" align=\"center\" cellspacing=\"1\">\n"; |
300 | $current_color = $message_highlight_list[$theid]['color']; |
301 | for($x = 0; $x < 5; $x++) { |
721d2a60 |
302 | echo "<tr>\n"; |
303 | for($y = 0; $y < 19; $y++) { |
d79e01f5 |
304 | $gridindex = "$y,$x"; |
305 | $gridcolor = $new_color_list[$gridindex]; |
306 | $selected = ($gridcolor == $current_color)?'SELECTED':'' ; |
307 | echo "<td bgcolor=#$gridcolor><input type='radio' name=color_type value='#$gridcolor' $selected>\n"; |
308 | echo "</td>\n"; |
721d2a60 |
309 | } |
310 | echo "</tr>\n"; |
d79e01f5 |
311 | } |
312 | echo "</table>\n"; |
313 | echo "</tr></td>\n"; |
314 | |
315 | echo ' <tr><td><small><small> </small></small></td></tr>' . "\n"; |
316 | echo " <tr bgcolor=\"$color[0]\">\n"; |
317 | echo ' <td align="center" colspan=2>' . "\n"; |
318 | echo " <select name=match_type>\n"; |
319 | oh_opt( 'from', |
320 | ($message_highlight_list[$theid]['match_type'] == 'from'), |
321 | _("From") ); |
322 | oh_opt( 'to', |
323 | ($message_highlight_list[$theid]['match_type'] == 'to'), |
324 | _("To") ); |
325 | oh_opt( 'cc', |
326 | ($message_highlight_list[$theid]['match_type'] == 'cc'), |
327 | _("Cc") ); |
328 | oh_opt( 'to_cc', |
329 | ($message_highlight_list[$theid]['match_type'] == 'to_cc'), |
330 | _("To or Cc") ); |
331 | oh_opt( 'subject', |
332 | ($message_highlight_list[$theid]['match_type'] == 'subject'), |
333 | _("Subject") ); |
334 | echo " </select>\n"; |
335 | echo '<b>' . _("Matches") . ':</b> '; |
336 | if (isset($message_highlight_list[$theid]['value'])) |
337 | $disp = $message_highlight_list[$theid]['value']; |
338 | else |
339 | $disp = ''; |
340 | $disp = htmlspecialchars($disp); |
341 | echo ' <input type="text" value="' . $disp . |
342 | '" name="value" size=40>'; |
343 | echo " </td>\n"; |
344 | echo " </tr>\n"; |
345 | echo "</table>\n"; |
346 | echo '<center><input type="submit" value="' . _("Submit") . "\"></center>\n"; |
347 | echo "</form>\n"; |
348 | } |
349 | do_hook('options_highlight_bottom'); |
9d157cec |
350 | ?> |
c57b0888 |
351 | </body></html> |