Changeset 9336ba2 in github


Ignore:
Timestamp:
Apr 12, 2012 7:52:09 AM (13 months ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.8
Children:
373e3df
Parents:
28391b4
Message:
  • Fix importing to LDAP addressbook when mail attribute is required by validating input data with autofix
Location:
program
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_ldap.php

    r21a0d91 r9336ba2  
    994994            // try to complete record automatically 
    995995            if ($autofix) { 
     996                $sn_field    = $this->fieldmap['surname']; 
     997                $fn_field    = $this->fieldmap['firstname']; 
     998                $mail_field  = $this->fieldmap['email']; 
     999 
     1000                // try to extract surname and firstname from displayname 
    9961001                $reverse_map = array_flip($this->fieldmap); 
    9971002                $name_parts  = preg_split('/[\s,.]+/', $save_data['name']); 
    998                 $sn_field    = $this->fieldmap['surname']; 
    999                 $fn_field    = $this->fieldmap['firstname']; 
    10001003 
    10011004                if ($sn_field && $missing[$sn_field]) { 
     
    10071010                    $save_data['firstname'] = array_shift($name_parts); 
    10081011                    unset($missing[$fn_field]); 
     1012                } 
     1013 
     1014                // try to fix missing e-mail, very often on import 
     1015                // from vCard we have email:other only defined 
     1016                if ($mail_field && $missing[$mail_field]) { 
     1017                    $emails = $this->get_col_values('email', $save_data, true); 
     1018                    if (!empty($emails) && ($email = array_shift($emails))) { 
     1019                        $save_data['email'] = $email; 
     1020                        unset($missing[$mail_field]); 
     1021                    } 
    10091022                } 
    10101023            } 
  • program/steps/addressbook/import.inc

    r7fe3811 r9336ba2  
    165165 
    166166    foreach ($vcards as $vcard) { 
    167       $email = $vcard->email[0]; 
    168  
    169       // skip entries without an e-mail address 
    170       if (empty($email)) { 
     167      $email    = $vcard->email[0]; 
     168      $a_record = $vcard->get_assoc(); 
     169 
     170      // skip entries without an e-mail address or invalid 
     171      if (empty($email) || !$CONTACTS->validate($a_record, true)) { 
    171172        $IMPORT_STATS->nomail++; 
    172173        continue; 
     
    189190      } 
    190191 
    191       $a_record = $vcard->get_assoc(); 
    192192      $a_record['vcard'] = $vcard->export(); 
    193193 
Note: See TracChangeset for help on using the changeset viewer.