summaryrefslogtreecommitdiff
path: root/plugins/vcard_attachments
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-08-13 19:21:21 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2010-08-13 19:21:21 +0000
commit3e496a51aae9f2d41ba220d17e2aae8ba7ea7d59 (patch)
tree493686a0c79671b24b3c29a002be315d0e384950 /plugins/vcard_attachments
parentb5abab330f033d1a0c32b1a8c361b65afc1dd21b (diff)
- Recognize Apple Address Book vcards (#1486916)
git-svn-id: https://svn.roundcube.net/trunk@3897 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/vcard_attachments')
-rw-r--r--plugins/vcard_attachments/vcard_attachments.php43
1 files changed, 28 insertions, 15 deletions
diff --git a/plugins/vcard_attachments/vcard_attachments.php b/plugins/vcard_attachments/vcard_attachments.php
index 17dff4dc3..4bf9accbb 100644
--- a/plugins/vcard_attachments/vcard_attachments.php
+++ b/plugins/vcard_attachments/vcard_attachments.php
@@ -26,32 +26,21 @@ class vcard_attachments extends rcube_plugin
}
/**
- * Check message attachments for vcards
+ * Check message bodies and attachments for vcards
*/
function message_load($p)
{
$this->message = $p['object'];
- // handle attachments with specified content type:
- // Content-Type: text/vcard;
- // Content-Type: text/x-vcard;
- // Content-Type: text/directory; profile=vCard;
+ // handle attachments vcard attachments
foreach ((array)$this->message->attachments as $attachment) {
- if ($attachment->mimetype == 'text/vcard' ||
- $attachment->mimetype == 'text/x-vcard' ||
- ($attachment->mimetype == 'text/directory' && $attachment->ctype_parameters['profile']
- && strtolower($attachment->ctype_parameters['profile']) == 'vcard')
- ) {
+ if ($this->is_vcard($attachment)) {
$this->vcard_parts[] = $attachment->mime_id;
}
}
// the same with message bodies
foreach ((array)$this->message->parts as $idx => $part) {
- if ($part->mimetype == 'text/vcard' ||
- $part->mimetype == 'text/x-vcard' ||
- ($part->mimetype == 'text/directory' && $part->ctype_parameters['profile']
- && strtolower($part->ctype_parameters['profile']) == 'vcard')
- ) {
+ if ($this->is_vcard($part)) {
$this->vcard_parts[] = $part->mime_id;
$this->vcard_bodies[] = $part->mime_id;
}
@@ -157,4 +146,28 @@ class vcard_attachments extends rcube_plugin
$rcmail->output->send();
}
+ /**
+ * Checks if specified message part is a vcard data
+ *
+ * @param rcube_message_part Part object
+ *
+ * @return boolean True if part is of type vcard
+ */
+ function is_vcard($part)
+ {
+ return (
+ // Content-Type: text/vcard;
+ $part->mimetype == 'text/vcard' ||
+ // Content-Type: text/x-vcard;
+ $part->mimetype == 'text/x-vcard' ||
+ // Content-Type: text/directory; profile=vCard;
+ ($part->mimetype == 'text/directory' && (
+ ($part->ctype_parameters['profile'] &&
+ strtolower($part->ctype_parameters['profile']) == 'vcard')
+ // Content-Type: text/directory; (with filename=*.vcf)
+ || ($part->filename && preg_match('/\.vcf$/i', $part->filename))
+ )
+ )
+ );
+ }
}