Skip to content

Commit

Permalink
Merge pull request #9606 from johndoh/vcard_import2
Browse files Browse the repository at this point in the history
compare both email and name before skipping vcard import
  • Loading branch information
pabzm authored Sep 12, 2024
2 parents f8d9cb1 + 9e5a18e commit 6b64eab
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions program/actions/contacts/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,25 @@ public function run($args = [])

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;
Expand Down

0 comments on commit 6b64eab

Please sign in to comment.