diff --git a/ChangeLog b/ChangeLog index bfc8ee888..d16133613 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2007-05-30 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoObject.m ([SOGoObject -davURL]): new method + that returns the full dav url to self. + ([SOGoObject -soURL]): same as above but for the so url (Web UI). + ([SOGoObject -soURLToBaseContainerForUser:uid]): new method that + returns the full so url to the base of the SOGo module to which + self belongs, and for the specified user. + ([SOGoObject -soURLToBaseContainerForCurrentUser]): same as above + but for the current user. + ([SOGoObject -httpURLForAdvisoryToUser:uid]): new protocol method + required by the acl advisory templates and which returns a link + the target user can click to activate its new subscription. + ([SOGoObject -resourceURLForAdvisoryToUser:uid]): same as above + but for inclusion of the application/x-sogo-notification part, + which will be handled by the Lightning enhancer plugin. + * UI/MailerUI/UIxMailFolderActions.m ([UIxMailFolderActions -subscribeAction]) ([UIxMailFolderActions -unsubscribeAction]): new stub methods that do nothing yet since imap folder subscription is not handled yet. diff --git a/SoObjects/SOGo/SOGoObject.h b/SoObjects/SOGo/SOGoObject.h index b265699ef..8d83c8d79 100644 --- a/SoObjects/SOGo/SOGoObject.h +++ b/SoObjects/SOGo/SOGoObject.h @@ -41,6 +41,7 @@ @class NSMutableString; @class NSException; @class NSTimeZone; +@class NSURL; @class WOContext; @class GCSFolderManager; @@ -69,6 +70,11 @@ - (NSString *) nameInContainer; - (id) container; +- (NSURL *) davURL; +- (NSURL *) soURL; +- (NSURL *) soURLToBaseContainerForUser: (NSString *) uid; +- (NSURL *) soURLToBaseContainerForCurrentUser; + /* ownership */ - (void) setOwner: (NSString *) newOwner; @@ -104,7 +110,12 @@ forUser: (NSString *) uid; - (void) removeAclsForUsers: (NSArray *) users; - (NSString *) defaultUserID; -- (BOOL) hasSupportForDefaultRoles; + +- (void) sendACLAdditionAdvisoryToUser: (NSString *) uid; +- (void) sendACLRemovalAdvisoryToUser: (NSString *) uid; + +- (NSString *) httpURLForAdvisoryToUser: (NSString *) uid; +- (NSString *) resourceURLForAdvisoryToUser: (NSString *) uid; /* description */ diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 5ca5809f7..cd60e5857 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -24,19 +24,24 @@ Please use gnustep-base instead. #endif -#import +#import +#import +#import +#import +#import + +#import #import +#import +#import #import #import #import -#import +#import +#import +#import #import -#import - -#import "common.h" - -#import "NSArray+Utilities.h" -#import "NSString+Utilities.h" +#import #import "SOGoPermissions.h" #import "SOGoUser.h" @@ -45,6 +50,9 @@ #import "SOGoDAVRendererTypes.h" +#import "NSArray+Utilities.h" +#import "NSString+Utilities.h" + #import "SOGoObject.h" @interface SOGoObject(Content) @@ -737,9 +745,118 @@ static BOOL kontactGroupDAV = YES; return nil; } -- (BOOL) hasSupportForDefaultRoles +- (void) sendACLAdvisoryTemplate: (NSString *) template + toUser: (NSString *) uid { - return NO; + NSString *language, *pageName; + SOGoUser *user; + SOGoACLAdvisory *page; + WOApplication *app; + + user = [SOGoUser userWithLogin: uid roles: nil]; + language = [user language]; + pageName = [NSString stringWithFormat: @"SOGoACL%@%@Advisory", + language, template]; + + app = [WOApplication application]; + page = [app pageWithName: pageName inContext: context]; + [page setACLObject: self]; + [page setRecipientUID: uid]; + [page send]; +} + +- (void) sendACLAdditionAdvisoryToUser: (NSString *) uid +{ + return [self sendACLAdvisoryTemplate: @"Addition" + toUser: uid]; +} + +- (void) sendACLRemovalAdvisoryToUser: (NSString *) uid +{ + return [self sendACLAdvisoryTemplate: @"Removal" + toUser: uid]; +} + +- (NSURL *) _urlPreferringParticle: (NSString *) expected + overThisOne: (NSString *) possible +{ + NSURL *serverURL, *davURL; + NSMutableArray *path; + NSString *baseURL, *urlMethod; + + serverURL = [context serverURL]; + baseURL = [self baseURLInContext: context]; + path = [NSMutableArray arrayWithArray: [baseURL componentsSeparatedByString: + @"/"]]; + urlMethod = [path objectAtIndex: 2]; + if (![urlMethod isEqualToString: expected]) + { + if ([urlMethod isEqualToString: possible]) + [path replaceObjectAtIndex: 2 withObject: expected]; + else + [path insertObject: expected atIndex: 2]; + } + + davURL = [[NSURL alloc] initWithScheme: [serverURL scheme] + host: [serverURL host] + path: [path componentsJoinedByString: @"/"]]; + [davURL autorelease]; + + return davURL; +} + +- (NSURL *) davURL +{ + return [self _urlPreferringParticle: @"dav" overThisOne: @"so"]; +} + +- (NSURL *) soURL +{ + return [self _urlPreferringParticle: @"so" overThisOne: @"dav"]; +} + +- (NSURL *) soURLToBaseContainerForUser: (NSString *) uid +{ + NSURL *soURL, *baseSoURL; + NSArray *basePath; + NSMutableArray *newPath; + + soURL = [self soURL]; + basePath = [[soURL path] componentsSeparatedByString: @"/"]; + newPath + = [NSMutableArray arrayWithArray: + [basePath subarrayWithRange: NSMakeRange (0, 5)]]; + [newPath replaceObjectAtIndex: 3 withObject: uid]; + + baseSoURL = [[NSURL alloc] initWithScheme: [soURL scheme] + host: [soURL host] + path: [newPath componentsJoinedByString: @"/"]]; + [baseSoURL autorelease]; + + return baseSoURL; +} + +- (NSURL *) soURLToBaseContainerForCurrentUser +{ + NSString *currentLogin; + + currentLogin = [[context activeUser] login]; + + return [self soURLToBaseContainerForUser: currentLogin]; +} + +- (NSString *) httpURLForAdvisoryToUser: (NSString *) uid +{ + [self subclassResponsibility: _cmd]; + + return nil; +} + +- (NSString *) resourceURLForAdvisoryToUser: (NSString *) uid +{ + [self subclassResponsibility: _cmd]; + + return nil; } /* description */