/** * set vacation for account * * @param Felamimail_Model_Sieve_Vacation $_vacation * @return Felamimail_Model_Sieve_Vacation */ public function setVacation(Felamimail_Model_Sieve_Vacation $_vacation) { $account = Felamimail_Controller_Account::getInstance()->get($_vacation->getId()); $this->_setSieveBackendAndAuthenticate($account); $this->_addVacationUserData($_vacation, $account); $this->_checkCapabilities($_vacation); $this->_addVacationSubject($_vacation); $fsv = $_vacation->getFSV(); $script = $this->_getSieveScript($account); if ($script === NULL) { $script = $this->_createNewSieveScript($account); } $script->setVacation($fsv); if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Put updated vacation SIEVE script ' . $this->_scriptName); } $this->_putScript($account, $script); Felamimail_Controller_Account::getInstance()->setVacationActive($account, $_vacation->enabled); return $this->getVacation($account); }
/** * persist vacation data in db */ protected function _saveVacation() { if (empty($this->_vacation)) { return; } $vacationRecord = new Felamimail_Model_Sieve_Vacation(); $vacationRecord->setFromFSV($this->_vacation); $vacationRecord->account_id = $this->_accountId; $vacationRecord->setId($this->_accountId); $vacationRecord->addresses = Zend_Json::encode($vacationRecord->addresses); if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Saving vacation in DB: ' . print_r($vacationRecord->toArray(), TRUE)); } try { $oldVac = $this->_vacationBackend->get($vacationRecord->getId()); $this->_vacationBackend->update($vacationRecord); } catch (Tinebase_Exception_NotFound $tenf) { $this->_vacationBackend->create($vacationRecord); } }
/** * persist vacation data in db */ protected function _saveVacation() { if (empty($this->_vacation)) { return; } $vacationRecord = new Felamimail_Model_Sieve_Vacation(); $vacationRecord->setFromFSV($this->_vacation); $vacationRecord->account_id = $this->_accountId; $vacationRecord->setId($this->_accountId); $vacationRecord->addresses = Zend_Json::encode($vacationRecord->addresses); try { $oldVac = $this->_vacationBackend->get($vacationRecord->getId()); $this->_vacationBackend->update($vacationRecord); } catch (Tinebase_Exception_NotFound $tenf) { $this->_vacationBackend->create($vacationRecord); } }