carlos22 / carddav2fb

:notebook: A command-line PHP script allowing to import CardDAV-based VCards (e.g. from 'owncloud') to a phonebook in a AVM FRITZ!Box
The Unlicense
86 stars 67 forks source link

Contact name not imported for ownCloud created contacts #9

Open Fensterbank opened 8 years ago

Fensterbank commented 8 years ago

I'm testing this script with the newest owncloud / nextcloud release and noticed it doesn't work for me.

PHP Notice:  Undefined offset: 0 in /home/fileshare/carddav2fb/carddav2fb.php on line 181
PHP Notice:  Undefined offset: 0 in /home/fileshare/carddav2fb/carddav2fb.php on line 186

The undefined offset occurs because there is no real name in the vcard, only the FN (friendly name) is set, which is not used from the script.

BEGIN:VCARD
VERSION:3.0
FN:Mike Kunze
UID:bc44600d-ff0f-4400-89b1-518e39d6a0d8
TEL;TYPE=HOME\,VOICE:06439 69 75 74
END:VCARD

The result is that we don't have a name and entries are imported like with a null value fritz

For me I would be fixed by using $vcard_obj->fn[0] instead of $vcard_obj->n[0]. I'm ready to test it and bring up a pull request, but I'm not sure, if this is really broken or it's a special case. Did you have the N-Property in you vcard files? Which owncloud version did you used?

I tested it in a brand new nextcloud installation with brand new contacts created inside of the contacts app.