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