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