alecpl
2011-04-14 ae1db2239e4c2a67f09ecc6d35b70fc7079425bf
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'];