isAttachment() public method

For our purposes, an attachment is any MIME part that can be downloaded by itself (i.e. all the data needed to view the part is contained within the download data).
public isAttachment ( string $id, string $mime_type ) : boolean
$id string The MIME Id for the part we are checking.
$mime_type string The MIME type.
return boolean True if an attachment.
示例#1
0
 public function testReplaceMime()
 {
     $fixture = file_get_contents(__DIR__ . '/fixtures/signed_attachment.eml');
     $mime = new Horde_ActiveSync_Mime(Horde_Mime_Part::parseMessage($fixture));
     foreach ($mime->contentTypeMap() as $id => $type) {
         if ($mime->isAttachment($id, $type)) {
             $part = new Horde_Mime_Part();
             $part->setType('text/plain');
             $part->setContents(sprintf('An attachment named %s was removed by Horde_ActiveSync_Test', $mime->getPart($id)->getName(true)));
             $mime->removePart($id);
             $mime->addPart($part);
         }
     }
     $this->assertEquals(true, $mime->hasAttachments());
     $this->assertEquals('An attachment named foxtrotjobs.png was removed by Horde_ActiveSync_Test', $mime->getPart('3')->getContents());
 }
示例#2
0
 /**
  * Determines if a MIME type is an attachment.
  * For our purposes, an attachment is any MIME part that can be
  * downloaded by itself (i.e. all the data needed to view the part is
  * contained within the download data).
  *
  * @param string $id         The MIME Id for the part we are checking.
  * @param string $mime_type  The MIME type.
  *
  * @return boolean  True if an attachment.
  * @deprecated Will be removed in 3.0 (Only used in self::hasAttachments call).
  */
 public function isAttachment($id, $mime_type)
 {
     return $this->_message->isAttachment($id, $mime_type);
 }