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