diff --git a/NEWS b/NEWS index 40a1b7277..be722a25c 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ Bug fixes - [web] fixed email reminder with attendees (#4115) - [web] prevented form to be marked dirty when changing password (#4138) - [web] restored support for SOGoLDAPContactInfoAttribute + - [web] avoid duplicated email addresses in LDAP-based addressbook (#4129) - [core] cherry-picked comma escaping fix from v2 (#3296) - [core] fix sogo-tool restore potentially crashing on corrupted data (#4048) - [core] handle properly mails using windows-1255 charset (#4124) diff --git a/SoObjects/Contacts/NGVCard+SOGo.m b/SoObjects/Contacts/NGVCard+SOGo.m index b430e124d..0cc8963d4 100644 --- a/SoObjects/Contacts/NGVCard+SOGo.m +++ b/SoObjects/Contacts/NGVCard+SOGo.m @@ -236,19 +236,40 @@ convention: - (void) _setEmails: (NSDictionary *) ldifRecord { CardElement *homeMail; - NSString* mail; + NSArray *emails; + NSEnumerator *mailList; + id mail; // Emails from the configured mail fields of the source have already been extracted in // [LDAPSource _fillEmailsOfEntry:intoLDIFRecord:] [self addElementWithTag: @"email" ofType: @"work" withValue: [ldifRecord objectForKey: @"c_emails"]]; + // When importing an LDIF file, add the default mail attribute mail = [ldifRecord objectForKey: @"mail"]; - if ([mail length] && ![[self emails] containsObject: mail]) - [self addElementWithTag: @"email" - ofType: @"work" - withValue: [ldifRecord objectForKey: @"mail"]]; + if (mail) + { + emails = [self emails]; + if ([mail isKindOfClass: [NSArray class]]) + { + mailList = [(NSArray *)mail objectEnumerator]; + while ((mail = [mailList nextObject])) + { + if ([mail length] && ![emails containsObject: mail]) + [self addElementWithTag: @"email" + ofType: @"work" + withValue: mail]; + } + } + else if ([mail length] && ![emails containsObject: mail]) + { + [self addElementWithTag: @"email" + ofType: @"work" + withValue: mail]; + } + } + homeMail = [self elementWithTag: @"email" ofType: @"home"]; [homeMail setSingleValue: [ldifRecord objectForKey: @"mozillasecondemail"] forKey: @""]; [[self uniqueChildWithTag: @"x-mozilla-html"] diff --git a/SoObjects/SOGo/CardElement+SOGo.m b/SoObjects/SOGo/CardElement+SOGo.m index 4770ad036..75008936f 100644 --- a/SoObjects/SOGo/CardElement+SOGo.m +++ b/SoObjects/SOGo/CardElement+SOGo.m @@ -25,6 +25,7 @@ #import #import +#import #import "SOGoUser.h" #import "SOGoUserDefaults.h" @@ -74,14 +75,15 @@ */ - (NSString *) jsonRepresentation { - NSString *v; + id v; NSMutableDictionary *attrs; attrs = [NSMutableDictionary dictionary]; - v = [self value: 0 ofAttribute: @"type"]; - if ([v length]) - [attrs setObject: v + v = [[self attributes] objectForCaseInsensitiveKey: @"type"]; + if (v && [v isKindOfClass: [NSArray class]] && [v count]) + // We can have multiple types, but we only return the first one + [attrs setObject: [v objectAtIndex: 0] forKey: @"type"]; [attrs setObject: [self flattenedValuesForKey: @""] forKey: @"value"];