fixed some quoting problems in searching and message highlighting
[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 **/
11
12 session_start();
13
14 if (!isset($config_php))
15 include("../config/config.php");
16 if (!isset($strings_php))
17 include("../functions/strings.php");
18 if (!isset($page_header_php))
19 include("../functions/page_header.php");
20 if (!isset($display_messages_php))
21 include("../functions/display_messages.php");
22 if (!isset($imap_php))
23 include("../functions/imap.php");
24 if (!isset($array_php))
25 include("../functions/array.php");
26 if (!isset($i18n_php))
27 include("../functions/i18n.php");
28
29
30 if ($action == "delete" && isset($theid)) {
31 removePref($data_dir, $username, "highlight$theid");
32 } else if ($action == "save") {
33 if (!$theid) $theid = 0;
34 $identname = ereg_replace(",", " ", $identname);
35 $identname = str_replace("\\\\", "\\", $identname);
36 $identname = str_replace("\\\"", "\"", $identname);
37 $identname = str_replace("\"", "&quot;", $identname);
38 if ($color_type == 1) $newcolor = $newcolor_choose;
39 else $newcolor = $newcolor_input;
40
41 $newcolor = ereg_replace(",", "", $newcolor);
42 $newcolor = ereg_replace("#", "", $newcolor);
43 $newcolor = "$newcolor";
44 $value = ereg_replace(",", " ", $value);
45 $value = str_replace("\\\\", "\\", $value);
46 $value = str_replace("\\\"", "\"", $value);
47 $value = str_replace("\"", "&quot;", $value);
48
49 setPref($data_dir, $username, "highlight$theid", $identname.",".$newcolor.",".$value.",".$match_type);
50 $message_highlight_list[$theid]["name"] = $identname;
51 $message_highlight_list[$theid]["color"] = $newcolor;
52 $message_highlight_list[$theid]["value"] = $value;
53 $message_highlight_list[$theid]["match_type"] = $match_type;
54 }
55 include("../src/load_prefs.php");
56 displayPageHeader($color, "None");
57 ?>
58 <br>
59 <table width=95% align=center border=0 cellpadding=2 cellspacing=0><tr><td bgcolor="<?php echo $color[0] ?>">
60 <center><b><?php echo _("Options") . " - " . _("Message Highlighting"); ?></b></center>
61 </td></tr></table>
62
63 <?php
64 echo "<br><center>[<a href=\"options_highlight.php?action=add\">" . _("New") . "</a>]";
65 echo " - [<a href=\"options.php\">"._("Done")."</a>]</center><br>\n";
66 if (count($message_highlight_list) >= 1) {
67 echo "<table border=0 cellpadding=3 cellspacing=0 align=center width=80%>\n";
68 for ($i=0; $i < count($message_highlight_list); $i++) {
69 echo "<tr>\n";
70 echo " <td width=1% bgcolor=" . $color[4] . ">\n";
71 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";
72 echo " </td>";
73 echo " <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n";
74 echo " " . $message_highlight_list[$i]["name"];
75 echo " </td>\n";
76 echo " <td bgcolor=" . $message_highlight_list[$i]["color"] . ">\n";
77 echo " ".$message_highlight_list[$i]["match_type"]." = " . $message_highlight_list[$i]["value"];
78 echo " </td>\n";
79 echo "</tr>\n";
80 }
81 echo "</table>\n";
82 echo "<br>\n";
83 } else {
84 echo "<center>" . _("No highlighting is defined") . "</center><br>\n";
85 echo "<br>\n";
86 }
87 if ($action == "edit" || $action == "add") {
88 if (!isset($theid)) $theid = count($message_highlight_list);
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 for ($i=0; $i < 14; $i++) {
105 if ($color_list[$i] == $message_highlight_list[$theid]["color"]) {
106 $selected_choose = " checked";
107 ${"selected".$i} = " selected";
108 continue;
109 }
110 }
111 if (!$message_highlight_list[$theid]["color"])
112 $selected_choose = " checked";
113 else if (!$selected_choose)
114 $selected_input = " checked";
115
116 echo "<form action=\"options_highlight.php\">\n";
117 echo "<input type=\"hidden\" value=\"save\" name=\"action\">\n";
118 echo "<input type=\"hidden\" value=\"$theid\" name=\"theid\">\n";
119 echo "<table width=80% align=center cellpadding=3 cellspacing=0 border=0>\n";
120 echo " <tr bgcolor=\"$color[0]\">\n";
121 echo " <td align=right width=25%><b>\n";
122 echo _("Identifying name") . ":";
123 echo " </b></td>\n";
124 echo " <td width=75%>\n";
125 $disp = $message_highlight_list[$theid]["name"];
126 $disp = str_replace("\\\\", "\\", $disp);
127 $disp = str_replace("\\\"", "\"", $disp);
128 $disp = str_replace("\"", "&quot;", $disp);
129 echo " <input type=\"text\" value=\"".$disp."\" name=\"identname\">";
130 echo " </td>\n";
131 echo " </tr>\n";
132 echo " <tr><td><small><small>&nbsp;</small></small></td></tr>\n";
133 echo " <tr bgcolor=\"$color[0]\">\n";
134 echo " <td align=right width=25%><b>\n";
135 echo _("Color") . ":";
136 echo " </b></td>\n";
137 echo " <td width=75%>\n";
138 echo " <input type=\"radio\" name=color_type value=1$selected_choose> &nbsp;<select name=newcolor_choose>\n";
139 echo " <option value=\"$color_list[0]\"$selected0>" . _("Dark Blue") . "\n";
140 echo " <option value=\"$color_list[1]\"$selected1>" . _("Dark Green") . "\n";
141 echo " <option value=\"$color_list[2]\"$selected2>" . _("Dark Yellow") . "\n";
142 echo " <option value=\"$color_list[3]\"$selected3>" . _("Dark Cyan") . "\n";
143 echo " <option value=\"$color_list[4]\"$selected4>" . _("Dark Magenta") . "\n";
144 echo " <option value=\"$color_list[5]\"$selected5>" . _("Light Blue") . "\n";
145 echo " <option value=\"$color_list[6]\"$selected6>" . _("Light Green") . "\n";
146 echo " <option value=\"$color_list[7]\"$selected7>" . _("Light Yellow") . "\n";
147 echo " <option value=\"$color_list[8]\"$selected8>" . _("Light Cyan") . "\n";
148 echo " <option value=\"$color_list[9]\"$selected9>" . _("Light Magenta") . "\n";
149 echo " <option value=\"$color_list[10]\"$selected10>" . _("Dark Gray") . "\n";
150 echo " <option value=\"$color_list[11]\"$selected11>" . _("Medium Gray") . "\n";
151 echo " <option value=\"$color_list[12]\"$selected12>" . _("Light Gray") . "\n";
152 echo " <option value=\"$color_list[13]\"$selected13>" . _("White") . "\n";
153 echo " </select><br>\n";
154 echo " <input type=\"radio\" name=color_type value=2$selected_input> &nbsp;". _("Other:") ."<input type=\"text\" value=\"";
155 if ($selected_input) echo $message_highlight_list[$theid]["color"];
156 echo "\" name=\"newcolor_input\" size=7> "._("Ex: 63aa7f")."<br>\n";
157 echo " </td>\n";
158 echo " </tr>\n";
159 echo " <tr><td><small><small>&nbsp;</small></small></td></tr>\n";
160 echo " <tr bgcolor=\"$color[0]\">\n";
161 echo " <td align=right width=25%><b>\n";
162 echo _("Match") . ":";
163 echo " </b></td>\n";
164 echo " <td width=75%>\n";
165 echo " <select name=match_type>\n";
166 if ($message_highlight_list[$theid]["match_type"] == "from") echo " <option value=\"from\" selected>From\n";
167 else echo " <option value=\"from\">From\n";
168 if ($message_highlight_list[$theid]["match_type"] == "to") echo " <option value=\"to\" selected>To\n";
169 else echo " <option value=\"to\">To\n";
170 if ($message_highlight_list[$theid]["match_type"] == "cc") echo " <option value=\"cc\" selected>Cc\n";
171 else echo " <option value=\"cc\">Cc\n";
172 if ($message_highlight_list[$theid]["match_type"] == "to_cc") echo " <option value=\"to_cc\" selected>To or Cc\n";
173 else echo " <option value=\"to_cc\">To or Cc\n";
174 if ($message_highlight_list[$theid]["match_type"] == "subject") echo " <option value=\"subject\" selected>Subject\n";
175 else echo " <option value=\"subject\">Subject\n";
176 echo " </select>\n";
177 $disp = $message_highlight_list[$theid]["value"];
178 $disp = str_replace("\\\\", "\\", $disp);
179 $disp = str_replace("\\\"", "\"", $disp);
180 $disp = str_replace("\"", "&quot;", $disp);
181 echo " <nobr><input type=\"text\" value=\"".$disp."\" name=\"value\">";
182 echo " <nobr></td>\n";
183 echo " </tr>\n";
184 echo "</table>\n";
185 echo "<center><input type=\"submit\" value=\"" . _("Submit") . "\"></center>\n";
186 echo "</form>\n";
187 }
188 ?>
189 </body></html>