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

Contacts: Move checksum check to Contact.

This commit is contained in:
Thomas Tanghus 2013-03-13 05:57:35 +01:00
parent 006bf317f4
commit e956420b1e

View File

@ -189,7 +189,9 @@ class Contact extends VObject\VCard implements IPIMObject {
public function read($data = null) {
// NOTE: Maybe this will mess with
// the magic accessors.
if(!$this->children) {
if($this->children && is_null($data)) {
return true;
} else {
if(isset($this->props['vcard'])
&& $this->props['vcard'] instanceof VObject\VCard) {
$this->children = $this->props['vcard']->children();
@ -238,6 +240,24 @@ class Contact extends VObject\VCard implements IPIMObject {
return true;
}
/**
* Get a property by the checksum of its serialized value
*
* @param string $checksum An 8 char m5d checksum.
* @return \Sabre\VObject\Propert|null
*/
public function getPropertyByChecksum($checksum) {
$this->read();
$line = null;
foreach($this->children as $i => $property) {
if(substr(md5($property->serialize()), 0, 8) == $checksum ) {
$line = $i;
break;
}
}
return isset($this->children[$line]) ? $this->children[$line] : null;
}
public function lastModified() {
if(!isset($this->props['lastmodified'])) {
$this->read();
@ -246,4 +266,4 @@ class Contact extends VObject\VCard implements IPIMObject {
? isset($this->props['lastmodified'])
: null;
}
}
}