From dc20900e10f9a080f1ffa164c1e6b0dd62f6c46b Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 14 Feb 2012 01:56:38 +0100 Subject: [PATCH] Modify check for missing UID. --- apps/contacts/lib/vcard.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index f10af83964c..cc25c009d67 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -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())); -- 2.39.5