From: hickert Date: Thu, 8 Mar 2007 07:38:34 +0000 (+0000) Subject: Added save method. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9d45792ebfea9693b701a01fdf6c40b4075f6dba;p=gosa.git Added save method. Added else element. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5757 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index a8f9aa740..28ac518bd 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -84,7 +84,7 @@ class My_Tree extends Tree } /* Handle identifiers */ - $identifiers = array("if","elsif","end","reject","redirect","vacation","keep","discard","comment","fileinto","require","stop"); + $identifiers = array("else","if","elsif","end","reject","redirect","vacation","keep","discard","comment","fileinto","require","stop"); if($node['class'] == "identifier" && in_array($node['text'],$identifiers)){ $this->mode_stack[] = array("TYPE" => $node['text']); } diff --git a/include/sieve/class_sieve.inc b/include/sieve/class_sieve.inc index bdbf7d6fd..c16345f2b 100644 --- a/include/sieve/class_sieve.inc +++ b/include/sieve/class_sieve.inc @@ -104,34 +104,45 @@ class sieve $this->line=fgets($this->fp,1024); $this->token = split(" ", $this->line, 2); - if($this->token[0] == "NO"){ - /* we need to try and extract the error code from here. There are two possibilites: one, that it will take the form of: - NO ("yyyyy") "zzzzzzz" or, two, NO {yyyyy} "zzzzzzzzzzz" */ - $this->x = 0; - list($this->ltoken, $this->mtoken, $this->rtoken) = split(" ", $this->line." ", 3); - if($this->mtoken[0] == "{"){ - while($this->mtoken[$this->x] != "}" or $this->err_len < 1){ - $this->err_len = substr($this->mtoken, 1, $this->x); - $this->x++; - } - //print "
Trying to receive $this->err_len bytes for result
"; - $this->line = fgets($this->fp,$this->err_len); - $this->error_raw[]=substr($this->line, 0, strlen($this->line) -2); //we want to be nice and strip crlf's - $this->err_recv = strlen($this->line); - - while($this->err_recv < $this->err_len){ - //print "
Trying to receive ".($this->err_len-$this->err_recv)." bytes for result
"; - $this->line = fgets($this->fp, ($this->err_len-$this->err_recv)); - $this->error_raw[]=substr($this->line, 0, strlen($this->line) -2); //we want to be nice and strip crlf's - $this->err_recv += strlen($this->line); - } /* end while */ - $this->line = fgets($this->fp, 1024); //we need to grab the last crlf, i think. this may be a bug... - $this->error=EC_UNKNOWN; - - } /* end if */ - elseif($this->mtoken[0] == "("){ - switch($this->mtoken){ - case "(\"QUOTA\")": + if($this->token[0] == "NO"){ + /* we need to try and extract the error code from here. There are two possibilites: one, that it will take the form of: + NO ("yyyyy") "zzzzzzz" or, two, NO {yyyyy} "zzzzzzzzzzz" */ + $this->x = 0; + list($this->ltoken, $this->mtoken, $this->rtoken) = split(" ", $this->line." ", 3); + if($this->mtoken[0] == "{"){ + while($this->mtoken[$this->x] != "}" or $this->err_len < 1){ + $this->err_len = substr($this->mtoken, 1, $this->x); + $this->x++; + } + //print "
Trying to receive $this->err_len bytes for result
"; + $this->line = fgets($this->fp,$this->err_len); + $this->error_raw[]=substr($this->line, 0, strlen($this->line) -2); //we want to be nice and strip crlf's + $this->err_recv = strlen($this->line); + + $last_cnt_to_fetch = -1; + while($this->err_recv < ($this->err_len)){ + + /* We are trying to read the same count of chars + * as we tried last while loop. + * There must be something wrong- + */ + if($last_cnt_to_fetch == ($this->err_len-$this->err_recv)){ + $cur = $max; + echo "Sieve : failed to read error msgs, .. skipped endless loop! ~class_sieve.inc 525"; + } + $last_cnt_to_fetch = $this->err_len-$this->err_recv; + $this->line = fgets($this->fp);//, ($this->err_len-$this->err_recv)); + $this->error_raw[]=substr($this->line, 0, strlen($this->line) -2); //we want to be nice and strip crlf's + $this->err_recv += strlen($this->line); + } /* end while */ + + $this->line = fgets($this->fp, 1024); //we need to grab the last crlf, i think. this may be a bug... + $this->error=EC_UNKNOWN; + + } /* end if */ + elseif($this->mtoken[0] == "("){ + switch($this->mtoken){ + case "(\"QUOTA\")": $this->error = EC_QUOTA; $this->error_raw=$this->rtoken; break; diff --git a/include/sieve/class_sieveElement_If.inc b/include/sieve/class_sieveElement_If.inc index c488aca14..11b5c1b92 100644 --- a/include/sieve/class_sieveElement_If.inc +++ b/include/sieve/class_sieveElement_If.inc @@ -144,7 +144,7 @@ class sieve_if /* 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['Match_type_value'])." "; } $script .= sieve_create_strings($data['Key_List']); @@ -189,7 +189,7 @@ class sieve_if /* 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['Match_type_value'])." "; } $script .= sieve_create_strings($data['Key_List']); @@ -235,7 +235,7 @@ class sieve_if /* 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['Match_type_value'])." "; } $script .= sieve_create_strings($data['Key_List']); diff --git a/include/sieve/class_sieveElements.inc b/include/sieve/class_sieveElements.inc index ae082422c..42ab948f9 100644 --- a/include/sieve/class_sieveElements.inc +++ b/include/sieve/class_sieveElements.inc @@ -6,6 +6,20 @@ class sieve_elsif extends sieve_if var $TYPE = "elsif"; } +class sieve_else +{ + function execute() + { + $smarty = get_smarty(); + return($smarty->fetch(get_template_path("templates/element_else.tpl",TRUE,dirname(__FILE__)))); + } + + function get_sieve_script_part() + { + return(" else "); + } +} + /* Sieve comment tag */ class sieve_comment diff --git a/include/sieve/class_sieveManagement.inc b/include/sieve/class_sieveManagement.inc index eae942688..a97652fda 100644 --- a/include/sieve/class_sieveManagement.inc +++ b/include/sieve/class_sieveManagement.inc @@ -34,7 +34,10 @@ class sieveManagement extends plugin var $current_script = -1; var $current_handler = NULL; - + + var $sieve_handle = NULL; + + /* Initialize the class and load all sieve scripts * try to parse them and display errors */ @@ -82,12 +85,14 @@ class sieveManagement extends plugin $ret = $p->parse($script); if(!$ret){ $this->scripts[$key]['MSG'] = "".$p->status_text.""; - $this->scripts[$key]['STATUS'] = FALSE; + $this->scripts[$key]['STATUS'] = _("Parse failed"); }else{ - $this->scripts[$key]['STATUS'] = TRUE; + $this->scripts[$key]['STATUS'] = _("Parse successful"); } $this->scripts[$key]['PARSER'] = $p; + $this->scripts[$key]['EDITED'] = FALSE; } + $this->sieve_handle = $sieve; } @@ -115,6 +120,7 @@ class sieveManagement extends plugin /* Save currently edited sieve script. */ if(isset($_POST['save_sieve_changes'])){ $this->scripts[$this->current_script]['PARSER'] = $this->current_handler; + $this->scripts[$this->current_script]['EDITED'] = TRUE; $this->current_handler = NULL; } @@ -133,15 +139,23 @@ class sieveManagement extends plugin */ $List = new divSelectBox("sieveManagement"); foreach($this->scripts as $key => $script){ + + $edited = $script['EDITED']; + $field1 = array("string" => $script['NAME']); - if($script['STATUS']){ - $field2 = array("string" => _("Parse successful")); + $field2 = array("string" => $script['STATUS']); + $field3 = array("string" => _("Script length")." : ".strlen($script['SCRIPT'])); + + if($edited){ + $field4 = array("string" => ""._("Edited")."", + "attach" => "style='width:30px;'"); }else{ - $field2 = array("string" => _("Parse failed") .$script['MSG']); + $field4 = array("string" => "", + "attach" => "style='width:30px;'"); } - $field3 = array("string" => _("Script length")." : ".strlen($script['SCRIPT'])); - $field4 = array("string" => ""); - $List ->AddEntry(array($field1,$field2,$field3,$field4)); + + $field5 = array("string" => ""); + $List ->AddEntry(array($field1,$field2,$field3,$field4,$field5)); } $display ="

Sieve script management

"; @@ -166,12 +180,38 @@ class sieveManagement extends plugin function save() { - $ret = ""; - echo $ret; + return($everything_went_fine); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/include/sieve/templates/element_else.tpl b/include/sieve/templates/element_else.tpl new file mode 100644 index 000000000..86eb1f2cc --- /dev/null +++ b/include/sieve/templates/element_else.tpl @@ -0,0 +1,7 @@ + + + + +
+ {t}else{/t} +
diff --git a/plugins/personal/mail/class_mailAccount.inc b/plugins/personal/mail/class_mailAccount.inc index b755e260b..11298822d 100644 --- a/plugins/personal/mail/class_mailAccount.inc +++ b/plugins/personal/mail/class_mailAccount.inc @@ -251,8 +251,9 @@ class mailAccount extends plugin /* Save sieve changes */ if(isset($_POST['sieve_finish'])){ - $this->dialog->save(); - $this->dialog = NULL; + if($this->dialog->save()){ + $this->dialog = NULL; + } } if(is_object($this->dialog)){