]> source.dussan.org Git - nextcloud-server.git/commitdiff
Modify check for missing UID.
authorThomas Tanghus <thomas@tanghus.net>
Tue, 14 Feb 2012 00:56:38 +0000 (01:56 +0100)
committerThomas Tanghus <thomas@tanghus.net>
Tue, 14 Feb 2012 00:56:38 +0000 (01:56 +0100)
apps/contacts/lib/vcard.php

index f10af83964c5bf7af03965bc2bfea9b1361c64f9..cc25c009d67d10b6151c1d42444d33f399ac0cec 100644 (file)
@@ -124,10 +124,9 @@ class OC_Contacts_VCard{
                                OC_Log::write('contacts','OC_Contacts_VCard::add. Added missing \'N\' field: '.$n,OC_Log::DEBUG);
                        }
                        $uid = $card->getAsString('UID');
-                       if(is_null($uid)){
+                       if(!$uid){
                                $card->setUID();
                                $uid = $card->getAsString('UID');
-                               //$data = $card->serialize();
                        };
                        $uri = $uid.'.vcf';
 
@@ -176,7 +175,7 @@ class OC_Contacts_VCard{
         * @return insertid
         */
        public static function addFromDAVData($id,$uri,$data){
-               $fn = $n = null;
+               $fn = $n = $uid = null;
                $email = null;
                $card = OC_VObject::parse($data);
                if(!is_null($card)){
@@ -187,6 +186,9 @@ class OC_Contacts_VCard{
                                if($property->name == 'N'){
                                        $n = $property->value;
                                }
+                               if($property->name == 'UID'){
+                                       $uid = $property->value;
+                               }
                                if($property->name == 'EMAIL' && is_null($email)){
                                        $email = $property->value;
                                }
@@ -210,6 +212,10 @@ class OC_Contacts_VCard{
                        $data = $card->serialize();
                        OC_Log::write('contacts','OC_Contacts_VCard::add. Added missing \'N\' field: '.$n,OC_Log::DEBUG);
                }
+               if(!$uid) {
+                       $card->setUID();
+                       $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()));