/**
  * get sieve vacation string
  * 
  * @return string
  */
 protected function _getVacationString()
 {
     if ($this->_vacation && $this->_vacation->isEnabled()) {
         $vacation = $this->_vacation->__toString();
     } else {
         $vacation = '';
     }
     return $vacation;
 }
 /**
  * get sieve vacation object
  * 
  * @return Expressomail_Sieve_Vacation
  */
 public function getFSV()
 {
     $fsv = new Expressomail_Sieve_Vacation();
     $fsv->setEnabled($this->enabled)->setDays(is_int($this->days) && $this->days > 0 ? $this->days : 7)->setSubject($this->subject)->setFrom($this->from)->setMime($this->mime)->setReason($this->reason)->setDateEnabled($this->date_enabled);
     $this->setTimezone(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE));
     if ($this->start_date instanceof Tinebase_DateTime) {
         $fsv->setStartdate($this->start_date->format('Y-m-d'));
     }
     if ($this->end_date instanceof Tinebase_DateTime) {
         $fsv->setEnddate($this->end_date->format('Y-m-d'));
     }
     $this->setTimezone('UTC');
     if (is_array($this->addresses)) {
         foreach ($this->addresses as $address) {
             $fsv->addAddress($address);
         }
     }
     return $fsv;
 }
 /**
  * parse sieve parts and set vacation
  * 
  * @param array $parts
  */
 protected function _parseSmartSieveVacation($parts)
 {
     $vacation = new Expressomail_Sieve_Vacation();
     $vacation->setDays($parts[1])->setReason($this->_unescapeChars($parts[3]))->setEnabled($parts[4] == 'on' ? true : false);
     $addresses = explode(',', $this->_unescapeChars($parts[2]));
     $addresses = array_map('trim', $addresses, array('"'));
     foreach ($addresses as $address) {
         $vacation->addAddress($address);
     }
     $this->setVacation($vacation);
 }
 /**
  * test disabled vacation
  */
 public function testDisabledVacation()
 {
     $script = new Expresomail_Sieve_Backend_Script();
     $vacation = new Expressomail_Sieve_Vacation();
     $vacation->setEnabled(false)->addAddress('*****@*****.**')->setDays(8)->setReason('Tine 2.0 Unit Test');
     $script->setVacation($vacation);
     $sieveScript = $script->getSieve();
     $this->assertNotContains('vacation :days 8 :addresses ["*****@*****.**"]', $sieveScript);
     $this->assertContains('Expressomail_Sieve_Vacation', $sieveScript);
     $this->assertContains('Tine 2.0 Unit Test', $sieveScript);
 }