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

Documentation generated on Mon, 13 Jan 2020 04:25:08 +0100 by phpDocumentor 1.4.3