From: hickert Date: Tue, 13 Mar 2007 14:08:10 +0000 (+0000) Subject: Several changes X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5646ccb89227486fe2db0515bebe0d48c6075a92;p=gosa.git Several changes git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5776 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index 1816f92b7..826817b88 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -18,7 +18,7 @@ class My_Tree extends Tree var $add_new = FALSE; var $add_new_id = 0; - var $add_type = "up"; + var $add_type = "top"; var $add_element_type = ""; /* Create a html interface for the current sieve filter @@ -46,10 +46,48 @@ class My_Tree extends Tree if($this->add_new && isset($_POST['select_new_element_type'])){ - $ele = new $this->add_element_type(array(),microtime()); - - $this->pap[] = $ele; - $this->add_new = FALSE; + $ele = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime())); + $start = $end = array(); + $found = false; + + if($this->add_type == "top"){ + foreach($this->pap as $key => $obj){ + if($obj->object_id == $this->add_new_id){ + $found = true; + } + if(!$found){ + $start[] = $obj; + }else{ + $end[] = $obj; + } + } + }else{ + foreach($this->pap as $key => $obj){ + if(!$found){ + $start[] = $obj; + }else{ + $end[] = $obj; + } + if($obj->object_id == $this->add_new_id){ + $found = true; + } + } + } + + if($found){ + $new = array(); + foreach($start as $obj){ + $new[] = $obj; + } + $new[] = $ele; + foreach($end as $obj){ + $new[] = $obj; + } + $this->pap = $new; + $this->add_new = FALSE; + }else{ + print_red(_("Something went wrong while adding a new entry.")); + } } if($this->add_new){ diff --git a/include/sieve/class_sieveElement_Block_End.inc b/include/sieve/class_sieveElement_Block_End.inc index 403585f89..8f5739f1c 100644 --- a/include/sieve/class_sieveElement_Block_End.inc +++ b/include/sieve/class_sieveElement_Block_End.inc @@ -2,6 +2,13 @@ class sieve_block_end { + var $object_id= -1; + + function sieve_block_end($data = NULL,$object_id) + { + $this->object_id = $object_id; + } + function execute() { $smarty = get_smarty(); diff --git a/include/sieve/class_sieveElement_Block_Start.inc b/include/sieve/class_sieveElement_Block_Start.inc index 799f1fa84..fc924ce8f 100644 --- a/include/sieve/class_sieveElement_Block_Start.inc +++ b/include/sieve/class_sieveElement_Block_Start.inc @@ -2,6 +2,13 @@ class sieve_block_start { + var $object_id= -1; + + function sieve_block_start($data = NULL,$object_id) + { + $this->object_id = $object_id; + } + function execute() { $smarty = get_smarty(); diff --git a/include/sieve/class_sieveElement_Comment.inc b/include/sieve/class_sieveElement_Comment.inc index d3f6747dd..0b718b804 100644 --- a/include/sieve/class_sieveElement_Comment.inc +++ b/include/sieve/class_sieveElement_Comment.inc @@ -14,11 +14,21 @@ class sieve_comment function sieve_comment($data,$object_id) { $this->object_id = $object_id; + + if($data == NULL){ + $data = array('ELEMENTS' => array(array('class' => "quoted-string" ,"text" => _("Your comment here")))); + } + foreach($data['ELEMENTS'] as $node){ $this->data .= $node['text']; } } + function check() + { + return(array()) ; + } + function save_object() { if(isset($_POST['comment_'.$this->object_id])){ diff --git a/include/sieve/class_sieveElement_Discard.inc b/include/sieve/class_sieveElement_Discard.inc index 5998164b6..504fe4adb 100644 --- a/include/sieve/class_sieveElement_Discard.inc +++ b/include/sieve/class_sieveElement_Discard.inc @@ -14,6 +14,11 @@ class sieve_discard { return("discard;\n"); } + function check() + { + return(array()) ; + } + function save_object() { diff --git a/include/sieve/class_sieveElement_Fileinto.inc b/include/sieve/class_sieveElement_Fileinto.inc index e595250aa..c15dc444c 100644 --- a/include/sieve/class_sieveElement_Fileinto.inc +++ b/include/sieve/class_sieveElement_Fileinto.inc @@ -53,6 +53,11 @@ class sieve_fileinto return($str); } + function check() + { + return(array()); + } + function get_mail_boxes() { return(array("not"=>"not","impplemented/yet"=>"impplemented/yet")); diff --git a/include/sieve/class_sieveElement_Redirect.inc b/include/sieve/class_sieveElement_Redirect.inc index 13b851e72..de599151e 100644 --- a/include/sieve/class_sieveElement_Redirect.inc +++ b/include/sieve/class_sieveElement_Redirect.inc @@ -3,7 +3,8 @@ class sieve_redirect { var $data = array(); var $object_id = -1; - + var $LastError =""; + function save_object() { if(isset($_POST['redirect_to_'.$this->object_id])){ @@ -15,8 +16,25 @@ class sieve_redirect } + function check() + { + $msgs = array(); + + if(!is_email(preg_replace("/\"/","",$this->data))){ + $msgs[] =_("Please specify a valid email address."); + } + + return($msgs); + } + function sieve_redirect($data,$object_id) { + $this->object_id = $object_id; + + if($data == NULL){ + $data = array('ELEMENTS' => array(array('class' => "quoted-string" ,"text" => _("Put a mail address here")))); + } + foreach($data['ELEMENTS'] as $node ){ if(in_array($node['class'],array("quoted-string","text"))){ $this->data = $node['text']; @@ -38,6 +56,8 @@ class sieve_redirect $smarty = get_smarty(); $smarty->assign("ID", $this->object_id); $smarty->assign("Destinations" , $values); + $smarty->assign("LastError" , $this->check()); + $smarty->assign("LastErrorCnt" , count($this->check())); $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__))); $object= $smarty->fetch(get_template_path("templates/element_redirect.tpl",TRUE,dirname(__FILE__))); $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container); diff --git a/include/sieve/class_sieveElement_Reject.inc b/include/sieve/class_sieveElement_Reject.inc index 0d5423845..e930456fd 100644 --- a/include/sieve/class_sieveElement_Reject.inc +++ b/include/sieve/class_sieveElement_Reject.inc @@ -15,6 +15,11 @@ class sieve_reject } } + function check() + { + return(array()); + } + function sieve_reject($data,$object_id) { $this->object_id = $object_id; diff --git a/include/sieve/class_sieveElement_Vacation.inc b/include/sieve/class_sieveElement_Vacation.inc index 182f023df..95e6ef216 100644 --- a/include/sieve/class_sieveElement_Vacation.inc +++ b/include/sieve/class_sieveElement_Vacation.inc @@ -106,6 +106,12 @@ class sieve_vacation $this->reason = "\"".trim(preg_replace("/\"/","",$vr))."\""; } } + + function check() + { + return(array()) ; + } + function execute() { $Addresses = ""; diff --git a/include/sieve/class_sieveManagement.inc b/include/sieve/class_sieveManagement.inc index cfbbb748e..22db80a40 100644 --- a/include/sieve/class_sieveManagement.inc +++ b/include/sieve/class_sieveManagement.inc @@ -210,7 +210,6 @@ class sieveManagement extends plugin $this->scripts[$this->current_script]['EDITED'] = TRUE; $this->current_handler = NULL; }else{ - print_a($chk); print_red(_("Please fix all errors before saving.")); } } diff --git a/include/sieve/templates/element_redirect.tpl b/include/sieve/templates/element_redirect.tpl index bf624d913..b2864f77d 100644 --- a/include/sieve/templates/element_redirect.tpl +++ b/include/sieve/templates/element_redirect.tpl @@ -1,4 +1,4 @@ -{if $LastError != ""} +{if $LastErrorCnt != 0} + + {foreach from=$LastError item=val key=key} + + + + + {/foreach} +
@@ -12,13 +12,18 @@ {t}Redirect{/t} {t}Redirect mail to following recipients{/t} -   - {if $LastError != ""} -
- {$LastError} - {/if}
+ {$LastError[$key]} +
@@ -26,7 +31,7 @@
-{if $LastError != ""} +{if $LastErrorCnt != 0}