diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-01-31 19:26:26 +0100 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-01-31 19:30:56 +0100 |
commit | 3f1486534f687fdcad219b97072ed71a2998de87 (patch) | |
tree | 62137ae8c829291bbc9daf137ad4f813724565ca /apps/contacts/ajax/addproperty.php | |
parent | db1f77e4f51b1172aabe12defdd8228e9dd3b93b (diff) | |
download | nextcloud-server-3f1486534f687fdcad219b97072ed71a2998de87.tar.gz nextcloud-server-3f1486534f687fdcad219b97072ed71a2998de87.zip |
- 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
Diffstat (limited to 'apps/contacts/ajax/addproperty.php')
-rw-r--r-- | apps/contacts/ajax/addproperty.php | 23 |
1 files changed, 15 insertions, 8 deletions
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); |