コード例 #1
0
 /**
  * Send the reading confirmation in a message who has the correct header and is not seen yet
  *
  * @return void
  */
 public function sendReadingConfirmation()
 {
     if (!is_array($this->headers)) {
         $this->headers = Felamimail_Controller_Message::getInstance()->getMessageHeaders($this->getId(), NULL, TRUE);
     }
     if ((isset($this->headers['disposition-notification-to']) || array_key_exists('disposition-notification-to', $this->headers)) && $this->headers['disposition-notification-to']) {
         $translate = Tinebase_Translation::getTranslation($this->_application);
         $from = Felamimail_Controller_Account::getInstance()->get($this->account_id);
         $message = new Felamimail_Model_Message();
         $message->account_id = $this->account_id;
         $punycodeConverter = Felamimail_Controller_Message::getInstance()->getPunycodeConverter();
         $to = Felamimail_Message::convertAddresses($this->headers['disposition-notification-to'], $punycodeConverter);
         if (empty($to)) {
             throw new Felamimail_Exception('disposition-notification-to header does not contain a valid email address');
         }
         $message->content_type = Felamimail_Model_Message::CONTENT_TYPE_HTML;
         $message->to = $to[0]['email'];
         $message->subject = $translate->_('Reading Confirmation:') . ' ' . $this->subject;
         $message->body = $translate->_('Your message:') . ' ' . $this->subject . "\n" . $translate->_('Received on') . ' ' . $this->received . "\n" . $translate->_('Was read by:') . ' ' . $from->from . ' <' . $from->email . '> ' . $translate->_('on') . ' ' . date('Y-m-d H:i:s');
         $message->body = Tinebase_Mail::convertFromTextToHTML($message->body, 'felamimail-body-blockquote');
         Felamimail_Controller_Message_Send::getInstance()->sendMessage($message);
     }
 }
コード例 #2
0
 /**
  * convert between content types (text/plain => text/html for example)
  * 
  * @param string $_from
  * @param string $_to
  * @param string $_text
  * @param string $_eol
  * @param boolean $_addMarkup
  * @return string
  * 
  * @todo we should use Felamimail_Model_Message::getPlainTextBody here / move all conversion to one place
  * @todo remove addHtmlMarkup?
  */
 public static function convertContentType($_from, $_to, $_text)
 {
     // nothing todo
     if ($_from == $_to) {
         return $_text;
     }
     if ($_from == Zend_Mime::TYPE_TEXT && $_to == Zend_Mime::TYPE_HTML) {
         $text = Tinebase_Mail::convertFromTextToHTML($_text, 'felamimail-body-blockquote');
         $text = self::addHtmlMarkup($text);
     } else {
         $text = self::convertFromHTMLToText($_text);
     }
     return $text;
 }
コード例 #3
0
 /**
  * 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);
 }
 /**
  * test conversion from plain text to html (quotes ('> > ...') to blockquotes)
  * 
  * @see 0005334: convert plain text quoting ("> ") to html blockquotes
  */
 public function testTextToHtml()
 {
     $plaintextMessage = "blabla\n" . "> lalülüüla\n" . "> \n" . "> > >lala\n" . ">  >\n" . ">  > xyz\n" . "\n\n" . "> jojo\n" . "jojo\n";
     $result = Tinebase_Mail::convertFromTextToHTML($plaintextMessage, 'felamimail-body-blockquote');
     $this->assertEquals('blabla<br /><blockquote class="felamimail-body-blockquote">lalülüüla<br /><br />' . '<blockquote class="felamimail-body-blockquote"><blockquote class="felamimail-body-blockquote">lala<br />' . '</blockquote><br />xyz<br /></blockquote></blockquote><br /><br /><blockquote class="felamimail-body-blockquote">jojo<br /></blockquote>jojo<br />', $result);
 }