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