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