Horde_ActiveSync_Imap_Message::getMimePart PHP Méthode

getMimePart() public méthode

Fetch a part of a MIME message.
public getMimePart ( integer $id, array $options = [] ) : Horde_Mime_Part
$id integer The MIME index of the part requested.
$options array Additional options: - length: (integer) If set, only download this many bytes of the bodypart from the server. DEFAULT: All data is retrieved. - nocontents: (boolean) If true, don't add the contents to the part DEFAULT: Contents are added to the part
Résultat Horde_Mime_Part The raw MIME part asked for.
    public function getMimePart($id, array $options = array())
    {
        $part = $this->basePart->getPart($id);
        if ($part && strcasecmp($part->getCharset(), 'ISO-8859-1') === 0) {
            $part->setCharset('windows-1252');
        }
        if (!empty($id) && !is_null($part) && substr($id, -2) != '.0' && empty($options['nocontents']) && !$part->getContents(array('stream' => true))) {
            $body = $this->getBodyPart($id, array('decode' => true, 'length' => empty($options['length']) ? null : $options['length'], 'stream' => true));
            $part->setContents($body, array('encoding' => $this->_lastBodyPartDecode, 'usestream' => true));
        }
        return $part;
    }

Usage Example

Exemple #1
0
 /**
  * Append the current Draft message to the IMAP server.
  *
  * @return array  An array with the following keys:
  *     - uid: (integer)   The new draft message's IMAP UID.
  *     - atchash: (array) An attachment hash of newly added attachments.
  */
 public function append($folderid)
 {
     // Init
     $atc_map = array();
     $atc_hash = array();
     // Create the wrapper part.
     $base = new Horde_Mime_Part();
     $base->setType('multipart/mixed');
     // Check to see if we have any existing parts to add.
     if (!empty($this->_imapMessage)) {
         foreach ($this->_imapMessage->getStructure() as $part) {
             if ($part->isAttachment() && !in_array($part->getMimeId(), $this->_atcDelete)) {
                 $base->addPart($this->_imapMessage->getMimePart($part->getMimeId()));
             }
         }
     }
     // Add body
     $base->addPart($this->_textPart);
     // Add Mime headers
     $base->addMimeHeaders(array('headers' => $this->_headers));
     foreach ($this->_atcAdd as $atc) {
         $base->addPart($atc);
         $atc_map[$atc->displayname] = $atc->clientid;
     }
     $stream = $base->toString(array('stream' => true, 'headers' => $this->_headers->toString()));
     $new_uid = $this->_imap->appendMessage($folderid, $stream, array('\\draft', '\\seen'));
     foreach ($base as $part) {
         if ($part->isAttachment() && !empty($atc_map[$part->getName()])) {
             $atc_hash['add'][$atc_map[$part->getName()]] = $folderid . ':' . $stat['id'] . ':' . $part->getMimeId();
         }
     }
     // If we pulled down an existing Draft, delete it now since the
     // new one will replace it.
     if (!empty($this->_imapMessage)) {
         $this->_imap->deleteMessages(array($this->_draftUid), $folderid);
     }
     return array('uid' => $new_uid, 'atchash' => $atc_hash);
 }
All Usage Examples Of Horde_ActiveSync_Imap_Message::getMimePart