Browse Source
Merge pull request #9606 from johndoh/vcard_import2
compare both email and name before skipping vcard import
pull/9637/head
Pablo Zmdl
11 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
15 additions and
4 deletions
-
program/actions/contacts/import.php
|
|
@ -199,14 +199,25 @@ class rcmail_action_contacts_import extends rcmail_action_contacts_index |
|
|
|
|
|
|
|
if (!$replace) { |
|
|
|
$existing = null; |
|
|
|
$search_fields = []; |
|
|
|
$search_values = []; |
|
|
|
|
|
|
|
// compare e-mail address
|
|
|
|
if ($email) { |
|
|
|
$existing = $CONTACTS->search('email', $email, 1, false); |
|
|
|
$search_fields[] = 'email'; |
|
|
|
$search_values[] = $email; |
|
|
|
} |
|
|
|
// compare display name if email not found
|
|
|
|
if ((!$existing || !$existing->count) && $vcard->displayname) { |
|
|
|
$existing = $CONTACTS->search('name', $vcard->displayname, 1, false); |
|
|
|
|
|
|
|
if ($vcard->displayname) { |
|
|
|
$search_fields[] = 'name'; |
|
|
|
$search_values[] = $vcard->displayname; |
|
|
|
} |
|
|
|
|
|
|
|
// compare email and/or display name if available
|
|
|
|
if (!empty($search_fields)) { |
|
|
|
$existing = $CONTACTS->search($search_fields, $search_values, 1, false); |
|
|
|
} |
|
|
|
|
|
|
|
if ($existing && $existing->count) { |
|
|
|
self::$stats->skipped++; |
|
|
|
self::$stats->skipped_names[] = $vcard->displayname ?: $email; |
|
|
|