diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index c7ce63c84..d82e9da0a 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -373,7 +373,9 @@ static NSArray *childRecordFields = nil; dd = [[context activeUser] domainDefaults]; displayNameFormat = [dd subscriptionFolderFormat]; - name = [folderSubscriptionValues keysWithFormat: displayNameFormat]; + // Use a format only if it was defined by the user + if (displayNameFormat) + name = [folderSubscriptionValues keysWithFormat: displayNameFormat]; } return name; diff --git a/Tools/SOGoToolManageACL.m b/Tools/SOGoToolManageACL.m index 6465ebd63..fb40a595d 100644 --- a/Tools/SOGoToolManageACL.m +++ b/Tools/SOGoToolManageACL.m @@ -35,12 +35,17 @@ #import #import #import +#import +#import #import +#import #import #import #import +#import + #import "SOGoTool.h" typedef enum @@ -49,6 +54,8 @@ typedef enum ManageACLGet = 0, ManageACLAdd = 1, ManageACLRemove = 2, + ManageACLSubscribe = 3, + ManageACLUnsubscribe = 3, } SOGoManageACLCommand; @interface SOGoToolManageACL : SOGoTool @@ -99,14 +106,16 @@ typedef enum - (void) usage { - fprintf (stderr, "manage-acl get|add|remove owner folder user \n\n" - " get get ACL information of folder for user\n" - " add add ACL information of folder for user\n" - " remove remove all ACL information of folder for user\n" - " owner the user owning the folder\n" - " folder the folder - Calendar/ or Contacst/\n" - " user the user to get/set rights for - 'ALL', '', 'anonymous' are supported\n" - " rights rights to add\n\n" + fprintf (stderr, "manage-acl get|add|remove|subscribe|unsubscribe owner folder user \n\n" + " get get ACL information of folder for user\n" + " add add ACL information of folder for user\n" + " remove remove all ACL information of folder for user\n" + " subscribe subscribe user to owner's folder\n" + " unsubscribe unsubscribe user to owner's folder\n" + " owner the user owning the folder\n" + " folder the folder - Calendar/ or Contacst/\n" + " user the user to get/set rights for - 'ALL', '', 'anonymous' are supported\n" + " rights rights to add\n\n" "Example: sogo-tool manage-acl get jdoe Calendar/personal\n\n" "Note: You can add only one access right at the time. To set them all at once,\n" " invoke 'remove' first to remove them all.\n\n"); @@ -131,6 +140,10 @@ typedef enum } else if ([s isEqualToString: @"remove"]) command = ManageACLRemove; + else if ([s isEqualToString: @"subscribe"]) + command = ManageACLSubscribe; + else if ([s isEqualToString: @"unsubscribe"]) + command = ManageACLUnsubscribe; else { [self usage]; @@ -349,9 +362,7 @@ typedef enum if ([theUser isEqualToString: @"ALL"]) qs = [NSString stringWithFormat: @"c_uid LIKE '\%'", theUser]; else - { - qs = [NSString stringWithFormat: @"c_uid = '%@'", theUser]; - } + qs = [NSString stringWithFormat: @"c_uid = '%@'", theUser]; qualifier = [EOQualifier qualifierWithQualifierFormat: qs]; @@ -363,6 +374,30 @@ typedef enum forPath: path]; } +- (void) subscribeOrUnsubscribeUser: (NSString *) theUser + toFolder: (GCSFolder *) theFolder + reallyDo: (BOOL) reallyDo +{ + SOGoParentFolder *parentFolder; + SOGoUserFolder *userFolder; + SOGoGCSFolder *gcsFolder; + WOContext *localContext; + NSArray *components; + + localContext = [WOContext context]; + [localContext setActiveUser: [SOGoUser userWithLogin: owner]]; + userFolder = [SOGoUserFolder objectWithName: owner inContainer: nil]; + components = [folder componentsSeparatedByString: @"/"]; + parentFolder = [userFolder lookupName: [components objectAtIndex: 0] + inContext: localContext + acquire: NO]; + + gcsFolder = [parentFolder lookupPersonalFolder: [components objectAtIndex: 1] + ignoringRights: YES]; + + [gcsFolder subscribeUserOrGroup: user reallyDo: YES response: nil]; +} + - (BOOL) proceed { NSAutoreleasePool *pool; @@ -391,6 +426,10 @@ typedef enum [self removeACLForUser: user folder: f]; else if (command == ManageACLAdd) [self addACLForUser: user folder: f]; + else if (command == ManageACLSubscribe) + [self subscribeOrUnsubscribeUser: user toFolder: f reallyDo: YES]; + else if (command == ManageACLUnsubscribe) + [self subscribeOrUnsubscribeUser: user toFolder: f reallyDo: NO]; else [self usage]; }