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