From e4a84d49202b2aa42251910dcbc1ffb8de6b498f Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Mon, 25 Aug 2014 12:15:05 -0400 Subject: [PATCH] Fix usage of SOGoSubscriptionFolderFormat default --- NEWS | 1 + SoObjects/SOGo/SOGoGCSFolder.h | 6 ++-- SoObjects/SOGo/SOGoGCSFolder.m | 63 +++++++++++++++++----------------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/NEWS b/NEWS index 00e96f1ce..92bb55872 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ Bug fixes - fixed crasher when subscribing users to resources (#2892) - fixed encoding of new calendars and new subscriptions (JavaScript only) - fixed display of users with no possible subscription + - fixed usage of SOGoSubscriptionFolderFormat domain default when the folder's name hasn't been changed 2.2.7 (2014-07-30) ------------------ diff --git a/SoObjects/SOGo/SOGoGCSFolder.h b/SoObjects/SOGo/SOGoGCSFolder.h index 794ebc9ac..806be9105 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.h +++ b/SoObjects/SOGo/SOGoGCSFolder.h @@ -1,6 +1,6 @@ /* Copyright (C) 2004-2005 SKYRIX Software AG - Copyright (C) 2006-2013 Inverse inc. + Copyright (C) 2006-2014 Inverse inc. This file is part of SOGo. @@ -53,7 +53,6 @@ NSString *ocsPath; GCSFolder *ocsFolder; NSMutableDictionary *childRecords; - NSMutableDictionary *folderSubscriptionValues; BOOL userCanAccessAllObjects; /* i.e. user obtains 'Access Object' on subobjects */ } @@ -102,7 +101,8 @@ withReference: (NSString *) reference; - (BOOL) subscribeUserOrGroup: (NSString *) theIdentifier - reallyDo: (BOOL) reallyDo; + reallyDo: (BOOL) reallyDo + response: (WOResponse *) theResponse; - (BOOL) userIsSubscriber: (NSString *) subscribingUser; - (void) initializeQuickTablesAclsInContext: (WOContext *) localContext; diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index d23e05013..e128f7424 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -196,7 +196,6 @@ static NSArray *childRecordFields = nil; ocsPath = nil; ocsFolder = nil; childRecords = [NSMutableDictionary new]; - folderSubscriptionValues = nil; userCanAccessAllObjects = NO; } @@ -208,7 +207,6 @@ static NSArray *childRecordFields = nil; [ocsFolder release]; [ocsPath release]; [childRecords release]; - [folderSubscriptionValues release]; [super dealloc]; } @@ -287,9 +285,6 @@ static NSArray *childRecordFields = nil; - (void) _setDisplayNameFromRow: (NSDictionary *) row { NSString *primaryDN; - NSDictionary *ownerIdentity; - NSString *subjectFormat; - SOGoDomainDefaults *dd; primaryDN = [row objectForKey: @"c_foldername"]; @@ -301,7 +296,7 @@ static NSArray *childRecordFields = nil; displayName = [self labelForKey: primaryDN inContext: context]; else - displayName =primaryDN; + displayName = primaryDN; RETAIN(displayName); } @@ -348,7 +343,31 @@ static NSArray *childRecordFields = nil; - (void) _fetchDisplayNameFromSubscriber { + NSDictionary *ownerIdentity, *folderSubscriptionValues; + NSString *displayNameFormat; + SOGoDomainDefaults *dd; + displayName = [self folderPropertyValueInCategory: @"FolderDisplayNames"]; + if (!displayName) + { + [self _fetchDisplayNameFromOwner]; + + // 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: displayName, @"FolderName", + [ownerIdentity objectForKey: @"cn"], @"UserName", + [ownerIdentity objectForKey: @"c_email"], @"Email", nil]; + + dd = [[context activeUser] domainDefaults]; + displayNameFormat = [dd subscriptionFolderFormat]; + + displayName = [folderSubscriptionValues keysWithFormat: displayNameFormat]; + } + [displayName retain]; } @@ -855,13 +874,10 @@ static NSArray *childRecordFields = nil; 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; @@ -869,7 +885,7 @@ static NSArray *childRecordFields = nil; int i; dict = [[SOGoUserManager sharedUserManager] contactInfosForUserWithUIDorEmail: theIdentifier]; - + if ([[dict objectForKey: @"isGroup"] boolValue]) { SOGoGroup *aGroup; @@ -891,28 +907,12 @@ static NSArray *childRecordFields = nil; else allUsers = [NSArray array]; } - + 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]; + [theResponse appendContentString: [self displayName]]; for (i = 0; i < [allUsers count]; i++) { @@ -926,8 +926,7 @@ static NSArray *childRecordFields = nil; [us setObject: moduleSettings forKey: [container nameInContainer]]; } - folderSubscription - = [moduleSettings objectForKey: @"SubscribedFolders"]; + folderSubscription = [moduleSettings objectForKey: @"SubscribedFolders"]; subscriptionPointer = [self folderReference]; folderShowAlarms = [moduleSettings objectForKey: @"FolderShowAlarms"]; @@ -950,7 +949,7 @@ static NSArray *childRecordFields = nil; forKey: @"FolderShowAlarms"]; } - [self setFolderPropertyValue: formattedName + [self setFolderPropertyValue: [self displayName] inCategory: @"FolderDisplayNames" settings: us];