Source for file options_highlight.php

Documentation is available at options_highlight.php

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

Documentation generated on Sat, 07 Oct 2006 16:32:56 +0300 by phpDocumentor 1.3.0RC6