diff --git a/ChangeLog b/ChangeLog index d5cc529f0..8e7a3278e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-06-11 Wolfgang Sourdeau + + * UI/MainUI/SOGoUserHomePage.m (-usersSearchAction): do not return + the user information for the current user. + (-foldersSearchAction): the method only search folders for the + owner of the current folder. The "user" parameter has thus been + removed. + 2009-06-10 Wolfgang Sourdeau * SoObjects/SOGo/NSString+Utilities.m (-stringByDetectingURLs): diff --git a/SoObjects/Contacts/SOGoUserFolder+Contacts.h b/SoObjects/Contacts/SOGoUserFolder+Contacts.h index 9d8b9d3be..89f1ca0a3 100644 --- a/SoObjects/Contacts/SOGoUserFolder+Contacts.h +++ b/SoObjects/Contacts/SOGoUserFolder+Contacts.h @@ -24,7 +24,6 @@ #define SOGOUSERFOLDER_CONTACTS_H @class NSArray; -@class NSString; #import diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 62ff946c2..e5f219abf 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -718,7 +718,7 @@ static NSArray *childRecordFields = nil; currentUser = [localContext activeUser]; - if (delegatedUsers && [delegatedUsers count]) + if ([delegatedUsers count]) { if (![currentUser isSuperUser]) { diff --git a/SoObjects/SOGo/SOGoUserFolder.m b/SoObjects/SOGo/SOGoUserFolder.m index 2f9505dfc..99bdaec51 100644 --- a/SoObjects/SOGo/SOGoUserFolder.m +++ b/SoObjects/SOGo/SOGoUserFolder.m @@ -129,7 +129,8 @@ static NSString *LDAPContactInfoAttribute = nil; for (count = 0; count < max; count++) { node = [children objectAtIndex: count]; - componentName = [[(id)node attribute: @"name"] lowercaseString]; + componentName = [[(id)node attribute: @"name"] + lowercaseString]; [filter setObject: [node textValue] forKey: componentName]; } diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index 793d0878b..3dee81769 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -289,16 +289,17 @@ static NSString *LDAPContactInfoAttribute = nil; return response; } -- (WOResponse *) _usersResponseForResults: (NSEnumerator *) users +- (WOResponse *) _usersResponseForResults: (NSArray *) users { WOResponse *response; NSString *uid; NSMutableString *responseString; NSDictionary *contact; - NSString *contactInfo; + NSString *contactInfo, *login; NSArray *allUsers; int i; + login = [[context activeUser] login]; response = [context response]; [response setStatus: 200]; [response setHeader: @"text/plain; charset=utf-8" @@ -308,25 +309,28 @@ static NSString *LDAPContactInfoAttribute = nil; // We sort our array - this is pretty useful for the Web // interface of SOGo. - allUsers = [[users allObjects] - sortedArrayUsingSelector: @selector(caseInsensitiveDisplayNameCompare:)]; + allUsers = [users + sortedArrayUsingSelector: @selector (caseInsensitiveDisplayNameCompare:)]; for (i = 0; i < [allUsers count]; i++) { contact = [allUsers objectAtIndex: i]; uid = [contact objectForKey: @"c_uid"]; - if ([LDAPContactInfoAttribute length]) - { - contactInfo = [contact objectForKey: LDAPContactInfoAttribute]; - if (!contactInfo) - contactInfo = @""; - } - else - contactInfo = @""; - [responseString appendFormat: @"%@:%@:%@:%@\n", uid, - [contact objectForKey: @"cn"], - [contact objectForKey: @"c_email"], - contactInfo]; + if (![uid isEqualToString: login]) + { + if ([LDAPContactInfoAttribute length]) + { + contactInfo = [contact objectForKey: LDAPContactInfoAttribute]; + if (!contactInfo) + contactInfo = @""; + } + else + contactInfo = @""; + [responseString appendFormat: @"%@:%@:%@:%@\n", uid, + [contact objectForKey: @"cn"], + [contact objectForKey: @"c_email"], + contactInfo]; + } } [response appendContentString: responseString]; [responseString release]; @@ -339,14 +343,13 @@ static NSString *LDAPContactInfoAttribute = nil; NSString *contact; id result; LDAPUserManager *um; - NSEnumerator *users; um = [LDAPUserManager sharedUserManager]; contact = [self queryParameterForKey: @"search"]; if ([contact length]) { - users = [[um fetchUsersMatching: contact] objectEnumerator]; - result = [self _usersResponseForResults: users]; + result + = [self _usersResponseForResults: [um fetchUsersMatching: contact]]; } else result = [NSException exceptionWithHTTPStatus: 400 @@ -375,27 +378,23 @@ static NSString *LDAPContactInfoAttribute = nil; - (id ) foldersSearchAction { - NSString *contact, *folderType; + NSString *folderType; NSArray *folders; id result; + SOGoUserFolder *userFolder; - contact = [self queryParameterForKey: @"user"]; - if ([contact length]) + folderType = [self queryParameterForKey: @"type"]; + if ([folderType length]) { - folderType = [self queryParameterForKey: @"type"]; - if ([folderType length]) - { - folders = [[self clientObject] foldersOfType: folderType - forUID: contact]; - result = [self _foldersResponseForResults: folders]; - } - else - result = [NSException exceptionWithHTTPStatus: 400 - reason: @"missing 'type' parameter"]; + userFolder = [self clientObject]; + folders + = [userFolder foldersOfType: folderType + forUID: [userFolder ownerInContext: context]]; + result = [self _foldersResponseForResults: folders]; } else result = [NSException exceptionWithHTTPStatus: 400 - reason: @"missing 'user' parameter"]; + reason: @"missing 'type' parameter"]; return result; } diff --git a/UI/WebServerResources/UIxContactsUserFolders.js b/UI/WebServerResources/UIxContactsUserFolders.js index 68449cdd9..ded19b9fb 100644 --- a/UI/WebServerResources/UIxContactsUserFolders.js +++ b/UI/WebServerResources/UIxContactsUserFolders.js @@ -94,9 +94,9 @@ function onUserNodeToggle(event) { this.stopObserving("click", onUserNodeToggle); var person = this.parentNode.getAttribute("dataname"); - var url = (UserFolderURL + "foldersSearch" - + "?user=" + escape(person) - + "&type=" + window.opener.userFolderType); + + var url = (UserFolderURLForUser(person) + "foldersSearch" + + "?type=" + window.opener.userFolderType); var nodeId = this.getAttribute("id").substr(3); triggerAjaxRequest(url, foldersSearchCallback, { nodeId: nodeId, user: person }); diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index fa11b3858..d1523957f 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -352,9 +352,7 @@ function getContrastingTextColor(bgColor) { // Consider all colors with less than 56% brightness as dark colors and // use white as the foreground color, otherwise use black. - return ((brightness < 144) - ? "white" - : "black"); + return ((brightness < 144) ? "white" : "black"); } function triggerAjaxRequest(url, callback, userdata, content, headers) { @@ -1615,6 +1613,19 @@ function configureLinkBanner() { } } +/* accessing another user's data */ +function UserFolderURLForUser(user) { + var folderArray = UserFolderURL.split("/"); + var count; + if (UserFolderURL.endsWith('/')) + count = folderArray.length - 2; + else + count = folderArray.length - 1; + folderArray[count] = escape(user); + + return folderArray.join("/"); +} + /* folder creation */ function createFolder(name, okCB, notOkCB) { if (name) {