suppress unnecessary update of uid (which overwrites an existing uid with the eGW default uid), happend for existing entries, if the uid was not given in the update, also removed etag increment, as so_sql::update does not longer call our save method

This commit is contained in:
Ralf Becker 2008-07-02 15:28:52 +00:00
parent 70052c8355
commit 7ae3cc0dda

View File

@ -607,6 +607,8 @@ class addressbook_sql extends so_sql
{
if (is_array($keys) && count($keys)) $this->data_merge($keys);
$new_entry = !$this->data['id'];
if (isset($this->data['etag'])) // do we have an etag in the data to write
{
$etag = $this->data['etag'];
@ -623,17 +625,15 @@ class addressbook_sql extends so_sql
else
{
unset($this->data['etag']);
$new_entry = !$this->data['id'];
if (!($err = parent::save(array('contact_etag=contact_etag+1'))) && $new_entry)
{
$this->data['etag'] = 0;
}
}
// enforce a minium uid strength
if (!$err && (strlen($this->data['uid']) < 20 || is_numeric($this->data['uid'])))
if (!$err && ($new_entry || isset($this->data['uid'])) && (strlen($this->data['uid']) < 20 || is_numeric($this->data['uid'])))
{
parent::update(array('uid' => common::generate_uid('addressbook',$this->data['id'])));
$this->data['etag']++;
//echo "<p>set uid={$this->data['uid']}, etag={$this->data['etag']}</p>";
}
return $err;