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