4 * options_highlight.php
6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Displays message highlighting options
12 * @package squirrelmail
15 /** Path for SquirrelMail required files. */
16 define('SM_PATH','../');
18 /* SquirrelMail required files. */
19 require_once(SM_PATH
. 'include/validate.php');
20 require_once(SM_PATH
. 'functions/display_messages.php');
21 require_once(SM_PATH
. 'functions/imap.php');
22 require_once(SM_PATH
. 'functions/plugin.php');
23 require_once(SM_PATH
. 'functions/strings.php');
24 require_once(SM_PATH
. 'functions/html.php');
27 if (isset($_GET['action'])) {
28 $action = $_GET['action'];
30 if (isset($_GET['theid'])) {
31 $theid = $_GET['theid'];
33 if (isset($_GET['identname'])) {
34 $identname = $_GET['identname'];
36 if (isset($_GET['newcolor_choose'])) {
37 $newcolor_choose = $_GET['newcolor_choose'];
39 if (isset($_GET['newcolor_input'])) {
40 $newcolor_input = $_GET['newcolor_input'];
42 if (isset($_GET['color_type'])) {
43 $color_type = $_GET['color_type'];
45 if (isset($_GET['match_type'])) {
46 $match_type = $_GET['match_type'];
48 if (isset($_GET['value'])) {
49 $value = $_GET['value'];
52 /* end of get globals */
54 function oh_opt( $val, $sel, $tit ) {
55 echo "<option value=\"$val\"";
58 echo ">$tit</option>\n";
61 if (! isset($action)) {
64 if (! isset($message_highlight_list)) {
65 $message_highlight_list = array();
68 if (isset($theid) && ($action == 'delete') ||
70 ($action == 'down')) {
74 foreach($message_highlight_list as $rid => $rule) {
83 foreach($message_highlight_list as $rid => $rule) {
85 $temp_rule = $new_rules[$rid-1];
86 $new_rules[$rid-1] = $rule;
87 $new_rules[$rid] = $temp_rule;
89 $new_rules[$rid] = $rule;
94 $new_rules = $message_highlight_list;
97 $message_highlight_list = $new_rules;
99 setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
101 header( 'Location: ' .get_location(). '/options_highlight.php' );
103 } else if ($action == 'save') {
105 if ($color_type == 1) $newcolor = $newcolor_choose;
106 elseif ($color_type == 2) $newcolor = $newcolor_input;
107 else $newcolor = $color_type;
109 $newcolor = str_replace('#', '', $newcolor);
110 $newcolor = str_replace('"', '', $newcolor);
111 $newcolor = str_replace('\'', '', $newcolor);
112 $value = str_replace(',', ' ', $value);
115 $message_highlight_list[$theid] =
116 array( 'name' => $identname, 'color' => $newcolor,
117 'value' => $value, 'match_type' => $match_type );
119 $message_highlight_list[] =
120 array( 'name' => $identname, 'color' => $newcolor,
121 'value' => $value, 'match_type' => $match_type );
124 setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
126 displayPageHeader($color, 'None');
129 html_tag( 'table', "\n" .
130 html_tag( 'tr', "\n" .
131 html_tag( 'td', '<center><b>' . _("Options") . ' - ' . _("Message Highlighting") . '</b></center>', 'left')
133 'center', $color[9], 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) . "<br>\n" .
134 html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="1" cellspacing="0"' ) .
135 html_tag( 'tr' ) . "\n" .
136 html_tag( 'td', '', 'left' );
138 echo '<center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]'.
139 ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n";
140 $mhl_count = count($message_highlight_list);
141 if ($mhl_count > 0) {
142 echo html_tag( 'table', '', 'center', '', 'width="80%" border="0" cellpadding="3" cellspacing="0"' ) . "\n";
143 for ($i=0; $i < $mhl_count; $i++
) {
145 switch ($message_highlight_list[$i]['match_type'] ) {
147 $match_type = _("From");
150 $match_type = _("To");
153 $match_type = _("Cc");
156 $match_type = _("To or Cc");
159 $match_type = _("subject");
163 $links = '<small>[<a href="options_highlight.php?action=edit&theid=' . $i . '">' .
165 '</a>] [<a href="options_highlight.php?action=delete&theid='. $i . '">' .
168 $links .= '</a>] [<a href="options_highlight.php?action=up&theid='. $i . '">' . _("Up");
170 if($i+
1 < $mhl_count) {
171 $links .= '</a>] [<a href="options_highlight.php?action=down&theid='. $i . '">' . _("Down");
173 $links .= '</a>]</small>';
178 'left', $color[4], 'width="20%" nowrap' ) .
180 htmlspecialchars($message_highlight_list[$i]['name']) ,
183 $match_type . ' = ' .
184 htmlspecialchars($message_highlight_list[$i]['value']) ,
186 '', $message_highlight_list[$i]['color'] ) . "\n";
191 echo '<center>' . _("No highlighting is defined") . "</center><br>\n".
194 if ($action == 'edit' ||
$action == 'add') {
196 $color_list[0] = '4444aa';
197 $color_list[1] = '44aa44';
198 $color_list[2] = 'aaaa44';
199 $color_list[3] = '44aaaa';
200 $color_list[4] = 'aa44aa';
201 $color_list[5] = 'aaaaff';
202 $color_list[6] = 'aaffaa';
203 $color_list[7] = 'ffffaa';
204 $color_list[8] = 'aaffff';
205 $color_list[9] = 'ffaaff';
206 $color_list[10] = 'aaaaaa';
207 $color_list[11] = 'bfbfbf';
208 $color_list[12] = 'dfdfdf';
209 $color_list[13] = 'ffffff';
211 # helpful color chart from http://www.visibone.com/colorlab/big.html
212 $new_color_list["0,0"] = 'cccccc';
213 $new_color_list["0,1"] = '999999';
214 $new_color_list["0,2"] = '666666';
215 $new_color_list["0,3"] = '333333';
216 $new_color_list["0,4"] = '000000';
219 $new_color_list["1,0"] = 'ff0000';
220 $new_color_list["1,1"] = 'cc0000';
221 $new_color_list["1,2"] = '990000';
222 $new_color_list["1,3"] = '660000';
223 $new_color_list["1,4"] = '330000';
225 $new_color_list["2,0"] = 'ffcccc';
226 $new_color_list["2,1"] = 'cc9999';
227 $new_color_list["2,2"] = '996666';
228 $new_color_list["2,3"] = '663333';
229 $new_color_list["2,4"] = '330000';
231 $new_color_list["3,0"] = 'ffcccc';
232 $new_color_list["3,1"] = 'ff9999';
233 $new_color_list["3,2"] = 'ff6666';
234 $new_color_list["3,3"] = 'ff3333';
235 $new_color_list["3,4"] = 'ff0000';
238 $new_color_list["4,0"] = '00ff00';
239 $new_color_list["4,1"] = '00cc00';
240 $new_color_list["4,2"] = '009900';
241 $new_color_list["4,3"] = '006600';
242 $new_color_list["4,4"] = '003300';
244 $new_color_list["5,0"] = 'ccffcc';
245 $new_color_list["5,1"] = '99cc99';
246 $new_color_list["5,2"] = '669966';
247 $new_color_list["5,3"] = '336633';
248 $new_color_list["5,4"] = '003300';
250 $new_color_list["6,0"] = 'ccffcc';
251 $new_color_list["6,1"] = '99ff99';
252 $new_color_list["6,2"] = '66ff66';
253 $new_color_list["6,3"] = '33ff33';
254 $new_color_list["6,4"] = '00ff00';
257 $new_color_list["7,0"] = '0000ff';
258 $new_color_list["7,1"] = '0000cc';
259 $new_color_list["7,2"] = '000099';
260 $new_color_list["7,3"] = '000066';
261 $new_color_list["7,4"] = '000033';
263 $new_color_list["8,0"] = 'ccccff';
264 $new_color_list["8,1"] = '9999cc';
265 $new_color_list["8,2"] = '666699';
266 $new_color_list["8,3"] = '333366';
267 $new_color_list["8,4"] = '000033';
269 $new_color_list["9,0"] = 'ccccff';
270 $new_color_list["9,1"] = '9999ff';
271 $new_color_list["9,2"] = '6666ff';
272 $new_color_list["9,3"] = '3333ff';
273 $new_color_list["9,4"] = '0000ff';
276 $new_color_list["10,0"] = 'ffff00';
277 $new_color_list["10,1"] = 'cccc00';
278 $new_color_list["10,2"] = '999900';
279 $new_color_list["10,3"] = '666600';
280 $new_color_list["10,4"] = '333300';
282 $new_color_list["11,0"] = 'ffffcc';
283 $new_color_list["11,1"] = 'cccc99';
284 $new_color_list["11,2"] = '999966';
285 $new_color_list["11,3"] = '666633';
286 $new_color_list["11,4"] = '333300';
288 $new_color_list["12,0"] = 'ffffcc';
289 $new_color_list["12,1"] = 'ffff99';
290 $new_color_list["12,2"] = 'ffff66';
291 $new_color_list["12,3"] = 'ffff33';
292 $new_color_list["12,4"] = 'ffff00';
295 $new_color_list["13,0"] = '00ffff';
296 $new_color_list["13,1"] = '00cccc';
297 $new_color_list["13,2"] = '009999';
298 $new_color_list["13,3"] = '006666';
299 $new_color_list["13,4"] = '003333';
301 $new_color_list["14,0"] = 'ccffff';
302 $new_color_list["14,1"] = '99cccc';
303 $new_color_list["14,2"] = '669999';
304 $new_color_list["14,3"] = '336666';
305 $new_color_list["14,4"] = '003333';
307 $new_color_list["15,0"] = 'ccffff';
308 $new_color_list["15,1"] = '99ffff';
309 $new_color_list["15,2"] = '66ffff';
310 $new_color_list["15,3"] = '33ffff';
311 $new_color_list["15,4"] = '00ffff';
314 $new_color_list["16,0"] = 'ff00ff';
315 $new_color_list["16,1"] = 'cc00cc';
316 $new_color_list["16,2"] = '990099';
317 $new_color_list["16,3"] = '660066';
318 $new_color_list["16,4"] = '330033';
320 $new_color_list["17,0"] = 'ffccff';
321 $new_color_list["17,1"] = 'cc99cc';
322 $new_color_list["17,2"] = '996699';
323 $new_color_list["17,3"] = '663366';
324 $new_color_list["17,4"] = '330033';
326 $new_color_list["18,0"] = 'ffccff';
327 $new_color_list["18,1"] = 'ff99ff';
328 $new_color_list["18,2"] = 'ff66ff';
329 $new_color_list["18,3"] = 'ff33ff';
330 $new_color_list["18,4"] = 'ff00ff';
332 $selected_input = '';
333 $selected_choose = '';
335 for ($i=0; $i < 14; $i++
) {
336 $
{"selected".$i} = '';
338 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['color'])) {
339 for ($i=0; $i < 14; $i++
) {
340 if ($color_list[$i] == $message_highlight_list[$theid]['color']) {
341 $selected_choose = ' checked';
342 $
{"selected".$i} = ' selected';
348 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['color'])) {
349 $current_color = $message_highlight_list[$theid]['color'];
352 $current_color = '63aa7f';
355 $pre_defined_color = 0;
356 for($x = 0; $x < 5; $x++
) {
357 for($y = 0; $y < 19; $y++
) {
358 $gridindex = "$y,$x";
359 $gridcolor = $new_color_list[$gridindex];
360 if ($gridcolor == $current_color) {
361 $pre_defined_color = 1;
367 if (isset($theid) && !isset($message_highlight_list[$theid]['color']))
368 $selected_choose = ' checked';
369 else if ($pre_defined_color)
370 $selected_predefined = ' checked';
371 else if ($selected_choose == '')
372 $selected_input = ' checked';
374 echo '<form name="f" action="options_highlight.php">' . "\n";
375 echo '<input type="hidden" value="save" name="action">' . "\n";
376 if($action == 'edit')
377 echo '<input type="hidden" value="'.(isset($theid)?
$theid:'').'" name="theid">' . "\n";
378 echo html_tag( 'table', '', 'center', '', 'width="80%" cellpadding="3" cellspacing="0" border="0"' ) . "\n";
379 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
380 echo html_tag( 'td', '', 'right', '', 'nowrap' ) . "<b>\n";
381 echo _("Identifying name") . ":";
382 echo ' </b></td>' . "\n";
383 echo html_tag( 'td', '', 'left' ) . "\n";
384 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['name']))
385 $disp = $message_highlight_list[$theid]['name'];
388 $disp = htmlspecialchars($disp);
389 echo " <input type=\"text\" value=\"".$disp."\" name=\"identname\">";
392 echo html_tag( 'tr', html_tag( 'td', '<small><small> </small></small>', 'left' ) ) ."\n";
393 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
394 echo html_tag( 'td', '<b>'. _("Color") . ':</b>', 'right' );
395 echo html_tag( 'td', '', 'left' );
396 echo " <input type=\"radio\" name=color_type value=1$selected_choose> <select name=newcolor_choose>\n";
397 echo " <option value=\"$color_list[0]\"$selected0>" . _("Dark Blue") . "\n";
398 echo " <option value=\"$color_list[1]\"$selected1>" . _("Dark Green") . "\n";
399 echo " <option value=\"$color_list[2]\"$selected2>" . _("Dark Yellow") . "\n";
400 echo " <option value=\"$color_list[3]\"$selected3>" . _("Dark Cyan") . "\n";
401 echo " <option value=\"$color_list[4]\"$selected4>" . _("Dark Magenta") . "\n";
402 echo " <option value=\"$color_list[5]\"$selected5>" . _("Light Blue") . "\n";
403 echo " <option value=\"$color_list[6]\"$selected6>" . _("Light Green") . "\n";
404 echo " <option value=\"$color_list[7]\"$selected7>" . _("Light Yellow") . "\n";
405 echo " <option value=\"$color_list[8]\"$selected8>" . _("Light Cyan") . "\n";
406 echo " <option value=\"$color_list[9]\"$selected9>" . _("Light Magenta") . "\n";
407 echo " <option value=\"$color_list[10]\"$selected10>" . _("Dark Gray") . "\n";
408 echo " <option value=\"$color_list[11]\"$selected11>" . _("Medium Gray") . "\n";
409 echo " <option value=\"$color_list[12]\"$selected12>" . _("Light Gray") . "\n";
410 echo " <option value=\"$color_list[13]\"$selected13>" . _("White") . "\n";
411 echo " </select><br>\n";
412 echo " <input type=\"radio\" name=color_type value=2$selected_input> ". _("Other:") ."<input type=\"text\" value=\"";
413 if ($selected_input && isset($theid)) echo $message_highlight_list[$theid]["color"];
414 echo '" name="newcolor_input" size="7"> '._("Ex: 63aa7f")."<br>\n";
418 # Show grid of color choices
419 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
420 echo html_tag( 'td', '', 'left', '', 'colspan="2"' );
421 echo html_tag( 'table', '', 'center', '', 'border=0 cellpadding="2" cellspacing="1"' ) . "\n";
423 for($x = 0; $x < 5; $x++
) {
424 echo html_tag( 'tr' ) . "\n";
425 for($y = 0; $y < 19; $y++
) {
426 $gridindex = "$y,$x";
427 $gridcolor = $new_color_list[$gridindex];
428 $selected = ($gridcolor == $current_color) ?
' checked' : '' ;
429 echo html_tag( 'td', '<input type="radio" name="color_type" value="#' . $gridcolor .'"' . $selected . '>', 'left', $gridcolor, 'colspan="2"' );
436 echo html_tag( 'tr', html_tag( 'td', '<small><small> </small></small>', 'left' ) ) . "\n";
437 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
438 echo html_tag( 'td', '', 'center', '', 'colspan="2"' ) . "\n";
439 echo " <select name=match_type>\n";
441 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'from':1),
444 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'to':0),
447 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'cc':0),
450 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'to_cc':0),
453 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'subject':0),
456 echo '<b>' . _("Matches") . ':</b> ';
457 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['value']))
458 $disp = $message_highlight_list[$theid]['value'];
461 $disp = htmlspecialchars($disp);
462 echo ' <input type="text" value="' . $disp .
463 '" name="value" size=40>';
467 echo '<center><input type="submit" value="' . _("Submit") . "\"></center>\n";
470 do_hook('options_highlight_bottom');
472 </table
></body
></html
>