8fb86a38e55330640513608d31c72708fe0e8ddb
[squirrelmail.git] / src / options_highlight.php
1 <?php
2
3 /**
4 * options_highlight.php
5 *
6 * Copyright (c) 1999-2001 The SquirrelMail Development Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Displays message highlighting options
10 *
11 * $Id$
12 */
13
14 require_once('../src/validate.php');
15 require_once('../functions/display_messages.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/array.php');
18 require_once('../functions/plugin.php');
19
20 function oh_opt( $val, $sel, $tit ) {
21 echo " <option value=\"$val\"";
22 if ( $sel )
23 echo 'selected';
24 echo ">$tit</option>\n";
25 }
26
27 if (! isset($action))
28 $action = '';
29 if (! isset($message_highlight_list))
30 $message_highlight_list = array();
31
32 if ($action == 'delete' && isset($theid)) {
33 removePref($data_dir, $username, "highlight$theid");
34 } else if ($action == 'save') {
35 if (!$theid) $theid = 0;
36 $identname = ereg_replace(',', ' ', $identname);
37 if ($color_type == 1) $newcolor = $newcolor_choose;
38 elseif ($color_type == 2) $newcolor = $newcolor_input;
39 else $newcolor = $color_type;
40
41 $newcolor = ereg_replace(',', '', $newcolor);
42 $newcolor = ereg_replace('#', '', $newcolor);
43 $newcolor = ereg_replace('"', '', $newcolor);
44 $newcolor = ereg_replace('\'', '', $newcolor);
45 $value = ereg_replace(',', ' ', $value);
46
47 setPref($data_dir, $username, "highlight$theid", $identname.','.$newcolor.','.$value.','.$match_type);
48 $message_highlight_list[$theid]['name'] = $identname;
49 $message_highlight_list[$theid]['color'] = $newcolor;
50 $message_highlight_list[$theid]['value'] = $value;
51 $message_highlight_list[$theid]['match_type'] = $match_type;
52 }
53 displayPageHeader($color, 'None');
54 ?>
55 <br>
56 <table width="95%" align="center" border="0" cellpadding="2" cellspacing="0"><tr><td bgcolor="<?php echo $color[0] ?>">
57 <center><b><?php echo _("Options") . ' - ' . _("Message Highlighting"); ?></b></center>
58 </td></tr></table>
59
60 <?php
61 echo '<br><center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]'.
62 ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n";
63 if (count($message_highlight_list) >= 1) {
64 echo '<table border="0" cellpadding="3" cellspacing="0" align="center" width="80%">'."\n";
65 for ($i=0; $i < count($message_highlight_list); $i++) {
66 echo '<tr bgcolor="' . $message_highlight_list[$i]['color'] . '">'.
67 "<td width=5% bgcolor=\"$color[4]\" nobr>".
68 "<small>[<a href=\"options_highlight.php?action=edit&theid=$i\">".
69 _("Edit") .
70 '</a>]&nbsp;[<a href="options_highlight.php?action=delete&theid='.
71 $i . '">' . _("Delete") . '</a>]</small>'.
72 '</td><td>'.
73 htmlspecialchars($message_highlight_list[$i]['name']) .
74 '</td><td>'.
75 $message_highlight_list[$i]['match_type'] . ' = ' .
76 htmlspecialchars($message_highlight_list[$i]['value']).
77 '</td></tr>';
78 }
79 echo "</table>\n".
80 "<br>\n";
81 } else {
82 echo '<center>' . _("No highlighting is defined") . "</center><br>\n".
83 "<br>\n";
84 }
85 if ($action == 'edit' || $action == 'add') {
86 if (!isset($theid))
87 {
88 $theid = count($message_highlight_list);
89 $message_highlight_list[$theid] = array();
90 }
91
92 $color_list[0] = '4444aa';
93 $color_list[1] = '44aa44';
94 $color_list[2] = 'aaaa44';
95 $color_list[3] = '44aaaa';
96 $color_list[4] = 'aa44aa';
97 $color_list[5] = 'aaaaff';
98 $color_list[6] = 'aaffaa';
99 $color_list[7] = 'ffffaa';
100 $color_list[8] = 'aaffff';
101 $color_list[9] = 'ffaaff';
102 $color_list[10] = 'aaaaaa';
103 $color_list[11] = 'bfbfbf';
104 $color_list[12] = 'dfdfdf';
105 $color_list[13] = 'ffffff';
106
107 # helpful color chart from http://www.visibone.com/colorlab/big.html
108 $new_color_list["0,0"] = 'cccccc';
109 $new_color_list["0,1"] = '999999';
110 $new_color_list["0,2"] = '666666';
111 $new_color_list["0,3"] = '333333';
112 $new_color_list["0,4"] = '000000';
113
114 # red
115 $new_color_list["1,0"] = 'ff0000';
116 $new_color_list["1,1"] = 'cc0000';
117 $new_color_list["1,2"] = '990000';
118 $new_color_list["1,3"] = '660000';
119 $new_color_list["1,4"] = '330000';
120
121 $new_color_list["2,0"] = 'ffcccc';
122 $new_color_list["2,1"] = 'cc9999';
123 $new_color_list["2,2"] = '996666';
124 $new_color_list["2,3"] = '663333';
125 $new_color_list["2,4"] = '330000';
126
127 $new_color_list["3,0"] = 'ffcccc';
128 $new_color_list["3,1"] = 'ff9999';
129 $new_color_list["3,2"] = 'ff6666';
130 $new_color_list["3,3"] = 'ff3333';
131 $new_color_list["3,4"] = 'ff0000';
132
133 # green
134 $new_color_list["4,0"] = '00ff00';
135 $new_color_list["4,1"] = '00cc00';
136 $new_color_list["4,2"] = '009900';
137 $new_color_list["4,3"] = '006600';
138 $new_color_list["4,4"] = '003300';
139
140 $new_color_list["5,0"] = 'ccffcc';
141 $new_color_list["5,1"] = '99cc99';
142 $new_color_list["5,2"] = '669966';
143 $new_color_list["5,3"] = '336633';
144 $new_color_list["5,4"] = '003300';
145
146 $new_color_list["6,0"] = 'ccffcc';
147 $new_color_list["6,1"] = '99ff99';
148 $new_color_list["6,2"] = '66ff66';
149 $new_color_list["6,3"] = '33ff33';
150 $new_color_list["6,4"] = '00ff00';
151
152 # blue
153 $new_color_list["7,0"] = '0000ff';
154 $new_color_list["7,1"] = '0000cc';
155 $new_color_list["7,2"] = '000099';
156 $new_color_list["7,3"] = '000066';
157 $new_color_list["7,4"] = '000033';
158
159 $new_color_list["8,0"] = 'ccccff';
160 $new_color_list["8,1"] = '9999cc';
161 $new_color_list["8,2"] = '666699';
162 $new_color_list["8,3"] = '333366';
163 $new_color_list["8,4"] = '000033';
164
165 $new_color_list["9,0"] = 'ccccff';
166 $new_color_list["9,1"] = '9999ff';
167 $new_color_list["9,2"] = '6666ff';
168 $new_color_list["9,3"] = '3333ff';
169 $new_color_list["9,4"] = '0000ff';
170
171 # yellow
172 $new_color_list["10,0"] = 'ffff00';
173 $new_color_list["10,1"] = 'cccc00';
174 $new_color_list["10,2"] = '999900';
175 $new_color_list["10,3"] = '666600';
176 $new_color_list["10,4"] = '333300';
177
178 $new_color_list["11,0"] = 'ffffcc';
179 $new_color_list["11,1"] = 'cccc99';
180 $new_color_list["11,2"] = '999966';
181 $new_color_list["11,3"] = '666633';
182 $new_color_list["11,4"] = '333300';
183
184 $new_color_list["12,0"] = 'ffffcc';
185 $new_color_list["12,1"] = 'ffff99';
186 $new_color_list["12,2"] = 'ffff66';
187 $new_color_list["12,3"] = 'ffff33';
188 $new_color_list["12,4"] = 'ffff00';
189
190 # cyan
191 $new_color_list["13,0"] = '00ffff';
192 $new_color_list["13,1"] = '00cccc';
193 $new_color_list["13,2"] = '009999';
194 $new_color_list["13,3"] = '006666';
195 $new_color_list["13,4"] = '003333';
196
197 $new_color_list["14,0"] = 'ccffff';
198 $new_color_list["14,1"] = '99cccc';
199 $new_color_list["14,2"] = '669999';
200 $new_color_list["14,3"] = '336666';
201 $new_color_list["14,4"] = '003333';
202
203 $new_color_list["15,0"] = 'ccffff';
204 $new_color_list["15,1"] = '99ffff';
205 $new_color_list["15,2"] = '66ffff';
206 $new_color_list["15,3"] = '33ffff';
207 $new_color_list["15,4"] = '00ffff';
208
209 # magenta
210 $new_color_list["16,0"] = 'ff00ff';
211 $new_color_list["16,1"] = 'cc00cc';
212 $new_color_list["16,2"] = '990099';
213 $new_color_list["16,3"] = '660066';
214 $new_color_list["16,4"] = '330033';
215
216 $new_color_list["17,0"] = 'ffccff';
217 $new_color_list["17,1"] = 'cc99cc';
218 $new_color_list["17,2"] = '996699';
219 $new_color_list["17,3"] = '663366';
220 $new_color_list["17,4"] = '330033';
221
222 $new_color_list["18,0"] = 'ffccff';
223 $new_color_list["18,1"] = 'ff99ff';
224 $new_color_list["18,2"] = 'ff66ff';
225 $new_color_list["18,3"] = 'ff33ff';
226 $new_color_list["18,4"] = 'ff00ff';
227
228 $selected_input = '';
229 $selected_choose = '';
230
231 for ($i=0; $i < 14; $i++) {
232 ${"selected".$i} = '';
233 }
234 if (isset($message_highlight_list[$theid]['color'])) {
235 for ($i=0; $i < 14; $i++) {
236 if ($color_list[$i] == $message_highlight_list[$theid]['color']) {
237 $selected_choose = ' checked';
238 ${"selected".$i} = ' selected';
239 continue;
240 }
241 }
242 }
243 if (!isset($message_highlight_list[$theid]['color']))
244 $selected_choose = ' checked';
245 else if ($selected_choose == '')
246 $selected_input = ' checked';
247
248 echo '<form name="f" action="options_highlight.php">' . "\n";
249 echo '<input type="hidden" value="save" name="action">' . "\n";
250 echo '<input type="hidden" value="'.$theid.'" name="theid">' . "\n";
251 echo '<table width="80%" align="center" cellpadding="3" cellspacing="0" border="0">' . "\n";
252 echo " <tr bgcolor=\"$color[0]\">\n";
253 echo " <td align=\"right\" nobr><b>\n";
254 echo _("Identifying name") . ":";
255 echo ' </b></td>' . "\n";
256 echo ' <td>' . "\n";
257 if (isset($message_highlight_list[$theid]['name']))
258 $disp = $message_highlight_list[$theid]['name'];
259 else
260 $disp = '';
261 $disp = htmlspecialchars($disp);
262 echo " <input type=\"text\" value=\"".$disp."\" name=\"identname\">";
263 echo " </td>\n";
264 echo " </tr>\n";
265 echo ' <tr><td><small><small>&nbsp;</small></small></td></tr>' . "\n";
266 echo " <tr bgcolor=\"$color[0]\">\n";
267 echo ' <td align="right"><b>' . "\n";
268 echo _("Color") . ':';
269 echo " </b></td>\n";
270 echo ' <td>' . "\n";
271 echo " <input type=\"radio\" name=color_type value=1$selected_choose> &nbsp;<select name=newcolor_choose>\n";
272 echo " <option value=\"$color_list[0]\"$selected0>" . _("Dark Blue") . "\n";
273 echo " <option value=\"$color_list[1]\"$selected1>" . _("Dark Green") . "\n";
274 echo " <option value=\"$color_list[2]\"$selected2>" . _("Dark Yellow") . "\n";
275 echo " <option value=\"$color_list[3]\"$selected3>" . _("Dark Cyan") . "\n";
276 echo " <option value=\"$color_list[4]\"$selected4>" . _("Dark Magenta") . "\n";
277 echo " <option value=\"$color_list[5]\"$selected5>" . _("Light Blue") . "\n";
278 echo " <option value=\"$color_list[6]\"$selected6>" . _("Light Green") . "\n";
279 echo " <option value=\"$color_list[7]\"$selected7>" . _("Light Yellow") . "\n";
280 echo " <option value=\"$color_list[8]\"$selected8>" . _("Light Cyan") . "\n";
281 echo " <option value=\"$color_list[9]\"$selected9>" . _("Light Magenta") . "\n";
282 echo " <option value=\"$color_list[10]\"$selected10>" . _("Dark Gray") . "\n";
283 echo " <option value=\"$color_list[11]\"$selected11>" . _("Medium Gray") . "\n";
284 echo " <option value=\"$color_list[12]\"$selected12>" . _("Light Gray") . "\n";
285 echo " <option value=\"$color_list[13]\"$selected13>" . _("White") . "\n";
286 echo " </select><br>\n";
287 echo " <input type=\"radio\" name=color_type value=2$selected_input> &nbsp;". _("Other:") ."<input type=\"text\" value=\"";
288 if ($selected_input) echo $message_highlight_list[$theid]["color"];
289 echo '" name="newcolor_input" size="7"> '._("Ex: 63aa7f")."<br>\n";
290 echo " </td>\n";
291 echo " </tr>\n";
292
293 # Show grid of color choices
294 echo "<tr bgcolor=$color[0]><td colspan='2'>\n";
295 echo "<table border=0 cellpadding=\"2\" align=\"center\" cellspacing=\"1\">\n";
296 $current_color = $message_highlight_list[$theid]['color'];
297 for($x = 0; $x < 5; $x++) {
298 echo "<tr>\n";
299 for($y = 0; $y < 19; $y++) {
300 $gridindex = "$y,$x";
301 $gridcolor = $new_color_list[$gridindex];
302 $selected = ($gridcolor == $current_color)?'SELECTED':'' ;
303 echo "<td bgcolor=#$gridcolor><input type='radio' name=color_type value='#$gridcolor' $selected>\n";
304 echo "</td>\n";
305 }
306 echo "</tr>\n";
307 }
308 echo "</table>\n";
309 echo "</tr></td>\n";
310
311 echo ' <tr><td><small><small>&nbsp;</small></small></td></tr>' . "\n";
312 echo " <tr bgcolor=\"$color[0]\">\n";
313 echo ' <td align="center" colspan=2>' . "\n";
314 echo " <select name=match_type>\n";
315 oh_opt( 'from',
316 ($message_highlight_list[$theid]['match_type'] == 'from'),
317 _("From") );
318 oh_opt( 'to',
319 ($message_highlight_list[$theid]['match_type'] == 'to'),
320 _("To") );
321 oh_opt( 'cc',
322 ($message_highlight_list[$theid]['match_type'] == 'cc'),
323 _("Cc") );
324 oh_opt( 'to_cc',
325 ($message_highlight_list[$theid]['match_type'] == 'to_cc'),
326 _("To or Cc") );
327 oh_opt( 'subject',
328 ($message_highlight_list[$theid]['match_type'] == 'subject'),
329 _("Subject") );
330 echo " </select>\n";
331 echo '<b>' . _("Matches") . ':</b> ';
332 if (isset($message_highlight_list[$theid]['value']))
333 $disp = $message_highlight_list[$theid]['value'];
334 else
335 $disp = '';
336 $disp = htmlspecialchars($disp);
337 echo ' <input type="text" value="' . $disp .
338 '" name="value" size=40>';
339 echo " </td>\n";
340 echo " </tr>\n";
341 echo "</table>\n";
342 echo '<center><input type="submit" value="' . _("Submit") . "\"></center>\n";
343 echo "</form>\n";
344 }
345 do_hook('options_highlight_bottom');
346 ?>
347 </body></html>