コード例 #1
0
ファイル: Sieve.php プロジェクト: rodrigofns/ExpressoLivre3
 /**
  * check sieve backend capabilities
  * 
  * @param Felamimail_Model_Sieve_Vacation $_vacation
  */
 protected function _checkCapabilities(Felamimail_Model_Sieve_Vacation $_vacation)
 {
     $capabilities = $this->_backend->capability();
     if (!in_array('mime', $capabilities['SIEVE'])) {
         unset($_vacation->mime);
         $_vacation->reason = Felamimail_Model_Message::convertHTMLToPlainTextWithQuotes($_vacation->reason);
     }
     if (preg_match('/cyrus/i', $capabilities['IMPLEMENTATION'])) {
         // cyrus does not support :from
         unset($_vacation->from);
     }
 }
コード例 #2
0
 /**
  * do substitutions in vacation message
  * 
  * @param Felamimail_Model_Sieve_Vacation $vacation
  * @param string $message
  * @return string
  * 
  * @todo get locale from placeholder (i.e. endDate-_LOCALESTRING_)
  * @todo get field from placeholder (i.e. representation-_FIELDNAME_)
  * @todo use html templates?
  * @todo use ZF templates / phplib tpl files?
  */
 protected function _doMessageSubstitutions(Felamimail_Model_Sieve_Vacation $vacation, $message)
 {
     $timezone = Tinebase_Core::getUserTimezone();
     $representatives = $vacation->contact_ids ? Addressbook_Controller_Contact::getInstance()->getMultiple($vacation->contact_ids) : array();
     if ($vacation->contact_ids && count($representatives) > 0) {
         // sort representatives
         $representativesArray = array();
         foreach ($vacation->contact_ids as $id) {
             $representativesArray[] = $representatives->getById($id);
         }
     }
     try {
         $ownContact = Addressbook_Controller_Contact::getInstance()->getContactByUserId(Tinebase_Core::getUser()->getId());
     } catch (Exception $e) {
         if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $e);
         }
         $ownContact = NULL;
     }
     $search = array('{startDate-en_US}', '{endDate-en_US}', '{startDate-de_DE}', '{endDate-de_DE}', '{representation-n_fn-1}', '{representation-n_fn-2}', '{representation-email-1}', '{representation-email-2}', '{representation-tel_work-1}', '{representation-tel_work-2}', '{owncontact-n_fn}', '{signature}');
     $replace = array(Tinebase_Translation::dateToStringInTzAndLocaleFormat($vacation->start_date, $timezone, new Zend_Locale('en_US'), 'date'), Tinebase_Translation::dateToStringInTzAndLocaleFormat($vacation->end_date, $timezone, new Zend_Locale('en_US'), 'date'), Tinebase_Translation::dateToStringInTzAndLocaleFormat($vacation->start_date, $timezone, new Zend_Locale('de_DE'), 'date'), Tinebase_Translation::dateToStringInTzAndLocaleFormat($vacation->end_date, $timezone, new Zend_Locale('de_DE'), 'date'), isset($representativesArray[0]) ? $representativesArray[0]->n_fn : 'unknown person', isset($representativesArray[1]) ? $representativesArray[1]->n_fn : 'unknown person', isset($representativesArray[0]) ? $representativesArray[0]->email : 'unknown email', isset($representativesArray[1]) ? $representativesArray[1]->email : 'unknown email', isset($representativesArray[0]) ? $representativesArray[0]->tel_work : 'unknown phone', isset($representativesArray[1]) ? $representativesArray[1]->tel_work : 'unknown phone', $ownContact ? $ownContact->n_fn : '', $vacation->signature ? Felamimail_Model_Message::convertHTMLToPlainTextWithQuotes(preg_replace("/\\r|\\n/", '', $vacation->signature)) : '');
     $result = str_replace($search, $replace, $message);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $result);
     }
     return $result;
 }