1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00

Use setPropertyByName

This commit is contained in:
LEDfan 2014-12-07 09:22:13 +01:00
parent adfbbe3fbf
commit 5a653a2a52

View File

@ -188,39 +188,7 @@ SQL;
$contact = $addressBook->getChild($id);
foreach($properties as $name => $value) {
switch($name) {
case 'ADR':
case 'N':
if(is_array($value)) {
$property = \Sabre\VObject\Property::create($name);
$property->setValue($value);
$contact->add($property);
} else {
$contact->{$name} = $value;
}
break;
case 'BDAY':
// TODO: try/catch
$date = New \DateTime($value);
$contact->BDAY = $date->format('Y-m-d');
$contact->BDAY->VALUE = 'DATE';
break;
case 'EMAIL':
case 'TEL':
case 'IMPP': // NOTE: We don't know if it's GTalk, Jabber etc. only the protocol
case 'URL':
if(is_array($value)) {
foreach($value as $val) {
$contact->add($name, strip_tags($val));
}
} else {
$contact->add($name, strip_tags($value));
}
break;
default:
$contact->{$name} = $value;
break;
}
$contact->setPropertyByName($name, $value);
}
$contact->save();