fixed not working PUT of groups/lists

This commit is contained in:
Ralf Becker 2012-02-18 10:18:14 +00:00
parent cfded2a918
commit bfd50d213e
2 changed files with 14 additions and 7 deletions

View File

@ -556,7 +556,8 @@ class addressbook_groupdav extends groupdav_handler
}
// send evtl. necessary respose headers: Location, etag, ...
$this->put_response_headers($contact, $options['path'], $retval, self::$path_attr != 'id');
// epl-11.1 needs && !$is_group, as we dont store carddav_name for lists!
$this->put_response_headers($contact, $options['path'], $retval, self::$path_attr != 'id' && !$is_group);
if ($this->debug > 1) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval));
return $retval;
@ -569,7 +570,7 @@ class addressbook_groupdav extends groupdav_handler
* @param array|false $oldContact
* @param int|boolean $list_id or false on error
*/
function save_group(array $contact, $oldContact=null)
function save_group(array &$contact, $oldContact=null)
{
$data = array('list_name' => $contact['n_fn']);
foreach(array('id','carddav_name','uid') as $name)
@ -608,15 +609,15 @@ class addressbook_groupdav extends groupdav_handler
$filter = array('uid' => $to_delete ? array_merge($to_add, $to_delete) : $to_add);
if (($contacts =& $this->bo->search(array(),'id,uid','','','',False,'AND',false,$filter)))
{
foreach($contacts as $contact)
foreach($contacts as $c)
{
if ($to_delete && in_array($contact['uid'], $to_delete))
if ($to_delete && in_array($c['uid'], $to_delete))
{
$to_delete_ids[] = $contact['id'];
$to_delete_ids[] = $c['id'];
}
else
{
$to_add_ids[] = $contact['id'];
$to_add_ids[] = $c['id'];
}
}
}
@ -624,8 +625,10 @@ class addressbook_groupdav extends groupdav_handler
if ($to_add_ids) $this->bo->add2list($to_add_ids, $list_id, array());
if ($to_delete_ids) $this->bo->remove_from_list($to_delete_ids, $list_id);
}
$list_id = $data['list_carddav_name'];
}
if ($this->debug > 1) error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') returning '.array2string($list_id));
if ($this->debug > 1) error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id));
$contact = $data;
return $list_id;
}

View File

@ -546,6 +546,10 @@ class addressbook_sql extends so_sql_cf
{
$data['list_owner'] = $owner;
}
if (isset($keys['list_carddav_name']))
{
$keys = false; // cant PUT a name in 11.1
}
if (!$keys || !($list_id = $this->db->select($this->lists_table,'list_id',$keys,__LINE__,__FILE__)->fetchColumn()))
{
$data['list_created'] = time();