From f66f5f02e30d9fc2d5c06eeefb4377b8ff36fce2 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 08 Apr 2011 02:15:37 -0400
Subject: [PATCH] - Removed dependency on rcube_* functions, small improvements

---
 program/steps/addressbook/import.inc |   44 +++++++++++++++++++++++++++++---------------
 1 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/program/steps/addressbook/import.inc b/program/steps/addressbook/import.inc
index 2390e98..e20fbe0 100644
--- a/program/steps/addressbook/import.inc
+++ b/program/steps/addressbook/import.inc
@@ -5,7 +5,7 @@
  | program/steps/addressbook/import.inc                                  |
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
- | Copyright (C) 2008-2009, Roundcube Dev. - Switzerland                 |
+ | Copyright (C) 2008-2009, The Roundcube Dev Team                       |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
  | PURPOSE:                                                              |
@@ -62,13 +62,27 @@
   global $IMPORT_STATS;
   
   $vars = get_object_vars($IMPORT_STATS);
-  $vars['names'] = join(', ', array_map('Q', $IMPORT_STATS->names));
+  $vars['names'] = $vars['skipped_names'] = '';
   
-  return html::p($attrib, Q(rcube_label(array(
-    'name' => 'importconfirm',
-    'nr' => $IMORT_STATS->inserted,
-    'vars' => $vars,
-  )), 'show'));
+  $content = html::p(null, rcube_label(array(
+      'name' => 'importconfirm',
+      'nr' => $IMORT_STATS->inserted,
+      'vars' => $vars,
+    )) . ($IMPORT_STATS->names ? ':' : '.'));
+    
+  if ($IMPORT_STATS->names)
+    $content .= html::p('em', join(', ', array_map('Q', $IMPORT_STATS->names)));
+  
+  if ($IMPORT_STATS->skipped) {
+      $content .= html::p(null, rcube_label(array(
+          'name' => 'importconfirmskipped',
+          'nr' => $IMORT_STATS->skipped,
+          'vars' => $vars,
+        )) . ':');
+      $content .= html::p('em', join(', ', array_map('Q', $IMPORT_STATS->skipped_names)));
+  }
+  
+  return html::div($attrib, $content);
 }
 
 
@@ -120,6 +134,7 @@
   else {
     $IMPORT_STATS = new stdClass;
     $IMPORT_STATS->names = array();
+    $IMPORT_STATS->skipped_names = array();
     $IMPORT_STATS->count = count($vcards);
     $IMPORT_STATS->inserted = $IMPORT_STATS->skipped = $IMPORT_STATS->nomail = $IMPORT_STATS->errors = 0;
     
@@ -134,8 +149,11 @@
         $IMPORT_STATS->nomail++;
         continue;
       }
+
+      // We're using UTF8 internally
+      $email = rcube_idn_to_utf8($email);
       
-      if (!$replace) {
+      if (!$replace && $email) {
         // compare e-mail address
         $existing = $CONTACTS->search('email', $email, false, false);
         if (!$existing->count) {  // compare display name
@@ -143,17 +161,13 @@
         }
         if ($existing->count) {
           $IMPORT_STATS->skipped++;
+          $IMPORT_STATS->skipped_names[] = $vcard->displayname;
           continue;
         }
       }
       
-      $a_record = array(
-        'name' => $vcard->displayname,
-        'firstname' => $vcard->firstname,
-        'surname' => $vcard->surname,
-        'email' => $email,
-        'vcard' => $vcard->export(),
-      );
+      $a_record = $vcard->get_assoc();
+      $a_record['vcard'] = $vcard->export();
       
       $plugin = $RCMAIL->plugins->exec_hook('contact_create', array('record' => $a_record, 'source' => null));
       $a_record = $plugin['record'];

--
Gitblit v1.9.1