4 * options_highlight.php
6 * Copyright (c) 1999-2005 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
17 * Path for SquirrelMail required files.
20 define('SM_PATH','../');
22 /* SquirrelMail required files. */
23 require_once(SM_PATH
. 'include/validate.php');
24 include_once(SM_PATH
. 'functions/display_messages.php');
25 include_once(SM_PATH
. 'functions/imap.php');
26 include_once(SM_PATH
. 'functions/plugin.php');
27 include_once(SM_PATH
. 'functions/strings.php');
28 include_once(SM_PATH
. 'functions/html.php');
29 include_once(SM_PATH
. 'functions/forms.php');
32 sqGetGlobalVar('action', $action);
33 sqGetGlobalVar('theid', $theid);
34 sqGetGlobalVar('identname', $identname);
35 sqGetGlobalVar('newcolor_choose', $newcolor_choose);
36 sqGetGlobalVar('newcolor_input', $newcolor_input);
37 sqGetGlobalVar('color_type', $color_type);
38 sqGetGlobalVar('match_type', $match_type);
39 sqGetGlobalVar('value', $value);
41 /* end of get globals */
43 function oh_opt( $val, $sel, $tit ) {
44 echo "<option value=\"$val\"";
46 echo ' selected="selected"';
47 echo ">$tit</option>\n";
50 if (! isset($action)) {
53 if (! isset($message_highlight_list)) {
54 $message_highlight_list = array();
57 if (isset($theid) && ($action == 'delete') ||
59 ($action == 'down')) {
63 foreach($message_highlight_list as $rid => $rule) {
72 foreach($message_highlight_list as $rid => $rule) {
74 $temp_rule = $new_rules[$rid-1];
75 $new_rules[$rid-1] = $rule;
76 $new_rules[$rid] = $temp_rule;
78 $new_rules[$rid] = $rule;
83 $new_rules = $message_highlight_list;
86 $message_highlight_list = $new_rules;
88 setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
90 header( 'Location: ' .get_location(). '/options_highlight.php' );
92 } else if ($action == 'save') {
94 if ($color_type == 1) $newcolor = $newcolor_choose;
95 elseif ($color_type == 2) $newcolor = $newcolor_input;
96 else $newcolor = $color_type;
98 $newcolor = str_replace('#', '', $newcolor);
99 $newcolor = str_replace('"', '', $newcolor);
100 $newcolor = str_replace('\'', '', $newcolor);
101 $value = str_replace(',', ' ', $value);
104 $message_highlight_list[$theid] =
105 array( 'name' => $identname, 'color' => $newcolor,
106 'value' => $value, 'match_type' => $match_type );
108 $message_highlight_list[] =
109 array( 'name' => $identname, 'color' => $newcolor,
110 'value' => $value, 'match_type' => $match_type );
113 setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
115 displayPageHeader($color, 'None');
118 html_tag( 'table', "\n" .
119 html_tag( 'tr', "\n" .
120 html_tag( 'td', '<center><b>' . _("Options") . ' - ' . _("Message Highlighting") . '</b></center>', 'left')
122 'center', $color[9], 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) . "<br />\n" .
123 html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="1" cellspacing="0"' ) .
124 html_tag( 'tr' ) . "\n" .
125 html_tag( 'td', '', 'left' );
127 echo '<center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]'.
128 ' - [<a href="options.php">'._("Done").'</a>]</center><br />'."\n";
129 $mhl_count = count($message_highlight_list);
130 if ($mhl_count > 0) {
131 echo html_tag( 'table', '', 'center', '', 'width="80%" border="0" cellpadding="3" cellspacing="0"' ) . "\n";
132 for ($i=0; $i < $mhl_count; $i++
) {
134 switch ($message_highlight_list[$i]['match_type'] ) {
136 $match_type = _("From");
139 $match_type = _("To");
142 $match_type = _("Cc");
145 $match_type = _("To or Cc");
148 $match_type = _("subject");
152 $links = '<small>[<a href="options_highlight.php?action=edit&theid=' . $i . '">' .
154 '</a>] [<a href="options_highlight.php?action=delete&theid='. $i . '">' .
157 $links .= '</a>] [<a href="options_highlight.php?action=up&theid='. $i . '">' . _("Up");
159 if($i+
1 < $mhl_count) {
160 $links .= '</a>] [<a href="options_highlight.php?action=down&theid='. $i . '">' . _("Down");
162 $links .= '</a>]</small>';
167 'left', $color[4], 'width="20%" style="white-space: nowrap;"' ) .
169 htmlspecialchars($message_highlight_list[$i]['name']) ,
172 $match_type . ' = ' .
173 htmlspecialchars($message_highlight_list[$i]['value']) ,
175 '', $message_highlight_list[$i]['color'] ) . "\n";
180 echo '<center>' . _("No highlighting is defined") . "</center><br />\n".
183 if ($action == 'edit' ||
$action == 'add') {
185 $color_list[0] = '4444aa';
186 $color_list[1] = '44aa44';
187 $color_list[2] = 'aaaa44';
188 $color_list[3] = '44aaaa';
189 $color_list[4] = 'aa44aa';
190 $color_list[5] = 'aaaaff';
191 $color_list[6] = 'aaffaa';
192 $color_list[7] = 'ffffaa';
193 $color_list[8] = 'aaffff';
194 $color_list[9] = 'ffaaff';
195 $color_list[10] = 'aaaaaa';
196 $color_list[11] = 'bfbfbf';
197 $color_list[12] = 'dfdfdf';
198 $color_list[13] = 'ffffff';
200 # helpful color chart from http://www.visibone.com/colorlab/big.html
201 $new_color_list["0,0"] = 'cccccc';
202 $new_color_list["0,1"] = '999999';
203 $new_color_list["0,2"] = '666666';
204 $new_color_list["0,3"] = '333333';
205 $new_color_list["0,4"] = '000000';
208 $new_color_list["1,0"] = 'ff0000';
209 $new_color_list["1,1"] = 'cc0000';
210 $new_color_list["1,2"] = '990000';
211 $new_color_list["1,3"] = '660000';
212 $new_color_list["1,4"] = '330000';
214 $new_color_list["2,0"] = 'ffcccc';
215 $new_color_list["2,1"] = 'cc9999';
216 $new_color_list["2,2"] = '996666';
217 $new_color_list["2,3"] = '663333';
218 $new_color_list["2,4"] = '330000';
220 $new_color_list["3,0"] = 'ffcccc';
221 $new_color_list["3,1"] = 'ff9999';
222 $new_color_list["3,2"] = 'ff6666';
223 $new_color_list["3,3"] = 'ff3333';
224 $new_color_list["3,4"] = 'ff0000';
227 $new_color_list["4,0"] = '00ff00';
228 $new_color_list["4,1"] = '00cc00';
229 $new_color_list["4,2"] = '009900';
230 $new_color_list["4,3"] = '006600';
231 $new_color_list["4,4"] = '003300';
233 $new_color_list["5,0"] = 'ccffcc';
234 $new_color_list["5,1"] = '99cc99';
235 $new_color_list["5,2"] = '669966';
236 $new_color_list["5,3"] = '336633';
237 $new_color_list["5,4"] = '003300';
239 $new_color_list["6,0"] = 'ccffcc';
240 $new_color_list["6,1"] = '99ff99';
241 $new_color_list["6,2"] = '66ff66';
242 $new_color_list["6,3"] = '33ff33';
243 $new_color_list["6,4"] = '00ff00';
246 $new_color_list["7,0"] = '0000ff';
247 $new_color_list["7,1"] = '0000cc';
248 $new_color_list["7,2"] = '000099';
249 $new_color_list["7,3"] = '000066';
250 $new_color_list["7,4"] = '000033';
252 $new_color_list["8,0"] = 'ccccff';
253 $new_color_list["8,1"] = '9999cc';
254 $new_color_list["8,2"] = '666699';
255 $new_color_list["8,3"] = '333366';
256 $new_color_list["8,4"] = '000033';
258 $new_color_list["9,0"] = 'ccccff';
259 $new_color_list["9,1"] = '9999ff';
260 $new_color_list["9,2"] = '6666ff';
261 $new_color_list["9,3"] = '3333ff';
262 $new_color_list["9,4"] = '0000ff';
265 $new_color_list["10,0"] = 'ffff00';
266 $new_color_list["10,1"] = 'cccc00';
267 $new_color_list["10,2"] = '999900';
268 $new_color_list["10,3"] = '666600';
269 $new_color_list["10,4"] = '333300';
271 $new_color_list["11,0"] = 'ffffcc';
272 $new_color_list["11,1"] = 'cccc99';
273 $new_color_list["11,2"] = '999966';
274 $new_color_list["11,3"] = '666633';
275 $new_color_list["11,4"] = '333300';
277 $new_color_list["12,0"] = 'ffffcc';
278 $new_color_list["12,1"] = 'ffff99';
279 $new_color_list["12,2"] = 'ffff66';
280 $new_color_list["12,3"] = 'ffff33';
281 $new_color_list["12,4"] = 'ffff00';
284 $new_color_list["13,0"] = '00ffff';
285 $new_color_list["13,1"] = '00cccc';
286 $new_color_list["13,2"] = '009999';
287 $new_color_list["13,3"] = '006666';
288 $new_color_list["13,4"] = '003333';
290 $new_color_list["14,0"] = 'ccffff';
291 $new_color_list["14,1"] = '99cccc';
292 $new_color_list["14,2"] = '669999';
293 $new_color_list["14,3"] = '336666';
294 $new_color_list["14,4"] = '003333';
296 $new_color_list["15,0"] = 'ccffff';
297 $new_color_list["15,1"] = '99ffff';
298 $new_color_list["15,2"] = '66ffff';
299 $new_color_list["15,3"] = '33ffff';
300 $new_color_list["15,4"] = '00ffff';
303 $new_color_list["16,0"] = 'ff00ff';
304 $new_color_list["16,1"] = 'cc00cc';
305 $new_color_list["16,2"] = '990099';
306 $new_color_list["16,3"] = '660066';
307 $new_color_list["16,4"] = '330033';
309 $new_color_list["17,0"] = 'ffccff';
310 $new_color_list["17,1"] = 'cc99cc';
311 $new_color_list["17,2"] = '996699';
312 $new_color_list["17,3"] = '663366';
313 $new_color_list["17,4"] = '330033';
315 $new_color_list["18,0"] = 'ffccff';
316 $new_color_list["18,1"] = 'ff99ff';
317 $new_color_list["18,2"] = 'ff66ff';
318 $new_color_list["18,3"] = 'ff33ff';
319 $new_color_list["18,4"] = 'ff00ff';
321 $selected_input = FALSE;
323 $selected_choose = FALSE;
324 $selected_predefined = FALSE;
326 for ($i=0; $i < 14; $i++
) {
327 $
{"selected".$i} = '';
329 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['color'])) {
330 for ($i=0; $i < 14; $i++
) {
331 if ($color_list[$i] == $message_highlight_list[$theid]['color']) {
332 $selected_choose = TRUE;
333 $selected_i = $color_list[$i];
339 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['color'])) {
340 $current_color = $message_highlight_list[$theid]['color'];
343 $current_color = '63aa7f';
346 $pre_defined_color = 0;
347 for($x = 0; $x < 5; $x++
) {
348 for($y = 0; $y < 19; $y++
) {
349 $gridindex = "$y,$x";
350 $gridcolor = $new_color_list[$gridindex];
351 if ($gridcolor == $current_color) {
352 $pre_defined_color = 1;
358 if (isset($theid) && !isset($message_highlight_list[$theid]['color']))
359 $selected_choose = TRUE;
360 else if ($pre_defined_color)
361 $selected_predefined = TRUE;
362 else if ($selected_choose == '')
363 $selected_input = TRUE;
365 echo addForm('options_highlight.php', 'post', 'f').
366 addHidden('action', 'save');
367 if($action == 'edit') {
368 echo addHidden('theid', (isset($theid)?
$theid:''));
370 echo html_tag( 'table', '', 'center', '', 'width="80%" cellpadding="3" cellspacing="0" border="0"' ) . "\n";
371 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
372 echo html_tag( 'td', '', 'right', '', 'style="white-space: nowrap;"' ) . "<b>\n";
373 echo _("Identifying name") . ":";
374 echo ' </b></td>' . "\n";
375 echo html_tag( 'td', '', 'left' ) . "\n";
376 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['name']))
377 $disp = $message_highlight_list[$theid]['name'];
380 echo " ".addInput('identname', $disp);
383 echo html_tag( 'tr', html_tag( 'td', '<small><small> </small></small>', 'left' ) ) ."\n";
384 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
385 echo html_tag( 'td', '<b>'. _("Color") . ':</b>', 'right' );
386 echo html_tag( 'td', '', 'left' );
387 echo ' '.addRadioBox('color_type', $selected_choose, '1');
390 $color_list[0] => _("Dark Blue"),
391 $color_list[1] => _("Dark Green"),
392 $color_list[2] => _("Dark Yellow"),
393 $color_list[3] => _("Dark Cyan"),
394 $color_list[4] => _("Dark Magenta"),
395 $color_list[5] => _("Light Blue"),
396 $color_list[6] => _("Light Green"),
397 $color_list[7] => _("Light Yellow"),
398 $color_list[8] => _("Light Cyan"),
399 $color_list[9] => _("Light Magenta"),
400 $color_list[10] => _("Dark Gray"),
401 $color_list[11] => _("Medium Gray"),
402 $color_list[12] => _("Light Gray"),
403 $color_list[13] => _("White") );
405 echo addSelect('newcolor_choose', $selops, $selected_i, TRUE);
408 echo ' '.addRadioBox('color_type', $selected_input, 2).
409 ' '. _("Other:") .
410 addInput('newcolor_input',
411 (($selected_input && isset($theid)) ?
$message_highlight_list[$theid]['color'] : ''),
413 echo _("Ex: 63aa7f")."<br />\n";
417 # Show grid of color choices
418 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
419 echo html_tag( 'td', '', 'left', '', 'colspan="2"' );
420 echo html_tag( 'table', '', 'center', '', 'border="0" cellpadding="2" cellspacing="1"' ) . "\n";
422 for($x = 0; $x < 5; $x++
) {
423 echo html_tag( 'tr' ) . "\n";
424 for($y = 0; $y < 19; $y++
) {
425 $gridindex = "$y,$x";
426 $gridcolor = $new_color_list[$gridindex];
427 echo html_tag( 'td', addRadioBox('color_type', ($gridcolor == $current_color), '#'.$gridcolor),
428 'left', $gridcolor, 'colspan="2"' );
435 echo html_tag( 'tr', html_tag( 'td', '<small><small> </small></small>', 'left' ) ) . "\n";
436 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
437 echo html_tag( 'td', '', 'center', '', 'colspan="2"' ) . "\n";
438 echo " <select name=\"match_type\">\n";
440 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'from':1),
443 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'to':0),
446 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'cc':0),
449 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'to_cc':0),
452 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'subject':0),
455 echo '<b>' . _("Matches") . ':</b> ';
456 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['value']))
457 $disp = $message_highlight_list[$theid]['value'];
460 echo ' '.addInput('value', $disp, 40);
464 echo '<center><input type="submit" value="' . _("Submit") . "\" /></center>\n";
467 do_hook('options_highlight_bottom');
470 </table
></body
></html
>