1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +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 * @return Contact|null
*/ */
function getChild($id) { function getChild($id) {
//\OCP\Util::writeLog('contacts', __METHOD__.' id: '.$id, \OCP\Util::DEBUG);
if(!isset($this->objects[$id])) { if(!isset($this->objects[$id])) {
$contact = $this->backend->getContact($this->getId(), $id); $contact = $this->backend->getContact($this->getId(), $id);
if($contact) { if($contact) {
@ -170,20 +171,13 @@ class Addressbook extends PIMCollectionAbstract {
* @return int|bool * @return int|bool
*/ */
public function addChild($data = null) { public function addChild($data = null) {
//if($data instanceof VObject\VCard || is_array($data)) { $contact = new Contact($this, $this->backend, $data);
$contact = new Contact($this, $this->backend, $data); if($contact->save() === false) {
if($contact->save() === false) { return false;
return false; }
} $id = $contact->getId();
$id = $contact->getId(); \OCP\Util::writeLog('contacts', __METHOD__.' id: '.$id, \OCP\Util::DEBUG);
$this->objects[$id] = $contact; return $id;
return $id;
/*} else {
throw new Exception(
__METHOD__
. ' This method accepts only an array or an instance of OCA\\Contacts\\VCard'
);
}*/
} }
/** /**