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 | |
c57b0888 |
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'); |
9d157cec |
19 | |
c57b0888 |
20 | function oh_opt( $val, $sel, $tit ) { |
21 | echo " <option value=\"$val\""; |
22 | if ( $sel ) |
23 | echo 'selected'; |
24 | echo ">$tit</option>\n"; |
25 | } |
e697b6cc |
26 | |
1863670d |
27 | if (! isset($action)) |
28 | $action = ''; |
29 | if (! isset($message_highlight_list)) |
30 | $message_highlight_list = array(); |
9d157cec |
31 | |
e1db998a |
32 | if ($action == 'delete' && isset($theid)) { |
e4bf514f |
33 | removePref($data_dir, $username, "highlight$theid"); |
e1db998a |
34 | } else if ($action == 'save') { |
e4bf514f |
35 | if (!$theid) $theid = 0; |
e1db998a |
36 | $identname = ereg_replace(',', ' ', $identname); |
44f642f5 |
37 | if ($color_type == 1) $newcolor = $newcolor_choose; |
721d2a60 |
38 | elseif ($color_type == 2) $newcolor = $newcolor_input; |
39 | else $newcolor = $color_type; |
e697b6cc |
40 | |
e1db998a |
41 | $newcolor = ereg_replace(',', '', $newcolor); |
42 | $newcolor = ereg_replace('#', '', $newcolor); |
22765520 |
43 | $newcolor = ereg_replace('"', '', $newcolor); |
44 | $newcolor = ereg_replace('\'', '', $newcolor); |
e1db998a |
45 | $value = ereg_replace(',', ' ', $value); |
acb61cb4 |
46 | |
e1db998a |
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; |
e697b6cc |
52 | } |
e1db998a |
53 | displayPageHeader($color, 'None'); |
c36ed9cf |
54 | ?> |
e9f8ea4e |
55 | <br> |
721d2a60 |
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> |
c36ed9cf |
59 | |
8442ac08 |
60 | <?php |
e697b6cc |
61 | echo '<br><center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]'. |
62 | ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n"; |
44f642f5 |
63 | if (count($message_highlight_list) >= 1) { |
e1db998a |
64 | echo '<table border="0" cellpadding="3" cellspacing="0" align="center" width="80%">'."\n"; |
44f642f5 |
65 | for ($i=0; $i < count($message_highlight_list); $i++) { |
e697b6cc |
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>] [<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>'; |
44f642f5 |
78 | } |
e697b6cc |
79 | echo "</table>\n". |
80 | "<br>\n"; |
9d157cec |
81 | } else { |
e697b6cc |
82 | echo '<center>' . _("No highlighting is defined") . "</center><br>\n". |
83 | "<br>\n"; |
44f642f5 |
84 | } |
e1db998a |
85 | if ($action == 'edit' || $action == 'add') { |
5b528f70 |
86 | if (!isset($theid)) |
87 | { |
88 | $theid = count($message_highlight_list); |
89 | $message_highlight_list[$theid] = array(); |
90 | } |
e697b6cc |
91 | |
e1db998a |
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'; |
e697b6cc |
105 | $color_list[13] = 'ffffff'; |
106 | |
721d2a60 |
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'; |
e697b6cc |
151 | |
721d2a60 |
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 | |
e1db998a |
228 | $selected_input = ''; |
5b528f70 |
229 | $selected_choose = ''; |
e697b6cc |
230 | |
cd928157 |
231 | for ($i=0; $i < 14; $i++) { |
e1db998a |
232 | ${"selected".$i} = ''; |
cd928157 |
233 | } |
e1db998a |
234 | if (isset($message_highlight_list[$theid]['color'])) { |
cd928157 |
235 | for ($i=0; $i < 14; $i++) { |
e1db998a |
236 | if ($color_list[$i] == $message_highlight_list[$theid]['color']) { |
237 | $selected_choose = ' checked'; |
238 | ${"selected".$i} = ' selected'; |
cd928157 |
239 | continue; |
240 | } |
e697b6cc |
241 | } |
44f642f5 |
242 | } |
e1db998a |
243 | if (!isset($message_highlight_list[$theid]['color'])) |
244 | $selected_choose = ' checked'; |
5b528f70 |
245 | else if ($selected_choose == '') |
e1db998a |
246 | $selected_input = ' checked'; |
c36ed9cf |
247 | |
e1db998a |
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"; |
e9f8ea4e |
252 | echo " <tr bgcolor=\"$color[0]\">\n"; |
22765520 |
253 | echo " <td align=\"right\" nobr><b>\n"; |
9d157cec |
254 | echo _("Identifying name") . ":"; |
e1db998a |
255 | echo ' </b></td>' . "\n"; |
22765520 |
256 | echo ' <td>' . "\n"; |
e1db998a |
257 | if (isset($message_highlight_list[$theid]['name'])) |
258 | $disp = $message_highlight_list[$theid]['name']; |
1863670d |
259 | else |
e697b6cc |
260 | $disp = ''; |
22765520 |
261 | $disp = htmlspecialchars($disp); |
acb61cb4 |
262 | echo " <input type=\"text\" value=\"".$disp."\" name=\"identname\">"; |
9d157cec |
263 | echo " </td>\n"; |
264 | echo " </tr>\n"; |
e1db998a |
265 | echo ' <tr><td><small><small> </small></small></td></tr>' . "\n"; |
e9f8ea4e |
266 | echo " <tr bgcolor=\"$color[0]\">\n"; |
22765520 |
267 | echo ' <td align="right"><b>' . "\n"; |
e1db998a |
268 | echo _("Color") . ':'; |
e9f8ea4e |
269 | echo " </b></td>\n"; |
22765520 |
270 | echo ' <td>' . "\n"; |
44f642f5 |
271 | echo " <input type=\"radio\" name=color_type value=1$selected_choose> <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"; |
1863670d |
287 | echo " <input type=\"radio\" name=color_type value=2$selected_input> ". _("Other:") ."<input type=\"text\" value=\""; |
721d2a60 |
288 | if ($selected_input) echo $message_highlight_list[$theid]["color"]; |
e1db998a |
289 | echo '" name="newcolor_input" size="7"> '._("Ex: 63aa7f")."<br>\n"; |
9d157cec |
290 | echo " </td>\n"; |
291 | echo " </tr>\n"; |
721d2a60 |
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]; |
e697b6cc |
302 | $selected = ($gridcolor == $current_color)?'SELECTED':'' ; |
721d2a60 |
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 | |
e1db998a |
311 | echo ' <tr><td><small><small> </small></small></td></tr>' . "\n"; |
e9f8ea4e |
312 | echo " <tr bgcolor=\"$color[0]\">\n"; |
22765520 |
313 | echo ' <td align="center" colspan=2>' . "\n"; |
3e69e88b |
314 | echo " <select name=match_type>\n"; |
e697b6cc |
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") ); |
3e69e88b |
330 | echo " </select>\n"; |
22765520 |
331 | echo '<b>' . _("Matches") . ':</b> '; |
e1db998a |
332 | if (isset($message_highlight_list[$theid]['value'])) |
333 | $disp = $message_highlight_list[$theid]['value']; |
1863670d |
334 | else |
335 | $disp = ''; |
22765520 |
336 | $disp = htmlspecialchars($disp); |
337 | echo ' <input type="text" value="' . $disp . |
338 | '" name="value" size=40>'; |
339 | echo " </td>\n"; |
9d157cec |
340 | echo " </tr>\n"; |
341 | echo "</table>\n"; |
e1db998a |
342 | echo '<center><input type="submit" value="' . _("Submit") . "\"></center>\n"; |
9d157cec |
343 | echo "</form>\n"; |
e697b6cc |
344 | } |
22765520 |
345 | do_hook('options_highlight_bottom'); |
9d157cec |
346 | ?> |
c57b0888 |
347 | </body></html> |