From: hickert Date: Wed, 7 Mar 2007 14:01:42 +0000 (+0000) Subject: Updated sieve stuff X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=18420c321b6306313393b6ef873e8fbb705aee2a;p=gosa.git Updated sieve stuff git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5756 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index bca523f2c..a8f9aa740 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -138,7 +138,7 @@ class My_Tree extends Tree { foreach($this->pap as $key => $obj){ - if(in_array(get_class($obj),array("sieve_if","sieve_vacation"))){ + if(in_array(get_class($obj),array("sieve_if","sieve_elsif","sieve_vacation","sieve_comment","sieve_reject","sieve_fileinto","sieve_require","sieve_redirect"))){ $this->pap[$key]->save_object(); } } diff --git a/include/sieve/class_sieveElement_If.inc b/include/sieve/class_sieveElement_If.inc index 0b8c5caad..c488aca14 100644 --- a/include/sieve/class_sieveElement_If.inc +++ b/include/sieve/class_sieveElement_If.inc @@ -487,6 +487,11 @@ class sieve_if case "exists" : { + /* Toggle Inverse ? */ + if(isset($_POST['toggle_inverse_'.$element_id])){ + $parsed[$key]['Inverse'] = !$parsed[$key]['Inverse']; + } + /* get list of match values */ if(isset($_POST['Values_'.$element_id])){ $vls = stripslashes($_POST['Values_'.$element_id]); @@ -609,16 +614,10 @@ class sieve_if $name .= " - "._("Else"); } - /* Create new html block */ - $str =" - - - -
". - $name; - $str .= $this->get_as_html(); - $str .= "
"; - return($str); + $smarty = get_smarty(); + $smarty->assign("Name", $name); + $smarty->assign("Contents", $this->get_as_html()); + return($smarty->fetch(get_template_path("templates/element_if_else.tpl",TRUE,dirname(__FILE__)))); } diff --git a/include/sieve/class_sieveElements.inc b/include/sieve/class_sieveElements.inc index 1c62f35fa..ae082422c 100644 --- a/include/sieve/class_sieveElements.inc +++ b/include/sieve/class_sieveElements.inc @@ -1,45 +1,68 @@ data."\n"); } - function sieve_comment($data) + function sieve_comment($data,$object_id) { + $this->object_id = $object_id; foreach($data['ELEMENTS'] as $node){ $this->data .= $node['text']; } } + function save_object() + { + if(isset($_POST['comment_'.$this->object_id])){ + $cm = $_POST['comment_'.$this->object_id]; + $this->data = "/*".$cm."*/"; + } + } + function execute() { - $str ="
"._("Comment"); - $str .=""; - $str .="
"; - return($str); + $Comment = $this->data; + + /* Remove comment tags */ + if(preg_match("/^#/",$Comment)){ + $Comment = preg_replace("/^#/","",$Comment); + }elseif(preg_match("#\/\*#",$Comment)){ + $Comment = preg_replace("#^\/\*#","",$Comment); + $Comment = preg_replace("#\*\/$#","",$Comment); + } + + /* Create html object */ + $smarty = get_smarty(); + $smarty->assign("Comment",$Comment); + $smarty->assign("ID",$this->object_id); + return($smarty->fetch(get_template_path("templates/element_comment.tpl",TRUE,dirname(__FILE__)))); } } class sieve_require - { var $data = array(); - - function sieve_require($data) + var $object_id = -1; + + function sieve_require($data,$object_id) { + $this->object_id = $object_id; foreach($data['ELEMENTS'] as $node ){ if(in_array($node['class'],array("quoted-string","text"))){ $this->data[] = preg_replace("/\"/","",$node['text']); @@ -47,6 +70,21 @@ class sieve_require } } + function save_object() + { + /* Get the values should check for, they are seperated by , */ + if(isset($_POST['require_'.$this->object_id])){ + $vls = stripslashes($_POST['require_'.$this->object_id]); + $tmp = array(); + + $tmp2 = split(",",$vls); + foreach($tmp2 as $val){ + $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\""; + } + $this->data = $tmp; + } + } + function get_sieve_script_part() { $tmp = sieve_create_strings($this->data); @@ -55,12 +93,16 @@ class sieve_require function execute() { - $str = "
"._("Script includes"); - foreach($this->data as $req){ - $str .= " ".$req.""; + $Require = ""; + foreach($this->data as $key){ + $Require .= $key.", "; } - $str .="
"; - return($str); + $Require = preg_replace("/,$/","",trim($Require)); + + $smarty = get_smarty(); + $smarty->assign("Require",$Require); + $smarty->assign("ID",$this->object_id); + return($smarty->fetch(get_template_path("templates/element_require.tpl",TRUE,dirname(__FILE__)))); } } @@ -79,9 +121,8 @@ class sieve_discard function execute() { - $str = "
"._("Discard message"); - $str .="
"; - return($str); + $smarty = get_smarty(); + return($smarty->fetch(get_template_path("templates/element_discard.tpl",TRUE,dirname(__FILE__)))); } } @@ -90,9 +131,20 @@ class sieve_discard class sieve_reject { var $data = array(); + var $object_id = -1; - function sieve_reject($data) + function save_object() + { + if(isset($_POST['reject_message_'.$this->object_id])){ + $msg = stripslashes($_POST['reject_message_'.$this->object_id]); + + $this->data = $msg; + } + } + + function sieve_reject($data,$object_id) { + $this->object_id = $object_id; $str = ""; foreach($data['ELEMENTS'] as $node ){ if(in_array($node['class'],array("quoted-string","text"))){ @@ -109,18 +161,33 @@ class sieve_reject function execute() { - $str = "
"._("Reject mail"); - $str .= " "; - $str .="
"; - return($str); + $smarty = get_smarty(); + $smarty->assign("ID",$this->object_id); + $smarty->assign("Message",$this->data); + return($smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__)))); } } class sieve_redirect { var $data = array(); + var $object_id = -1; - function sieve_redirect($data) + function save_object() + { + if(isset($_POST['redirect_to_'.$this->object_id])){ + $rt = stripslashes($_POST['redirect_to_'.$this->object_id]); + + $tmp = array(); + $tmp2 = split(",",$rt); + foreach($tmp2 as $val){ + $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\""; + } + $this->data = $tmp; + } + } + + function sieve_redirect($data,$object_id) { foreach($data['ELEMENTS'] as $node ){ if(in_array($node['class'],array("quoted-string","text"))){ @@ -142,21 +209,41 @@ class sieve_redirect function execute() { - $str = "
"._("Redirect to"); - foreach($this->data as $dest){ - $str .= "
"; + $values = ""; + foreach($this->data as $key){ + $values .= $key.", "; } - $str .="
"; - return($str); + $values = preg_replace("/,$/","",trim($values)); + + $smarty = get_smarty(); + $smarty->assign("Destinations" , $values); + $smarty->assign("ID" , $this->object_id); + return($smarty->fetch(get_template_path("templates/element_redirect.tpl",TRUE,dirname(__FILE__)))); } } class sieve_fileinto { - var $data = array(); + var $data = array(); + var $object_id= -1; + var $options = array(); - function sieve_fileinto($data) + function save_object() { + $mbs = $this->get_mail_boxes(); + + if(isset($_POST['fileinto_'.$this->object_id])){ + $mb = $_POST['fileinto_'.$this->object_id]; + + if(isset($mbs[$mb])) { + $this->data[0] = $mb; + } + } + } + + function sieve_fileinto($data,$object_id) + { + $this->object_id = $object_id; foreach($data['ELEMENTS'] as $node ){ if(in_array($node['class'],array("quoted-string","text"))){ $this->data[] = preg_replace("/\"/","",$node['text']); @@ -177,15 +264,16 @@ class sieve_fileinto function execute() { - $str = "
"._("File into"); - $str .= ""; - $str .="
"; + $smarty = get_smarty(); + $smarty->assign("Selected",$this->data[0]); + $smarty->assign("Boxes", $this->get_mail_boxes()); + $smarty->assign("ID", $this->object_id); + return($smarty->fetch(get_template_path("templates/element_fileinto.tpl",TRUE,dirname(__FILE__)))); + } - return($str); + function get_mail_boxes() + { + return(array("not","impplemented/yet")); } } @@ -297,7 +385,6 @@ class sieve_vacation } } - function execute() { $Addresses = ""; @@ -305,7 +392,6 @@ class sieve_vacation $Addresses .= $key.", "; } $Addresses = preg_replace("/,$/","",trim($Addresses)); - $smarty = get_smarty(); $smarty->assign("Reason",$this->reason); $smarty->assign("Addresses",$Addresses); @@ -321,33 +407,27 @@ class sieve_block_start { function execute() { - return(" - - - - -
- - "); + $smarty = get_smarty(); + return($smarty->fetch(get_template_path("templates/element_block_start.tpl",TRUE,dirname(__FILE__)))); } + function get_sieve_script_part() { return("{\n"); } - } class sieve_block_end { function execute() { - return("
"); + $smarty = get_smarty(); + return($smarty->fetch(get_template_path("templates/element_block_end.tpl",TRUE,dirname(__FILE__)))); } function get_sieve_script_part() { return("}\n"); } - } /* This class handles the keep statement */ @@ -355,14 +435,8 @@ class sieve_keep { function execute() { - $str = " - - - -
". - _("Keep message"); - $str .="
"; - return($str); + $smarty = get_smarty(); + return($smarty->fetch(get_template_path("templates/element_keep.tpl",TRUE,dirname(__FILE__)))); } function get_sieve_script_part() { @@ -376,14 +450,8 @@ class sieve_stop { function execute() { - $str = " - - - -
". - _("Stop here"); - $str .="
"; - return($str); + $smarty = get_smarty(); + return($smarty->fetch(get_template_path("templates/element_stop.tpl",TRUE,dirname(__FILE__)))); } function get_sieve_script_part() diff --git a/include/sieve/templates/element_allof.tpl b/include/sieve/templates/element_allof.tpl index a4e811ab2..4a79f35da 100644 --- a/include/sieve/templates/element_allof.tpl +++ b/include/sieve/templates/element_allof.tpl @@ -1,6 +1,11 @@ -
+ {if $Inverse} {else} diff --git a/include/sieve/templates/element_anyof.tpl b/include/sieve/templates/element_anyof.tpl index 7eebc2ec8..bdef028fc 100644 --- a/include/sieve/templates/element_anyof.tpl +++ b/include/sieve/templates/element_anyof.tpl @@ -1,6 +1,11 @@ - + +
+ {if $Inverse} {else} diff --git a/include/sieve/templates/element_block_end.tpl b/include/sieve/templates/element_block_end.tpl new file mode 100644 index 000000000..b5af6fbde --- /dev/null +++ b/include/sieve/templates/element_block_end.tpl @@ -0,0 +1,3 @@ +
diff --git a/include/sieve/templates/element_block_start.tpl b/include/sieve/templates/element_block_start.tpl new file mode 100644 index 000000000..fd3cea33f --- /dev/null +++ b/include/sieve/templates/element_block_start.tpl @@ -0,0 +1,8 @@ + + + + - + + + + + + + - - - {else} - + + + + {/if}
+ + diff --git a/include/sieve/templates/element_comment.tpl b/include/sieve/templates/element_comment.tpl new file mode 100644 index 000000000..d3094d85d --- /dev/null +++ b/include/sieve/templates/element_comment.tpl @@ -0,0 +1,12 @@ + + + + + + + +
+ {t}Comment{/t} +
+ +
diff --git a/include/sieve/templates/element_discard.tpl b/include/sieve/templates/element_discard.tpl new file mode 100644 index 000000000..01a9e8cc5 --- /dev/null +++ b/include/sieve/templates/element_discard.tpl @@ -0,0 +1,7 @@ + + + + +
+ {t}Discard message{/t} +
diff --git a/include/sieve/templates/element_exists.tpl b/include/sieve/templates/element_exists.tpl index 626cf875c..f8eb32203 100644 --- a/include/sieve/templates/element_exists.tpl +++ b/include/sieve/templates/element_exists.tpl @@ -1,23 +1,21 @@ - -
- {t}Exists{/t} + {if $LastError != ""} {$LastError}
{/if} {if $Inverse} - {t}If header attribute does not exists{/t} + {else} - {t}If header attribute(s) exists{/t} + {/if} + + {t}If header attribute(s) exists{/t}
- + - -
diff --git a/include/sieve/templates/element_fileinto.tpl b/include/sieve/templates/element_fileinto.tpl new file mode 100644 index 000000000..1bd1d8453 --- /dev/null +++ b/include/sieve/templates/element_fileinto.tpl @@ -0,0 +1,10 @@ + + + + +
+ {t}Move mail into folder{/t} + +
diff --git a/include/sieve/templates/element_if_else.tpl b/include/sieve/templates/element_if_else.tpl new file mode 100644 index 000000000..fa6772893 --- /dev/null +++ b/include/sieve/templates/element_if_else.tpl @@ -0,0 +1,8 @@ + + + + +
+ {$Name} + {$Contents} +
diff --git a/include/sieve/templates/element_keep.tpl b/include/sieve/templates/element_keep.tpl new file mode 100644 index 000000000..eae62debd --- /dev/null +++ b/include/sieve/templates/element_keep.tpl @@ -0,0 +1,7 @@ + + + + +
+ {t}Keep message{/t} +
diff --git a/include/sieve/templates/element_redirect.tpl b/include/sieve/templates/element_redirect.tpl new file mode 100644 index 000000000..47bcbe2f2 --- /dev/null +++ b/include/sieve/templates/element_redirect.tpl @@ -0,0 +1,13 @@ + + + + + + + +
+ {t}Redirect{/t} + {t}Redirect mail to following recipients{/t} +
+ +
diff --git a/include/sieve/templates/element_reject.tpl b/include/sieve/templates/element_reject.tpl new file mode 100644 index 000000000..28483346f --- /dev/null +++ b/include/sieve/templates/element_reject.tpl @@ -0,0 +1,13 @@ + + + + + + + +
+ {t}Reject mail{/t} +   +
+ +
diff --git a/include/sieve/templates/element_require.tpl b/include/sieve/templates/element_require.tpl new file mode 100644 index 000000000..0cde8e3fb --- /dev/null +++ b/include/sieve/templates/element_require.tpl @@ -0,0 +1,12 @@ + + + + + + + +
+ {t}Require{/t} +
+ +
diff --git a/include/sieve/templates/element_stop.tpl b/include/sieve/templates/element_stop.tpl new file mode 100644 index 000000000..92a4c214b --- /dev/null +++ b/include/sieve/templates/element_stop.tpl @@ -0,0 +1,8 @@ + + + + +
+ {t}Stop{/t}
+ {t}Stop execution here!{/t} +
diff --git a/include/sieve/templates/element_vacation.tpl b/include/sieve/templates/element_vacation.tpl index 4cb133a8b..ed6e2b072 100644 --- a/include/sieve/templates/element_vacation.tpl +++ b/include/sieve/templates/element_vacation.tpl @@ -4,35 +4,49 @@ {if $Expert}
+ + {t}Vacation Message{/t} + + +
{t}Release date{/t}  + - +  {t}days{/t}
{t}Receiver{/t} + - -
+
- - + {t}Vacation Message{/t} +
+ +