summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 18420c3)
raw | patch | inline | side by side (parent: 18420c3)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 8 Mar 2007 07:38:34 +0000 (07:38 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 8 Mar 2007 07:38:34 +0000 (07:38 +0000) |
Added else element.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5757 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5757 594d385d-05f5-0310-b6e9-bd551577e9d8
index a8f9aa740e24a1066dae7eca9ae4f8531c8b0659..28ac518bd9bce6075f48a2356254bce04d4ed3d5 100644 (file)
}
/* 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']);
}
index bdbf7d6fdbea70af45a0fa4b34dc92128a00b9f4..c16345f2b394285b1d930a4d607ba325ad49e330 100644 (file)
$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 "<br>Trying to receive $this->err_len bytes for result<br>";
- $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 "<br>Trying to receive ".($this->err_len-$this->err_recv)." bytes for result<br>";
- $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 "<br>Trying to receive $this->err_len bytes for result<br>";
+ $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;
index c488aca1400ab0eb26515703911d3b6ec9e501f2..11b5c1b92fb47f089c3bf7f245f76f43b545a89d 100644 (file)
/* 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']);
/* 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']);
/* 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']);
index ae082422cb979853e584ec142ec7b965e5a3f577..42ab948f9b8808a7a7d07ad8da3066fad90bbb62 100644 (file)
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
index eae9426885851dc30d6921d76c72b064cc736655..a97652fda450059e15d1c248fa479b5f52bb24cb 100644 (file)
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
*/
$ret = $p->parse($script);
if(!$ret){
$this->scripts[$key]['MSG'] = "<font color='red'>".$p->status_text."</font>";
- $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;
}
/* 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;
}
*/
$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" => "<img src='images/fai_new_hook.png' alt='"._("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" => "<input type='image' name='editscript_".$key."' src='images/edit.png'>");
- $List ->AddEntry(array($field1,$field2,$field3,$field4));
+
+ $field5 = array("string" => "<input type='image' name='editscript_".$key."' src='images/edit.png'>");
+ $List ->AddEntry(array($field1,$field2,$field3,$field4,$field5));
}
$display ="<h2>Sieve script management</h2>";
function save()
{
- $ret = "<textarea style='width:100%;height:400px;'>";
- foreach($this->scripts as $script){
- $ret .= ($script['PARSER']->get_sieve_script());
+ /* Connect to sieve class and try to get all available sieve scripts */
+ $cfg= $this->config->data['SERVERS']['IMAP'][$this->parent->gosaMailServer];
+
+ $this->sieve_handle=
+ new sieve( $cfg["sieve_server"],
+ $cfg["sieve_port"],
+ $this->parent->mail,
+ $cfg["password"],
+ $cfg["admin"]);
+
+ if (!$this->sieve_handle->sieve_login()){
+ print_red(sprintf(_("Can't log into SIEVE server. Server says '%s'."),to_string($this->sieve_handle->error_raw)));
+ return;
+ }
+
+ $everything_went_fine = TRUE;
+
+ 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)){
+ 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));
+ $this->scripts[$key]['STATUS'] = "<font color='red'>".
+ _("Failed to save sieve script").": ".
+ to_string($this->sieve_handle->error_raw).
+ "</font>";
+ }
+ }
}
- $ret .= "</textarea>";
- 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
--- /dev/null
@@ -0,0 +1,7 @@
+<table style='width:100%;background-color:#ffb23a; padding:3px;'>
+ <tr>
+ <td>
+ <b>{t}else{/t}</b>
+ </td>
+ </tr>
+</table>
diff --git a/plugins/personal/mail/class_mailAccount.inc b/plugins/personal/mail/class_mailAccount.inc
index b755e260b60e2fc5067bd056eeb37044c2308037..11298822d4c80e544baa1aa1307e7290eff6c191 100644 (file)
/* 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)){