/** * get sieve vacation object * * @return Felamimail_Sieve_Vacation */ public function getFSV() { $fsv = new Felamimail_Sieve_Vacation(); $fsv->setEnabled($this->enabled)->setDays($this->days)->setSubject($this->subject)->setFrom($this->from)->setMime($this->mime)->setReason($this->reason); if (is_array($this->addresses)) { foreach ($this->addresses as $address) { $fsv->addAddress($address); } } return $fsv; }
/** * 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 Felamimail_Sieve_Vacation */ public function getFSV() { $fsv = new Felamimail_Sieve_Vacation(); $fsv->setEnabled($this->enabled)->setDays($this->days && (int) $this->days > 0 ? (int) $this->days : 7)->setSubject($this->subject)->setFrom($this->from)->setMime($this->mime)->setReason($this->reason)->setDateEnabled($this->date_enabled); $this->setTimezone(Tinebase_Core::getUserTimezone()); 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; }
/** * test disabled vacation */ public function testDisabledVacation() { $script = new Felamimail_Sieve_Backend_Script(); $vacation = new Felamimail_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('Felamimail_Sieve_Vacation', $sieveScript); $this->assertContains('Tine 2.0 Unit Test', $sieveScript); }
/** * parse sieve parts and set vacation * * @param array $parts */ protected function _parseSmartSieveVacation($parts) { $vacation = new Felamimail_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); }