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
16 * Path for SquirrelMail required files.
19 define('SM_PATH','../');
21 /* SquirrelMail required files. */
22 require_once(SM_PATH
. 'include/validate.php');
23 require_once(SM_PATH
. 'functions/display_messages.php');
24 require_once(SM_PATH
. 'functions/imap.php');
25 require_once(SM_PATH
. 'functions/plugin.php');
26 require_once(SM_PATH
. 'functions/strings.php');
27 require_once(SM_PATH
. 'functions/html.php');
28 require_once(SM_PATH
. 'functions/forms.php');
31 sqGetGlobalVar('action', $action);
32 sqGetGlobalVar('theid', $theid);
33 sqGetGlobalVar('identname', $identname);
34 sqGetGlobalVar('newcolor_choose', $newcolor_choose);
35 sqGetGlobalVar('newcolor_input', $newcolor_input);
36 sqGetGlobalVar('color_type', $color_type);
37 sqGetGlobalVar('match_type', $match_type);
38 sqGetGlobalVar('value', $value);
40 /* end of get globals */
42 function oh_opt( $val, $sel, $tit ) {
43 echo "<option value=\"$val\"";
46 echo ">$tit</option>\n";
49 if (! isset($action)) {
52 if (! isset($message_highlight_list)) {
53 $message_highlight_list = array();
56 if (isset($theid) && ($action == 'delete') ||
58 ($action == 'down')) {
62 foreach($message_highlight_list as $rid => $rule) {
71 foreach($message_highlight_list as $rid => $rule) {
73 $temp_rule = $new_rules[$rid-1];
74 $new_rules[$rid-1] = $rule;
75 $new_rules[$rid] = $temp_rule;
77 $new_rules[$rid] = $rule;
82 $new_rules = $message_highlight_list;
85 $message_highlight_list = $new_rules;
87 setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
89 header( 'Location: ' .get_location(). '/options_highlight.php' );
91 } else if ($action == 'save') {
93 if ($color_type == 1) $newcolor = $newcolor_choose;
94 elseif ($color_type == 2) $newcolor = $newcolor_input;
95 else $newcolor = $color_type;
97 $newcolor = str_replace('#', '', $newcolor);
98 $newcolor = str_replace('"', '', $newcolor);
99 $newcolor = str_replace('\'', '', $newcolor);
100 $value = str_replace(',', ' ', $value);
103 $message_highlight_list[$theid] =
104 array( 'name' => $identname, 'color' => $newcolor,
105 'value' => $value, 'match_type' => $match_type );
107 $message_highlight_list[] =
108 array( 'name' => $identname, 'color' => $newcolor,
109 'value' => $value, 'match_type' => $match_type );
112 setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
114 displayPageHeader($color, 'None');
117 html_tag( 'table', "\n" .
118 html_tag( 'tr', "\n" .
119 html_tag( 'td', '<center><b>' . _("Options") . ' - ' . _("Message Highlighting") . '</b></center>', 'left')
121 'center', $color[9], 'width="95%" border="0" cellpadding="1" cellspacing="0"' ) . "<br>\n" .
122 html_tag( 'table', '', '', '', 'width="100%" border="0" cellpadding="1" cellspacing="0"' ) .
123 html_tag( 'tr' ) . "\n" .
124 html_tag( 'td', '', 'left' );
126 echo '<center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]'.
127 ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n";
128 $mhl_count = count($message_highlight_list);
129 if ($mhl_count > 0) {
130 echo html_tag( 'table', '', 'center', '', 'width="80%" border="0" cellpadding="3" cellspacing="0"' ) . "\n";
131 for ($i=0; $i < $mhl_count; $i++
) {
133 switch ($message_highlight_list[$i]['match_type'] ) {
135 $match_type = _("From");
138 $match_type = _("To");
141 $match_type = _("Cc");
144 $match_type = _("To or Cc");
147 $match_type = _("subject");
151 $links = '<small>[<a href="options_highlight.php?action=edit&theid=' . $i . '">' .
153 '</a>] [<a href="options_highlight.php?action=delete&theid='. $i . '">' .
156 $links .= '</a>] [<a href="options_highlight.php?action=up&theid='. $i . '">' . _("Up");
158 if($i+
1 < $mhl_count) {
159 $links .= '</a>] [<a href="options_highlight.php?action=down&theid='. $i . '">' . _("Down");
161 $links .= '</a>]</small>';
166 'left', $color[4], 'width="20%" nowrap' ) .
168 htmlspecialchars($message_highlight_list[$i]['name']) ,
171 $match_type . ' = ' .
172 htmlspecialchars($message_highlight_list[$i]['value']) ,
174 '', $message_highlight_list[$i]['color'] ) . "\n";
179 echo '<center>' . _("No highlighting is defined") . "</center><br>\n".
182 if ($action == 'edit' ||
$action == 'add') {
184 $color_list[0] = '4444aa';
185 $color_list[1] = '44aa44';
186 $color_list[2] = 'aaaa44';
187 $color_list[3] = '44aaaa';
188 $color_list[4] = 'aa44aa';
189 $color_list[5] = 'aaaaff';
190 $color_list[6] = 'aaffaa';
191 $color_list[7] = 'ffffaa';
192 $color_list[8] = 'aaffff';
193 $color_list[9] = 'ffaaff';
194 $color_list[10] = 'aaaaaa';
195 $color_list[11] = 'bfbfbf';
196 $color_list[12] = 'dfdfdf';
197 $color_list[13] = 'ffffff';
199 # helpful color chart from http://www.visibone.com/colorlab/big.html
200 $new_color_list["0,0"] = 'cccccc';
201 $new_color_list["0,1"] = '999999';
202 $new_color_list["0,2"] = '666666';
203 $new_color_list["0,3"] = '333333';
204 $new_color_list["0,4"] = '000000';
207 $new_color_list["1,0"] = 'ff0000';
208 $new_color_list["1,1"] = 'cc0000';
209 $new_color_list["1,2"] = '990000';
210 $new_color_list["1,3"] = '660000';
211 $new_color_list["1,4"] = '330000';
213 $new_color_list["2,0"] = 'ffcccc';
214 $new_color_list["2,1"] = 'cc9999';
215 $new_color_list["2,2"] = '996666';
216 $new_color_list["2,3"] = '663333';
217 $new_color_list["2,4"] = '330000';
219 $new_color_list["3,0"] = 'ffcccc';
220 $new_color_list["3,1"] = 'ff9999';
221 $new_color_list["3,2"] = 'ff6666';
222 $new_color_list["3,3"] = 'ff3333';
223 $new_color_list["3,4"] = 'ff0000';
226 $new_color_list["4,0"] = '00ff00';
227 $new_color_list["4,1"] = '00cc00';
228 $new_color_list["4,2"] = '009900';
229 $new_color_list["4,3"] = '006600';
230 $new_color_list["4,4"] = '003300';
232 $new_color_list["5,0"] = 'ccffcc';
233 $new_color_list["5,1"] = '99cc99';
234 $new_color_list["5,2"] = '669966';
235 $new_color_list["5,3"] = '336633';
236 $new_color_list["5,4"] = '003300';
238 $new_color_list["6,0"] = 'ccffcc';
239 $new_color_list["6,1"] = '99ff99';
240 $new_color_list["6,2"] = '66ff66';
241 $new_color_list["6,3"] = '33ff33';
242 $new_color_list["6,4"] = '00ff00';
245 $new_color_list["7,0"] = '0000ff';
246 $new_color_list["7,1"] = '0000cc';
247 $new_color_list["7,2"] = '000099';
248 $new_color_list["7,3"] = '000066';
249 $new_color_list["7,4"] = '000033';
251 $new_color_list["8,0"] = 'ccccff';
252 $new_color_list["8,1"] = '9999cc';
253 $new_color_list["8,2"] = '666699';
254 $new_color_list["8,3"] = '333366';
255 $new_color_list["8,4"] = '000033';
257 $new_color_list["9,0"] = 'ccccff';
258 $new_color_list["9,1"] = '9999ff';
259 $new_color_list["9,2"] = '6666ff';
260 $new_color_list["9,3"] = '3333ff';
261 $new_color_list["9,4"] = '0000ff';
264 $new_color_list["10,0"] = 'ffff00';
265 $new_color_list["10,1"] = 'cccc00';
266 $new_color_list["10,2"] = '999900';
267 $new_color_list["10,3"] = '666600';
268 $new_color_list["10,4"] = '333300';
270 $new_color_list["11,0"] = 'ffffcc';
271 $new_color_list["11,1"] = 'cccc99';
272 $new_color_list["11,2"] = '999966';
273 $new_color_list["11,3"] = '666633';
274 $new_color_list["11,4"] = '333300';
276 $new_color_list["12,0"] = 'ffffcc';
277 $new_color_list["12,1"] = 'ffff99';
278 $new_color_list["12,2"] = 'ffff66';
279 $new_color_list["12,3"] = 'ffff33';
280 $new_color_list["12,4"] = 'ffff00';
283 $new_color_list["13,0"] = '00ffff';
284 $new_color_list["13,1"] = '00cccc';
285 $new_color_list["13,2"] = '009999';
286 $new_color_list["13,3"] = '006666';
287 $new_color_list["13,4"] = '003333';
289 $new_color_list["14,0"] = 'ccffff';
290 $new_color_list["14,1"] = '99cccc';
291 $new_color_list["14,2"] = '669999';
292 $new_color_list["14,3"] = '336666';
293 $new_color_list["14,4"] = '003333';
295 $new_color_list["15,0"] = 'ccffff';
296 $new_color_list["15,1"] = '99ffff';
297 $new_color_list["15,2"] = '66ffff';
298 $new_color_list["15,3"] = '33ffff';
299 $new_color_list["15,4"] = '00ffff';
302 $new_color_list["16,0"] = 'ff00ff';
303 $new_color_list["16,1"] = 'cc00cc';
304 $new_color_list["16,2"] = '990099';
305 $new_color_list["16,3"] = '660066';
306 $new_color_list["16,4"] = '330033';
308 $new_color_list["17,0"] = 'ffccff';
309 $new_color_list["17,1"] = 'cc99cc';
310 $new_color_list["17,2"] = '996699';
311 $new_color_list["17,3"] = '663366';
312 $new_color_list["17,4"] = '330033';
314 $new_color_list["18,0"] = 'ffccff';
315 $new_color_list["18,1"] = 'ff99ff';
316 $new_color_list["18,2"] = 'ff66ff';
317 $new_color_list["18,3"] = 'ff33ff';
318 $new_color_list["18,4"] = 'ff00ff';
320 $selected_input = FALSE;
322 $selected_choose = FALSE;
323 $selected_predefined = FALSE;
325 for ($i=0; $i < 14; $i++
) {
326 $
{"selected".$i} = '';
328 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['color'])) {
329 for ($i=0; $i < 14; $i++
) {
330 if ($color_list[$i] == $message_highlight_list[$theid]['color']) {
331 $selected_choose = TRUE;
332 $selected_i = $color_list[$i];
338 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['color'])) {
339 $current_color = $message_highlight_list[$theid]['color'];
342 $current_color = '63aa7f';
345 $pre_defined_color = 0;
346 for($x = 0; $x < 5; $x++
) {
347 for($y = 0; $y < 19; $y++
) {
348 $gridindex = "$y,$x";
349 $gridcolor = $new_color_list[$gridindex];
350 if ($gridcolor == $current_color) {
351 $pre_defined_color = 1;
357 if (isset($theid) && !isset($message_highlight_list[$theid]['color']))
358 $selected_choose = TRUE;
359 else if ($pre_defined_color)
360 $selected_predefined = TRUE;
361 else if ($selected_choose == '')
362 $selected_input = TRUE;
364 echo addForm('options_highlight.php', 'POST', 'f').
365 addHidden('action', 'save');
366 if($action == 'edit') {
367 echo addHidden('theid', (isset($theid)?
$theid:''));
369 echo html_tag( 'table', '', 'center', '', 'width="80%" cellpadding="3" cellspacing="0" border="0"' ) . "\n";
370 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
371 echo html_tag( 'td', '', 'right', '', 'nowrap' ) . "<b>\n";
372 echo _("Identifying name") . ":";
373 echo ' </b></td>' . "\n";
374 echo html_tag( 'td', '', 'left' ) . "\n";
375 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['name']))
376 $disp = $message_highlight_list[$theid]['name'];
379 echo " ".addInput('identname', $disp);
382 echo html_tag( 'tr', html_tag( 'td', '<small><small> </small></small>', 'left' ) ) ."\n";
383 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
384 echo html_tag( 'td', '<b>'. _("Color") . ':</b>', 'right' );
385 echo html_tag( 'td', '', 'left' );
386 echo ' '.addRadioBox('color_type', $selected_choose, '1');
389 $color_list[0] => _("Dark Blue"),
390 $color_list[1] => _("Dark Green"),
391 $color_list[2] => _("Dark Yellow"),
392 $color_list[3] => _("Dark Cyan"),
393 $color_list[4] => _("Dark Magenta"),
394 $color_list[5] => _("Light Blue"),
395 $color_list[6] => _("Light Green"),
396 $color_list[7] => _("Light Yellow"),
397 $color_list[8] => _("Light Cyan"),
398 $color_list[9] => _("Light Magenta"),
399 $color_list[10] => _("Dark Gray"),
400 $color_list[11] => _("Medium Gray"),
401 $color_list[12] => _("Light Gray"),
402 $color_list[13] => _("White") );
404 echo addSelect('newcolor_choose', $selops, $selected_i, TRUE);
407 echo ' '.addRadioBox('color_type', $selected_input, 2).
408 ' '. _("Other:") .
409 addInput('newcolor_input',
410 (($selected_input && isset($theid)) ?
$message_highlight_list[$theid]['color'] : ''),
412 echo _("Ex: 63aa7f")."<br>\n";
416 # Show grid of color choices
417 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
418 echo html_tag( 'td', '', 'left', '', 'colspan="2"' );
419 echo html_tag( 'table', '', 'center', '', 'border=0 cellpadding="2" cellspacing="1"' ) . "\n";
421 for($x = 0; $x < 5; $x++
) {
422 echo html_tag( 'tr' ) . "\n";
423 for($y = 0; $y < 19; $y++
) {
424 $gridindex = "$y,$x";
425 $gridcolor = $new_color_list[$gridindex];
426 echo html_tag( 'td', addRadioBox('color_type', ($gridcolor == $current_color), '#'.$gridcolor),
427 'left', $gridcolor, 'colspan="2"' );
434 echo html_tag( 'tr', html_tag( 'td', '<small><small> </small></small>', 'left' ) ) . "\n";
435 echo html_tag( 'tr', '', '', $color[0] ) . "\n";
436 echo html_tag( 'td', '', 'center', '', 'colspan="2"' ) . "\n";
437 echo " <select name=match_type>\n";
439 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'from':1),
442 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'to':0),
445 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'cc':0),
448 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'to_cc':0),
451 (isset($theid)?
$message_highlight_list[$theid]['match_type'] == 'subject':0),
454 echo '<b>' . _("Matches") . ':</b> ';
455 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['value']))
456 $disp = $message_highlight_list[$theid]['value'];
459 echo ' '.addInput('value', $disp, 40);
463 echo '<center><input type="submit" value="' . _("Submit") . "\"></center>\n";
466 do_hook('options_highlight_bottom');
468 </table
></body
></html
>