1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-30 19:52:17 +01:00

Contacts: Fix deleting properties.

This commit is contained in:
Thomas Tanghus 2013-03-26 12:35:37 +01:00
parent a82de8fad8
commit 3d5e740325

View File

@ -328,6 +328,25 @@ class Contact extends VObject\VCard implements IPIMObject {
return true;
}
/**
* Get a property index in the contact by the checksum of its serialized value
*
* @param string $checksum An 8 char m5d checksum.
* @return \Sabre\VObject\Property Property by reference
* @throws An exception with error code 404 if the property is not found.
*/
public function getPropertyIndexByChecksum($checksum) {
$this->retrieve();
$idx = 0;
foreach($this->children as $i => &$property) {
if(substr(md5($property->serialize()), 0, 8) == $checksum ) {
return $idx;
}
$idx += 1;
}
throw new Exception('Property not found', 404);
}
/**
* Get a property by the checksum of its serialized value
*
@ -353,8 +372,9 @@ class Contact extends VObject\VCard implements IPIMObject {
* @throws @see getPropertyByChecksum
*/
public function unsetPropertyByChecksum($checksum) {
$property = $this->getPropertyByChecksum($checksum);
unset($property);
$idx = $this->getPropertyIndexByChecksum($checksum);
unset($this->children[$idx]);
$this->setSaved(false);
}
/**
@ -399,6 +419,7 @@ class Contact extends VObject\VCard implements IPIMObject {
break;
}
$this->setParameters($property, $parameters);
$this->setSaved(false);
return substr(md5($property->serialize()), 0, 8);
}
@ -447,6 +468,7 @@ class Contact extends VObject\VCard implements IPIMObject {
$this->{$name} = $value;
break;
}
$this->setSaved(false);
return true;
}