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