improved handling of SOGoSubscriptionFolderFormat

pull/48/head
Ludovic Marcotte 2014-07-24 12:48:03 -04:00
parent 5de51e8aa1
commit f6ef94a631
8 changed files with 96 additions and 51 deletions

1
NEWS
View File

@ -8,6 +8,7 @@ Enhancements
- improved badges of active tasks count - improved badges of active tasks count
- refresh draft folder after sending a message - refresh draft folder after sending a message
- now possible to DnD events in the calendar list - now possible to DnD events in the calendar list
- improved handling of SOGoSubscriptionFolderFormat
Bug fixes Bug fixes
- fixed weekdays translation in the datepicker - fixed weekdays translation in the datepicker

View File

@ -750,7 +750,8 @@ static SoSecurityManager *sm = nil;
for (userCount = 0; userCount < userMax; userCount++) for (userCount = 0; userCount < userMax; userCount++)
[currentFolder [currentFolder
subscribeUserOrGroup: [proxySubscribers objectAtIndex: userCount] subscribeUserOrGroup: [proxySubscribers objectAtIndex: userCount]
reallyDo: YES]; reallyDo: YES
response: nil];
} }
} }
} }
@ -775,7 +776,8 @@ static SoSecurityManager *sm = nil;
for (userCount = 0; userCount < userMax; userCount++) for (userCount = 0; userCount < userMax; userCount++)
[currentFolder [currentFolder
subscribeUserOrGroup: [proxySubscribers objectAtIndex: userCount] subscribeUserOrGroup: [proxySubscribers objectAtIndex: userCount]
reallyDo: NO]; reallyDo: NO
response: nil];
} }
} }
} }

View File

