diff --git a/addressbook/inc/class.bocontacts.inc.php b/addressbook/inc/class.bocontacts.inc.php index 4d58e560bd..c8e5acabae 100755 --- a/addressbook/inc/class.bocontacts.inc.php +++ b/addressbook/inc/class.bocontacts.inc.php @@ -420,9 +420,10 @@ class bocontacts extends socontacts * * @param mixed &$contact contact array with key id or (array of) id(s) * @param boolean $deny_account_delete=true if true never allow to delete accounts - * @return boolean true on success or false on failiure + * @param int $check_etag=null + * @return boolean|int true on success or false on failiure, 0 if etag does not match */ - function delete($contact,$deny_account_delete=true) + function delete($contact,$deny_account_delete=true,$check_etag=null) { if (is_array($contact) && isset($contact['id'])) { @@ -436,14 +437,15 @@ class bocontacts extends socontacts { $id = is_array($c) ? $c['id'] : $c; - if ($this->check_perms(EGW_ACL_DELETE,$c,$deny_account_delete) && parent::delete($id)) + $ok = false; + if ($this->check_perms(EGW_ACL_DELETE,$c,$deny_account_delete) && ($ok = parent::delete($id,$check_etag))) { egw_link::unlink(0,'addressbook',$id); $GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $id, 'delete', time()); } else { - return false; + return $ok; } } return true; diff --git a/addressbook/inc/class.socontacts.inc.php b/addressbook/inc/class.socontacts.inc.php index ed56e78161..624f94edb8 100755 --- a/addressbook/inc/class.socontacts.inc.php +++ b/addressbook/inc/class.socontacts.inc.php @@ -403,14 +403,18 @@ class socontacts * deletes contact entry including custom fields * * @param mixed $contact array with id or just the id - * @return boolean true on success or false on failiure + * @param int $check_etag=null + * @return boolean|int true on success or false on failiure, 0 if etag does not match */ - function delete($contact) + function delete($contact,$check_etag=null) { if (is_array($contact)) $contact = $contact['id']; + $where = array('id' => $contact); + if ($check_etag) $where['etag'] = $check_etag; + // delete mainfields - if ($this->somain->delete($contact)) + if ($this->somain->delete($where)) { // delete customfields, can return 0 if there are no customfields $this->soextra->delete(array($this->extra_id => $contact)); @@ -430,7 +434,7 @@ class socontacts } return true; } - return false; + return $check_etag ? 0 : false; // if etag given, we return 0 on failure, thought it could also mean the whole contact does not exist } /**