| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * options_highlight.php |
| 5 | * |
| 6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * Displays message highlighting options |
| 10 | * |
| 11 | * $Id$ |
| 12 | */ |
| 13 | |
| 14 | /* Path for SquirrelMail required files. */ |
| 15 | define('SM_PATH','../'); |
| 16 | |
| 17 | /* SquirrelMail required files. */ |
| 18 | require_once(SM_PATH . 'include/validate.php'); |
| 19 | require_once(SM_PATH . 'functions/display_messages.php'); |
| 20 | require_once(SM_PATH . 'functions/imap.php'); |
| 21 | require_once(SM_PATH . 'functions/array.php'); |
| 22 | require_once(SM_PATH . 'functions/plugin.php'); |
| 23 | require_once(SM_PATH . 'functions/strings.php'); |
| 24 | require_once(SM_PATH . 'functions/html.php'); |
| 25 | |
| 26 | function oh_opt( $val, $sel, $tit ) { |
| 27 | echo "<option value=\"$val\""; |
| 28 | if ( $sel ) |
| 29 | echo ' selected'; |
| 30 | echo ">$tit</option>\n"; |
| 31 | } |
| 32 | |
| 33 | if (! isset($action)) { |
| 34 | $action = ''; |
| 35 | } |
| 36 | if (! isset($message_highlight_list)) { |
| 37 | $message_highlight_list = array(); |
| 38 | } |
| 39 | |
| 40 | if ($action == 'delete' && isset($theid)) { |
| 41 | removePref($data_dir, $username, "highlight$theid"); |
| 42 | header( "Location: $SCRIPT_NAME" ); |
| 43 | exit; |
| 44 | } else if ($action == 'save') { |
| 45 | if (!$theid) $theid = 0; |
| 46 | $identname = str_replace(',', ' ', $identname); |
| 47 | if ($color_type == 1) $newcolor = $newcolor_choose; |
| 48 | elseif ($color_type == 2) $newcolor = $newcolor_input; |
| 49 | else $newcolor = $color_type; |
| 50 | |
| 51 | $newcolor = str_replace(',', '', $newcolor); |
| 52 | $newcolor = str_replace('#', '', $newcolor); |
| 53 | $newcolor = str_replace('"', '', $newcolor); |
| 54 | $newcolor = str_replace('\'', '', $newcolor); |
| 55 | $value = str_replace(',', ' ', $value); |
| 56 | |
| 57 | setPref($data_dir, $username, "highlight$theid", $identname.','.$newcolor.','.$value.','.$match_type); |
| 58 | $message_highlight_list[$theid]['name'] = $identname; |
| 59 | $message_highlight_list[$theid]['color'] = $newcolor; |
| 60 | $message_highlight_list[$theid]['value'] = $value; |
| 61 | $message_highlight_list[$theid]['match_type'] = $match_type; |
| 62 | } |
| 63 | displayPageHeader($color, 'None'); |
| 64 | |
| 65 | echo |
| 66 | html_tag( 'table', "\n" . |
| 67 | html_tag( 'tr', "\n" . |
| 68 | html_tag( 'td', '<center><b>' . _("Options") . ' - ' . _("Message Highlighting") . '</b></center>', 'left') |
| 69 | ), |
| 70 | 'center', $color[9], 'width="95% border="0" cellpadding="1" cellspacing="0"' ) . "<br>\n" . |
| 71 | html_tag( 'table', '', '', '', 'width="100% border="0" cellpadding="1" cellspacing="0"' ) . |
| 72 | html_tag( 'tr' ) . "\n" . |
| 73 | html_tag( 'td', '', 'left' ); |
| 74 | |
| 75 | echo '<center>[<a href="options_highlight.php?action=add">' . _("New") . '</a>]'. |
| 76 | ' - [<a href="options.php">'._("Done").'</a>]</center><br>'."\n"; |
| 77 | if (count($message_highlight_list) >= 1) { |
| 78 | echo html_tag( 'table', '', 'center', '', 'width="80% border="0" cellpadding="3" cellspacing="0"' ) . "\n"; |
| 79 | for ($i=0; $i < count($message_highlight_list); $i++) { |
| 80 | $match_type = ''; |
| 81 | switch ($message_highlight_list[$i]['match_type'] ) { |
| 82 | case 'from' : |
| 83 | $match_type = _("From"); |
| 84 | break; |
| 85 | case 'to' : |
| 86 | $match_type = _("To"); |
| 87 | break; |
| 88 | case 'cc' : |
| 89 | $match_type = _("Cc"); |
| 90 | break; |
| 91 | case 'to_cc' : |
| 92 | $match_type = _("To or Cc"); |
| 93 | break; |
| 94 | case 'subject' : |
| 95 | $match_type = _("subject"); |
| 96 | break; |
| 97 | } |
| 98 | |
| 99 | echo html_tag( 'tr', |
| 100 | html_tag( 'td', |
| 101 | '<small>[<a href="options_highlight.php?action=edit&theid=' . $i . '">' . |
| 102 | _("Edit") . |
| 103 | '</a>] [<a href="options_highlight.php?action=delete&theid='. |
| 104 | $i . '">' . _("Delete") . '</a>]</small>' , |
| 105 | 'left', $color[4], 'width="20%" nowrap' ) . |
| 106 | html_tag( 'td', |
| 107 | htmlspecialchars($message_highlight_list[$i]['name']) , |
| 108 | 'left' ) . |
| 109 | html_tag( 'td', |
| 110 | $match_type . ' = ' . |
| 111 | htmlspecialchars($message_highlight_list[$i]['value']) , |
| 112 | 'left' ) , |
| 113 | '', $message_highlight_list[$i]['color'] ) . "\n"; |
| 114 | } |
| 115 | echo "</table>\n". |
| 116 | "<br>\n"; |
| 117 | } else { |
| 118 | echo '<center>' . _("No highlighting is defined") . "</center><br>\n". |
| 119 | "<br>\n"; |
| 120 | } |
| 121 | if ($action == 'edit' || $action == 'add') { |
| 122 | if (!isset($theid)) |
| 123 | { |
| 124 | $theid = count($message_highlight_list); |
| 125 | $message_highlight_list[$theid] = array(); |
| 126 | } |
| 127 | |
| 128 | $color_list[0] = '4444aa'; |
| 129 | $color_list[1] = '44aa44'; |
| 130 | $color_list[2] = 'aaaa44'; |
| 131 | $color_list[3] = '44aaaa'; |
| 132 | $color_list[4] = 'aa44aa'; |
| 133 | $color_list[5] = 'aaaaff'; |
| 134 | $color_list[6] = 'aaffaa'; |
| 135 | $color_list[7] = 'ffffaa'; |
| 136 | $color_list[8] = 'aaffff'; |
| 137 | $color_list[9] = 'ffaaff'; |
| 138 | $color_list[10] = 'aaaaaa'; |
| 139 | $color_list[11] = 'bfbfbf'; |
| 140 | $color_list[12] = 'dfdfdf'; |
| 141 | $color_list[13] = 'ffffff'; |
| 142 | |
| 143 | # helpful color chart from http://www.visibone.com/colorlab/big.html |
| 144 | $new_color_list["0,0"] = 'cccccc'; |
| 145 | $new_color_list["0,1"] = '999999'; |
| 146 | $new_color_list["0,2"] = '666666'; |
| 147 | $new_color_list["0,3"] = '333333'; |
| 148 | $new_color_list["0,4"] = '000000'; |
| 149 | |
| 150 | # red |
| 151 | $new_color_list["1,0"] = 'ff0000'; |
| 152 | $new_color_list["1,1"] = 'cc0000'; |
| 153 | $new_color_list["1,2"] = '990000'; |
| 154 | $new_color_list["1,3"] = '660000'; |
| 155 | $new_color_list["1,4"] = '330000'; |
| 156 | |
| 157 | $new_color_list["2,0"] = 'ffcccc'; |
| 158 | $new_color_list["2,1"] = 'cc9999'; |
| 159 | $new_color_list["2,2"] = '996666'; |
| 160 | $new_color_list["2,3"] = '663333'; |
| 161 | $new_color_list["2,4"] = '330000'; |
| 162 | |
| 163 | $new_color_list["3,0"] = 'ffcccc'; |
| 164 | $new_color_list["3,1"] = 'ff9999'; |
| 165 | $new_color_list["3,2"] = 'ff6666'; |
| 166 | $new_color_list["3,3"] = 'ff3333'; |
| 167 | $new_color_list["3,4"] = 'ff0000'; |
| 168 | |
| 169 | # green |
| 170 | $new_color_list["4,0"] = '00ff00'; |
| 171 | $new_color_list["4,1"] = '00cc00'; |
| 172 | $new_color_list["4,2"] = '009900'; |
| 173 | $new_color_list["4,3"] = '006600'; |
| 174 | $new_color_list["4,4"] = '003300'; |
| 175 | |
| 176 | $new_color_list["5,0"] = 'ccffcc'; |
| 177 | $new_color_list["5,1"] = '99cc99'; |
| 178 | $new_color_list["5,2"] = '669966'; |
| 179 | $new_color_list["5,3"] = '336633'; |
| 180 | $new_color_list["5,4"] = '003300'; |
| 181 | |
| 182 | $new_color_list["6,0"] = 'ccffcc'; |
| 183 | $new_color_list["6,1"] = '99ff99'; |
| 184 | $new_color_list["6,2"] = '66ff66'; |
| 185 | $new_color_list["6,3"] = '33ff33'; |
| 186 | $new_color_list["6,4"] = '00ff00'; |
| 187 | |
| 188 | # blue |
| 189 | $new_color_list["7,0"] = '0000ff'; |
| 190 | $new_color_list["7,1"] = '0000cc'; |
| 191 | $new_color_list["7,2"] = '000099'; |
| 192 | $new_color_list["7,3"] = '000066'; |
| 193 | $new_color_list["7,4"] = '000033'; |
| 194 | |
| 195 | $new_color_list["8,0"] = 'ccccff'; |
| 196 | $new_color_list["8,1"] = '9999cc'; |
| 197 | $new_color_list["8,2"] = '666699'; |
| 198 | $new_color_list["8,3"] = '333366'; |
| 199 | $new_color_list["8,4"] = '000033'; |
| 200 | |
| 201 | $new_color_list["9,0"] = 'ccccff'; |
| 202 | $new_color_list["9,1"] = '9999ff'; |
| 203 | $new_color_list["9,2"] = '6666ff'; |
| 204 | $new_color_list["9,3"] = '3333ff'; |
| 205 | $new_color_list["9,4"] = '0000ff'; |
| 206 | |
| 207 | # yellow |
| 208 | $new_color_list["10,0"] = 'ffff00'; |
| 209 | $new_color_list["10,1"] = 'cccc00'; |
| 210 | $new_color_list["10,2"] = '999900'; |
| 211 | $new_color_list["10,3"] = '666600'; |
| 212 | $new_color_list["10,4"] = '333300'; |
| 213 | |
| 214 | $new_color_list["11,0"] = 'ffffcc'; |
| 215 | $new_color_list["11,1"] = 'cccc99'; |
| 216 | $new_color_list["11,2"] = '999966'; |
| 217 | $new_color_list["11,3"] = '666633'; |
| 218 | $new_color_list["11,4"] = '333300'; |
| 219 | |
| 220 | $new_color_list["12,0"] = 'ffffcc'; |
| 221 | $new_color_list["12,1"] = 'ffff99'; |
| 222 | $new_color_list["12,2"] = 'ffff66'; |
| 223 | $new_color_list["12,3"] = 'ffff33'; |
| 224 | $new_color_list["12,4"] = 'ffff00'; |
| 225 | |
| 226 | # cyan |
| 227 | $new_color_list["13,0"] = '00ffff'; |
| 228 | $new_color_list["13,1"] = '00cccc'; |
| 229 | $new_color_list["13,2"] = '009999'; |
| 230 | $new_color_list["13,3"] = '006666'; |
| 231 | $new_color_list["13,4"] = '003333'; |
| 232 | |
| 233 | $new_color_list["14,0"] = 'ccffff'; |
| 234 | $new_color_list["14,1"] = '99cccc'; |
| 235 | $new_color_list["14,2"] = '669999'; |
| 236 | $new_color_list["14,3"] = '336666'; |
| 237 | $new_color_list["14,4"] = '003333'; |
| 238 | |
| 239 | $new_color_list["15,0"] = 'ccffff'; |
| 240 | $new_color_list["15,1"] = '99ffff'; |
| 241 | $new_color_list["15,2"] = '66ffff'; |
| 242 | $new_color_list["15,3"] = '33ffff'; |
| 243 | $new_color_list["15,4"] = '00ffff'; |
| 244 | |
| 245 | # magenta |
| 246 | $new_color_list["16,0"] = 'ff00ff'; |
| 247 | $new_color_list["16,1"] = 'cc00cc'; |
| 248 | $new_color_list["16,2"] = '990099'; |
| 249 | $new_color_list["16,3"] = '660066'; |
| 250 | $new_color_list["16,4"] = '330033'; |
| 251 | |
| 252 | $new_color_list["17,0"] = 'ffccff'; |
| 253 | $new_color_list["17,1"] = 'cc99cc'; |
| 254 | $new_color_list["17,2"] = '996699'; |
| 255 | $new_color_list["17,3"] = '663366'; |
| 256 | $new_color_list["17,4"] = '330033'; |
| 257 | |
| 258 | $new_color_list["18,0"] = 'ffccff'; |
| 259 | $new_color_list["18,1"] = 'ff99ff'; |
| 260 | $new_color_list["18,2"] = 'ff66ff'; |
| 261 | $new_color_list["18,3"] = 'ff33ff'; |
| 262 | $new_color_list["18,4"] = 'ff00ff'; |
| 263 | |
| 264 | $selected_input = ''; |
| 265 | $selected_choose = ''; |
| 266 | |
| 267 | for ($i=0; $i < 14; $i++) { |
| 268 | ${"selected".$i} = ''; |
| 269 | } |
| 270 | if (isset($message_highlight_list[$theid]['color'])) { |
| 271 | for ($i=0; $i < 14; $i++) { |
| 272 | if ($color_list[$i] == $message_highlight_list[$theid]['color']) { |
| 273 | $selected_choose = ' checked'; |
| 274 | ${"selected".$i} = ' selected'; |
| 275 | continue; |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | if (isset($message_highlight_list[$theid]['color'])) { |
| 281 | $current_color = $message_highlight_list[$theid]['color']; |
| 282 | } |
| 283 | else { |
| 284 | $current_color = '63aa7f'; |
| 285 | } |
| 286 | |
| 287 | for($x = 0; $x < 5; $x++) { |
| 288 | for($y = 0; $y < 19; $y++) { |
| 289 | $gridindex = "$y,$x"; |
| 290 | $gridcolor = $new_color_list[$gridindex]; |
| 291 | if ($gridcolor == $current_color) { |
| 292 | $pre_defined_color = 1; |
| 293 | break; |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | if (!isset($message_highlight_list[$theid]['color'])) |
| 299 | $selected_choose = ' checked'; |
| 300 | else if ($pre_defined_color) |
| 301 | $selected_predefined = ' checked'; |
| 302 | else if ($selected_choose == '') |
| 303 | $selected_input = ' checked'; |
| 304 | |
| 305 | echo '<form name="f" action="options_highlight.php">' . "\n"; |
| 306 | echo '<input type="hidden" value="save" name="action">' . "\n"; |
| 307 | echo '<input type="hidden" value="'.$theid.'" name="theid">' . "\n"; |
| 308 | echo html_tag( 'table', '', 'center', '', 'width="80%" cellpadding="3" cellspacing="0" border="0"' ) . "\n"; |
| 309 | echo html_tag( 'tr', '', '', $color[0] ) . "\n"; |
| 310 | echo html_tag( 'td', '', 'right', '', 'nowrap' ) . "<b>\n"; |
| 311 | echo _("Identifying name") . ":"; |
| 312 | echo ' </b></td>' . "\n"; |
| 313 | echo html_tag( 'td', '', 'left' ) . "\n"; |
| 314 | if (isset($message_highlight_list[$theid]['name'])) |
| 315 | $disp = $message_highlight_list[$theid]['name']; |
| 316 | else |
| 317 | $disp = ''; |
| 318 | $disp = htmlspecialchars($disp); |
| 319 | echo " <input type=\"text\" value=\"".$disp."\" name=\"identname\">"; |
| 320 | echo " </td>\n"; |
| 321 | echo " </tr>\n"; |
| 322 | echo html_tag( 'tr', html_tag( 'td', '<small><small> </small></small>', 'left' ) ) ."\n"; |
| 323 | echo html_tag( 'tr', '', '', $color[0] ) . "\n"; |
| 324 | echo html_tag( 'td', '<b>'. _("Color") . ':</b>', 'right' ); |
| 325 | echo html_tag( 'td', '', 'left' ); |
| 326 | echo " <input type=\"radio\" name=color_type value=1$selected_choose> <select name=newcolor_choose>\n"; |
| 327 | echo " <option value=\"$color_list[0]\"$selected0>" . _("Dark Blue") . "\n"; |
| 328 | echo " <option value=\"$color_list[1]\"$selected1>" . _("Dark Green") . "\n"; |
| 329 | echo " <option value=\"$color_list[2]\"$selected2>" . _("Dark Yellow") . "\n"; |
| 330 | echo " <option value=\"$color_list[3]\"$selected3>" . _("Dark Cyan") . "\n"; |
| 331 | echo " <option value=\"$color_list[4]\"$selected4>" . _("Dark Magenta") . "\n"; |
| 332 | echo " <option value=\"$color_list[5]\"$selected5>" . _("Light Blue") . "\n"; |
| 333 | echo " <option value=\"$color_list[6]\"$selected6>" . _("Light Green") . "\n"; |
| 334 | echo " <option value=\"$color_list[7]\"$selected7>" . _("Light Yellow") . "\n"; |
| 335 | echo " <option value=\"$color_list[8]\"$selected8>" . _("Light Cyan") . "\n"; |
| 336 | echo " <option value=\"$color_list[9]\"$selected9>" . _("Light Magenta") . "\n"; |
| 337 | echo " <option value=\"$color_list[10]\"$selected10>" . _("Dark Gray") . "\n"; |
| 338 | echo " <option value=\"$color_list[11]\"$selected11>" . _("Medium Gray") . "\n"; |
| 339 | echo " <option value=\"$color_list[12]\"$selected12>" . _("Light Gray") . "\n"; |
| 340 | echo " <option value=\"$color_list[13]\"$selected13>" . _("White") . "\n"; |
| 341 | echo " </select><br>\n"; |
| 342 | echo " <input type=\"radio\" name=color_type value=2$selected_input> ". _("Other:") ."<input type=\"text\" value=\""; |
| 343 | if ($selected_input) echo $message_highlight_list[$theid]["color"]; |
| 344 | echo '" name="newcolor_input" size="7"> '._("Ex: 63aa7f")."<br>\n"; |
| 345 | echo " </td>\n"; |
| 346 | echo " </tr>\n"; |
| 347 | |
| 348 | # Show grid of color choices |
| 349 | echo html_tag( 'tr', '', '', $color[0] ) . "\n"; |
| 350 | echo html_tag( 'td', '', 'left', '', 'colspan="2"' ); |
| 351 | echo html_tag( 'table', '', 'center', '', 'border=0 cellpadding="2" cellspacing="1"' ) . "\n"; |
| 352 | |
| 353 | for($x = 0; $x < 5; $x++) { |
| 354 | echo html_tag( 'tr' ) . "\n"; |
| 355 | for($y = 0; $y < 19; $y++) { |
| 356 | $gridindex = "$y,$x"; |
| 357 | $gridcolor = $new_color_list[$gridindex]; |
| 358 | $selected = ($gridcolor == $current_color) ? ' checked' : '' ; |
| 359 | echo html_tag( 'td', '<input type="radio" name="color_type" value="#' . $gridcolor .'"' . $selected . '>', 'left', $gridcolor, 'colspan="2"' ); |
| 360 | } |
| 361 | echo "</tr>\n"; |
| 362 | } |
| 363 | echo "</table>\n"; |
| 364 | echo "</td></tr>\n"; |
| 365 | |
| 366 | echo html_tag( 'tr', html_tag( 'td', '<small><small> </small></small>', 'left' ) ) . "\n"; |
| 367 | echo html_tag( 'tr', '', '', $color[0] ) . "\n"; |
| 368 | echo html_tag( 'td', '', 'center', '', 'colspan="2"' ) . "\n"; |
| 369 | echo " <select name=match_type>\n"; |
| 370 | oh_opt( 'from', |
| 371 | ($message_highlight_list[$theid]['match_type'] == 'from'), |
| 372 | _("From") ); |
| 373 | oh_opt( 'to', |
| 374 | ($message_highlight_list[$theid]['match_type'] == 'to'), |
| 375 | _("To") ); |
| 376 | oh_opt( 'cc', |
| 377 | ($message_highlight_list[$theid]['match_type'] == 'cc'), |
| 378 | _("Cc") ); |
| 379 | oh_opt( 'to_cc', |
| 380 | ($message_highlight_list[$theid]['match_type'] == 'to_cc'), |
| 381 | _("To or Cc") ); |
| 382 | oh_opt( 'subject', |
| 383 | ($message_highlight_list[$theid]['match_type'] == 'subject'), |
| 384 | _("Subject") ); |
| 385 | echo " </select>\n"; |
| 386 | echo '<b>' . _("Matches") . ':</b> '; |
| 387 | if (isset($message_highlight_list[$theid]['value'])) |
| 388 | $disp = $message_highlight_list[$theid]['value']; |
| 389 | else |
| 390 | $disp = ''; |
| 391 | $disp = htmlspecialchars($disp); |
| 392 | echo ' <input type="text" value="' . $disp . |
| 393 | '" name="value" size=40>'; |
| 394 | echo " </td>\n"; |
| 395 | echo " </tr>\n"; |
| 396 | echo "</table>\n"; |
| 397 | echo '<center><input type="submit" value="' . _("Submit") . "\"></center>\n"; |
| 398 | echo "</form>\n"; |
| 399 | } |
| 400 | do_hook('options_highlight_bottom'); |
| 401 | ?> |
| 402 | </body></html> |