From: Michael M Slusarz Date: Tue, 18 Nov 2008 21:44:52 +0000 (-0700) Subject: Add findBody() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=59a9148fa38d17bd0b8901d28c9cb3e062ec137a;p=horde.git Add findBody() --- diff --git a/framework/Mime/lib/Horde/Mime/Message.php b/framework/Mime/lib/Horde/Mime/Message.php index d952d37f7..3ebf0befc 100644 --- a/framework/Mime/lib/Horde/Mime/Message.php +++ b/framework/Mime/lib/Horde/Mime/Message.php @@ -123,6 +123,28 @@ class Horde_Mime_Message extends Horde_Mime_Part } /** + * Finds the main "body" text part (if any) in a message. + * "Body" data is the first text part in the base MIME part. + * + * @param string $subtype Specifically search for this subtype. + * + * @return mixed The MIME ID of the main body part, or null if a body + part is not found. + */ + public function findBody($subtype = null) + { + foreach ($this->contentTypeMap() as $mime_id => $mime_type) { + if ((strpos($mime_type, 'text/') === 0) && + (intval($mime_id) == 1) && + (is_null($subtype) || (substr($mime_type, 5) == $subtype))) { + return $mime_id; + } + } + + return null; + } + + /** * Parse an array of MIME structure information into a Horde_Mime_Message * object. * This function can be called statically via: