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

Contacts: Don't store empty child in AddressBook

This commit is contained in:
Thomas Tanghus 2013-03-28 05:00:51 +01:00
parent ffc13d5cda
commit ca7d8d3332

View File

@ -119,6 +119,7 @@ class Addressbook extends PIMCollectionAbstract {
* @return Contact|null
*/
function getChild($id) {
//\OCP\Util::writeLog('contacts', __METHOD__.' id: '.$id, \OCP\Util::DEBUG);
if(!isset($this->objects[$id])) {
$contact = $this->backend->getContact($this->getId(), $id);
if($contact) {
@ -170,20 +171,13 @@ class Addressbook extends PIMCollectionAbstract {
* @return int|bool
*/
public function addChild($data = null) {
//if($data instanceof VObject\VCard || is_array($data)) {
$contact = new Contact($this, $this->backend, $data);
if($contact->save() === false) {
return false;
}
$id = $contact->getId();
$this->objects[$id] = $contact;
return $id;
/*} else {
throw new Exception(
__METHOD__
. ' This method accepts only an array or an instance of OCA\\Contacts\\VCard'
);
}*/
$contact = new Contact($this, $this->backend, $data);
if($contact->save() === false) {
return false;
}
$id = $contact->getId();
\OCP\Util::writeLog('contacts', __METHOD__.' id: '.$id, \OCP\Util::DEBUG);
return $id;
}
/**