Skip to content

Commit

Permalink
Support multiple descriptions from LDAP entries
Browse files Browse the repository at this point in the history
Fixes #3750
  • Loading branch information
cgx committed Aug 1, 2016
1 parent 6071375 commit 9d65d7c
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 30 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -21,6 +21,7 @@ Bug fixes
- [web] fixed position of ghost block when creating an event from DnD
- [web] fixed avatar image in autocompletion
- [web] restored expunge of current mailbox when leaving the Mail module
- [web] added support for multiple description values in LDAP entries (#3750)
- [eas] fixed long GUID issue preventing sometimes synchronisation (#3460)

3.1.4 (2016-07-12)
Expand Down
5 changes: 4 additions & 1 deletion SoObjects/Contacts/NGVCard+SOGo.h
@@ -1,6 +1,6 @@
/* NGVCard+SOGo.h - this file is part of SOGo
*
* Copyright (C) 2009-2015 Inverse inc.
* Copyright (C) 2009-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -49,6 +49,9 @@
- (NSString *) pager;
- (NSCalendarDate *) birthday;

- (void) setNotes: (NSArray *) newNotes;
- (NSArray *) notes;

@end

#endif /* NGVCARD_SOGO_H */
42 changes: 40 additions & 2 deletions SoObjects/Contacts/NGVCard+SOGo.m
@@ -1,6 +1,6 @@
/* NGVCard+SOGo.m - this file is part of SOGo
*
* Copyright (C) 2009-2015 Inverse inc.
* Copyright (C) 2009-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -339,7 +339,11 @@ - (void) updateFromLDIFRecord: (NSDictionary *) ldifRecord
setSingleValue: [ldifRecord objectForKey: @"c_info"]
forKey: @""];

[self setNote: [ldifRecord objectForKey: @"description"]];
o = [ldifRecord objectForKey: @"description"];
if ([o isKindOfClass: [NSArray class]])
[self setNotes: o];
else
[self setNote: o];

o = [ldifRecord objectForKey: @"vcardcategories"];

Expand Down Expand Up @@ -851,6 +855,40 @@ - (NSCalendarDate *) birthday
return date;
}

- (void) setNotes: (NSArray *) newNotes
{
NSUInteger count, max;

max = [newNotes count];
for (count = 0; count < max; count++)
{
[self addChildWithTag: @"note"
types: nil
singleValue: [newNotes objectAtIndex: count]];
}
}


- (NSArray *) notes
{
NSArray *notes;
NSMutableArray *flattenedNotes;
NSString *note;
NSUInteger count, max;

notes = [self childrenWithTag: @"note"];
max = [notes count];
flattenedNotes = [NSMutableArray arrayWithCapacity: max];

for (count = 0; count < max; count++)
{
note = [[notes objectAtIndex: count] flattenedValuesForKey: @""];
[flattenedNotes addObject: note];
}

return flattenedNotes;
}

- (NSMutableDictionary *) quickRecordFromContent: (NSString *) theContent
container: (id) theContainer
{
Expand Down
41 changes: 18 additions & 23 deletions UI/Contacts/UIxContactView.m
Expand Up @@ -705,22 +705,27 @@ - (NSArray *) deliveryAddresses
// return [self _cardStringWithLabel: @"Timezone:" value: [card tz]];
// }

- (NSString *) note
- (NSArray *) notes
{
NSMutableArray *notes;
NSString *note;
NSUInteger count, max;

note = [card note];
if (note)
notes = [NSMutableArray arrayWithArray: [card notes]];
max = [notes count];
for (count = 0; count < max; count++)
{
note = [notes objectAtIndex: count];
note = [note stringByEscapingHTMLString];
note = [note stringByReplacingString: @"\r\n"
withString: @"<br />"];
note = [note stringByReplacingString: @"\n"
withString: @"<br />"];

[notes replaceObjectAtIndex: count withObject: note];
}

return note;
//return [self _cardStringWithLabel: @"Note:" value: note];
return notes;
}

/* hrefs */
Expand Down Expand Up @@ -785,7 +790,7 @@ - (NSString *) note
* @apiSuccess (Success 200) {String} [c_fn] Fullname
* @apiSuccess (Success 200) {String} [c_screenname] Screen Name (X-AIM for now)
* @apiSuccess (Success 200) {String} [tz] Timezone
* @apiSuccess (Success 200) {String} [note] Note
* @apiSuccess (Success 200) {String} [notes] Notes
* @apiSuccess (Success 200) {String[]} allCategories All available categories
* @apiSuccess (Success 200) {Object[]} [categories] Categories assigned to the card
* @apiSuccess (Success 200) {String} categories.value Category name
Expand Down Expand Up @@ -853,31 +858,21 @@ - (NSString *) note
if (o) [data setObject: o forKey: @"nickname"];
o = [card title];
if ([o length] > 0)
{
[data setObject: o forKey: @"title"];
}
[data setObject: o forKey: @"title"];
o = [card role];
if ([o length] > 0)
{
[data setObject: o forKey: @"role"];
}
[data setObject: o forKey: @"role"];
o = [self orgUnits];
if ([o count] > 0)
{
[data setObject: o forKey: @"orgUnits"];
}
[data setObject: o forKey: @"orgUnits"];
o = [card workCompany];
if ([o length] > 0)
{
[data setObject: o forKey: @"c_org"];
}
[data setObject: o forKey: @"c_org"];

o = [card birthday];
if (o)
{
[data setObject: [o descriptionWithCalendarFormat: @"%Y-%m-%d"]
[data setObject: [o descriptionWithCalendarFormat: @"%Y-%m-%d"]
forKey: @"birthday"];
}

o = [card tz];
if (o) [data setObject: o forKey: @"tz"];
Expand All @@ -893,8 +888,8 @@ - (NSString *) note
o = [self urls];
if ([o count]) [data setObject: o forKey: @"urls"];

o = [self note];
if (o) [data setObject: o forKey: @"note"];
o = [self notes];
if (o) [data setObject: o forKey: @"notes"];
o = [self _fetchAndCombineCategoriesList];
if (o) [data setObject: o forKey: @"allCategories"];
if ([contact hasPhoto])
Expand Down
10 changes: 6 additions & 4 deletions UI/Templates/ContactsUI/UIxContactViewTemplate.wox
Expand Up @@ -147,10 +147,12 @@
</div>
</div>

<div class="pseudo-input-container" ng-show="editor.card.note">
<label class="pseudo-input-label"><var:string label:value="Note"/></label>
<div class="pseudo-input-field">
<div ng-bind-html="editor.card.note"><!-- note --></div>
<div class="section" ng-show="editor.card.notes">
<div class="pseudo-input-container" ng-repeat="note in editor.card.notes">
<label class="pseudo-input-label"><var:string label:value="Note"/></label>
<div class="pseudo-input-field">
<div ng-bind-html="note"><!-- note --></div>
</div>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions UI/WebServerResources/js/Contacts/Card.service.js
Expand Up @@ -140,6 +140,7 @@

this.refs = [];
this.categories = [];
this.notes = [this.note];
this.c_screenname = null;
angular.extend(this, data);
if (!this.$$fullname)
Expand Down

0 comments on commit 9d65d7c

Please sign in to comment.