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'); |
14 | include('../functions/strings.php'); |
15 | include('../config/config.php'); |
16 | include('../functions/page_header.php'); |
17 | include('../functions/display_messages.php'); |
18 | include('../functions/imap.php'); |
19 | include('../functions/array.php'); |
20 | include('../functions/i18n.php'); |
21 | include('../functions/plugin.php'); |
9d157cec |
22 | |
1863670d |
23 | if (! isset($action)) |
24 | $action = ''; |
25 | if (! isset($message_highlight_list)) |
26 | $message_highlight_list = array(); |
9d157cec |
27 | |
e1db998a |
28 | if ($action == 'delete' && isset($theid)) { |
e4bf514f |
29 | removePref($data_dir, $username, "highlight$theid"); |
e1db998a |
30 | } else if ($action == 'save') { |
e4bf514f |
31 | if (!$theid) $theid = 0; |
e1db998a |
32 | $identname = ereg_replace(',', ' ', $identname); |
a3309daf |
33 | $identname = str_replace('\\\\', '\\', $identname); |
34 | $identname = str_replace('\\"', '"', $identname); |
e1db998a |
35 | $identname = str_replace('"', '"', $identname); |
44f642f5 |
36 | if ($color_type == 1) $newcolor = $newcolor_choose; |
37 | else $newcolor = $newcolor_input; |
c36ed9cf |
38 | |
e1db998a |
39 | $newcolor = ereg_replace(',', '', $newcolor); |
40 | $newcolor = ereg_replace('#', '', $newcolor); |
44f642f5 |
41 | $newcolor = "$newcolor"; |
e1db998a |
42 | $value = ereg_replace(',', ' ', $value); |
a3309daf |
43 | $value = str_replace('\\\\', '\\', $value); |
44 | $value = str_replace('\\"', '"', $value); |
e1db998a |
45 | $value = str_replace('"', '"', $value); |
acb61cb4 |
46 | |
e1db998a |
47 | setPref($data_dir, $username, "highlight$theid", $identname.','.$newcolor.','.$value.','.$match_type); |
48 | $message_highlight_list[$theid]['name'] = $identname; |
49 | $message_highlight_list[$theid]['color'] = $newcolor; |
50 | $message_highlight_list[$theid]['value'] = $value; |
51 | $message_highlight_list[$theid]['match_type'] = $match_type; |
c36ed9cf |
52 | } |
e1db998a |
53 | include('../src/load_prefs.php'); |
54 | displayPageHeader($color, 'None'); |
c36ed9cf |
55 | ?> |
e9f8ea4e |
56 | <br> |
e1db998a |
57 | <table width="95%" align="center" border="0" cellpadding="2" cellspacing="0"><tr><td bgcolor="<?php echo $color[0] ?>"> |
58 | <center><b><?php echo _("Options") . ' - ' . _("Message Highlighting"); ?></b></center> |
c36ed9cf |
59 | </td></tr></table> |
60 | |
8442ac08 |
61 | <?php |
e1db998a |
62 | echo '<br><center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]'; |
63 | echo ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n"; |
44f642f5 |
64 | if (count($message_highlight_list) >= 1) { |
e1db998a |
65 | echo '<table border="0" cellpadding="3" cellspacing="0" align="center" width="80%">'."\n"; |
44f642f5 |
66 | for ($i=0; $i < count($message_highlight_list); $i++) { |
67 | echo "<tr>\n"; |
e1db998a |
68 | echo ' <td width="1%" bgcolor="' . $color[4] . "\">\n"; |
e4bf514f |
69 | echo "<nobr><small>[<a href=\"options_highlight.php?action=edit&theid=$i\">" . _("Edit") . "</a>] [<a href=\"options_highlight.php?action=delete&theid=$i\">"._("Delete")."</a>]</small></nobr>\n"; |
e1db998a |
70 | echo ' </td>'; |
71 | echo ' <td bgcolor="' . $message_highlight_list[$i]['color'] . "\">\n"; |
1d0e64d8 |
72 | echo ' ' . $message_highlight_list[$i]['name'] . ' '; |
44f642f5 |
73 | echo " </td>\n"; |
e1db998a |
74 | echo ' <td bgcolor="' . $message_highlight_list[$i]['color'] . "\">\n"; |
75 | echo ' '.$message_highlight_list[$i]['match_type'].' = ' . $message_highlight_list[$i]['value']; |
44f642f5 |
76 | echo " </td>\n"; |
77 | echo "</tr>\n"; |
78 | } |
79 | echo "</table>\n"; |
80 | echo "<br>\n"; |
9d157cec |
81 | } else { |
e1db998a |
82 | echo '<center>' . _("No highlighting is defined") . "</center><br>\n"; |
44f642f5 |
83 | echo "<br>\n"; |
84 | } |
e1db998a |
85 | if ($action == 'edit' || $action == 'add') { |
5b528f70 |
86 | if (!isset($theid)) |
87 | { |
88 | $theid = count($message_highlight_list); |
89 | $message_highlight_list[$theid] = array(); |
90 | } |
c36ed9cf |
91 | |
e1db998a |
92 | $color_list[0] = '4444aa'; |
93 | $color_list[1] = '44aa44'; |
94 | $color_list[2] = 'aaaa44'; |
95 | $color_list[3] = '44aaaa'; |
96 | $color_list[4] = 'aa44aa'; |
97 | $color_list[5] = 'aaaaff'; |
98 | $color_list[6] = 'aaffaa'; |
99 | $color_list[7] = 'ffffaa'; |
100 | $color_list[8] = 'aaffff'; |
101 | $color_list[9] = 'ffaaff'; |
102 | $color_list[10] = 'aaaaaa'; |
103 | $color_list[11] = 'bfbfbf'; |
104 | $color_list[12] = 'dfdfdf'; |
105 | $color_list[13] = 'ffffff'; |
1863670d |
106 | |
e1db998a |
107 | $selected_input = ''; |
5b528f70 |
108 | $selected_choose = ''; |
1863670d |
109 | |
cd928157 |
110 | for ($i=0; $i < 14; $i++) { |
e1db998a |
111 | ${"selected".$i} = ''; |
cd928157 |
112 | } |
e1db998a |
113 | if (isset($message_highlight_list[$theid]['color'])) { |
cd928157 |
114 | for ($i=0; $i < 14; $i++) { |
e1db998a |
115 | if ($color_list[$i] == $message_highlight_list[$theid]['color']) { |
116 | $selected_choose = ' checked'; |
117 | ${"selected".$i} = ' selected'; |
cd928157 |
118 | continue; |
119 | } |
5b528f70 |
120 | } |
44f642f5 |
121 | } |
e1db998a |
122 | if (!isset($message_highlight_list[$theid]['color'])) |
123 | $selected_choose = ' checked'; |
5b528f70 |
124 | else if ($selected_choose == '') |
e1db998a |
125 | $selected_input = ' checked'; |
c36ed9cf |
126 | |
e1db998a |
127 | echo '<form name="f" action="options_highlight.php">' . "\n"; |
128 | echo '<input type="hidden" value="save" name="action">' . "\n"; |
129 | echo '<input type="hidden" value="'.$theid.'" name="theid">' . "\n"; |
130 | echo '<table width="80%" align="center" cellpadding="3" cellspacing="0" border="0">' . "\n"; |
e9f8ea4e |
131 | echo " <tr bgcolor=\"$color[0]\">\n"; |
e1db998a |
132 | echo " <td align=\"right\" width=\"25%\"><b>\n"; |
9d157cec |
133 | echo _("Identifying name") . ":"; |
e1db998a |
134 | echo ' </b></td>' . "\n"; |
135 | echo ' <td width="75%">' . "\n"; |
136 | if (isset($message_highlight_list[$theid]['name'])) |
137 | $disp = $message_highlight_list[$theid]['name']; |
1863670d |
138 | else |
7106ac9c |
139 | $disp = ' '; |
a3309daf |
140 | $disp = str_replace('\\\\', '\\', $disp); |
141 | $disp = str_replace('\\"', '"', $disp); |
e1db998a |
142 | $disp = str_replace('"', '"', $disp); |
acb61cb4 |
143 | echo " <input type=\"text\" value=\"".$disp."\" name=\"identname\">"; |
9d157cec |
144 | echo " </td>\n"; |
145 | echo " </tr>\n"; |
e1db998a |
146 | echo ' <tr><td><small><small> </small></small></td></tr>' . "\n"; |
e9f8ea4e |
147 | echo " <tr bgcolor=\"$color[0]\">\n"; |
e1db998a |
148 | echo ' <td align="right" width="25%"><b>' . "\n"; |
149 | echo _("Color") . ':'; |
e9f8ea4e |
150 | echo " </b></td>\n"; |
e1db998a |
151 | echo ' <td width="75%">' . "\n"; |
44f642f5 |
152 | echo " <input type=\"radio\" name=color_type value=1$selected_choose> <select name=newcolor_choose>\n"; |
153 | echo " <option value=\"$color_list[0]\"$selected0>" . _("Dark Blue") . "\n"; |
154 | echo " <option value=\"$color_list[1]\"$selected1>" . _("Dark Green") . "\n"; |
155 | echo " <option value=\"$color_list[2]\"$selected2>" . _("Dark Yellow") . "\n"; |
156 | echo " <option value=\"$color_list[3]\"$selected3>" . _("Dark Cyan") . "\n"; |
157 | echo " <option value=\"$color_list[4]\"$selected4>" . _("Dark Magenta") . "\n"; |
158 | echo " <option value=\"$color_list[5]\"$selected5>" . _("Light Blue") . "\n"; |
159 | echo " <option value=\"$color_list[6]\"$selected6>" . _("Light Green") . "\n"; |
160 | echo " <option value=\"$color_list[7]\"$selected7>" . _("Light Yellow") . "\n"; |
161 | echo " <option value=\"$color_list[8]\"$selected8>" . _("Light Cyan") . "\n"; |
162 | echo " <option value=\"$color_list[9]\"$selected9>" . _("Light Magenta") . "\n"; |
163 | echo " <option value=\"$color_list[10]\"$selected10>" . _("Dark Gray") . "\n"; |
164 | echo " <option value=\"$color_list[11]\"$selected11>" . _("Medium Gray") . "\n"; |
165 | echo " <option value=\"$color_list[12]\"$selected12>" . _("Light Gray") . "\n"; |
166 | echo " <option value=\"$color_list[13]\"$selected13>" . _("White") . "\n"; |
167 | echo " </select><br>\n"; |
1863670d |
168 | echo " <input type=\"radio\" name=color_type value=2$selected_input> ". _("Other:") ."<input type=\"text\" value=\""; |
e4bf514f |
169 | if ($selected_input) echo $message_highlight_list[$theid]["color"]; |
e1db998a |
170 | echo '" name="newcolor_input" size="7"> '._("Ex: 63aa7f")."<br>\n"; |
9d157cec |
171 | echo " </td>\n"; |
172 | echo " </tr>\n"; |
e1db998a |
173 | echo ' <tr><td><small><small> </small></small></td></tr>' . "\n"; |
e9f8ea4e |
174 | echo " <tr bgcolor=\"$color[0]\">\n"; |
e1db998a |
175 | echo ' <td align="right" width="25%"><b>' . "\n"; |
176 | echo _("Match") . ':'; |
e9f8ea4e |
177 | echo " </b></td>\n"; |
e1db998a |
178 | echo ' <td width="75%">' . "\n"; |
3e69e88b |
179 | echo " <select name=match_type>\n"; |
e1db998a |
180 | if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'from') echo " <option value=\"from\" selected>From\n"; |
c36ed9cf |
181 | else echo " <option value=\"from\">From\n"; |
e1db998a |
182 | if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'to') echo " <option value=\"to\" selected>To\n"; |
c36ed9cf |
183 | else echo " <option value=\"to\">To\n"; |
e1db998a |
184 | if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'cc') echo " <option value=\"cc\" selected>Cc\n"; |
1195c340 |
185 | else echo " <option value=\"cc\">Cc\n"; |
e1db998a |
186 | 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"; |
1195c340 |
187 | else echo " <option value=\"to_cc\">To or Cc\n"; |
e1db998a |
188 | if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'subject') echo " <option value=\"subject\" selected>Subject\n"; |
c36ed9cf |
189 | else echo " <option value=\"subject\">Subject\n"; |
3e69e88b |
190 | echo " </select>\n"; |
e1db998a |
191 | if (isset($message_highlight_list[$theid]['value'])) |
192 | $disp = $message_highlight_list[$theid]['value']; |
1863670d |
193 | else |
194 | $disp = ''; |
a3309daf |
195 | $disp = str_replace('\\\\', '\\', $disp); |
196 | $disp = str_replace('\\"', '"', $disp); |
e1db998a |
197 | $disp = str_replace('"', '"', $disp); |
198 | echo ' <nobr><input type="text" value="'.$disp.'" name="value">'; |
e90872be |
199 | echo " <nobr></td>\n"; |
9d157cec |
200 | echo " </tr>\n"; |
201 | echo "</table>\n"; |
e1db998a |
202 | echo '<center><input type="submit" value="' . _("Submit") . "\"></center>\n"; |
9d157cec |
203 | echo "</form>\n"; |
e1db998a |
204 | do_hook('options_highlight_bottom'); |
c36ed9cf |
205 | } |
9d157cec |
206 | ?> |
c36ed9cf |
207 | </body></html> |