* Addressbook/CardDAV: fix not working import / PUT of birthday in vCard

and prefer=representation on a "412 Precondition Failed" for a group
This commit is contained in:
Ralf Becker 2015-10-16 07:50:43 +00:00
parent a54294ae2e
commit c33b041d23
2 changed files with 9 additions and 4 deletions

View File

@ -672,6 +672,8 @@ class addressbook_groupdav extends groupdav_handler
if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok");
if ($save_ok === 0) if ($save_ok === 0)
{ {
// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
$this->check_return_representation($options, $id, $user);
return '412 Precondition Failed'; return '412 Precondition Failed';
} }
return '403 Forbidden'; // happens when writing new entries in AB's without ADD rights return '403 Forbidden'; // happens when writing new entries in AB's without ADD rights

View File

@ -929,7 +929,10 @@ class addressbook_vcal extends addressbook_bo
{ {
if (!empty($fieldName)) if (!empty($fieldName))
{ {
$value = trim($vcardValues[$vcardKey]['values'][$fieldKey]); if (is_scalar($vcardValues[$vcardKey]['values'][$fieldKey]))
{
$value = trim($vcardValues[$vcardKey]['values'][$fieldKey]);
}
if ($pref_tel && (($vcardKey == $pref_tel) || if ($pref_tel && (($vcardKey == $pref_tel) ||
($vcardValues[$vcardKey]['name'] == 'TEL') && ($vcardValues[$vcardKey]['name'] == 'TEL') &&
($vcardValues[$vcardKey]['value'] == $vcardValues[$pref_tel]['value']))) ($vcardValues[$vcardKey]['value'] == $vcardValues[$pref_tel]['value'])))
@ -939,9 +942,9 @@ class addressbook_vcal extends addressbook_bo
switch($fieldName) switch($fieldName)
{ {
case 'bday': case 'bday':
$contact[$fieldName] = $vcardValues[$vcardKey]['values']['year'] . $contact[$fieldName] = $vcardValues[$vcardKey]['value']['year'] .
'-' . $vcardValues[$vcardKey]['values']['month'] . '-' . $vcardValues[$vcardKey]['value']['month'] .
'-' . $vcardValues[$vcardKey]['values']['mday']; '-' . $vcardValues[$vcardKey]['value']['mday'];
break; break;
case 'private': case 'private':