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
- 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

View File

@ -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];
}
}
}

View File

@ -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;

View File

@ -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];
}
}

View File

@ -1,8 +1,6 @@
/* UIxAclEditor.m - this file is part of SOGo
*
* Copyright (C) 2006-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* 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

View File

@ -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

View File

@ -1,8 +1,6 @@
/* SOGoUserHomePage.m - this file is part of SOGo
*
* Copyright (C) 2007-2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* 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;
}

View File

@ -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)))