forked from extern/egroupware
optional check etag/optimistic lock on delete too
This commit is contained in:
parent
3a5b24dfda
commit
ec3327010c
@ -420,9 +420,10 @@ class bocontacts extends socontacts
|
|||||||
*
|
*
|
||||||
* @param mixed &$contact contact array with key id or (array of) id(s)
|
* @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
|
* @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']))
|
if (is_array($contact) && isset($contact['id']))
|
||||||
{
|
{
|
||||||
@ -436,14 +437,15 @@ class bocontacts extends socontacts
|
|||||||
{
|
{
|
||||||
$id = is_array($c) ? $c['id'] : $c;
|
$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);
|
egw_link::unlink(0,'addressbook',$id);
|
||||||
$GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $id, 'delete', time());
|
$GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $id, 'delete', time());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return $ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -403,14 +403,18 @@ class socontacts
|
|||||||
* deletes contact entry including custom fields
|
* deletes contact entry including custom fields
|
||||||
*
|
*
|
||||||
* @param mixed $contact array with id or just the id
|
* @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'];
|
if (is_array($contact)) $contact = $contact['id'];
|
||||||
|
|
||||||
|
$where = array('id' => $contact);
|
||||||
|
if ($check_etag) $where['etag'] = $check_etag;
|
||||||
|
|
||||||
// delete mainfields
|
// delete mainfields
|
||||||
if ($this->somain->delete($contact))
|
if ($this->somain->delete($where))
|
||||||
{
|
{
|
||||||
// delete customfields, can return 0 if there are no customfields
|
// delete customfields, can return 0 if there are no customfields
|
||||||
$this->soextra->delete(array($this->extra_id => $contact));
|
$this->soextra->delete(array($this->extra_id => $contact));
|
||||||
@ -430,7 +434,7 @@ class socontacts
|
|||||||
}
|
}
|
||||||
return true;
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user