Since: 2.19.0
Author: Michael J Rubinsky (mrubinsk@horde.org)
示例#1
0
 public function testHasiCalendar()
 {
     $fixture = file_get_contents(__DIR__ . '/fixtures/invitation_one.eml');
     $mime = new Horde_ActiveSync_Mime(Horde_Mime_Part::parseMessage($fixture));
     $this->assertEquals(true, $mime->hasAttachments());
     $this->assertEquals(false, $mime->isSigned());
     $this->assertEquals(true, (bool) $mime->hasiCalendar());
 }
示例#2
0
 /**
  * Determine which parts we need, and fetches them from the IMAP client.
  * Takes into account the available parts and the BODYPREF/BODYPARTPREF
  * options.
  */
 protected function _getParts()
 {
     // Look for the parts we need. We try to detect and fetch only the parts
     // we need, while ensuring we have something to return. So, e.g., if we
     // don't have BODYPREF_TYPE_HTML, we only request plain text, but if we
     // can't find plain text but we have a html body, fetch that anyway.
     $text_id = $this->_basePart->findBody('plain');
     $html_id = $this->_basePart->findBody('html');
     // Deduce which part(s) we need to request.
     $want_html_text = $this->_wantHtml();
     $want_plain_text = $this->_wantPlainText($html_id, $want_html_text);
     $want_html_as_plain = false;
     if (!empty($text_id) && $want_plain_text) {
         $text_body_part = $this->_basePart->getPart($text_id);
     } elseif ($want_plain_text && !empty($html_id) && empty($this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_MIME])) {
         $want_html_text = true;
         $want_html_as_plain = true;
     }
     if (!empty($html_id) && $want_html_text) {
         $html_body_part = $this->_basePart->getPart($html_id);
     }
     // Make sure we have truncation if needed.
     if (empty($this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN]) && !empty($this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_HTML]) && $want_plain_text && $want_html_text) {
         // We only have HTML truncation data, requested HTML body but only
         // have plaintext.
         $this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN] = $this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_HTML];
     }
     // Fetch the data from the IMAP client.
     $data = $this->_fetchData(array('html_id' => $html_id, 'text_id' => $text_id));
     if (!empty($text_id) && $want_plain_text) {
         $this->_plain = $this->_getPlainPart($data, $text_body_part);
     }
     if (!empty($html_id) && $want_html_text) {
         $results = $this->_getHtmlPart($data, $html_body_part, $want_html_as_plain);
         $this->_html = !empty($results['html']) ? $results['html'] : null;
         $this->_plain = !empty($results['plain']) ? $results['plain'] : null;
     }
     if (!empty($this->_options['bodypartprefs'])) {
         $this->_bodyPart = $this->_getBodyPart($data, !empty($html_id) ? $html_body_part : $text_body_part, empty($html_id));
     }
     $text_body_part = null;
     $html_body_part = null;
 }
示例#3
0
 /**
  * Determine which parts we need, and fetches them from the IMAP client.
  * Takes into account the available parts and the BODYPREF/BODYPARTPREF
  * options.
  */
 protected function _getParts()
 {
     // Look for the parts we need. We try to detect and fetch only the parts
     // we need, while ensuring we have something to return. So, e.g., if we
     // don't have BODYPREF_TYPE_HTML, we only request plain text, but if we
     // can't find plain text but we have a html body, fetch that anyway.
     //
     // If this is any type of Report (like a NDR) we can't use findBody
     // since some MTAs generate MDRs with no explicit mime type in the
     // human readable portion (the first part). We assume the MDR contains
     // three parts as specified in the RFC: (1) A human readable part, (2)
     // A machine parsable body Machine parsable body part
     // [message/disposition-notification] and (3) The (optional) original
     // message [message/rfc822]
     switch ($this->_basePart->getType()) {
         case 'message/disposition-notification':
             // OL may send this without an appropriate multipart/report wrapper.
             // Not sure what to do about this yet. Probably parse the machine
             // part and write out some basic text?
             break;
         case 'multipart/report':
             $iterator = $this->_basePart->partIterator(false);
             $iterator->rewind();
             if (!($curr = $iterator->current())) {
                 break;
             }
             $text_id = $curr->getMimeId();
             $html_id = null;
             break;
         default:
             $text_id = $this->_basePart->findBody('plain');
             $html_id = $this->_basePart->findBody('html');
     }
     // Deduce which part(s) we need to request.
     $want_html_text = $this->_wantHtml();
     $want_plain_text = $this->_wantPlainText($html_id, $want_html_text);
     $want_html_as_plain = false;
     if (!empty($text_id) && $want_plain_text) {
         $text_body_part = $this->_basePart->getPart($text_id);
     } elseif ($want_plain_text && !empty($html_id) && empty($this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_MIME])) {
         $want_html_text = true;
         $want_html_as_plain = true;
     }
     if (!empty($html_id) && $want_html_text) {
         $html_body_part = $this->_basePart->getPart($html_id);
     }
     // Make sure we have truncation if needed.
     if (empty($this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN]) && !empty($this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_HTML]) && $want_plain_text && $want_html_text) {
         // We only have HTML truncation data, requested HTML body but only
         // have plaintext.
         $this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN] = $this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_HTML];
     }
     // Fetch the data from the IMAP client.
     $data = $this->_fetchData(array('html_id' => $html_id, 'text_id' => $text_id));
     if (!empty($text_id) && $want_plain_text) {
         $this->_plain = $this->_getPlainPart($data, $text_body_part);
     }
     if (!empty($html_id) && $want_html_text) {
         $results = $this->_getHtmlPart($data, $html_body_part, $want_html_as_plain);
         $this->_html = !empty($results['html']) ? $results['html'] : null;
         $this->_plain = !empty($results['plain']) ? $results['plain'] : null;
     }
     if (!empty($this->_options['bodypartprefs'])) {
         $this->_bodyPart = $this->_getBodyPart($data, !empty($html_id) ? $html_body_part : $text_body_part, empty($html_id));
     }
     $text_body_part = null;
     $html_body_part = null;
 }
示例#4
0
 /**
  * Return the S/MIME encryption status of this message (RFC2633)
  *
  * @param Horde_Mime_Part $message  A mime part to check. If omitted, use
  *                                  self::$_message.
  *
  * @return boolean True if message is S/MIME signed or encrypted,
  *                 false otherwise.
  */
 public function isEncrypted(Horde_Mime_Part $message = null)
 {
     if (!empty($message)) {
         $message = new Horde_ActiveSync_Mime($message);
         return $message->isEncrypted();
     }
     return $this->basePart->isEncrypted();
 }
示例#5
0
 /**
  * Return the S/MIME status of this message (RFC2633)
  *
  * @param Horde_Mime_Part $message  A mime part to check. If omitted, use
  *                                  $this->_message.
  *
  * @return boolean True if message is S/MIME signed or encrypted,
  *                 false otherwise.
  */
 public function isSigned(Horde_Mime_Part $message = null)
 {
     if (!empty($message)) {
         $message = new Horde_ActiveSync_Mime($message);
         return $message->isSigned();
     }
     return $this->_message->isSigned();
 }