summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2011-05-13 18:08:37 +0000
committerthomascube <thomas@roundcube.net>2011-05-13 18:08:37 +0000
commit6b19999841f97e1addfa6ebce79a887aad7467c9 (patch)
tree1ec019d304979a01af367c097acc596e86bf8306
parent445a4ca04dfcd255f9d89ee76757b04c2d87bbfc (diff)
Correctly handle empty contact names when importing
-rw-r--r--program/include/rcube_vcard.php6
-rw-r--r--program/localization/de_DE/messages.inc3
-rw-r--r--program/steps/addressbook/import.inc6
3 files changed, 10 insertions, 5 deletions
diff --git a/program/include/rcube_vcard.php b/program/include/rcube_vcard.php
index 4457bf3c9..40ec353e5 100644
--- a/program/include/rcube_vcard.php
+++ b/program/include/rcube_vcard.php
@@ -95,6 +95,10 @@ class rcube_vcard
($detected_charset = self::detect_encoding(self::vcard_encode($this->raw))) && $detected_charset != RCMAIL_CHARSET) {
$this->raw = self::charset_convert($this->raw, $detected_charset);
}
+
+ // consider FN empty if the same as the primary e-mail address
+ if ($this->raw['FN'][0][0] == $this->raw['EMAIL'][0][0])
+ $this->raw['FN'][0][0] = '';
// find well-known address fields
$this->displayname = $this->raw['FN'][0][0];
@@ -402,7 +406,7 @@ class rcube_vcard
if (preg_match('/^END:VCARD$/i', $line)) {
// parse vcard
$obj = new rcube_vcard(self::cleanup($vcard_block), $charset, true);
- if (!empty($obj->displayname))
+ if (!empty($obj->displayname) || !empty($obj->email))
$out[] = $obj;
$in_vcard_block = false;
diff --git a/program/localization/de_DE/messages.inc b/program/localization/de_DE/messages.inc
index d30594cc9..42a397f0f 100644
--- a/program/localization/de_DE/messages.inc
+++ b/program/localization/de_DE/messages.inc
@@ -108,7 +108,8 @@ $messages['contactaddedtogroup'] = 'Kontakte wurden dieser Gruppe hinzugefügt';
$messages['contactremovedfromgroup'] = 'Kontakte wurden aus dieser Gruppe entfernt';
$messages['importwait'] = 'Daten werden importiert, bitte warten...';
$messages['importerror'] = 'Import fehlgeschlagen! Die hochgeladene Datei ist nicht im vCard-Format.';
-$messages['importconfirm'] = '<b>Es wurden $inserted Adressen erfolgreich importiert und $skipped bestehende Einträge übersprungen</b>:<p><em>$names</em></p>';
+$messages['importconfirm'] = '<b>Es wurden $inserted Adressen erfolgreich importiert</b>';
+$messages['importconfirmskipped'] = '<b>$skipped bestehende Einträge wurden übersprungen</b>';
$messages['opnotpermitted'] = 'Operation nicht erlaubt!';
$messages['nofromaddress'] = 'Fehlende E-Mail-Adresse in ausgewählter Identität';
$messages['editorwarning'] = 'Beim Wechseln in den Texteditor gehen alle Textformatierungen verloren. Möchten Sie fortfahren?';
diff --git a/program/steps/addressbook/import.inc b/program/steps/addressbook/import.inc
index e20fbe082..4583be508 100644
--- a/program/steps/addressbook/import.inc
+++ b/program/steps/addressbook/import.inc
@@ -156,12 +156,12 @@ if ($_FILES['_file']['tmp_name'] && is_uploaded_file($_FILES['_file']['tmp_name'
if (!$replace && $email) {
// compare e-mail address
$existing = $CONTACTS->search('email', $email, false, false);
- if (!$existing->count) { // compare display name
+ if (!$existing->count && $vcard->displayname) { // compare display name
$existing = $CONTACTS->search('name', $vcard->displayname, false, false);
}
if ($existing->count) {
$IMPORT_STATS->skipped++;
- $IMPORT_STATS->skipped_names[] = $vcard->displayname;
+ $IMPORT_STATS->skipped_names[] = $vcard->displayname ? $vcard->displayname : $email;
continue;
}
}
@@ -180,7 +180,7 @@ if ($_FILES['_file']['tmp_name'] && is_uploaded_file($_FILES['_file']['tmp_name'
if ($success) {
$IMPORT_STATS->inserted++;
- $IMPORT_STATS->names[] = $vcard->displayname;
+ $IMPORT_STATS->names[] = $vcard->displayname ? $vcard->displayname : $email;
} else {
$IMPORT_STATS->errors++;
}