| 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 | include('../src/validate.php'); |
| 14 | include('../functions/page_header.php'); |
| 15 | include('../functions/display_messages.php'); |
| 16 | include('../functions/imap.php'); |
| 17 | include('../functions/array.php'); |
| 18 | include('../functions/plugin.php'); |
| 19 | |
| 20 | if (! isset($action)) |
| 21 | $action = ''; |
| 22 | if (! isset($message_highlight_list)) |
| 23 | $message_highlight_list = array(); |
| 24 | |
| 25 | if ($action == 'delete' && isset($theid)) { |
| 26 | removePref($data_dir, $username, "highlight$theid"); |
| 27 | } else if ($action == 'save') { |
| 28 | if (!$theid) $theid = 0; |
| 29 | $identname = ereg_replace(',', ' ', $identname); |
| 30 | $identname = str_replace('\\\\', '\\', $identname); |
| 31 | $identname = str_replace('\\"', '"', $identname); |
| 32 | $identname = str_replace('"', '"', $identname); |
| 33 | if ($color_type == 1) $newcolor = $newcolor_choose; |
| 34 | else $newcolor = $newcolor_input; |
| 35 | |
| 36 | $newcolor = ereg_replace(',', '', $newcolor); |
| 37 | $newcolor = ereg_replace('#', '', $newcolor); |
| 38 | $newcolor = "$newcolor"; |
| 39 | $value = ereg_replace(',', ' ', $value); |
| 40 | $value = str_replace('\\\\', '\\', $value); |
| 41 | $value = str_replace('\\"', '"', $value); |
| 42 | $value = str_replace('"', '"', $value); |
| 43 | |
| 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; |
| 49 | } |
| 50 | include('../src/load_prefs.php'); |
| 51 | displayPageHeader($color, 'None'); |
| 52 | ?> |
| 53 | <br> |
| 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> |
| 56 | </td></tr></table> |
| 57 | |
| 58 | <?php |
| 59 | echo '<br><center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]'; |
| 60 | echo ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n"; |
| 61 | if (count($message_highlight_list) >= 1) { |
| 62 | echo '<table border="0" cellpadding="3" cellspacing="0" align="center" width="80%">'."\n"; |
| 63 | for ($i=0; $i < count($message_highlight_list); $i++) { |
| 64 | echo "<tr>\n"; |
| 65 | echo ' <td width="1%" bgcolor="' . $color[4] . "\">\n"; |
| 66 | echo "<nobr><small>[<a href=\"options_highlight.php?action=edit&theid=$i\">" . _("Edit") . "</a>] [<a href=\"options_highlight.php?action=delete&theid=$i\">"._("Delete")."</a>]</small></nobr>\n"; |
| 67 | echo ' </td>'; |
| 68 | echo ' <td bgcolor="' . $message_highlight_list[$i]['color'] . "\">\n"; |
| 69 | echo ' ' . $message_highlight_list[$i]['name'] . ' '; |
| 70 | echo " </td>\n"; |
| 71 | echo ' <td bgcolor="' . $message_highlight_list[$i]['color'] . "\">\n"; |
| 72 | echo ' '.$message_highlight_list[$i]['match_type'].' = ' . $message_highlight_list[$i]['value']; |
| 73 | echo " </td>\n"; |
| 74 | echo "</tr>\n"; |
| 75 | } |
| 76 | echo "</table>\n"; |
| 77 | echo "<br>\n"; |
| 78 | } else { |
| 79 | echo '<center>' . _("No highlighting is defined") . "</center><br>\n"; |
| 80 | echo "<br>\n"; |
| 81 | } |
| 82 | if ($action == 'edit' || $action == 'add') { |
| 83 | if (!isset($theid)) |
| 84 | { |
| 85 | $theid = count($message_highlight_list); |
| 86 | $message_highlight_list[$theid] = array(); |
| 87 | } |
| 88 | |
| 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'; |
| 103 | |
| 104 | $selected_input = ''; |
| 105 | $selected_choose = ''; |
| 106 | |
| 107 | for ($i=0; $i < 14; $i++) { |
| 108 | ${"selected".$i} = ''; |
| 109 | } |
| 110 | if (isset($message_highlight_list[$theid]['color'])) { |
| 111 | for ($i=0; $i < 14; $i++) { |
| 112 | if ($color_list[$i] == $message_highlight_list[$theid]['color']) { |
| 113 | $selected_choose = ' checked'; |
| 114 | ${"selected".$i} = ' selected'; |
| 115 | continue; |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | if (!isset($message_highlight_list[$theid]['color'])) |
| 120 | $selected_choose = ' checked'; |
| 121 | else if ($selected_choose == '') |
| 122 | $selected_input = ' checked'; |
| 123 | |
| 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"; |
| 128 | echo " <tr bgcolor=\"$color[0]\">\n"; |
| 129 | echo " <td align=\"right\" width=\"25%\"><b>\n"; |
| 130 | echo _("Identifying name") . ":"; |
| 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']; |
| 135 | else |
| 136 | $disp = ' '; |
| 137 | $disp = str_replace('\\\\', '\\', $disp); |
| 138 | $disp = str_replace('\\"', '"', $disp); |
| 139 | $disp = str_replace('"', '"', $disp); |
| 140 | echo " <input type=\"text\" value=\"".$disp."\" name=\"identname\">"; |
| 141 | echo " </td>\n"; |
| 142 | echo " </tr>\n"; |
| 143 | echo ' <tr><td><small><small> </small></small></td></tr>' . "\n"; |
| 144 | echo " <tr bgcolor=\"$color[0]\">\n"; |
| 145 | echo ' <td align="right" width="25%"><b>' . "\n"; |
| 146 | echo _("Color") . ':'; |
| 147 | echo " </b></td>\n"; |
| 148 | echo ' <td width="75%">' . "\n"; |
| 149 | echo " <input type=\"radio\" name=color_type value=1$selected_choose> <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"; |
| 165 | echo " <input type=\"radio\" name=color_type value=2$selected_input> ". _("Other:") ."<input type=\"text\" value=\""; |
| 166 | if ($selected_input) echo $message_highlight_list[$theid]["color"]; |
| 167 | echo '" name="newcolor_input" size="7"> '._("Ex: 63aa7f")."<br>\n"; |
| 168 | echo " </td>\n"; |
| 169 | echo " </tr>\n"; |
| 170 | echo ' <tr><td><small><small> </small></small></td></tr>' . "\n"; |
| 171 | echo " <tr bgcolor=\"$color[0]\">\n"; |
| 172 | echo ' <td align="right" width="25%"><b>' . "\n"; |
| 173 | echo _("Match") . ':'; |
| 174 | echo " </b></td>\n"; |
| 175 | echo ' <td width="75%">' . "\n"; |
| 176 | echo " <select name=match_type>\n"; |
| 177 | if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'from') echo " <option value=\"from\" selected>From\n"; |
| 178 | else echo " <option value=\"from\">From\n"; |
| 179 | if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'to') echo " <option value=\"to\" selected>To\n"; |
| 180 | else echo " <option value=\"to\">To\n"; |
| 181 | if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'cc') echo " <option value=\"cc\" selected>Cc\n"; |
| 182 | else echo " <option value=\"cc\">Cc\n"; |
| 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"; |
| 184 | else echo " <option value=\"to_cc\">To or Cc\n"; |
| 185 | if (isset($message_highlight_list[$theid]['match_type']) && $message_highlight_list[$theid]['match_type'] == 'subject') echo " <option value=\"subject\" selected>Subject\n"; |
| 186 | else echo " <option value=\"subject\">Subject\n"; |
| 187 | echo " </select>\n"; |
| 188 | if (isset($message_highlight_list[$theid]['value'])) |
| 189 | $disp = $message_highlight_list[$theid]['value']; |
| 190 | else |
| 191 | $disp = ''; |
| 192 | $disp = str_replace('\\\\', '\\', $disp); |
| 193 | $disp = str_replace('\\"', '"', $disp); |
| 194 | $disp = str_replace('"', '"', $disp); |
| 195 | echo ' <nobr><input type="text" value="'.$disp.'" name="value">'; |
| 196 | echo " <nobr></td>\n"; |
| 197 | echo " </tr>\n"; |
| 198 | echo "</table>\n"; |
| 199 | echo '<center><input type="submit" value="' . _("Submit") . "\"></center>\n"; |
| 200 | echo "</form>\n"; |
| 201 | do_hook('options_highlight_bottom'); |
| 202 | } |
| 203 | ?> |
| 204 | </body></html> |