diff --git a/NEWS b/NEWS index 742d6e268..22d67d66b 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ Enhancements - improved badges of active tasks count - refresh draft folder after sending a message - now possible to DnD events in the calendar list + - improved handling of SOGoSubscriptionFolderFormat Bug fixes - fixed weekdays translation in the datepicker diff --git a/SoObjects/Appointments/SOGoAppointmentFolders.m b/SoObjects/Appointments/SOGoAppointmentFolders.m index 99b73a636..f5ae1b23c 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolders.m +++ b/SoObjects/Appointments/SOGoAppointmentFolders.m @@ -750,7 +750,8 @@ static SoSecurityManager *sm = nil; for (userCount = 0; userCount < userMax; userCount++) [currentFolder subscribeUserOrGroup: [proxySubscribers objectAtIndex: userCount] - reallyDo: YES]; + reallyDo: YES + response: nil]; } } } @@ -775,7 +776,8 @@ static SoSecurityManager *sm = nil; for (userCount = 0; userCount < userMax; userCount++) [currentFolder subscribeUserOrGroup: [proxySubscribers objectAtIndex: userCount] - reallyDo: NO]; + reallyDo: NO + response: nil]; } } } diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index b0110f58d..d23e05013 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -216,18 +216,17 @@ static NSArray *childRecordFields = nil; - (void) setFolderPropertyValue: (id) theValue inCategory: (NSString *) theKey + settings: (SOGoUserSettings *) theSettings { - SOGoUserSettings *settings; NSMutableDictionary *folderSettings, *values; NSString *module; - settings = [[context activeUser] userSettings]; module = [container nameInContainer]; - folderSettings = [settings objectForKey: module]; + folderSettings = [theSettings objectForKey: module]; if (!folderSettings) { folderSettings = [NSMutableDictionary dictionary]; - [settings setObject: folderSettings forKey: module]; + [theSettings setObject: folderSettings forKey: module]; } values = [folderSettings objectForKey: theKey]; if (theValue) @@ -249,7 +248,19 @@ static NSArray *childRecordFields = nil; [folderSettings removeObjectForKey: theKey]; } - [settings synchronize]; + [theSettings synchronize]; +} + +- (void) setFolderPropertyValue: (id) theValue + inCategory: (NSString *) theKey +{ + SOGoUserSettings *settings; + + settings = [[context activeUser] userSettings]; + + [self setFolderPropertyValue: theValue + inCategory: theKey + settings: settings]; } - (id) folderPropertyValueInCategory: (NSString *) theKey @@ -281,34 +292,19 @@ static NSArray *childRecordFields = nil; SOGoDomainDefaults *dd; primaryDN = [row objectForKey: @"c_foldername"]; + if ([primaryDN length]) - { - displayName = [NSMutableString new]; - if ([primaryDN isEqualToString: [container defaultFolderName]]) - [displayName appendString: [self labelForKey: primaryDN - inContext: context]]; - else - [displayName appendString: primaryDN]; - - if (!activeUserIsOwner) { - // We MUST NOT use SOGoUser instances here (by calling -primaryIdentity) - // as it'll load user defaults and user settings which is _very costly_ - // since it involves JSON parsing and database requests - ownerIdentity = [[SOGoUserManager sharedUserManager] - contactInfosForUserWithUIDorEmail: owner]; - - folderSubscriptionValues = [[NSMutableDictionary alloc] initWithObjectsAndKeys: displayName, @"FolderName", - [ownerIdentity objectForKey: @"cn"], @"UserName", - [ownerIdentity objectForKey: @"c_email"], @"Email", nil]; + DESTROY(displayName); - dd = [[context activeUser] domainDefaults]; - subjectFormat = [dd subscriptionFolderFormat]; + if ([primaryDN isEqualToString: [container defaultFolderName]]) + displayName = [self labelForKey: primaryDN + inContext: context]; + else + displayName =primaryDN; - displayName = [folderSubscriptionValues keysWithFormat: subjectFormat]; - [displayName retain]; + RETAIN(displayName); } - } } /* This method fetches the display name defined by the owner, but is also the @@ -365,6 +361,7 @@ static NSArray *childRecordFields = nil; else { [self _fetchDisplayNameFromSubscriber]; + if (!displayName) [self _fetchDisplayNameFromOwner]; } @@ -856,11 +853,15 @@ static NSArray *childRecordFields = nil; - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier reallyDo: (BOOL) reallyDo + response: (WOResponse *) theResponse { + NSDictionary *ownerIdentity, *folderSubscriptionValues; NSMutableDictionary *moduleSettings, *folderShowAlarms; + NSString *subjectFormat, *formattedName; NSMutableArray *folderSubscription; NSString *subscriptionPointer; NSMutableArray *allUsers; + SOGoDomainDefaults *dd; SOGoUserSettings *us; NSDictionary *dict; SOGoUser *sogoUser; @@ -892,6 +893,26 @@ static NSArray *childRecordFields = nil; } rc = NO; + + // We MUST NOT use SOGoUser instances here (by calling -primaryIdentity) + // as it'll load user defaults and user settings which is _very costly_ + // since it involves JSON parsing and database requests + ownerIdentity = [[SOGoUserManager sharedUserManager] + contactInfosForUserWithUIDorEmail: owner]; + + + folderSubscriptionValues = [[NSDictionary alloc] initWithObjectsAndKeys: [self displayName], @"FolderName", + [ownerIdentity objectForKey: @"cn"], @"UserName", + [ownerIdentity objectForKey: @"c_email"], @"Email", nil]; + + dd = [[context activeUser] domainDefaults]; + subjectFormat = [dd subscriptionFolderFormat]; + + formattedName = [folderSubscriptionValues keysWithFormat: subjectFormat]; + + // This is consumed by SOGo Integrator during folder subscription since v24.0.6 + if (theResponse) + [theResponse appendContentString: formattedName]; for (i = 0; i < [allUsers count]; i++) { @@ -929,6 +950,10 @@ static NSArray *childRecordFields = nil; forKey: @"FolderShowAlarms"]; } + [self setFolderPropertyValue: formattedName + inCategory: @"FolderDisplayNames" + settings: us]; + [folderSubscription addObjectUniquely: subscriptionPointer]; // By default, we disable alarms on subscribed calendars @@ -987,7 +1012,7 @@ static NSArray *childRecordFields = nil; response = [context response]; [response setHeader: @"text/plain; charset=utf-8" forKey: @"Content-Type"]; - [response setStatus: 204]; + [response setStatus: 200]; currentUser = [context activeUser]; delegatedUsers = [self _parseDAVDelegatedUsers]; @@ -1002,7 +1027,8 @@ static NSArray *childRecordFields = nil; create contention on GDNC. */ for (count = 0; count < max; count++) [self subscribeUserOrGroup: [delegatedUsers objectAtIndex: count] - reallyDo: reallyDo]; + reallyDo: reallyDo + response: response]; } else { @@ -1021,7 +1047,9 @@ static NSArray *childRecordFields = nil; @"You cannot (un)subscribe to a folder that you own!"]; } else - [self subscribeUserOrGroup: userLogin reallyDo: reallyDo]; + [self subscribeUserOrGroup: userLogin + reallyDo: reallyDo + response: response]; } return response; diff --git a/SoObjects/SOGo/SOGoUserFolder.m b/SoObjects/SOGo/SOGoUserFolder.m index c450dc0cf..9292f9ffa 100644 --- a/SoObjects/SOGo/SOGoUserFolder.m +++ b/SoObjects/SOGo/SOGoUserFolder.m @@ -153,13 +153,15 @@ - (NSArray *) _subFoldersFromFolder: (SOGoParentFolder *) parentFolder { - NSMutableArray *folders; - NSEnumerator *subfolders; - SOGoFolder *currentFolder; - NSString *folderName, *folderOwner; - Class subfolderClass; + NSDictionary *folderSubscriptionValues, *ownerIdentity; + NSString *folderName, *folderOwner, *formattedName; NSMutableDictionary *currentDictionary; SoSecurityManager *securityManager; + SOGoFolder *currentFolder; + NSEnumerator *subfolders; + NSMutableArray *folders; + SOGoDomainDefaults *dd; + Class subfolderClass; folders = [NSMutableArray array]; @@ -190,6 +192,18 @@ forKey: @"owner"]; [currentDictionary setObject: [currentFolder folderType] forKey: @"type"]; + + dd = [[context activeUser] domainDefaults]; + ownerIdentity = [[SOGoUserManager sharedUserManager] + contactInfosForUserWithUIDorEmail: owner]; + folderSubscriptionValues = [[NSDictionary alloc] initWithObjectsAndKeys: [currentFolder displayName], @"FolderName", + [ownerIdentity objectForKey: @"cn"], @"UserName", + [ownerIdentity objectForKey: @"c_email"], @"Email", nil]; + + formattedName = [folderSubscriptionValues keysWithFormat: [dd subscriptionFolderFormat]]; + [currentDictionary setObject: formattedName + forKey: @"formattedName"]; + [folders addObject: currentDictionary]; } } diff --git a/UI/Common/UIxAclEditor.m b/UI/Common/UIxAclEditor.m index a50e0ff07..8c39a7ebd 100644 --- a/UI/Common/UIxAclEditor.m +++ b/UI/Common/UIxAclEditor.m @@ -1,8 +1,6 @@ /* UIxAclEditor.m - this file is part of SOGo * - * Copyright (C) 2006-2010 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2006-2014 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 @@ -138,7 +136,7 @@ - (BOOL) canSubscribeUsers { return [[self clientObject] - respondsToSelector: @selector (subscribeUserOrGroup:reallyDo:)]; + respondsToSelector: @selector (subscribeUserOrGroup:reallyDo:response:)]; } - (BOOL) currentUserIsSubscribed diff --git a/UI/Common/UIxFolderActions.m b/UI/Common/UIxFolderActions.m index fb0a95eeb..74f0134c7 100644 --- a/UI/Common/UIxFolderActions.m +++ b/UI/Common/UIxFolderActions.m @@ -89,7 +89,10 @@ } else { - [clientObject subscribeUserOrGroup: login reallyDo: reallyDo]; + [clientObject subscribeUserOrGroup: login + reallyDo: reallyDo + response: response]; + if (isMailInvitation) { mailInvitationURL @@ -373,7 +376,8 @@ max = [userIDs count]; for (count = 0; count < max; count++) [folder subscribeUserOrGroup: [userIDs objectAtIndex: count] - reallyDo: YES]; + reallyDo: YES + response: response]; ex = nil; } else diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index 95d7a72de..4031b4900 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -1,8 +1,6 @@ /* SOGoUserHomePage.m - this file is part of SOGo * - * Copyright (C) 2007-2010 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2007-2014 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 @@ -447,7 +445,7 @@ foldersEnum = [folders objectEnumerator]; while ((currentFolder = [foldersEnum nextObject])) [response appendContentString: - [currentFolder keysWithFormat: @";%{displayName}:%{name}:%{type}"]]; + [currentFolder keysWithFormat: @";%{displayName}:%{name}:%{type}:%{formattedName}"]]; return response; } diff --git a/UI/WebServerResources/UIxContactsUserFolders.js b/UI/WebServerResources/UIxContactsUserFolders.js index 2df373add..d66457835 100644 --- a/UI/WebServerResources/UIxContactsUserFolders.js +++ b/UI/WebServerResources/UIxContactsUserFolders.js @@ -198,7 +198,9 @@ function addFolderBranchToTree(tree, user, folder, nodeId, subId, isLast) { var node = new dTreeNode(subId, nodeId, name, 0, '#', folderId, folderInfos[2] + '-folder', '', '', icon, icon); node._ls = isLast; + var content = tree.node(node, (nodeId + subId), null); + content._formattedName = folderInfos[3]; return content; } @@ -227,9 +229,7 @@ function onConfirmFolderSelection(event) { folderName = description.replace(/>,.*$/, ">", "g"); } else { - var resource = $(topNode.selectedEntry).down("SPAN.nodeName"); - folderName = resource.innerHTML; - folderName = folderName.replace(/>,.*(\))?$/, ">)$1", "g"); + folderName = node._formattedName; } var data = { folderName: folderName, folder: folder, type: type, window: window }; if (parent$(accessToSubscribedFolder(folder)))