diff options
Diffstat (limited to 'program/include')
-rw-r--r-- | program/include/rcube_ldap.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php index 130eada63..08b7cd99c 100644 --- a/program/include/rcube_ldap.php +++ b/program/include/rcube_ldap.php @@ -993,10 +993,13 @@ class rcube_ldap extends rcube_addressbook if ($missing) { // try to complete record automatically if ($autofix) { - $reverse_map = array_flip($this->fieldmap); - $name_parts = preg_split('/[\s,.]+/', $save_data['name']); $sn_field = $this->fieldmap['surname']; $fn_field = $this->fieldmap['firstname']; + $mail_field = $this->fieldmap['email']; + + // try to extract surname and firstname from displayname + $reverse_map = array_flip($this->fieldmap); + $name_parts = preg_split('/[\s,.]+/', $save_data['name']); if ($sn_field && $missing[$sn_field]) { $save_data['surname'] = array_pop($name_parts); @@ -1007,6 +1010,16 @@ class rcube_ldap extends rcube_addressbook $save_data['firstname'] = array_shift($name_parts); unset($missing[$fn_field]); } + + // try to fix missing e-mail, very often on import + // from vCard we have email:other only defined + if ($mail_field && $missing[$mail_field]) { + $emails = $this->get_col_values('email', $save_data, true); + if (!empty($emails) && ($email = array_shift($emails))) { + $save_data['email'] = $email; + unset($missing[$mail_field]); + } + } } // TODO: generate message saying which fields are missing |