/** * get vacation message defined by template / do substitutions for dates and representative * * @param array $vacationData * @return array */ public function getVacationMessage($vacationData) { $record = new Felamimail_Model_Sieve_Vacation(array(), TRUE); $record->setFromJsonInUsersTimezone($vacationData); $message = Felamimail_Controller_Sieve::getInstance()->getVacationMessage($record); $htmlMessage = Tinebase_Mail::convertFromTextToHTML($message, 'felamimail-body-blockquote'); return array('message' => $htmlMessage); }
/** * 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); } }
/** * 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); }
/** * get vacation message defined by template / do substitutions for dates and representative * * @param Felamimail_Model_Sieve_Vacation $vacation * @return string */ public function getVacationMessage(Felamimail_Model_Sieve_Vacation $vacation) { if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($vacation->toArray(), TRUE)); } $message = $this->_getMessageFromTemplateFile($vacation->template_id); $message = $this->_doMessageSubstitutions($vacation, $message); return $message; }
/** * set sieve vacation for account * * @param array $recordData * @return array */ public function saveVacation($recordData) { $record = new Felamimail_Model_Sieve_Vacation(array(), TRUE); $record->setFromJsonInUsersTimezone($recordData); $record = Felamimail_Controller_Sieve::getInstance()->setVacation($record); return $this->_recordToJson($record); }
/** * 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); } }