From 3f1486534f687fdcad219b97072ed71a2998de87 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 31 Jan 2012 19:26:26 +0100 Subject: - Fixed http://bugs.owncloud.org/thebuggenie/owncloud/issues/oc-93 Property was added multiple times. - Fixed http://bugs.owncloud.org/thebuggenie/owncloud/issues/oc-8 "Missing "N" field: Contacts app not compatible with vcard 3.0 format" - Almost sure I've fixed http://bugs.owncloud.org/thebuggenie/owncloud/issues/oc-27 "Full name in Contacts app doesn't sync to iOS 5 contacts" because it is caused by oc-8 --- apps/contacts/ajax/addproperty.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'apps/contacts/ajax/addproperty.php') diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index a4b5c591197..c90af217c87 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -54,6 +54,21 @@ if(!is_array($value)){ } $parameters = isset($_POST['parameters']) ? $_POST['parameters'] : array(); +// Prevent setting a duplicate entry +$current = $vcard->select($name); +foreach($current as $item) { + $tmpvalue = (is_array($value)?implode(';', $value):$value); + if($tmpvalue == $item->value) { + OC_JSON::error(array('data' => array('message' => $l->t('Trying to add duplicate property: ').$name.': '.$tmpvalue))); + OC_Log::write('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name.': '.$tmpvalue, OC_Log::DEBUG); + exit(); + } +} + +if(is_array($value)) { + ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form! +} + $property = $vcard->addProperty($name, $value); //, $parameters); $line = count($vcard->children) - 1; @@ -74,14 +89,6 @@ foreach ($parameters as $key=>$element) { } $checksum = md5($vcard->children[$line]->serialize()); -/* FIXME: OC_Contacts_App::getPropertyLineByChecksum throws an OC_JSON error when doing this check. - Fix for v. 3.1 -if(!is_null(OC_Contacts_App::getPropertyLineByChecksum($id, $checksum))) { - OC_JSON::error(array('data' => array('message' => $l->t('Trying to add duplicate property.')))); - OC_Log::write('contacts','ajax/addproperty.php: Trying to add duplicate property: '.$name, OC_Log::DEBUG); - exit(); -} -*/ if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) { OC_JSON::error(array('data' => array('message' => $l->t('Error adding contact property.')))); OC_Log::write('contacts','ajax/addproperty.php: Error updating contact property: '.$name, OC_Log::ERROR); -- cgit v1.2.3