@ -216,18 +216,17 @@ static NSArray *childRecordFields = nil;
- (void) setFolderPropertyValue: (id) theValue - (void) setFolderPropertyValue: (id) theValue
inCategory: (NSString *) theKey inCategory: (NSString *) theKey
settings: (SOGoUserSettings *) theSettings
{ {
SOGoUserSettings *settings;
NSMutableDictionary *folderSettings, *values; NSMutableDictionary *folderSettings, *values;
NSString *module; NSString *module;
settings = [[context activeUser] userSettings];
module = [container nameInContainer]; module = [container nameInContainer];
folderSettings = [settings objectForKey: module]; folderSettings = [theSettings objectForKey: module];
if (!folderSettings) if (!folderSettings)
{ {
folderSettings = [NSMutableDictionary dictionary]; folderSettings = [NSMutableDictionary dictionary];
[settings setObject: folderSettings forKey: module]; [theSettings setObject: folderSettings forKey: module];
} }
values = [folderSettings objectForKey: theKey]; values = [folderSettings objectForKey: theKey];
if (theValue) if (theValue)
@ -249,7 +248,19 @@ static NSArray *childRecordFields = nil;
[folderSettings removeObjectForKey: theKey]; [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 - (id) folderPropertyValueInCategory: (NSString *) theKey
@ -281,34 +292,19 @@ static NSArray *childRecordFields = nil;
SOGoDomainDefaults *dd; SOGoDomainDefaults *dd;
primaryDN = [row objectForKey: @"c_foldername"]; primaryDN = [row objectForKey: @"c_foldername"];
if ([primaryDN length]) 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) DESTROY(displayName);
// 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];
dd = [[context activeUser] domainDefaults]; if ([primaryDN isEqualToString: [container defaultFolderName]])
subjectFormat = [dd subscriptionFolderFormat]; displayName = [self labelForKey: primaryDN
inContext: context];
else
displayName =primaryDN;
displayName = [folderSubscriptionValues keysWithFormat: subjectFormat]; RETAIN(displayName);
[displayName retain];
} }
}
} }
/* This method fetches the display name defined by the owner, but is also the /* This method fetches the display name defined by the owner, but is also the
@ -365,6 +361,7 @@ static NSArray *childRecordFields = nil;
else else
{ {
[self _fetchDisplayNameFromSubscriber]; [self _fetchDisplayNameFromSubscriber];
if (!displayName) if (!displayName)
[self _fetchDisplayNameFromOwner]; [self _fetchDisplayNameFromOwner];
} }
@ -856,11 +853,15 @@ static NSArray *childRecordFields = nil;
- (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier
reallyDo: (BOOL) reallyDo reallyDo: (BOOL) reallyDo
response: (WOResponse *) theResponse
{ {
NSDictionary *ownerIdentity, *folderSubscriptionValues;
NSMutableDictionary *moduleSettings, *folderShowAlarms; NSMutableDictionary *moduleSettings, *folderShowAlarms;
NSString *subjectFormat, *formattedName;
NSMutableArray *folderSubscription; NSMutableArray *folderSubscription;
NSString *subscriptionPointer; NSString *subscriptionPointer;
NSMutableArray *allUsers; NSMutableArray *allUsers;
SOGoDomainDefaults *dd;
SOGoUserSettings *us; SOGoUserSettings *us;
NSDictionary *dict; NSDictionary *dict;
SOGoUser *sogoUser; SOGoUser *sogoUser;
@ -892,6 +893,26 @@ static NSArray *childRecordFields = nil;
} }
rc = NO; 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++) for (i = 0; i < [allUsers count]; i++)
{ {
@ -929,6 +950,10 @@ static NSArray *childRecordFields = nil;
forKey: @"FolderShowAlarms"]; forKey: @"FolderShowAlarms"];
} }
[self setFolderPropertyValue: formattedName
inCategory: @"FolderDisplayNames"
settings: us];
[folderSubscription addObjectUniquely: subscriptionPointer]; [folderSubscription addObjectUniquely: subscriptionPointer];
// By default, we disable alarms on subscribed calendars // By default, we disable alarms on subscribed calendars
@ -987,7 +1012,7 @@ static NSArray *childRecordFields = nil;
response = [context response]; response = [context response];
[response setHeader: @"text/plain; charset=utf-8" [response setHeader: @"text/plain; charset=utf-8"
forKey: @"Content-Type"]; forKey: @"Content-Type"];
[response setStatus: 204]; [response setStatus: 200];
currentUser = [context activeUser]; currentUser = [context activeUser];
delegatedUsers = [self _parseDAVDelegatedUsers]; delegatedUsers = [self _parseDAVDelegatedUsers];
@ -1002,7 +1027,8 @@ static NSArray *childRecordFields = nil;
create contention on GDNC. */ create contention on GDNC. */
for (count = 0; count < max; count++) for (count = 0; count < max; count++)
[self subscribeUserOrGroup: [delegatedUsers objectAtIndex: count] [self subscribeUserOrGroup: [delegatedUsers objectAtIndex: count]
reallyDo: reallyDo]; reallyDo: reallyDo
response: response];
} }
else else
{ {
@ -1021,7 +1047,9 @@ static NSArray *childRecordFields = nil;
@"You cannot (un)subscribe to a folder that you own!"]; @"You cannot (un)subscribe to a folder that you own!"];
} }
else else
[self subscribeUserOrGroup: userLogin reallyDo: reallyDo]; [self subscribeUserOrGroup: userLogin
reallyDo: reallyDo
response: response];
} }
return response; return response;

View File

@ -153,13 +153,15 @@
- (NSArray *) _subFoldersFromFolder: (SOGoParentFolder *) parentFolder - (NSArray *) _subFoldersFromFolder: (SOGoParentFolder *) parentFolder
{ {
NSMutableArray *folders; NSDictionary *folderSubscriptionValues, *ownerIdentity;
NSEnumerator *subfolders; NSString *folderName, *folderOwner, *formattedName;
SOGoFolder *currentFolder;
NSString *folderName, *folderOwner;
Class subfolderClass;
NSMutableDictionary *currentDictionary; NSMutableDictionary *currentDictionary;
SoSecurityManager *securityManager; SoSecurityManager *securityManager;
SOGoFolder *currentFolder;
NSEnumerator *subfolders;
NSMutableArray *folders;
SOGoDomainDefaults *dd;
Class subfolderClass;
folders = [NSMutableArray array]; folders = [NSMutableArray array];
@ -190,6 +192,18 @@
forKey: @"owner"]; forKey: @"owner"];
[currentDictionary setObject: [currentFolder folderType] [currentDictionary setObject: [currentFolder folderType]
forKey: @"type"]; 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]; [folders addObject: currentDictionary];
} }
} }

