diff --git a/include/sieve/class_sieveElement_Vacation.inc b/include/sieve/class_sieveElement_Vacation.inc
index 182f023df054447028e5c249e1b476563ce2f296..6854b1862e5c74ff4c4e6a261770444bf3e17217 100644 (file)
function sieve_vacation($data,$object_id)
{
+
+ $this->object_id = $object_id;
/* Usage: vacation [":days" number] [":subject" string]
[":from" string] [":addresses" string-list]
[":mime"] [":handle" string] <reason: string> */
/* Not all attribute types are supported by the sieve class right now */
$known_attrs = array(":days",":subject",":from",":mime",":handle");
+ /* skip if empty */
+ if(($data == NULL) || !is_array($data)) return;
+
/* Walk through elements */
for($i = 0 ; $i < count($data['ELEMENTS']) ; $i ++){
}
/* Add the vacation message */
- if($node['class'] == "quoted-string"){
- $this->reason = $node['text'];
+ if(in_array($node['class'],array("quoted-string","multi-line"))){
+
+ $tmp = sieve_get_strings($data['ELEMENTS'],$i);
+ $strs= $tmp['STRINGS'];
+
+ $data = "";
+ foreach($strs as $str){
+ $data .= $str;
+ }
+ $this->reason = $data;//preg_replace("/\"/","",$data);
}
}
}
if($this->days){
$str.= ":days ".$this->days;
}
- $str .= ":addresses ".sieve_create_strings($this->addresses);
- if($this->subject){
- $str.= ":subject ".sieve_create_strings($this->subject);
+
+ if(count($this->addresses)){
+ $str .= ":addresses ".sieve_create_strings($this->addresses);
+ if($this->subject){
+ $str.= ":subject ".sieve_create_strings($this->subject);
+ }
}
if($this->mime){
$str.= ":mime ".sieve_create_strings($this->mime);
$tmp = array();
$tmp2 = split(",",$vr);
foreach($tmp2 as $val){
- $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\"";
+ $ad = trim(preg_replace("/\"/","",$val));
+ if(!empty($ad)){
+ $tmp[] = "\"".$ad."\"";
+ }
}
$this->addresses = $tmp;
}
$this->reason = "\"".trim(preg_replace("/\"/","",$vr))."\"";
}
}
+
+ function check()
+ {
+ $msgs = array();
+ $err = FALSE;
+ foreach($this->addresses as $addr){
+ if(!is_email(preg_replace("/\"/","",$addr))){
+ $err = true;
+ }
+ }
+ if($err){
+ $msgs[] = _("Alternative sender addresse must be valid email addresses.");
+ }
+ return($msgs);
+ }
+
function execute()
{
$Addresses = "";
$Addresses .= $key.", ";
}
$Addresses = preg_replace("/,$/","",trim($Addresses));
+
$smarty = get_smarty();
+ $smarty->assign("LastError",$this->check());
+ $smarty->assign("LastErrorCnt",count($this->check()));
$smarty->assign("Reason",$this->reason);
$smarty->assign("Addresses",$Addresses);
$smarty->assign("Subject",$this->subject);
$smarty->assign("Days",$this->days);
$smarty->assign("ID",$this->object_id);
$smarty->assign("Expert",$this->Expert);
- return($smarty->fetch(get_template_path("templates/element_vacation.tpl",TRUE,dirname(__FILE__))));
+
+ $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
+ $object= $smarty->fetch(get_template_path("templates/element_vacation.tpl",TRUE,dirname(__FILE__)));
+ $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+ return($str);
}
}