[Svn] r3897 - trunk/plugins/vcard_attachments

trac at roundcube.net trac at roundcube.net
Fri Aug 13 21:21:21 CEST 2010


Author: alec
Date: 2010-08-13 14:21:21 -0500 (Fri, 13 Aug 2010)
New Revision: 3897

Modified:
   trunk/plugins/vcard_attachments/vcard_attachments.php
Log:
- Recognize Apple Address Book vcards (#1486916)


Modified: trunk/plugins/vcard_attachments/vcard_attachments.php
===================================================================
--- trunk/plugins/vcard_attachments/vcard_attachments.php	2010-08-13 06:25:30 UTC (rev 3896)
+++ trunk/plugins/vcard_attachments/vcard_attachments.php	2010-08-13 19:21:21 UTC (rev 3897)
@@ -26,32 +26,21 @@
     }
 
     /**
-     * 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 @@
         $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))
+                )
+            )
+        );
+    }
 }

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list