From: hickert Date: Thu, 8 Mar 2007 13:54:42 +0000 (+0000) Subject: text: tags are allowed now. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=003d76f426422c935a4fb0914247eea28bdf0ab3;p=gosa.git text: tags are allowed now. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5759 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index 28ac518bd..9499fd641 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -149,24 +149,32 @@ class My_Tree extends Tree { $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_reject"){ + $tmp.=$tmp2; + }else{ + + $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; } } } + if(!preg_match("/Generated by GOsa - Gonicus System Administrator/",$tmp)){ + $tmp = "#Generated by GOsa - Gonicus System Administrator \n ".$tmp; + } return($tmp); } } @@ -195,9 +203,19 @@ function sieve_create_strings($data) $ret = "[".$ret."]"; } }else{ - $ret = "\"".$data."\""; + + $Multiline = preg_match("/\n/",$data); + $data = preg_replace("/\r/","",$data);; + + if($Multiline){ + $ret = "text: \r\n".$data."\r\n.\r\n"; + }else{ + $ret = "\"".$data."\""; + } } $ret = preg_replace("/\"\"/","\"",$ret); + $ret = preg_replace("/\n/","\r\n",$ret); + return($ret); } diff --git a/include/sieve/class_scanner.inc b/include/sieve/class_scanner.inc index 3e22bb1d0..2a7fc37d2 100644 --- a/include/sieve/class_scanner.inc +++ b/include/sieve/class_scanner.inc @@ -58,7 +58,6 @@ class Scanner } } } - array_push($this->tokens_, array( 'class' => 'script-end', 'text' => 'script-end', @@ -131,10 +130,11 @@ class Scanner 'quoted-string' => '"(?:\\[\\"]|[^\x00"])*"', 'number' => '[[:digit:]]+(?:[KMG])?(?=\b)', 'comment' => '(?:\/\*(?:[^\*]|\*(?=[^\/]))*\*\/|#[^\r\n]*\r?\n)', - 'multi-line' => 'text:[ \t]*(?:#[^\r\n]*)?\r?\n(\.[^\r\n]+\r?\n|[^\.]*\r?\n)*\.\r?\n', +# 'multi-line' => 'text:[ \t]*(?:#[^\r\n]*)?\r?\n(\.[^\r\n]+\r?\n|[^\.]*\r?\n)*\.\r?\n', + 'multi-line' => 'text:[^;]*', 'identifier' => '[[:alpha:]_][[:alnum:]_]*(?=\b)', 'unknown token' => '[^ \r\n\t]+' ); } -?> \ No newline at end of file +?> diff --git a/include/sieve/class_semantics.inc b/include/sieve/class_semantics.inc index 80e893ebc..e37d5c631 100644 --- a/include/sieve/class_semantics.inc +++ b/include/sieve/class_semantics.inc @@ -126,7 +126,7 @@ class Semantics 'valid_after' => array('require', 'if', 'elsif', 'else', 'reject', 'fileinto', 'redirect', 'stop', 'keep', 'discard'), 'arguments' => array( array('class' => 'string', 'occurrences' => '1', 'values' => array( - array('occurrences' => '1', 'regex' => '".*"', 'name' => 'reason') + array('occurrences' => '1', 'regex' => '.*', 'name' => 'reason') )) ) ); diff --git a/include/sieve/class_sieveElements.inc b/include/sieve/class_sieveElements.inc index 42ab948f9..199e03bc7 100644 --- a/include/sieve/class_sieveElements.inc +++ b/include/sieve/class_sieveElements.inc @@ -147,6 +147,7 @@ class sieve_reject var $data = array(); var $object_id = -1; + function save_object() { if(isset($_POST['reject_message_'.$this->object_id])){ @@ -161,8 +162,14 @@ class sieve_reject $this->object_id = $object_id; $str = ""; foreach($data['ELEMENTS'] as $node ){ - if(in_array($node['class'],array("quoted-string","text"))){ - $str .= $node['text']; + if(in_array($node['class'],array("quoted-string","text","multi-line"))){ + + if($node['class'] == "multi-line"){ + $str .= preg_replace("/^text:[ \n\r]*/","",$node['text']); + $str = preg_replace("/[ \n\r]*\.[ \n\r]*$/","",$str); + }else{ + $str .= $node['text']; + } } } $this->data = preg_replace("/\"/","",$str); @@ -170,13 +177,20 @@ class sieve_reject function get_sieve_script_part() { - return("reject ".sieve_create_strings($this->data)."\n"); + return("reject ".sieve_create_strings($this->data).";\n"); } function execute() { + /* check if this will be a + * - single string "" + * - or a multi line text: ... ; + */ + $Multiline = preg_match("/\n/",$this->data); + $smarty = get_smarty(); $smarty->assign("ID",$this->object_id); + $smarty->assign("Multiline",$Multiline); $smarty->assign("Message",$this->data); return($smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__)))); } @@ -201,6 +215,7 @@ class sieve_redirect } } + function sieve_redirect($data,$object_id) { foreach($data['ELEMENTS'] as $node ){ @@ -210,17 +225,19 @@ class sieve_redirect } } + function get_sieve_script_part() { $tmp = ""; foreach($this->data as $dat){ $tmp.= "\"".$dat."\", "; } - $tmp = "[".preg_replace("/,$/","",trim($tmp))."]"; + $tmp = preg_replace("/,$/","",trim($tmp)); $tmp = preg_replace ("/\"\"/","\"",$tmp); - return("redirect ".$tmp."\n"); + return("redirect ".$tmp.";\n"); } - + + function execute() { $values = ""; @@ -271,9 +288,9 @@ class sieve_fileinto foreach($this->data as $dat){ $tmp.= "\"".$dat."\", "; } - $tmp = "[".preg_replace("/,$/","",trim($tmp))."]"; + $tmp = preg_replace("/,$/","",trim($tmp)); $tmp = preg_replace ("/\"\"/","\"",$tmp); - return("fileinto ".$tmp."\n"); + return("fileinto ".$tmp.";\n"); } function execute() @@ -364,8 +381,8 @@ class sieve_vacation if($this->mime){ $str.= ":mime ".sieve_create_strings($this->mime); } - $str .= " ".sieve_create_strings($this->reason); - return($str."\n"); + $str .= "\n ".sieve_create_strings($this->reason); + return($str." ; \n"); } diff --git a/include/sieve/class_sieveManagement.inc b/include/sieve/class_sieveManagement.inc index 4784011de..ea355b2e3 100644 --- a/include/sieve/class_sieveManagement.inc +++ b/include/sieve/class_sieveManagement.inc @@ -94,7 +94,7 @@ class sieveManagement extends plugin $ret = $p->parse($script); if(!$ret){ $this->scripts[$key]['MSG'] = "".$p->status_text.""; - $this->scripts[$key]['STATUS'] = _("Parse failed"); + $this->scripts[$key]['STATUS'] = _("Parse failed")."".$p->status_text.""; }else{ $this->scripts[$key]['STATUS'] = _("Parse successful"); } @@ -300,7 +300,7 @@ class sieveManagement extends plugin foreach($this->scripts as $key => $script){ if($script['EDITED']){ $data = $script['PARSER']->get_sieve_script(); - if(!$this->sieve_handle->sieve_sendscript($script['NAME']."1", $data)){ + if(!$this->sieve_handle->sieve_sendscript($script['NAME'], $data)){ gosa_log("Failed to save sieve script named '".$script['NAME']."': ".to_string($this->sieve_handle->error_raw)); $everything_went_fine = FALSE; print_red(to_string($this->sieve_handle->error_raw)); diff --git a/include/sieve/templates/element_reject.tpl b/include/sieve/templates/element_reject.tpl index 28483346f..f5cd572a6 100644 --- a/include/sieve/templates/element_reject.tpl +++ b/include/sieve/templates/element_reject.tpl @@ -3,11 +3,16 @@ {t}Reject mail{/t}   + {if $Multiline} + {t}This will be a multiline text element{/t} + {else} + {t}this will be stored as single string{/t} + {/if} - +