diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index ceac2dcfad2..619c124af88 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -108,10 +108,9 @@ class OC_Contacts_VCard{ if(!is_null($card)){ $fn = $card->getAsString('FN'); $uid = $card->getAsString('UID'); - if(is_null($uid)){ + if(!$uid){ $card->setUID(); $uid = $card->getAsString('UID'); - //$data = $card->serialize(); }; $uri = $uid.'.vcf'; @@ -158,14 +157,19 @@ class OC_Contacts_VCard{ * @return insertid */ public static function addFromDAVData($id,$uri,$data){ - $fn = null; - $email = null; + $fn = $n = $uid = $email = null; $card = OC_VObject::parse($data); if(!is_null($card)){ foreach($card->children as $property){ if($property->name == 'FN'){ $fn = $property->value; } + if($property->name == 'N'){ + $n = $property->value; + } + if($property->name == 'UID'){ + $uid = $property->value; + } if($property->name == 'EMAIL' && is_null($email)){ $email = $property->value; } @@ -180,6 +184,10 @@ class OC_Contacts_VCard{ $card->addProperty('EMAIL', $email); $data = $card->serialize(); } + 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()));