* Found my bug
[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
f740c049 13 include('../src/validate.php');
f740c049 14 include('../functions/display_messages.php');
15 include('../functions/imap.php');
16 include('../functions/array.php');
f740c049 17 include('../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);
a3309daf 29 $identname = str_replace('\\\\', '\\', $identname);
30 $identname = str_replace('\\"', '"', $identname);
e1db998a 31 $identname = str_replace('"', '&quot;', $identname);
44f642f5 32 if ($color_type == 1) $newcolor = $newcolor_choose;
33 else $newcolor = $newcolor_input;
c36ed9cf 34
e1db998a 35 $newcolor = ereg_replace(',', '', $newcolor);
36 $newcolor = ereg_replace('#', '', $newcolor);
44f642f5 37 $newcolor = "$newcolor";
e1db998a 38 $value = ereg_replace(',', ' ', $value);
a3309daf 39 $value = str_replace('\\\\', '\\', $value);
40 $value = str_replace('\\"', '"', $value);
e1db998a 41 $value = str_replace('"', '&quot;', $value);
acb61cb4 42
e1db998a 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;
c36ed9cf 48 }
e1db998a 49 displayPageHeader($color, 'None');
c36ed9cf 50?>
e9f8ea4e 51 <br>
e7db48af 52 <table width="95%" align="center" border="0" cellpadding="2" cellspacing="0">
53 <tr><td bgcolor="<?php echo $color[0] ?>" align="center">
c36ed9cf 54
e7db48af 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">
8442ac08 59<?php
e1db998a 60 echo '<br><center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]';
61 echo ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n";
44f642f5 62 if (count($message_highlight_list) >= 1) {
e1db998a 63 echo '<table border="0" cellpadding="3" cellspacing="0" align="center" width="80%">'."\n";
44f642f5 64 for ($i=0; $i < count($message_highlight_list); $i++) {
65 echo "<tr>\n";
e1db998a 66 echo ' <td width="1%" bgcolor="' . $color[4] . "\">\n";
e4bf514f 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";
e1db998a 68 echo ' </td>';
69 echo ' <td bgcolor="' . $message_highlight_list[$i]['color'] . "\">\n";
1d0e64d8 70 echo ' ' . $message_highlight_list[$i]['name'] . '&nbsp;';
44f642f5 71 echo " </td>\n";
e1db998a 72 echo ' <td bgcolor="' . $message_highlight_list[$i]['color'] . "\">\n";
73 echo ' '.$message_highlight_list[$i]['match_type'].' = ' . $message_highlight_list[$i]['value'];
44f642f5 74 echo " </td>\n";
75 echo "</tr>\n";
76 }
77 echo "</table>\n";
78 echo "<br>\n";
9d157cec 79 } else {
e7db48af 80 echo _("No highlighting is defined") . "<br>\n";
44f642f5 81 echo "<br>\n";
82 }
e1db998a 83 if ($action == 'edit' || $action == 'add') {
5b528f70 84 if (!isset($theid))
85 {
86 $theid = count($message_highlight_list);
87 $message_highlight_list[$theid] = array();
88 }
c36ed9cf 89
e1db998a 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';
1863670d 104
e1db998a 105 $selected_input = '';
5b528f70 106 $selected_choose = '';
1863670d 107
cd928157 108 for ($i=0; $i < 14; $i++) {
e1db998a 109 ${"selected".$i} = '';
cd928157 110 }
e1db998a 111 if (isset($message_highlight_list[$theid]['color'])) {
cd928157 112 for ($i=0; $i < 14; $i++) {
e1db998a 113 if ($color_list[$i] == $message_highlight_list[$theid]['color']) {
114 $selected_choose = ' checked';
115 ${"selected".$i} = ' selected';
cd928157 116 continue;
117 }
e7db48af 118 }
44f642f5 119 }
e1db998a 120 if (!isset($message_highlight_list[$theid]['color']))
121 $selected_choose = ' checked';
5b528f70 122 else if ($selected_choose == '')
e1db998a 123 $selected_input = ' checked';
c36ed9cf 124
e1db998a 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";
e9f8ea4e 129 echo " <tr bgcolor=\"$color[0]\">\n";
e1db998a 130 echo " <td align=\"right\" width=\"25%\"><b>\n";
9d157cec 131 echo _("Identifying name") . ":";
e1db998a 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'];
1863670d 136 else
7106ac9c 137 $disp = '&nbsp;';
a3309daf 138 $disp = str_replace('\\\\', '\\', $disp);
139 $disp = str_replace('\\"', '"', $disp);
e1db998a 140 $disp = str_replace('"', '&quot;', $disp);
acb61cb4 141 echo " <input type=\"text\" value=\"".$disp."\" name=\"identname\">";
9d157cec 142 echo " </td>\n";
143 echo " </tr>\n";
e1db998a 144 echo ' <tr><td><small><small>&nbsp;</small></small></td></tr>' . "\n";
e9f8ea4e 145 echo " <tr bgcolor=\"$color[0]\">\n";
e1db998a 146 echo ' <td align="right" width="25%"><b>' . "\n";
147 echo _("Color") . ':';
e9f8ea4e 148 echo " </b></td>\n";
e1db998a 149 echo ' <td width="75%">' . "\n";
44f642f5 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";
1863670d 166 echo " <input type=\"radio\" name=color_type value=2$selected_input> &nbsp;". _("Other:") ."<input type=\"text\" value=\"";
e7db48af 167 if ($selected_input)
168 echo $message_highlight_list[$theid]["color"];
e1db998a 169 echo '" name="newcolor_input" size="7"> '._("Ex: 63aa7f")."<br>\n";
9d157cec 170 echo " </td>\n";
171 echo " </tr>\n";
e1db998a 172 echo ' <tr><td><small><small>&nbsp;</small></small></td></tr>' . "\n";
e9f8ea4e 173 echo " <tr bgcolor=\"$color[0]\">\n";
e1db998a 174 echo ' <td align="right" width="25%"><b>' . "\n";
175 echo _("Match") . ':';
e9f8ea4e 176 echo " </b></td>\n";
e1db998a 177 echo ' <td width="75%">' . "\n";
3e69e88b 178 echo " <select name=match_type>\n";
e7db48af 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";
3e69e88b 199 echo " </select>\n";
e1db998a 200 if (isset($message_highlight_list[$theid]['value']))
201 $disp = $message_highlight_list[$theid]['value'];
1863670d 202 else
203 $disp = '';
a3309daf 204 $disp = str_replace('\\\\', '\\', $disp);
205 $disp = str_replace('\\"', '"', $disp);
e1db998a 206 $disp = str_replace('"', '&quot;', $disp);
207 echo ' <nobr><input type="text" value="'.$disp.'" name="value">';
e90872be 208 echo " <nobr></td>\n";
9d157cec 209 echo " </tr>\n";
210 echo "</table>\n";
e1db998a 211 echo '<center><input type="submit" value="' . _("Submit") . "\"></center>\n";
9d157cec 212 echo "</form>\n";
c36ed9cf 213 }
9d157cec 214?>
e7db48af 215
216 <?php do_hook('options_highlight_bottom'); ?>
217
218 </td></tr>
219 </table>
220
221</td></tr>
222</table>
c36ed9cf 223</body></html>