4 * options_highlight.php
6 * Displays message highlighting options
8 * @copyright © 1999-2007 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
16 * Include the SquirrelMail initialization file.
18 require('../include/init.php');
20 // include_once(SM_PATH . 'functions/imap.php');
21 require_once(SM_PATH
. 'functions/forms.php');
24 sqGetGlobalVar('action', $action);
25 sqGetGlobalVar('theid', $theid);
26 sqGetGlobalVar('identname', $identname);
27 sqGetGlobalVar('newcolor_choose', $newcolor_choose);
28 sqGetGlobalVar('newcolor_input', $newcolor_input);
29 sqGetGlobalVar('color_type', $color_type);
30 sqGetGlobalVar('match_type', $match_type);
31 sqGetGlobalVar('value', $value);
33 /* end of get globals */
35 function oh_opt( $val, $sel, $tit ) {
36 echo "<option value=\"$val\"";
38 echo ' selected="selected"';
39 echo ">$tit</option>\n";
42 if (! isset($action)) {
45 if (! isset($message_highlight_list)) {
46 $message_highlight_list = array();
49 if (isset($theid) && ($action == 'delete') ||
51 ($action == 'down')) {
55 foreach($message_highlight_list as $rid => $rule) {
64 foreach($message_highlight_list as $rid => $rule) {
66 $temp_rule = $new_rules[$rid-1];
67 $new_rules[$rid-1] = $rule;
68 $new_rules[$rid] = $temp_rule;
70 $new_rules[$rid] = $rule;
75 $new_rules = $message_highlight_list;
78 $message_highlight_list = $new_rules;
80 setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
82 header( 'Location: ' .get_location(). '/options_highlight.php' );
84 } else if ($action == 'save') {
86 if ($color_type == 1) $newcolor = $newcolor_choose;
87 elseif ($color_type == 2) $newcolor = $newcolor_input;
88 else $newcolor = $color_type;
90 $newcolor = str_replace('#', '', $newcolor);
91 $newcolor = str_replace('"', '', $newcolor);
92 $newcolor = str_replace('\'', '', $newcolor);
93 $value = str_replace(',', ' ', $value);
96 $message_highlight_list[$theid] =
97 array( 'name' => $identname, 'color' => $newcolor,
98 'value' => $value, 'match_type' => $match_type );
100 $message_highlight_list[] =
101 array( 'name' => $identname, 'color' => $newcolor,
102 'value' => $value, 'match_type' => $match_type );
105 setPref($data_dir, $username, 'hililist', serialize($message_highlight_list));
107 displayPageHeader($color);
110 * Display the current rule list
113 foreach($message_highlight_list as $index=>$rule) {
116 $a['Name'] = htmlspecialchars($rule['name']);
117 $a['Color'] = $rule['color'];
118 $a['MatchField'] = '';
119 $a['MatchValue'] = htmlspecialchars($rule['value']);
120 switch ($rule['match_type']) {
122 $a['MatchField'] = _("From");
125 $a['MatchField'] = _("To");
128 $a['MatchField'] = _("Cc");
131 $a['MatchField'] = _("To or Cc");
134 $a['MatchField'] = _("subject");
141 $oTemplate->assign('current_rules', $rules);
143 $oTemplate->assign('add_rule', 'options_highlight.php?action=add');
144 $oTemplate->assign('edit_rule', 'options_highlight.php?action=edit&theid=');
145 $oTemplate->assign('delete_rule', 'options_highlight.php?action=delete&theid=');
146 $oTemplate->assign('move_up', 'options_highlight.php?action=up&theid=');
147 $oTemplate->assign('move_down', 'options_highlight.php?action=down&theid=');
149 $oTemplate->display('options_highlight_list.tpl');
152 * Optionally, display the add/edit dialog
154 if ($action == 'edit' ||
$action == 'add') {
156 $color_list[0] = '4444aa';
157 $color_list[1] = '44aa44';
158 $color_list[2] = 'aaaa44';
159 $color_list[3] = '44aaaa';
160 $color_list[4] = 'aa44aa';
161 $color_list[5] = 'aaaaff';
162 $color_list[6] = 'aaffaa';
163 $color_list[7] = 'ffffaa';
164 $color_list[8] = 'aaffff';
165 $color_list[9] = 'ffaaff';
166 $color_list[10] = 'aaaaaa';
167 $color_list[11] = 'bfbfbf';
168 $color_list[12] = 'dfdfdf';
169 $color_list[13] = 'ffffff';
171 # helpful color chart from http://www.visibone.com/colorlab/big.html
172 $new_color_list["0,0"] = 'cccccc';
173 $new_color_list["0,1"] = '999999';
174 $new_color_list["0,2"] = '666666';
175 $new_color_list["0,3"] = '333333';
176 $new_color_list["0,4"] = '000000';
179 $new_color_list["1,0"] = 'ff0000';
180 $new_color_list["1,1"] = 'cc0000';
181 $new_color_list["1,2"] = '990000';
182 $new_color_list["1,3"] = '660000';
183 $new_color_list["1,4"] = '330000';
185 $new_color_list["2,0"] = 'ffcccc';
186 $new_color_list["2,1"] = 'cc9999';
187 $new_color_list["2,2"] = '996666';
188 $new_color_list["2,3"] = '663333';
189 $new_color_list["2,4"] = '330000';
191 $new_color_list["3,0"] = 'ffcccc';
192 $new_color_list["3,1"] = 'ff9999';
193 $new_color_list["3,2"] = 'ff6666';
194 $new_color_list["3,3"] = 'ff3333';
195 $new_color_list["3,4"] = 'ff0000';
198 $new_color_list["4,0"] = '00ff00';
199 $new_color_list["4,1"] = '00cc00';
200 $new_color_list["4,2"] = '009900';
201 $new_color_list["4,3"] = '006600';
202 $new_color_list["4,4"] = '003300';
204 $new_color_list["5,0"] = 'ccffcc';
205 $new_color_list["5,1"] = '99cc99';
206 $new_color_list["5,2"] = '669966';
207 $new_color_list["5,3"] = '336633';
208 $new_color_list["5,4"] = '003300';
210 $new_color_list["6,0"] = 'ccffcc';
211 $new_color_list["6,1"] = '99ff99';
212 $new_color_list["6,2"] = '66ff66';
213 $new_color_list["6,3"] = '33ff33';
214 $new_color_list["6,4"] = '00ff00';
217 $new_color_list["7,0"] = '0000ff';
218 $new_color_list["7,1"] = '0000cc';
219 $new_color_list["7,2"] = '000099';
220 $new_color_list["7,3"] = '000066';
221 $new_color_list["7,4"] = '000033';
223 $new_color_list["8,0"] = 'ccccff';
224 $new_color_list["8,1"] = '9999cc';
225 $new_color_list["8,2"] = '666699';
226 $new_color_list["8,3"] = '333366';
227 $new_color_list["8,4"] = '000033';
229 $new_color_list["9,0"] = 'ccccff';
230 $new_color_list["9,1"] = '9999ff';
231 $new_color_list["9,2"] = '6666ff';
232 $new_color_list["9,3"] = '3333ff';
233 $new_color_list["9,4"] = '0000ff';
236 $new_color_list["10,0"] = 'ffff00';
237 $new_color_list["10,1"] = 'cccc00';
238 $new_color_list["10,2"] = '999900';
239 $new_color_list["10,3"] = '666600';
240 $new_color_list["10,4"] = '333300';
242 $new_color_list["11,0"] = 'ffffcc';
243 $new_color_list["11,1"] = 'cccc99';
244 $new_color_list["11,2"] = '999966';
245 $new_color_list["11,3"] = '666633';
246 $new_color_list["11,4"] = '333300';
248 $new_color_list["12,0"] = 'ffffcc';
249 $new_color_list["12,1"] = 'ffff99';
250 $new_color_list["12,2"] = 'ffff66';
251 $new_color_list["12,3"] = 'ffff33';
252 $new_color_list["12,4"] = 'ffff00';
255 $new_color_list["13,0"] = '00ffff';
256 $new_color_list["13,1"] = '00cccc';
257 $new_color_list["13,2"] = '009999';
258 $new_color_list["13,3"] = '006666';
259 $new_color_list["13,4"] = '003333';
261 $new_color_list["14,0"] = 'ccffff';
262 $new_color_list["14,1"] = '99cccc';
263 $new_color_list["14,2"] = '669999';
264 $new_color_list["14,3"] = '336666';
265 $new_color_list["14,4"] = '003333';
267 $new_color_list["15,0"] = 'ccffff';
268 $new_color_list["15,1"] = '99ffff';
269 $new_color_list["15,2"] = '66ffff';
270 $new_color_list["15,3"] = '33ffff';
271 $new_color_list["15,4"] = '00ffff';
274 $new_color_list["16,0"] = 'ff00ff';
275 $new_color_list["16,1"] = 'cc00cc';
276 $new_color_list["16,2"] = '990099';
277 $new_color_list["16,3"] = '660066';
278 $new_color_list["16,4"] = '330033';
280 $new_color_list["17,0"] = 'ffccff';
281 $new_color_list["17,1"] = 'cc99cc';
282 $new_color_list["17,2"] = '996699';
283 $new_color_list["17,3"] = '663366';
284 $new_color_list["17,4"] = '330033';
286 $new_color_list["18,0"] = 'ffccff';
287 $new_color_list["18,1"] = 'ff99ff';
288 $new_color_list["18,2"] = 'ff66ff';
289 $new_color_list["18,3"] = 'ff33ff';
290 $new_color_list["18,4"] = 'ff00ff';
292 $selected_input = FALSE;
293 $selected_choose = FALSE;
294 $selected_predefined = FALSE;
296 $name = $action=='edit' && isset($theid) && isset($message_highlight_list[$theid]['name']) ?
$message_highlight_list[$theid]['name'] : '';
297 $field = $action=='edit' && isset($theid) && isset($message_highlight_list[$theid]['match_type']) ?
$message_highlight_list[$theid]['match_type'] : '';
298 $value = $action=='edit' && isset($theid) && isset($message_highlight_list[$theid]['value']) ?
$message_highlight_list[$theid]['value'] : '';
299 $color = $action=='edit' && isset($theid) && isset($message_highlight_list[$theid]['color']) ?
$message_highlight_list[$theid]['color'] : '';
301 if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['color'])) {
302 for ($i=0; $i < 14; $i++
) {
303 if ($color_list[$i] == $message_highlight_list[$theid]['color']) {
304 $selected_choose = TRUE;
310 $pre_defined_color = 0;
311 for($x = 0; $x < 5; $x++
) {
312 for($y = 0; $y < 19; $y++
) {
313 $gridindex = "$y,$x";
314 $gridcolor = $new_color_list[$gridindex];
315 if ($gridcolor == $color) {
316 $pre_defined_color = 1;
322 if (isset($theid) && !isset($message_highlight_list[$theid]['color']))
323 $selected_choose = TRUE;
324 else if ($pre_defined_color)
325 $selected_predefined = TRUE;
326 else if ($selected_choose == '')
327 $selected_input = TRUE;
329 $oTemplate->assign('rule_name', $name);
330 $oTemplate->assign('rule_value', $value);
331 $oTemplate->assign('rule_field', $field);
332 $oTemplate->assign('rule_color', $color);
333 $oTemplate->assign('color_radio', ($selected_choose ?
1 : ($selected_input ?
2 : 0)));
334 $oTemplate->assign('color_input', ($selected_input ?
$color : ''));
336 echo addForm('options_highlight.php', 'post', 'f').
337 addHidden('action', 'save');
338 if($action == 'edit') {
339 echo addHidden('theid', (isset($theid)?
$theid:''));
342 $oTemplate->display('options_highlight_addedit.tpl');
346 do_hook('options_highlight_bottom', $null);
348 $oTemplate->display('footer.tpl');