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