Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact import improvements #9431

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

johndoh
Copy link
Contributor

@johndoh johndoh commented May 1, 2024

For #9419

Some of the mappings in the current code work (pass the tests) but the result is different to what you get if you create the same contact manually through the UI and then export it as a vCard, for example Roundcube uses phone:mobile not phone:cell and there is no email:pref field. I have changed the mapping so it matches the fields in the UI. I added some more aliases rcube_vcard to show existing vCards with mismatched fields nicely.

I have removed the subtype other from the IM field because that does not exist in rcube_vcard which means if when you hit save in the UI the value simply disappears, it’s not saved.

I have removed the variable rcube_csv2vcard::$label_map because it’s a duplicate of contents of /program/localization/en_US/csv2vcard.incand just a bit confusing currently /program/localization/en_US/csv2vcard.inc is not used by the code and this PR changes that.

I have another reason for wanting to use /program/localization/en_US/csv2vcard.inc over rcube_csv2vcard::$label_map and if this PR gets merged then I will propose 1 additional change which will remove the rcube_csv2vcard::$csv2vcard_map variable and simplify the mapping process by storing both the source and destination for the map in /program/localization/en_US/csv2vcard.inc and allowing multiple sources (including multiple languages) for the same destination. This is a slightly larger and may be more controversial change hence the separate PR.

program/actions/contacts/import.php Outdated Show resolved Hide resolved
program/actions/contacts/import.php Outdated Show resolved Hide resolved
program/lib/Roundcube/rcube_csv2vcard.php Outdated Show resolved Hide resolved
program/lib/Roundcube/rcube_vcard.php Outdated Show resolved Hide resolved
program/localization/en_US/labels.inc Outdated Show resolved Hide resolved
program/lib/Roundcube/rcube_csv2vcard.php Outdated Show resolved Hide resolved
program/lib/Roundcube/rcube_vcard.php Outdated Show resolved Hide resolved
program/localization/en_US/labels.inc Outdated Show resolved Hide resolved
@johndoh
Copy link
Contributor Author

johndoh commented Jun 16, 2024

I moved the list_fields function back to rcmail_action_contacts_import because it relies on the contact list from its parent class rcmail_action_contacts. I think its the best place for it.

Also I completed the second part of my suggestion to remove the hard coded mapping information entirely and use 1 to define the source and destination.

@@ -201,7 +201,7 @@ class rcmail_action_contacts_index extends rcmail_action
'size' => 40,
'maxlength' => 128,
'label' => 'instantmessenger',
'subtypes' => ['aim', 'icq', 'msn', 'yahoo', 'jabber', 'skype', 'other'],
'subtypes' => ['aim', 'icq', 'msn', 'yahoo', 'jabber', 'skype'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 'other' is removed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's not supported by the rest of the code. It's not included in the vCard, so once you hit save the value is lost.

$map['work_state'] = "Work State";
$map['work_title'] = "Work Title";
$map['work_zip'] = "Work Zip";
$map['anniversary'][] = "Jahrestag";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this change. We should keep this file syntax simple.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is not simple about the syntax? This way, the mapping process is clearer. There is only one map of CSV field to vCard field rather than the CSV to internal ID, then a hard coded map of internl ID to vCard used currebtly. It also adds support variations of field names in the CSV file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$map['anniversary'][] is not simple ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for the nested array is to allow multiple labels to map to the same vCard field, e.g. currently the CSV labels first and given_name both map to vCard field firstname. Currently this is done via the hard coded rcube_csv2vcard::$csv2vcard_map. For me this is not simple. Adding a new field into the map means a change in 2 files, you have to know the hard coded map is there, there is no info about it in csv2vcard.inc. Using a nested array may not be simple but for me it is simpler than the current approach as it means there is only 1 place to change when adding a new field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants