]> source.dussan.org Git - nextcloud-server.git/commitdiff
- Added fix for empty 'FN' field on import via CardDAV clients.
authorThomas Tanghus <thomas@tanghus.net>
Thu, 19 Jan 2012 18:47:09 +0000 (19:47 +0100)
committerThomas Tanghus <thomas@tanghus.net>
Thu, 19 Jan 2012 18:47:09 +0000 (19:47 +0100)
- Make sure that the contact in the list has a display name.
- More tweaks on thumbnail caching.

apps/contacts/lib/vcard.php
apps/contacts/templates/part.contacts.php
apps/contacts/thumbnail.php

index 04b59a040fbc985c0d89012d693bd767cc127bfa..c99d53c9716b5a0f6ba0f1e43d4ed604da401845 100644 (file)
@@ -159,15 +159,27 @@ class OC_Contacts_VCard{
         */
        public static function addFromDAVData($id,$uri,$data){
                $fn = null;
+               $email = null;
                $card = OC_VObject::parse($data);
                if(!is_null($card)){
                        foreach($card->children as $property){
                                if($property->name == 'FN'){
                                        $fn = $property->value;
-                                       break;
+                               }
+                               if($property->name == 'EMAIL' && is_null($email)){
+                                       $email = $property->value;
                                }
                        }
                }
+               if(!$fn) {
+                       if($email) {
+                               $fn = $email;
+                       } else {
+                               $fn = 'Unknown';
+                       }
+                       $card->addProperty('EMAIL', $email);
+                       $data = $card->serialize();
+               }
 
                $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
                $result = $stmt->execute(array($id,$fn,$data,$uri,time()));
index 8d89e9c7ad1857b12beb80f529be95dc6937f428..7587670f974e26639d05cad175830bb70a7f618c 100644 (file)
@@ -1,3 +1,13 @@
-<?php foreach( $_['contacts'] as $contact ): ?>
-       <li book-id="<?php echo $contact['addressbookid']; ?>" data-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo $contact['fullname']; ?></a> </li>
+<?php foreach( $_['contacts'] as $contact ):
+       $display = trim($contact['fullname']);
+       if(!$display) {
+               $vcard = OC_Contacts_App::getContactVCard($contact['id']);
+               if(!is_null($vcard)) {
+                       $struct = OC_Contacts_VCard::structureContact($vcard);
+                       $display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]';
+               }
+       }
+       echo '<!-- '.$display.' -->';
+?>
+       <li book-id="<?php echo $contact['addressbookid']; ?>" data-id="<?php echo $contact['id']; ?>"><a href="index.php?id=<?php echo $contact['id']; ?>"><?php echo $display; ?></a></li>
 <?php endforeach; ?>
index f2b5701478576e51ffef47ef2619ee3bf36f250c..36d395171a92cd444147a7f830ead179716af633 100644 (file)
@@ -22,8 +22,8 @@
 
 // Init owncloud
 require_once('../../lib/base.php');
-//OC_JSON::checkLoggedIn();
-OC_Util::checkLoggedIn();
+OC_JSON::checkLoggedIn();
+//OC_Util::checkLoggedIn();
 OC_Util::checkAppEnabled('contacts');
 
 function getStandardImage(){