From: hickert Date: Fri, 21 Dec 2007 13:59:23 +0000 (+0000) Subject: Multiple edit X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=327ba93d21d7be0013a8e4edf5174c7255079f68;p=gosa.git Multiple edit -Mail: Placeholder in vcacation message will now be replaced with correct values. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8165 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/personal/mail/class_mailAccount.inc b/gosa-core/plugins/personal/mail/class_mailAccount.inc index bb00ffa84..f123d3825 100644 --- a/gosa-core/plugins/personal/mail/class_mailAccount.inc +++ b/gosa-core/plugins/personal/mail/class_mailAccount.inc @@ -423,47 +423,14 @@ class mailAccount extends plugin /* Import vacation message? */ if (isset($_POST["import_vacation"]) && isset($this->vacation[$_POST["vacation_template"]])){ - $contents= ""; - $lines= file($_POST["vacation_template"]); - foreach ($lines as $line){ - if (!preg_match('/^DESC:/', $line)){ - $contents.= $line; - } - } - /* Replace attributes */ - $attrs = array(); - $obj = NULL; - if(isset($this->parent->by_object['user'])){ - $attrs = $this->parent->by_object['user']->attributes; - $obj = $this->parent->by_object['user']; + + /* Save message */ + if($this->multiple_support_active){ + $contents = file_get_contents($_POST["vacation_template"]); }else{ - $obj = new user($this->config,$this->dn); - $attrs = $obj->attributes; - } - - if($obj){ - foreach ($attrs as $val){ - if(preg_match("/dateOfBirth/",$val)){ - if($obj->use_dob){ - $contents= preg_replace("/%$val/",date("Y-d-m",$obj->dateOfBirth),$contents); - } - }else { - $contents= preg_replace("/%$val/", - $obj->$val, $contents); - } - - /* Replace vacation start and end time */ - if(preg_match("/%start/",$contents)){ - $contents = preg_replace("/%start/",date("d.m.Y",$this->gosaVacationStart),$contents); - } - if(preg_match("/%end/",$contents)){ - $contents = preg_replace("/%end/",date("d.m.Y",$this->gosaVacationStop),$contents); - } - } + $contents = $this->prepare_vacation_template(file_get_contents($_POST["vacation_template"])); } - - /* Save message */ $this->gosaVacationMessage= htmlspecialchars($contents); } @@ -1216,6 +1183,50 @@ class mailAccount extends plugin )); } + + /*! \brief Prepare importet vacation string. \ + Replace placeholder like %givenName a.s.o. + @param string Vacation string + @return string Completed vacation string + */ + private function prepare_vacation_template($contents) + { + /* Replace attributes */ + $attrs = array(); + $obj = NULL; + if(isset($this->parent->by_object['user'])){ + $attrs = $this->parent->by_object['user']->attributes; + $obj = $this->parent->by_object['user']; + }else{ + $obj = new user($this->config,$this->dn); + $attrs = $obj->attributes; + } + + if($obj){ + foreach ($attrs as $val){ + if(preg_match("/dateOfBirth/",$val)){ + if($obj->use_dob){ + $contents= preg_replace("/%$val/",date("Y-d-m",$obj->dateOfBirth),$contents); + } + }else { + $contents= preg_replace("/%$val/", + $obj->$val, $contents); + } + + /* Replace vacation start and end time */ + if(preg_match("/%start/",$contents)){ + $contents = preg_replace("/%start/",date("d.m.Y",$this->gosaVacationStart),$contents); + } + if(preg_match("/%end/",$contents)){ + $contents = preg_replace("/%end/",date("d.m.Y",$this->gosaVacationStop),$contents); + } + } + } + return($contents); + } + + + /* Upated shared folder ACLs */ function updateSharedFolder() @@ -1364,6 +1375,12 @@ class mailAccount extends plugin } } $this->gosaMailDeliveryMode = "[".$tmp."]"; + + /* Set vacation message and replace placeholder like %givenName + */ + if(isset($values['gosaVacationMessage'])){ + $this->gosaVacationMessage = $this->prepare_vacation_template($values['gosaVacationMessage']); + } } }