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