/** * convert signature to text to remove all html tags and spaces/linebreaks, if the remains are empty -> set empty signature * * @param Felamimail_Model_Account $account */ protected function _checkSignature($account) { if (empty($account->signature)) { return; } $plainTextSignature = Felamimail_Message::convertFromHTMLToText($account->signature, "\n"); if (!preg_match('/[^\\s^\\n]/', $plainTextSignature, $matches)) { $account->signature = ''; } }
/** * prepare message parts that could be interesting for other apps * * @param Felamimail_Model_Message $_message */ public function prepareAndProcessParts(Felamimail_Model_Message $_message) { $preparedParts = new Tinebase_Record_RecordSet('Felamimail_Model_PreparedMessagePart'); foreach ($this->_supportedForeignContentTypes as $application => $contentType) { if (!Tinebase_Application::getInstance()->isInstalled($application) || !Tinebase_Core::getUser()->hasRight($application, Tinebase_Acl_Rights::RUN)) { if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' ' . $application . ' not installed or access denied.'); } continue; } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Looking for ' . $application . '[' . $contentType . '] content ...'); } $parts = $_message->getBodyParts(NULL, $contentType); foreach ($parts as $partId => $partData) { if ($partData['contentType'] !== $contentType) { continue; } if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' ' . $application . '[' . $contentType . '] content found.'); } $preparedPart = $this->_getForeignMessagePart($_message, $partId, $partData); if ($preparedPart) { $this->_processForeignMessagePart($application, $preparedPart); $preparedParts->addRecord(new Felamimail_Model_PreparedMessagePart(array('id' => $_message->getId() . '_' . $partId, 'contentType' => $contentType, 'preparedData' => $preparedPart))); } } } // PGP MIME Version 1 if ($_message->structure['contentType'] == 'multipart/encrypted' && isset($_message->structure['parts'][1]['subType']) && $_message->structure['parts'][1]['subType'] == 'pgp-encrypted') { $identification = $this->getMessagePart($_message, 1)->getContent(); if (strpos($identification, 'Version: 1') !== FALSE) { $amored = $this->getMessagePart($_message, 2)->getContent(); $preparedParts->addRecord(new Felamimail_Model_PreparedMessagePart(array('id' => $_message->getId() . '_2', 'contentType' => 'application/pgp-encrypted', 'preparedData' => $amored))); } } // PGP INLINE if (strpos($_message->body, '-----BEGIN PGP MESSAGE-----') !== false) { preg_match('/-----BEGIN PGP MESSAGE-----.*-----END PGP MESSAGE-----/', $_message->body, $matches); $amored = Felamimail_Message::convertFromHTMLToText($matches[0]); $preparedParts->addRecord(new Felamimail_Model_PreparedMessagePart(array('id' => $_message->getId(), 'contentType' => 'application/pgp-encrypted', 'preparedData' => $amored))); } $_message->preparedParts = $preparedParts; }