From 178c4c13e1697724e90dd3daf20383821931ba1c Mon Sep 17 00:00:00 2001 From: PhilW Date: Sun, 25 Aug 2024 10:38:08 +0100 Subject: [PATCH 1/4] add invalid and error details to vcard import report --- program/actions/contacts/import.php | 24 +++++++++++++++++++++++- program/localization/en_US/messages.inc | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/program/actions/contacts/import.php b/program/actions/contacts/import.php index 312b3d916d7..8de035a4567 100644 --- a/program/actions/contacts/import.php +++ b/program/actions/contacts/import.php @@ -158,6 +158,8 @@ public function run($args = []) self::$stats = new stdClass(); self::$stats->names = []; self::$stats->skipped_names = []; + self::$stats->invalid_names = []; + self::$stats->error_names = []; self::$stats->count = count($vcards); self::$stats->inserted = 0; self::$stats->skipped = 0; @@ -187,6 +189,7 @@ public function run($args = []) // skip invalid (incomplete) entries if (!$CONTACTS->validate($a_record, true)) { self::$stats->invalid++; + self::$stats->invalid_names[] = $vcard->displayname ?: $email; continue; } @@ -251,6 +254,7 @@ public function run($args = []) self::$stats->names[] = $a_record['name'] ?: $email; } else { self::$stats->errors++; + self::$stats->error_names[] = $a_record['name'] ?: $email; } } @@ -431,7 +435,7 @@ public static function import_confirm($attrib) { $rcmail = rcmail::get_instance(); $vars = get_object_vars(self::$stats); - $vars['names'] = $vars['skipped_names'] = ''; + $vars['names'] = $vars['skipped_names'] = $vars['invalid_names'] = $vars['error_names'] = ''; $content = html::p(null, $rcmail->gettext([ 'name' => 'importconfirm', @@ -453,6 +457,24 @@ public static function import_confirm($attrib) . html::p('em', implode(', ', array_map(['rcube', 'Q'], self::$stats->skipped_names))); } + if (self::$stats->invalid) { + $content .= html::p(null, $rcmail->gettext([ + 'name' => 'importconfirminvalid', + 'nr' => self::$stats->invalid, + 'vars' => $vars, + ]) . ':') + . html::p('em', implode(', ', array_map(['rcube', 'Q'], self::$stats->invalid_names))); + } + + if (self::$stats->errors) { + $content .= html::p(null, $rcmail->gettext([ + 'name' => 'importconfirmerrors', + 'nr' => self::$stats->errors, + 'vars' => $vars, + ]) . ':') + . html::p('em', implode(', ', array_map(['rcube', 'Q'], self::$stats->error_names))); + } + return html::div($attrib, $content); } diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc index b65b61fe36c..88066a11dbc 100644 --- a/program/localization/en_US/messages.inc +++ b/program/localization/en_US/messages.inc @@ -162,6 +162,8 @@ $messages['importwait'] = 'Importing, please wait...'; $messages['importformaterror'] = 'Import failed! The uploaded file is not a valid import data file.'; $messages['importconfirm'] = 'Successfully imported $inserted contacts'; $messages['importconfirmskipped'] = 'Skipped $skipped existing entries'; +$messages['importconfirminvalid'] = 'Skipped $invalid invalid entries'; +$messages['importconfirmerrors'] = 'Failed to import $errors valid contacts'; $messages['importmessagesuccess'] = 'Successfully imported $nr messages'; $messages['importmessageerror'] = 'Import failed! The uploaded file is not a valid message or mailbox file'; $messages['opnotpermitted'] = 'Operation not permitted!'; From 85bcfe644ae3b99db2f609102948feb6ad44b776 Mon Sep 17 00:00:00 2001 From: PhilW Date: Sat, 14 Sep 2024 06:22:09 +0100 Subject: [PATCH 2/4] small improvement to invalid vcard logging --- program/actions/contacts/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/program/actions/contacts/import.php b/program/actions/contacts/import.php index 8de035a4567..76bbafbd060 100644 --- a/program/actions/contacts/import.php +++ b/program/actions/contacts/import.php @@ -189,7 +189,7 @@ public function run($args = []) // skip invalid (incomplete) entries if (!$CONTACTS->validate($a_record, true)) { self::$stats->invalid++; - self::$stats->invalid_names[] = $vcard->displayname ?: $email; + self::$stats->invalid_names[] = rcube_addressbook::compose_display_name($a_record, true); continue; } From b5047f71a5e5f6b7bd97c29bf6634f6e95b61ee8 Mon Sep 17 00:00:00 2001 From: PhilW Date: Wed, 18 Sep 2024 19:05:02 +0100 Subject: [PATCH 3/4] remove pointless variable --- program/actions/contacts/import.php | 14 ++++---------- program/localization/en_US/messages.inc | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/program/actions/contacts/import.php b/program/actions/contacts/import.php index 76bbafbd060..4ce21f0fa97 100644 --- a/program/actions/contacts/import.php +++ b/program/actions/contacts/import.php @@ -434,13 +434,10 @@ public static function import_map($attrib) public static function import_confirm($attrib) { $rcmail = rcmail::get_instance(); - $vars = get_object_vars(self::$stats); - $vars['names'] = $vars['skipped_names'] = $vars['invalid_names'] = $vars['error_names'] = ''; $content = html::p(null, $rcmail->gettext([ 'name' => 'importconfirm', - 'nr' => self::$stats->inserted, - 'vars' => $vars, + 'vars' => ['inserted' => self::$stats->inserted], ]) . (self::$stats->names ? ':' : '.') ); @@ -451,8 +448,7 @@ public static function import_confirm($attrib) if (self::$stats->skipped) { $content .= html::p(null, $rcmail->gettext([ 'name' => 'importconfirmskipped', - 'nr' => self::$stats->skipped, - 'vars' => $vars, + 'vars' => ['skipped' => self::$stats->skipped], ]) . ':') . html::p('em', implode(', ', array_map(['rcube', 'Q'], self::$stats->skipped_names))); } @@ -460,8 +456,7 @@ public static function import_confirm($attrib) if (self::$stats->invalid) { $content .= html::p(null, $rcmail->gettext([ 'name' => 'importconfirminvalid', - 'nr' => self::$stats->invalid, - 'vars' => $vars, + 'vars' => ['invalid' => self::$stats->invalid], ]) . ':') . html::p('em', implode(', ', array_map(['rcube', 'Q'], self::$stats->invalid_names))); } @@ -469,8 +464,7 @@ public static function import_confirm($attrib) if (self::$stats->errors) { $content .= html::p(null, $rcmail->gettext([ 'name' => 'importconfirmerrors', - 'nr' => self::$stats->errors, - 'vars' => $vars, + 'vars' => ['errors' => self::$stats->errors], ]) . ':') . html::p('em', implode(', ', array_map(['rcube', 'Q'], self::$stats->error_names))); } diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc index 88066a11dbc..2070da05e25 100644 --- a/program/localization/en_US/messages.inc +++ b/program/localization/en_US/messages.inc @@ -161,8 +161,8 @@ $messages['nogroupassignmentschanged'] = 'No group assignments changed.'; $messages['importwait'] = 'Importing, please wait...'; $messages['importformaterror'] = 'Import failed! The uploaded file is not a valid import data file.'; $messages['importconfirm'] = 'Successfully imported $inserted contacts'; -$messages['importconfirmskipped'] = 'Skipped $skipped existing entries'; -$messages['importconfirminvalid'] = 'Skipped $invalid invalid entries'; +$messages['importconfirmskipped'] = 'Skipped $skipped existing contacts'; +$messages['importconfirminvalid'] = 'Skipped $invalid invalid contacts'; $messages['importconfirmerrors'] = 'Failed to import $errors valid contacts'; $messages['importmessagesuccess'] = 'Successfully imported $nr messages'; $messages['importmessageerror'] = 'Import failed! The uploaded file is not a valid message or mailbox file'; From 8468d297eed38e0f551e11fb1eab9d23c48aa24d Mon Sep 17 00:00:00 2001 From: PhilW Date: Wed, 20 Nov 2024 19:20:36 +0000 Subject: [PATCH 4/4] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d40f241019..3ad4636ed11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ - Convert images in HTML content pasted into HTML editor to `data:` URIs (and later to attachments) (#6938) - Add possibility to change ATTR_EMULATE_PREPARES via config file (#9213) - Use draft settings (like DSN) on "Edit as new" (#9349) +- Add more detailed feedback on vCard import errors (#9591) - Use new HTML5 parser available on PHP >= 8.4 - Installer: Show NOT OK if none of the database extensions is installed (#9594, #9604) - Mailvelope: Add a button to enable the extension for webmail domain (#9498)