From de3ee06e6a107905521f885f9207f0ecd98a9741 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 7 Mar 2007 05:43:58 +0000 Subject: [PATCH] Several sieve filter updates git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5751 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/sieve/class_My_Parser.inc | 13 +- include/sieve/class_My_Tree.inc | 57 ++- include/sieve/class_sieveElement_If.inc | 504 +++++++++++++++---- include/sieve/class_sieveElements.inc | 82 ++- include/sieve/class_sieveManagement.inc | 45 +- include/sieve/templates/element_address.tpl | 47 +- include/sieve/templates/element_envelope.tpl | 86 +++- include/sieve/templates/element_header.tpl | 150 ++++-- plugins/personal/mail/class_mailAccount.inc | 13 +- 9 files changed, 803 insertions(+), 194 deletions(-) diff --git a/include/sieve/class_My_Parser.inc b/include/sieve/class_My_Parser.inc index 6d796cd8a..b0ef7ea76 100644 --- a/include/sieve/class_My_Parser.inc +++ b/include/sieve/class_My_Parser.inc @@ -1,6 +1,6 @@ dumpParseTree()); + $ret = $this->dumpParseTree(); + return($ret); } @@ -35,7 +36,13 @@ class My_Parser extends Parser return $this->status_; } - + + function get_sieve_script() + { + return($this->tree_->get_sieve_script()); + } + + function save_object() { $this->tree_->save_object(); diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index 942f64e4c..922156017 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -33,7 +33,7 @@ class My_Tree extends Tree /* Create html results */ $this->dump_ ="
"; - foreach($this->pap as $object){ + foreach($this->pap as $key => $object){ if(is_object($object)){ $this->dump_ .= preg_replace("/>/",">\n",$object->execute()); } @@ -143,9 +143,64 @@ class My_Tree extends Tree } } } + + /* Need to be reviewed */ + function get_sieve_script() + { + $tmp =""; + if(count($this->pap)){ + $tmp = "#Generated by GOsa - Gonicus System Administrator\n"; + $buffer = ""; + foreach($this->pap as $part) { + if(get_class($part) == "sieve_block_end"){ + $buffer = substr($buffer,0,strlen($buffer)-(strlen(SIEVE_INDENT_TAB))); + } + $tmp2 = $part->get_sieve_script_part(); + $tmp3 = split("\n",$tmp2); + foreach($tmp3 as $str){ + $str2 = trim($str); + if(empty($str2)) continue; + $tmp.= $buffer.$str."\n"; + } + if(get_class($part) == "sieve_block_start"){ + $buffer .= SIEVE_INDENT_TAB; + } + } + } + return($tmp); + } } +/* Create valid sieve string/string-list + * out of a given array + */ +function sieve_create_strings($data) +{ + $ret = ""; + if(is_array($data)){ + if(count($data) == 1){ + $ret = "\""; + foreach($data as $dat){ + $ret .=$dat; + } + $ret.="\""; + }else{ + foreach($data as $dat){ + $ret.= "\""; + $ret.=$dat; + $ret.="\", "; + } + $ret = preg_replace("/,$/","",trim($ret)); + $ret = "[".$ret."]"; + } + }else{ + $ret = "\"".$data."\""; + } + $ret = preg_replace("/\"\"/","\"",$ret); + return($ret); +} + /* This checks if there is a string at the current position * in the token array. * If there is a string list at the current position, diff --git a/include/sieve/class_sieveElement_If.inc b/include/sieve/class_sieveElement_If.inc index e0d8fb1b8..03934e460 100644 --- a/include/sieve/class_sieveElement_If.inc +++ b/include/sieve/class_sieveElement_If.inc @@ -7,24 +7,349 @@ class sieve_if var $TYPE = "if"; var $id = -1; + var $address_parts = array(); + var $comparators = array(); + var $match_types = array(); + var $operators = array(); + + /* Initialize class + * $elements contains all tokens that belongs to this if/else tag + * $object_id cotains an unique tag id, to be able to create uniqe html post names + */ function sieve_if($elements,$object_id) { + /* Possible address parts we can select */ + $this->address_parts = array( + ":all" => _("Complete adress")." ("._("Default").")", + ":domain" => _("Domian part") , + ":localpart" => _("Local part")); + + /* comparator type */ + $this->comparators = array( + "i;ascii-casemap" => _("Case insensitive")." ("._("Default").")", + "i;octet" => _("Case sensitive"), + "i;ascii-numeric" => _("Numeric")); + + /* Match types */ + $this->match_types = array( + ":is" => _("is"), + ":contains" => _("contains"), + ":matches" => _("matches"), + ":count" => _("count"), + ":value" => _("value is")); + + /* Operators */ + $this->operators = array( + "lt" => _("less than"), + "le" => _("less or equal"), + "eq" => _("equals"), + "ge" => _("greater or equal"), + "gt" => _("greater than"), + "ne" => _("not equal")); + $this->id = $object_id; $this->elements = $elements; $this->_parsed = $this->_parse($elements['ELEMENTS'],1); } + + /* Returns the sieve script for this + * if/else tag. + */ + function get_sieve_script_part() + { + $tmp = "if ".$this->get_sieve_script_part_recursive($parsed = NULL,$id = 1,$obj_id=1); + return($tmp); + } + + + /* Recursivly create a sieve script out of the given + * tags and tokens provided by $parsed. + * $id specifies the depth of the current element. + * $obj_id is the current tag-id handled by this function + */ + function get_sieve_script_part_recursive($parsed = NULL,$id = 1,$obj_id=1) + { + $script =""; + if($parsed == NULL){ + $parsed = $this->_parsed; + } + + /* Walk through all elements */ + foreach($parsed as $key => $data){ + + /* Create Inverse Tag */ + if(is_array($data) && isset($data['Inverse']) && $data['Inverse']){ + $Inverse = TRUE; + }else{ + $Inverse = FALSE; + } + + /* Create elements */ + switch($key) + { + + /******************* + * True / False + *******************/ + + case "true" : + case "false" : + { + /* Invert this test if required */ + if($Inverse){ + $script .= "not "; + } + + $script .= $key; + + break; + } + + + /******************* + * Address + *******************/ + + case "address" : + { + /* [not] address + [address-part: tag] + [comparator: tag] + [match-type: tag] + + + */ + + /* Invert this test if required */ + if($Inverse){ + $script .= "not "; + } + + $script .="address "; + + /* Add address part tag */ + if(!empty($data['Address_Part']) && $data['Address_Part'] != ":all"){ + $script .= $data['Address_Part']." "; + } + + /* Add comparator */ + if(!empty($data['Comparator']) && $data['Comparator'] != ""){ + $script .= ":comparator ".$data['Comparator']." "; + } + + /* Add match type */ + $script .= $data['Match_type']." "; + + /* Add special match type for count and value */ + if(in_array($data['Match_type'], array(":value",":count")) && !empty($data['Match_type_value'])) { + $script .= $data['Match_type_value']." "; + } + + $script .= sieve_create_strings($data['Key_List']); + $script .= " "; + $script .= sieve_create_strings($data['Value_List']); + break; + } + + + /******************* + * Header + *******************/ + + case "header" : + { + /* [not] header + [comparator: tag] + [match-type: tag] + + + */ + + /* Invert ? */ + if($Inverse){ + $script .= "not "; + } + $script .="header "; + + /* Add address part tag */ + if(!empty($data['Address_Part']) && $data['Address_Part'] != ":all"){ + $script .= $data['Address_Part']." "; + } + + /* Add comparator */ + if(!empty($data['Comparator']) && $data['Comparator'] != ""){ + $script .= ":comparator ".$data['Comparator']." "; + } + + /* Add match type */ + $script .= $data['Match_type']." "; + + /* Add special match type for count and value */ + if(in_array($data['Match_type'], array(":value",":count")) && !empty($data['Match_type_value'])) { + $script .= $data['Match_type_value']." "; + } + + $script .= sieve_create_strings($data['Key_List']); + $script .= " "; + $script .= sieve_create_strings($data['Value_List']); + break; + } + + + /******************* + * Envelope + *******************/ + + case "envelope" : + { + /* [not] envelope + [address-part: tag] + [comparator: tag] + [match-type: tag] + + + */ + + /* Invert */ + if($Inverse){ + $script .= "not "; + } + + $script .="envelope "; + + /* Add address part tag */ + if(!empty($data['Address_Part']) && $data['Address_Part'] != ":all"){ + $script .= $data['Address_Part']." "; + } + + /* Add comparator */ + if(!empty($data['Comparator']) && $data['Comparator'] != ""){ + $script .= ":comparator ".$data['Comparator']." "; + } + + /* Add match type */ + $script .= $data['Match_type']." "; + + /* Add special match type for count and value */ + if(in_array($data['Match_type'], array(":value",":count")) && !empty($data['Match_type_value'])) { + $script .= $data['Match_type_value']." "; + } + + $script .= sieve_create_strings($data['Key_List']); + $script .= " "; + $script .= sieve_create_strings($data['Value_List']); + break; + } + + + /******************* + * Exists + *******************/ + case "exists" : + { + /* [not] exists + + */ + + /* Invert ? */ + if($Inverse){ + $script .= "not "; + } + + $script .= "exists ".sieve_create_strings($data['Values']); + break; + } + + + /******************* + * Size + *******************/ + case "size" : + { + /* [not] size + <":over" / ":under"> + + */ + + /* Invert ? */ + if($Inverse){ + $script .= "not "; + } + + /* Add size test */ + $script .="size "; + $script .=$data['Match_type']." "; + foreach($data['Value_List'] as $val){ + $script .= $val." "; + } + break; + } + + + /******************* + * Allof + *******************/ + case "anyof" : + case "allof" : + { + /* allof + anyof */ + + + /* Add spaces, to indent the code.*/ + $block = "\n"; + for($i = 0 ; $i < $id ; $i ++){ + $block .= SIEVE_INDENT_TAB; + } + + /* Add allof/anyof tag */ + $script.= " ".$key." ( "; + + /* Add each test parameter */ + foreach($data as $key2 => $dat){ + if(($key2 === "Inverse") && ($key2 == "Inverse")){ + continue; + } + $script.= $block.$this->get_sieve_script_part_recursive($dat, ($id +1),$key2).", "; + } + + /* Remove last _,_ and close the tag */ + $script = preg_replace("/,$/","",trim($script)); + $script.= $block.")"; + break ; + } + + default : + { + $script .= "THERE IS SOME IMPLEMENTATION MISSING FOR SIEVE SCRIPT CREATION :".$key; + } + } + } + return($script); + } + + + /* Ensure that all changes made on the ui + * will be saved. + */ function save_object() { $tmp = $this->save_object_recursive($parsed = NULL,$id = 1,$obj_id=1); $this->_parsed = $tmp; } + + /* Recursivly save all ui changes for the + * tags and tokens provided by $parsed. + * $id specifies the depth of the current element. + * $obj_id is the current tag-id handled by this function + */ function save_object_recursive($parsed = NULL,$id = 1,$obj_id=1) { - + /* Variable initialization */ $ret =""; if($parsed == NULL){ $parsed = $this->_parsed; @@ -40,42 +365,45 @@ class sieve_if switch($key) { - /******************* - * TRUE FALSE + * Address *******************/ + case "envelope" : + case "header" : case "address" : { - /* address [address-part: tag] [comparator: tag] [match-type: tag] */ - $address_parts = array( ":all" => _("Complete adress"), - ":domain" => _("Domian part") , - ":localpart" => _("Local part")); - - /* comparator type */ - $comparators = array( "i;octet" => _("Normal"), - "i;ascii-casemap" =>_("Case sensitive"), - "i;ascii-numeric" =>_("Numeric")); - - /* Match types */ - $match_types = array( ":is" => _("is"), - ":contains" => _("contains"), - ":matches" => _("matches"), - ":count" => _("count"), - ":value" => _("value is")); - - /* Operators */ - $operators = array( "lt" => _("less than"), - "le" => _("less or equal"), - "eq" => _("equals"), - "ge" => _("greater or equal"), - "gt" => _("greater than"), - "ne" => _("not equal")); - + /* [not] address + [address-part: tag] + [comparator: tag] + [match-type: tag] + + + */ + + /* Possible address parts we can select */ + $address_parts = $this->address_parts; + $comparators = $this->comparators; + $match_types = $this->match_types; + $operators = $this->operators; + + /* Toggle Inverse ? */ + if(isset($_POST['toggle_inverse_'.$element_id])){ + $parsed[$key]['Inverse'] = !$parsed[$key]['Inverse']; + } /* Check if we want to toggle the expert mode */ if(isset($_POST['Toggle_Expert_'.$element_id])){ - $parsed['address']['Expert'] = !$parsed['address']['Expert']; + $parsed[$key]['Expert'] = !$parsed[$key]['Expert']; + } + + /* Get address part */ + if(isset($_POST['address_part_'.$element_id])){ + $ap = $_POST['address_part_'.$element_id]; + + if(isset($address_parts[$ap])){ + $parsed[$key]['Address_Part'] = $ap; + } } /* Check if match type has changed */ @@ -83,48 +411,55 @@ class sieve_if $mt = $_POST['matchtype_'.$element_id]; if(isset($match_types[$mt])){ - $parsed['address']['Match_type'] = $mt; + $parsed[$key]['Match_type'] = $mt; + } + } + + /* Get the comparator tag, if posted */ + if(isset($_POST['comparator_'.$element_id])){ + $cp = $_POST['comparator_'.$element_id]; + + if(isset($comparators[$cp])){ + $parsed[$key]['Comparator'] = $cp; } } /* In case of :count and :value match types * we have a special match operator we should save. */ - if(in_array($parsed['address']['Match_type'],array(":value",":count"))){ + if(in_array($parsed[$key]['Match_type'],array(":value",":count"))){ if(isset($_POST['operator_'.$element_id])){ $op = $_POST['operator_'.$element_id]; if(isset($operators[$op])){ - $parsed['address']['Match_type_value'] = $op; + $parsed[$key]['Match_type_value'] = $op; } } } /* Get the address fields we should check, they are seperated by , */ if(isset($_POST['keys_'.$element_id])){ - $vls = $_POST['keys_'.$element_id]; + $vls = stripslashes($_POST['keys_'.$element_id]); $tmp = array(); $tmp2 = split(",",$vls); foreach($tmp2 as $val){ $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\""; } - $parsed['address']['Key_List'] = $tmp; + $parsed[$key]['Key_List'] = $tmp; } /* Get the values should check for, they are seperated by , */ if(isset($_POST['values_'.$element_id])){ - $vls = $_POST['values_'.$element_id]; + $vls = stripslashes($_POST['values_'.$element_id]); $tmp = array(); $tmp2 = split(",",$vls); foreach($tmp2 as $val){ $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\""; } - $parsed['address']['Value_List'] = $tmp; + $parsed[$key]['Value_List'] = $tmp; } - - break; } @@ -154,7 +489,7 @@ class sieve_if { /* get list of match values */ if(isset($_POST['Values_'.$element_id])){ - $vls = $_POST['Values_'.$element_id]; + $vls = stripslashes($_POST['Values_'.$element_id]); $tmp = array(); $tmp2 = split(",",$vls); @@ -340,28 +675,10 @@ class sieve_if case "header": { - /* comparator type */ - $comparators = array( "i;octet" => _("Normal"), - "i;ascii-casemap" =>_("Case sensitive"), - "i;ascii-numeric" =>_("Numeric")); - - /* Match types */ - $match_types = array( ":is" => _("is"), - ":contains" => _("contains"), - ":matches" => _("matches"), - ":over" => _("is over"), - ":count" => _("count"), - ":value" => _("value is"), - ":under" => _("is under")); - - /* Operators */ - $operators = array( "" => "-", - "lt" => _("less than"), - "le" => _("less or equal"), - "eq" => _("equals"), - "ge" => _("greater or equal"), - "gt" => _("greater than"), - "ne" => _("not equal")); + $address_parts = $this->address_parts; + $comparators = $this->comparators; + $match_types = $this->match_types; + $operators = $this->operators; $smarty = get_smarty(); $smarty->assign("comparators",$comparators); @@ -386,7 +703,9 @@ class sieve_if $values = preg_replace("/,$/","",trim($values)); $smarty->assign("keys",$keys); + $smarty->assign("Inverse",$Inverse); $smarty->assign("values",$values); + $smarty->assign("Expert", $data['Expert']); $smarty->assign("ID" , $element_id); @@ -396,31 +715,15 @@ class sieve_if case "envelope": { - /* comparator type */ - $comparators = array( "i;octet" => _("Normal"), - "i;ascii-casemap" =>_("Case sensitive"), - "i;ascii-numeric" =>_("Numeric")); - - /* Match types */ - $match_types = array( ":is" => _("is"), - ":contains" => _("contains"), - ":matches" => _("matches"), - ":over" => _("is over"), - ":count" => _("count"), - ":value" => _("value is"), - ":under" => _("is under")); - - /* Operators */ - $operators = array( "" => "-", - "lt" => _("less than"), - "le" => _("less or equal"), - "eq" => _("equals"), - "ge" => _("greater or equal"), - "gt" => _("greater than"), - "ne" => _("not equal")); + $address_parts = $this->address_parts; + $comparators = $this->comparators; + $match_types = $this->match_types; + $operators = $this->operators; $smarty = get_smarty(); + $smarty->assign("Inverse",$Inverse); $smarty->assign("comparators",$comparators); + $smarty->assign("Expert", $data['Expert']); $smarty->assign("match_types",$match_types); $smarty->assign("operators",$operators); @@ -449,32 +752,13 @@ class sieve_if case "address" : { - /* address [address-part: tag] [comparator: tag] [match-type: tag] */ - $address_parts = array( ":all" => _("Complete adress"), - ":domain" => _("Domian part") , - ":localpart" => _("Local part")); - - /* comparator type */ - $comparators = array( "i;octet" => _("Normal"), - "i;ascii-casemap" =>_("Case sensitive"), - "i;ascii-numeric" =>_("Numeric")); - - /* Match types */ - $match_types = array( ":is" => _("is"), - ":contains" => _("contains"), - ":matches" => _("matches"), - ":count" => _("count"), - ":value" => _("value is")); - - /* Operators */ - $operators = array( "lt" => _("less than"), - "le" => _("less or equal"), - "eq" => _("equals"), - "ge" => _("greater or equal"), - "gt" => _("greater than"), - "ne" => _("not equal")); + $address_parts = $this->address_parts; + $comparators = $this->comparators; + $match_types = $this->match_types; + $operators = $this->operators; $smarty = get_smarty(); + $smarty->assign("Inverse",$Inverse); $smarty->assign("address_parts",$address_parts); $smarty->assign("comparators",$comparators); $smarty->assign("match_types",$match_types); @@ -489,13 +773,13 @@ class sieve_if $keys = ""; foreach($data['Key_List'] as $key){ - $keys .= stripslashes($key).", "; + $keys .= $key.", "; } $keys = preg_replace("/,$/","",trim($keys)); $values = ""; foreach($data['Value_List'] as $key){ - $values .= stripslashes($key).", "; + $values .= $key.", "; } $values = preg_replace("/,$/","",trim($values)); $smarty->assign("keys",$keys); @@ -556,7 +840,7 @@ class sieve_if $Values = ""; foreach($data['Values'] as $val){ - $Values .= stripslashes($val).", "; + $Values .= $val.", "; } $Values = preg_replace("/,$/","",trim($Values)); diff --git a/include/sieve/class_sieveElements.inc b/include/sieve/class_sieveElements.inc index e8d70feba..768a4dfc6 100644 --- a/include/sieve/class_sieveElements.inc +++ b/include/sieve/class_sieveElements.inc @@ -10,7 +10,11 @@ class sieve_elsif extends sieve_if class sieve_comment { var $data = ""; - + + function get_sieve_script_part() + { + return($this->data."\n"); + } function sieve_comment($data) { @@ -43,6 +47,12 @@ class sieve_require } } + function get_sieve_script_part() + { + $tmp = sieve_create_strings($this->data); + return("require ".$tmp.";\n"); + } + function execute() { $str = "
"._("Script includes"); @@ -62,6 +72,11 @@ class sieve_discard { } + function get_sieve_script_part() + { + return("discard;\n"); + } + function execute() { $str = "
"._("Discard message"); @@ -87,6 +102,11 @@ class sieve_reject $this->data = preg_replace("/\"/","",$str); } + function get_sieve_script_part() + { + return("reject ".sieve_create_strings($this->data)."\n"); + } + function execute() { $str = "
"._("Reject mail"); @@ -109,6 +129,17 @@ class sieve_redirect } } + function get_sieve_script_part() + { + $tmp = ""; + foreach($this->data as $dat){ + $tmp.= "\"".$dat."\", "; + } + $tmp = "[".preg_replace("/,$/","",trim($tmp))."]"; + $tmp = preg_replace ("/\"\"/","\"",$tmp); + return("redirect ".$tmp."\n"); + } + function execute() { $str = "
"._("Redirect to"); @@ -133,6 +164,17 @@ class sieve_fileinto } } + function get_sieve_script_part() + { + $tmp = ""; + foreach($this->data as $dat){ + $tmp.= "\"".$dat."\", "; + } + $tmp = "[".preg_replace("/,$/","",trim($tmp))."]"; + $tmp = preg_replace ("/\"\"/","\"",$tmp); + return("fileinto ".$tmp."\n"); + } + function execute() { $str = "
"._("File into"); @@ -205,6 +247,23 @@ class sieve_vacation } } + function get_sieve_script_part() + { + $str = "vacation "; + if($this->days){ + $str.= ":days ".$this->days; + } + $str .= ":addresses ".sieve_create_strings($this->addresses); + if($this->subject){ + $str.= ":subject ".sieve_create_strings($this->subject); + } + if($this->mime){ + $str.= ":mime ".sieve_create_strings($this->mime); + } + $str .= " ".sieve_create_strings($this->reason); + return($str."\n"); + } + function execute() { @@ -230,6 +289,11 @@ class sieve_block_start "); } + function get_sieve_script_part() + { + return("{\n"); + } + } class sieve_block_end @@ -240,6 +304,11 @@ class sieve_block_end
"); } + function get_sieve_script_part() + { + return("}\n"); + } + } /* This class handles the keep statement */ @@ -256,6 +325,11 @@ class sieve_keep
"; return($str); } + function get_sieve_script_part() + { + return("keep;\n"); + } + } /* This class handles the stop statement */ @@ -272,6 +346,12 @@ class sieve_stop
"; return($str); } + + function get_sieve_script_part() + { + return("stop; \n"); + } + } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/include/sieve/class_sieveManagement.inc b/include/sieve/class_sieveManagement.inc index 59d9436e3..eae942688 100644 --- a/include/sieve/class_sieveManagement.inc +++ b/include/sieve/class_sieveManagement.inc @@ -32,6 +32,7 @@ class sieveManagement extends plugin var $parent = NULL; var $scripts= array(); + var $current_script = -1; var $current_handler = NULL; /* Initialize the class and load all sieve scripts @@ -101,16 +102,31 @@ class sieveManagement extends plugin $script = preg_replace("/_(x|y)/","",$script); $once = FALSE; + $this->current_script = $script; $this->current_handler = $this->scripts[$script]['PARSER']; } } - if(isset($_GET['xx'])){ + /* Abort saving */ + if(isset($_POST['cancel_sieve_changes'])){ + $this->current_handler = NULL; + } + + /* Save currently edited sieve script. */ + if(isset($_POST['save_sieve_changes'])){ + $this->scripts[$this->current_script]['PARSER'] = $this->current_handler; $this->current_handler = NULL; } + /* Create output for currently opened sieve script */ if($this->current_handler){ - return($this->current_handler->execute()); + $ret = $this->current_handler->execute(); + $ret .= "
+ +   + +
"; + return($ret); } /* Create list of available sieve scripts @@ -127,8 +143,17 @@ class sieveManagement extends plugin $field4 = array("string" => ""); $List ->AddEntry(array($field1,$field2,$field3,$field4)); } - - return($List->DrawList()); + + $display ="

