/**
* Determines if a MIME type is an attachment.
*
* @param Horde_Mime_Part $part The MIME part.
*/
public static function isAttachment(Horde_Mime_Part $part)
{
$type = $part->getType();
switch ($type) {
case 'application/ms-tnef':
case 'application/pgp-keys':
case 'application/vnd.ms-tnef':
return false;
}
if ($part->parent) {
switch ($part->parent->getType()) {
case 'multipart/encrypted':
switch ($type) {
case 'application/octet-stream':
return false;
}
break;
case 'multipart/signed':
switch ($type) {
case 'application/pgp-signature':
case 'application/pkcs7-signature':
case 'application/x-pkcs7-signature':
return false;
}
break;
}
}
switch ($part->getDisposition()) {
case 'attachment':
return true;
}
switch ($part->getPrimaryType()) {
case 'application':
if (strlen($part->getName())) {
return true;
}
break;
case 'audio':
case 'video':
return true;
case 'multipart':
return false;
}
return false;
}