View File

@ -1,8 +1,6 @@
/* UIxAclEditor.m - this file is part of SOGo /* UIxAclEditor.m - this file is part of SOGo
* *
* Copyright (C) 2006-2010 Inverse inc. * Copyright (C) 2006-2014 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -138,7 +136,7 @@
- (BOOL) canSubscribeUsers - (BOOL) canSubscribeUsers
{ {
return [[self clientObject] return [[self clientObject]
respondsToSelector: @selector (subscribeUserOrGroup:reallyDo:)]; respondsToSelector: @selector (subscribeUserOrGroup:reallyDo:response:)];
} }
- (BOOL) currentUserIsSubscribed - (BOOL) currentUserIsSubscribed

View File

@ -89,7 +89,10 @@
} }
else else
{ {
[clientObject subscribeUserOrGroup: login reallyDo: reallyDo]; [clientObject subscribeUserOrGroup: login
reallyDo: reallyDo
response: response];
if (isMailInvitation) if (isMailInvitation)
{ {
mailInvitationURL mailInvitationURL
@ -373,7 +376,8 @@
max = [userIDs count]; max = [userIDs count];
for (count = 0; count < max; count++) for (count = 0; count < max; count++)
[folder subscribeUserOrGroup: [userIDs objectAtIndex: count] [folder subscribeUserOrGroup: [userIDs objectAtIndex: count]
reallyDo: YES]; reallyDo: YES
response: response];
ex = nil; ex = nil;
} }
else else

View File

@ -1,8 +1,6 @@
/* SOGoUserHomePage.m - this file is part of SOGo /* SOGoUserHomePage.m - this file is part of SOGo
* *
* Copyright (C) 2007-2010 Inverse inc. * Copyright (C) 2007-2014 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
* This file is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -447,7 +445,7 @@
foldersEnum = [folders objectEnumerator]; foldersEnum = [folders objectEnumerator];
while ((currentFolder = [foldersEnum nextObject])) while ((currentFolder = [foldersEnum nextObject]))
[response appendContentString: [response appendContentString:
[currentFolder keysWithFormat: @";%{displayName}:%{name}:%{type}"]]; [currentFolder keysWithFormat: @";%{displayName}:%{name}:%{type}:%{formattedName}"]];
return response; return response;
} }

View File

@ -198,7 +198,9 @@ function addFolderBranchToTree(tree, user, folder, nodeId, subId, isLast) {
var node = new dTreeNode(subId, nodeId, name, 0, '#', folderId, var node = new dTreeNode(subId, nodeId, name, 0, '#', folderId,
folderInfos[2] + '-folder', '', '', icon, icon); folderInfos[2] + '-folder', '', '', icon, icon);
node._ls = isLast; node._ls = isLast;
var content = tree.node(node, (nodeId + subId), null); var content = tree.node(node, (nodeId + subId), null);
content._formattedName = folderInfos[3];
return content; return content;
} }
@ -227,9 +229,7 @@ function onConfirmFolderSelection(event) {
folderName = description.replace(/>,.*$/, ">", "g"); folderName = description.replace(/>,.*$/, ">", "g");
} }
else { else {
var resource = $(topNode.selectedEntry).down("SPAN.nodeName"); folderName = node._formattedName;
folderName = resource.innerHTML;
folderName = folderName.replace(/>,.*(\))?$/, ">)$1", "g");
} }
var data = { folderName: folderName, folder: folder, type: type, window: window }; var data = { folderName: folderName, folder: folder, type: type, window: window };
if (parent$(accessToSubscribedFolder(folder))) if (parent$(accessToSubscribedFolder(folder)))