Sieve script management

"; + $display .= _("Be careful. All your changes will be saved directly to sieve, if you use the save button below."); + $display .= $List->DrawList(); + + $display .= "

\n"; + $display .= "\n"; + $display .= " \n"; + $display .= "\n"; + $display .= "

"; + return($display);; } function save_object() @@ -137,7 +162,17 @@ class sieveManagement extends plugin $this->current_handler->save_object(); } } -} + + function save() + { + $ret = ""; + echo $ret; + } +} // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/include/sieve/templates/element_address.tpl b/include/sieve/templates/element_address.tpl index 6d1644088..80e4384ab 100755 --- a/include/sieve/templates/element_address.tpl +++ b/include/sieve/templates/element_address.tpl @@ -1,11 +1,5 @@ - - - - +
- {t}Address{/t} - -
{if $Expert} + + + + {else} + {/if} + {else} @@ -65,6 +79,14 @@ + {/if} diff --git a/include/sieve/templates/element_envelope.tpl b/include/sieve/templates/element_envelope.tpl index e1aace841..c99cfdd3c 100755 --- a/include/sieve/templates/element_envelope.tpl +++ b/include/sieve/templates/element_envelope.tpl @@ -1,8 +1,28 @@ -
@@ -17,6 +11,19 @@ + {t}Invert test{/t}? + + {if $Inverse} + + {else} + + {/if} + + +
@@ -44,20 +51,27 @@ {html_options options=$operators selected=$operator} +   + +   +
{t}Address fields to include{/t} - + {t}Values to match for{/t} - +
{t}If{/t}   + {t}Address{/t} + + {if $Inverse} + + {else} + + {/if} +   @@ -76,8 +98,11 @@ {/if} - - + + + +
+
+ {if $Expert} - + + + + @@ -14,36 +34,68 @@ {html_options options=$comparators selected=$comparator} - - + {if $match_type == ":count" || $match_type == ":value"} + {else} + + {/if} + + + {else} + + + + + {/if}
- {t}Envelope{/t} + + {t}Match type{/t} + + + + + {t}Invert test{/t}? + + {if $Inverse} + + {else} + + {/if} + +
- {t}Match type{/t} - - - - {t}operator{/t} - {html_options options=$operators selected=$operator} +   + +   +
- {t}Address fields{/t} + {t}Address fields to include{/t} - + - {t}Match values{/t} + {t}Values to match for{/t} - + +
+ {t}If{/t} +   + {t}Envelope{/t} + + {if $Inverse} + + {else} + + {/if} +   + + + {if $match_type == ":count" || $match_type == ":value"} + + {/if} + + + + +
diff --git a/include/sieve/templates/element_header.tpl b/include/sieve/templates/element_header.tpl index e32d8f678..c88466f1a 100755 --- a/include/sieve/templates/element_header.tpl +++ b/include/sieve/templates/element_header.tpl @@ -1,49 +1,109 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + {if $match_type == ":count" || $match_type == ":value"} + + + {else} + + {/if} + + + + + + + + + + {else} + + + + + + + {/if}
- {t}Header{/t} -
- {t}Comparator{/t} - - - - {t}Match type{/t} - - + {if $Expert} - - {t}operator{/t} - - -
- {t}Address fields{/t} - - - - {t}Match values{/t} - - -
+ {t}Match type{/t} + + + + + {t}Invert test{/t}? + + {if $Inverse} + + {else} + + {/if} + + +
+ + + {t}Comparator{/t} + + + + {t}operator{/t} + + + +   + +   +
+ {t}Address fields to include{/t} + + + + {t}Values to match for{/t} + + +
+ {t}If{/t} +   + {t}Envelope{/t} + + {if $Inverse} + + {else} + + {/if} +   + + + {if $match_type == ":count" || $match_type == ":value"} + + {/if} + + + + + +
diff --git a/plugins/personal/mail/class_mailAccount.inc b/plugins/personal/mail/class_mailAccount.inc index a09a9ae4c..b755e260b 100644 --- a/plugins/personal/mail/class_mailAccount.inc +++ b/plugins/personal/mail/class_mailAccount.inc @@ -243,7 +243,18 @@ class mailAccount extends plugin if(isset($_POST['sieveManagement'])) { $this->dialog = new sieveManagement($this->config,$this->dn,$this); } - + + /* Cancel sieve edit */ + if(isset($_POST['sieve_cancel'])){ + $this->dialog = NULL; + } + + /* Save sieve changes */ + if(isset($_POST['sieve_finish'])){ + $this->dialog->save(); + $this->dialog = NULL; + } + if(is_object($this->dialog)){ $this->dialog->save_object(); return($this->dialog->execute()); -- 2.30.2