9d157cec |
1 | <?php |
895905c0 |
2 | |
c57b0888 |
3 | /** |
4 | * options_highlight.php |
5 | * |
c57b0888 |
6 | * Displays message highlighting options |
7 | * |
4b5049de |
8 | * @copyright © 1999-2007 The SquirrelMail Project Team |
4b4abf93 |
9 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
30967a1e |
10 | * @version $Id$ |
8f6f9ba5 |
11 | * @package squirrelmail |
ca479ad1 |
12 | * @subpackage prefs |
c57b0888 |
13 | */ |
ef870322 |
14 | |
30967a1e |
15 | /** |
202bcbcc |
16 | * Include the SquirrelMail initialization file. |
30967a1e |
17 | */ |
202bcbcc |
18 | require('../include/init.php'); |
86725763 |
19 | |
202bcbcc |
20 | // include_once(SM_PATH . 'functions/imap.php'); |
21 | require_once(SM_PATH . 'functions/forms.php'); |
9d157cec |
22 | |
fe369c70 |
23 | /* get globals */ |
62366261 |
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); |
fe369c70 |
32 | |
fe369c70 |
33 | /* end of get globals */ |
91e0dccc |
34 | |
c57b0888 |
35 | function oh_opt( $val, $sel, $tit ) { |
d79e01f5 |
36 | echo "<option value=\"$val\""; |
c57b0888 |
37 | if ( $sel ) |
e1728a7a |
38 | echo ' selected="selected"'; |
c57b0888 |
39 | echo ">$tit</option>\n"; |
40 | } |
e697b6cc |
41 | |
d79e01f5 |
42 | if (! isset($action)) { |
43 | $action = ''; |
44 | } |
45 | if (! isset($message_highlight_list)) { |
46 | $message_highlight_list = array(); |
47 | } |
48 | |
8415b2d3 |
49 | if (isset($theid) && ($action == 'delete') || |
50 | ($action == 'up') || |
51 | ($action == 'down')) { |
1c159927 |
52 | $new_rules = array(); |
8415b2d3 |
53 | switch($action) { |
54 | case('delete'): |
55 | foreach($message_highlight_list as $rid => $rule) { |
56 | if($rid != $theid) { |
57 | $new_rules[] = $rule; |
58 | } |
59 | } |
60 | break; |
61 | case('down'): |
62 | $theid++; |
63 | case('up'): |
64 | foreach($message_highlight_list as $rid => $rule) { |
65 | if($rid == $theid) { |
66 | $temp_rule = $new_rules[$rid-1]; |
67 | $new_rules[$rid-1] = $rule; |
68 | $new_rules[$rid] = $temp_rule; |
69 | } else { |
70 | $new_rules[$rid] = $rule; |
71 | } |
72 | } |
73 | break; |
74 | default: |
75 | $new_rules = $message_highlight_list; |
76 | break; |
1c159927 |
77 | } |
134e4174 |
78 | $message_highlight_list = $new_rules; |
1c159927 |
79 | |
80 | setPref($data_dir, $username, 'hililist', serialize($message_highlight_list)); |
81 | |
d7746ca5 |
82 | header( 'Location: ' .get_location(). '/options_highlight.php' ); |
d79e01f5 |
83 | exit; |
84 | } else if ($action == 'save') { |
1c159927 |
85 | |
d79e01f5 |
86 | if ($color_type == 1) $newcolor = $newcolor_choose; |
87 | elseif ($color_type == 2) $newcolor = $newcolor_input; |
88 | else $newcolor = $color_type; |
89 | |
0f8a1ce9 |
90 | $newcolor = str_replace('#', '', $newcolor); |
91 | $newcolor = str_replace('"', '', $newcolor); |
92 | $newcolor = str_replace('\'', '', $newcolor); |
93 | $value = str_replace(',', ' ', $value); |
d79e01f5 |
94 | |
1c159927 |
95 | if(isset($theid)) { |
91e0dccc |
96 | $message_highlight_list[$theid] = |
1c159927 |
97 | array( 'name' => $identname, 'color' => $newcolor, |
98 | 'value' => $value, 'match_type' => $match_type ); |
99 | } else { |
91e0dccc |
100 | $message_highlight_list[] = |
1c159927 |
101 | array( 'name' => $identname, 'color' => $newcolor, |
102 | 'value' => $value, 'match_type' => $match_type ); |
103 | } |
104 | |
105 | setPref($data_dir, $username, 'hililist', serialize($message_highlight_list)); |
d79e01f5 |
106 | } |
876fdb60 |
107 | displayPageHeader($color); |
c36ed9cf |
108 | |
85c8aff6 |
109 | /** |
110 | * Display the current rule list |
111 | */ |
112 | $rules = array(); |
113 | foreach($message_highlight_list as $index=>$rule) { |
114 | $a = array(); |
115 | |
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']) { |
545238b1 |
121 | case 'from' : |
85c8aff6 |
122 | $a['MatchField'] = _("From"); |
123 | break; |
545238b1 |
124 | case 'to' : |
85c8aff6 |
125 | $a['MatchField'] = _("To"); |
126 | break; |
545238b1 |
127 | case 'cc' : |
85c8aff6 |
128 | $a['MatchField'] = _("Cc"); |
129 | break; |
545238b1 |
130 | case 'to_cc' : |
85c8aff6 |
131 | $a['MatchField'] = _("To or Cc"); |
132 | break; |
545238b1 |
133 | case 'subject' : |
85c8aff6 |
134 | $a['MatchField'] = _("subject"); |
135 | break; |
d79e01f5 |
136 | } |
85c8aff6 |
137 | |
138 | $rules[$index] = $a; |
d79e01f5 |
139 | } |
85c8aff6 |
140 | |
141 | $oTemplate->assign('current_rules', $rules); |
142 | |
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='); |
148 | |
149 | $oTemplate->display('options_highlight_list.tpl'); |
150 | |
151 | /** |
152 | * Optionally, display the add/edit dialog |
153 | */ |
d79e01f5 |
154 | if ($action == 'edit' || $action == 'add') { |
d79e01f5 |
155 | |
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'; |
170 | |
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'; |
177 | |
178 | # red |
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'; |
184 | |
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'; |
190 | |
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'; |
196 | |
197 | # green |
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'; |
203 | |
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'; |
209 | |
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'; |
215 | |
216 | # blue |
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'; |
222 | |
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'; |
228 | |
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'; |
234 | |
235 | # yellow |
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'; |
241 | |
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'; |
247 | |
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'; |
253 | |
254 | # cyan |
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'; |
260 | |
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'; |
266 | |
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'; |
272 | |
273 | # magenta |
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'; |
279 | |
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'; |
285 | |
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'; |
291 | |
62366261 |
292 | $selected_input = FALSE; |
62366261 |
293 | $selected_choose = FALSE; |
294 | $selected_predefined = FALSE; |
d79e01f5 |
295 | |
85c8aff6 |
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'] : ''; |
300 | |
89465360 |
301 | if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['color'])) { |
d79e01f5 |
302 | for ($i=0; $i < 14; $i++) { |
e1db998a |
303 | if ($color_list[$i] == $message_highlight_list[$theid]['color']) { |
62366261 |
304 | $selected_choose = TRUE; |
89465360 |
305 | continue; |
cd928157 |
306 | } |
89465360 |
307 | } |
d79e01f5 |
308 | } |
545238b1 |
309 | |
df2c5bc9 |
310 | $pre_defined_color = 0; |
545238b1 |
311 | for($x = 0; $x < 5; $x++) { |
312 | for($y = 0; $y < 19; $y++) { |
313 | $gridindex = "$y,$x"; |
314 | $gridcolor = $new_color_list[$gridindex]; |
85c8aff6 |
315 | if ($gridcolor == $color) { |
545238b1 |
316 | $pre_defined_color = 1; |
317 | break; |
318 | } |
319 | } |
320 | } |
321 | |
935a06bb |
322 | if (isset($theid) && !isset($message_highlight_list[$theid]['color'])) |
62366261 |
323 | $selected_choose = TRUE; |
545238b1 |
324 | else if ($pre_defined_color) |
62366261 |
325 | $selected_predefined = TRUE; |
d79e01f5 |
326 | else if ($selected_choose == '') |
62366261 |
327 | $selected_input = TRUE; |
85c8aff6 |
328 | |
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 : '')); |
335 | |
c435f076 |
336 | echo addForm('options_highlight.php', 'post', 'f'). |
62366261 |
337 | addHidden('action', 'save'); |
338 | if($action == 'edit') { |
339 | echo addHidden('theid', (isset($theid)?$theid:'')); |
340 | } |
85c8aff6 |
341 | |
342 | $oTemplate->display('options_highlight_addedit.tpl'); |
343 | |
d79e01f5 |
344 | echo "</form>\n"; |
345 | } |
6e515418 |
346 | do_hook('options_highlight_bottom', $null); |
a2b193bc |
347 | |
5c4ff7bf |
348 | $oTemplate->display('footer.tpl'); |
6e515418 |
349 | ?> |