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