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 14845 2020-01-07 08:09:34Z 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.  * Include the SquirrelMail initialization file.
  20.  */
  21. require('../include/init.php');
  22.  
  23. // include_once(SM_PATH . 'functions/imap.php');
  24. require_once(SM_PATH 'functions/forms.php');
  25.  
  26. /* get globals */
  27. sqGetGlobalVar('action'$action);
  28. sqGetGlobalVar('theid'$theid);
  29. sqGetGlobalVar('identname'$identname);
  30. sqGetGlobalVar('newcolor_choose'$newcolor_choose);
  31. sqGetGlobalVar('newcolor_input'$newcolor_input);
  32. sqGetGlobalVar('color_type'$color_type);
  33. sqGetGlobalVar('match_type'$match_type);
  34. sqGetGlobalVar('value'$value);
  35. sqgetGlobalVar('smtoken'$submitted_tokenSQ_FORM'');
  36.  
  37. /* end of get globals */
  38.  
  39. function oh_opt$val$sel$tit {
  40.     echo "<option value=\"$val\"";
  41.     if $sel )
  42.         echo ' selected="selected"';
  43.     echo  ">$tit</option>\n";
  44. }
  45.  
  46. if (isset($action)) {
  47.     $action '';
  48. }
  49. if (isset($message_highlight_list)) {
  50.     $message_highlight_list array();
  51. }
  52.  
  53. if (isset($theid&& ($action == 'delete'||
  54.                      ($action == 'up')     ||
  55.                      ($action == 'down')) {
  56.  
  57.     // security check
  58.     sm_validate_security_token($submitted_token-1TRUE);
  59.  
  60.     $new_rules array();
  61.     switch($action{
  62.         case('delete'):
  63.             foreach($message_highlight_list as $rid => $rule{
  64.                  if($rid != $theid{
  65.                      $new_rules[$rule;
  66.                  }
  67.             }
  68.             break;
  69.         case('down'):
  70.             $theid++;
  71.         case('up'):
  72.             foreach($message_highlight_list as $rid => $rule{
  73.                 if($rid == $theid{
  74.                     $temp_rule         $new_rules[$rid-1];
  75.                     $new_rules[$rid-1$rule;
  76.                     $new_rules[$rid]   $temp_rule;
  77.                 else {
  78.                     $new_rules[$rid]   $rule;
  79.                 }
  80.             }
  81.             break;
  82.         default:
  83.             $new_rules $message_highlight_list;
  84.             break;
  85.     }
  86.     $message_highlight_list $new_rules;
  87.  
  88.     setPref($data_dir$username'hililist'serialize($message_highlight_list));
  89.  
  90.     header'Location: ' .get_location()'/options_highlight.php' );
  91.     exit;
  92. else if ($action == 'save'{
  93.  
  94.     // security check
  95.     sm_validate_security_token($submitted_token-1TRUE);
  96.  
  97.     if ($color_type == 1$newcolor $newcolor_choose;
  98.     elseif ($color_type == 2$newcolor $newcolor_input;
  99.     else $newcolor $color_type;
  100.  
  101.     $newcolor str_replace('#'''$newcolor);
  102.     $newcolor str_replace('"'''$newcolor);
  103.     $newcolor str_replace('\''''$newcolor);
  104.     $value str_replace(','' '$value);
  105.  
  106.     if(isset($theid)) {
  107.         $message_highlight_list[$theid=
  108.             array'name' => $identname'color' => $newcolor,
  109.                    'value' => $value'match_type' => $match_type );
  110.     else {
  111.         $message_highlight_list[=
  112.             array'name' => $identname'color' => $newcolor,
  113.                    'value' => $value'match_type' => $match_type );
  114.     }
  115.  
  116.     setPref($data_dir$username'hililist'serialize($message_highlight_list));
  117. }
  118.  
  119. /**
  120.  * Display the current rule list
  121.  */
  122. $rules array();
  123. foreach($message_highlight_list as $index=>$rule{
  124.     $a array();
  125.     
  126.     $a['Name'sm_encode_html_special_chars($rule['name']);
  127.     $a['Color'$rule['color'];
  128.     $a['MatchField''';
  129.     $a['MatchValue'sm_encode_html_special_chars($rule['value']);
  130.     switch ($rule['match_type']{
  131.             case 'from' :
  132.                 $a['MatchField'_("From");
  133.                 break;
  134.             case 'to' :
  135.                 $a['MatchField'_("To");
  136.                 break;
  137.             case 'cc' :
  138.                 $a['MatchField'_("Cc");
  139.                 break;
  140.             case 'to_cc' :
  141.                 $a['MatchField'_("To or Cc");
  142.                 break;
  143.             case 'subject' :
  144.                 $a['MatchField'_("subject");
  145.                 break;
  146.     }
  147.     
  148.     $rules[$index$a;
  149. }
  150.  
  151. $oTemplate->assign('current_rules'$rules);
  152.  
  153.  
  154. $oTemplate->assign('add_rule''options_highlight.php?action=add');
  155. $oTemplate->assign('edit_rule''options_highlight.php?action=edit&amp;theid=');
  156. $oTemplate->assign('delete_rule''options_highlight.php?action=delete&amp;smtoken=' $token '&amp;theid=');
  157. $oTemplate->assign('move_up''options_highlight.php?action=up&amp;smtoken=' $token '&amp;theid=');
  158. $oTemplate->assign('move_down''options_highlight.php?action=down&amp;smtoken=' $token '&amp;theid=');
  159.  
  160. $oTemplate->display('options_highlight_list.tpl');
  161.  
  162. /**
  163.  * Optionally, display the add/edit dialog
  164.  */
  165. if ($action == 'edit' || $action == 'add'{
  166.  
  167.     $color_list[0'4444aa';
  168.     $color_list[1'44aa44';
  169.     $color_list[2'aaaa44';
  170.     $color_list[3'44aaaa';
  171.     $color_list[4'aa44aa';
  172.     $color_list[5'aaaaff';
  173.     $color_list[6'aaffaa';
  174.     $color_list[7'ffffaa';
  175.     $color_list[8'aaffff';
  176.     $color_list[9'ffaaff';
  177.     $color_list[10'aaaaaa';
  178.     $color_list[11'bfbfbf';
  179.     $color_list[12'dfdfdf';
  180.     $color_list[13'ffffff';
  181.  
  182.     # helpful color chart from http://www.visibone.com/colorlab/big.html
  183.     $new_color_list["0,0"'cccccc';
  184.     $new_color_list["0,1"'999999';
  185.     $new_color_list["0,2"'666666';
  186.     $new_color_list["0,3"'333333';
  187.     $new_color_list["0,4"'000000';
  188.  
  189.     # red
  190.     $new_color_list["1,0"'ff0000';
  191.     $new_color_list["1,1"'cc0000';
  192.     $new_color_list["1,2"'990000';
  193.     $new_color_list["1,3"'660000';
  194.     $new_color_list["1,4"'330000';
  195.  
  196.     $new_color_list["2,0"'ffcccc';
  197.     $new_color_list["2,1"'cc9999';
  198.     $new_color_list["2,2"'996666';
  199.     $new_color_list["2,3"'663333';
  200.     $new_color_list["2,4"'330000';
  201.  
  202.     $new_color_list["3,0"'ffcccc';
  203.     $new_color_list["3,1"'ff9999';
  204.     $new_color_list["3,2"'ff6666';
  205.     $new_color_list["3,3"'ff3333';
  206.     $new_color_list["3,4"'ff0000';
  207.  
  208.     # green
  209.     $new_color_list["4,0"'00ff00';
  210.     $new_color_list["4,1"'00cc00';
  211.     $new_color_list["4,2"'009900';
  212.     $new_color_list["4,3"'006600';
  213.     $new_color_list["4,4"'003300';
  214.  
  215.     $new_color_list["5,0"'ccffcc';
  216.     $new_color_list["5,1"'99cc99';
  217.     $new_color_list["5,2"'669966';
  218.     $new_color_list["5,3"'336633';
  219.     $new_color_list["5,4"'003300';
  220.  
  221.     $new_color_list["6,0"'ccffcc';
  222.     $new_color_list["6,1"'99ff99';
  223.     $new_color_list["6,2"'66ff66';
  224.     $new_color_list["6,3"'33ff33';
  225.     $new_color_list["6,4"'00ff00';
  226.  
  227.     # blue
  228.     $new_color_list["7,0"'0000ff';
  229.     $new_color_list["7,1"'0000cc';
  230.     $new_color_list["7,2"'000099';
  231.     $new_color_list["7,3"'000066';
  232.     $new_color_list["7,4"'000033';
  233.  
  234.     $new_color_list["8,0"'ccccff';
  235.     $new_color_list["8,1"'9999cc';
  236.     $new_color_list["8,2"'666699';
  237.     $new_color_list["8,3"'333366';
  238.     $new_color_list["8,4"'000033';
  239.  
  240.     $new_color_list["9,0"'ccccff';
  241.     $new_color_list["9,1"'9999ff';
  242.     $new_color_list["9,2"'6666ff';
  243.     $new_color_list["9,3"'3333ff';
  244.     $new_color_list["9,4"'0000ff';
  245.  
  246.     # yellow
  247.     $new_color_list["10,0"'ffff00';
  248.     $new_color_list["10,1"'cccc00';
  249.     $new_color_list["10,2"'999900';
  250.     $new_color_list["10,3"'666600';
  251.     $new_color_list["10,4"'333300';
  252.  
  253.     $new_color_list["11,0"'ffffcc';
  254.     $new_color_list["11,1"'cccc99';
  255.     $new_color_list["11,2"'999966';
  256.     $new_color_list["11,3"'666633';
  257.     $new_color_list["11,4"'333300';
  258.  
  259.     $new_color_list["12,0"'ffffcc';
  260.     $new_color_list["12,1"'ffff99';
  261.     $new_color_list["12,2"'ffff66';
  262.     $new_color_list["12,3"'ffff33';
  263.     $new_color_list["12,4"'ffff00';
  264.  
  265.     # cyan
  266.     $new_color_list["13,0"'00ffff';
  267.     $new_color_list["13,1"'00cccc';
  268.     $new_color_list["13,2"'009999';
  269.     $new_color_list["13,3"'006666';
  270.     $new_color_list["13,4"'003333';
  271.  
  272.     $new_color_list["14,0"'ccffff';
  273.     $new_color_list["14,1"'99cccc';
  274.     $new_color_list["14,2"'669999';
  275.     $new_color_list["14,3"'336666';
  276.     $new_color_list["14,4"'003333';
  277.  
  278.     $new_color_list["15,0"'ccffff';
  279.     $new_color_list["15,1"'99ffff';
  280.     $new_color_list["15,2"'66ffff';
  281.     $new_color_list["15,3"'33ffff';
  282.     $new_color_list["15,4"'00ffff';
  283.  
  284.     # magenta
  285.     $new_color_list["16,0"'ff00ff';
  286.     $new_color_list["16,1"'cc00cc';
  287.     $new_color_list["16,2"'990099';
  288.     $new_color_list["16,3"'660066';
  289.     $new_color_list["16,4"'330033';
  290.  
  291.     $new_color_list["17,0"'ffccff';
  292.     $new_color_list["17,1"'cc99cc';
  293.     $new_color_list["17,2"'996699';
  294.     $new_color_list["17,3"'663366';
  295.     $new_color_list["17,4"'330033';
  296.  
  297.     $new_color_list["18,0"'ffccff';
  298.     $new_color_list["18,1"'ff99ff';
  299.     $new_color_list["18,2"'ff66ff';
  300.     $new_color_list["18,3"'ff33ff';
  301.     $new_color_list["18,4"'ff00ff';
  302.  
  303.     $selected_input FALSE;
  304.     $selected_choose FALSE;
  305.     $selected_predefined FALSE;
  306.  
  307.     $name $action=='edit' && isset($theid&& isset($message_highlight_list[$theid]['name']$message_highlight_list[$theid]['name''';
  308.     $field $action=='edit' && isset($theid&& isset($message_highlight_list[$theid]['match_type']$message_highlight_list[$theid]['match_type''';
  309.     $value $action=='edit' && isset($theid&& isset($message_highlight_list[$theid]['value']$message_highlight_list[$theid]['value''';
  310.     $color $action=='edit' && isset($theid&& isset($message_highlight_list[$theid]['color']$message_highlight_list[$theid]['color''';
  311.     
  312.     if ($action == 'edit' && isset($theid&& isset($message_highlight_list[$theid]['color'])) {
  313.         for ($i=0$i 14$i++{
  314.             if ($color_list[$i== $message_highlight_list[$theid]['color']{
  315.                 $selected_choose TRUE;
  316.                 continue;
  317.             }
  318.         }
  319.     }
  320.  
  321.     $pre_defined_color 0;
  322.     for($x 0$x 5$x++{
  323.         for($y 0$y 19$y++{
  324.             $gridindex "$y,$x";
  325.             $gridcolor $new_color_list[$gridindex];
  326.             if ($gridcolor == $color{
  327.                 $pre_defined_color 1;
  328.                 break;
  329.             }
  330.         }
  331.     }
  332.  
  333.     if (isset($theid&& !isset($message_highlight_list[$theid]['color']))
  334.         $selected_choose TRUE;
  335.     else if ($pre_defined_color)
  336.         $selected_predefined TRUE;
  337.     else if ($selected_choose == '')
  338.         $selected_input TRUE;
  339.         
  340.     $oTemplate->assign('rule_name'$name);
  341.     $oTemplate->assign('rule_value'$value);
  342.     $oTemplate->assign('rule_field'$field);
  343.     $oTemplate->assign('rule_color'$color);
  344.     $oTemplate->assign('color_radio'($selected_choose ($selected_input 0)));
  345.     $oTemplate->assign('color_input'($selected_input $color ''));
  346.     
  347.     echo addForm('options_highlight.php''post''f'''''array()TRUE).
  348.          addHidden('action''save');
  349.     if($action == 'edit'{
  350.         echo addHidden('theid'(isset($theid)?$theid:''));
  351.     }
  352.     
  353.     $oTemplate->display('options_highlight_addedit.tpl');
  354.     
  355.     echo "</form>\n";
  356. }
  357. do_hook('options_highlight_bottom'$null);
  358.  
  359. $oTemplate->display('footer.tpl');

Documentation generated on Mon, 13 Jan 2020 04:23:18 +0100 by phpDocumentor 1.4.3