diff --git a/ChangeLog b/ChangeLog index dc5eafdf5..d66e11986 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2007-03-29 Wolfgang Sourdeau +2007-03-29 Wolfgang Sourdeau + + * UI/Common/UIxFolderActions.m ([UIxFolderActions + -activateFolderAction]): new method that change the "active" + settings in the folder-related fields in the user settings. + ([UIxFolderActions -deactivateFolderAction]): see above. * UI/Contacts/UIxContactFoldersView.m ([UIxContactFoldersView -checkRightsAction]): removed method. diff --git a/UI/Common/UIxFolderActions.h b/UI/Common/UIxFolderActions.h index ff959c3e7..5a08a684b 100644 --- a/UI/Common/UIxFolderActions.h +++ b/UI/Common/UIxFolderActions.h @@ -45,6 +45,9 @@ - (WOResponse *) subscribeAction; - (WOResponse *) unsubscribeAction; +- (WOResponse *) canAccessContentAction; +- (WOResponse *) activateFolderAction; +- (WOResponse *) deactivateFolderAction; @end diff --git a/UI/Common/UIxFolderActions.m b/UI/Common/UIxFolderActions.m index 82c257e03..473aaaef7 100644 --- a/UI/Common/UIxFolderActions.m +++ b/UI/Common/UIxFolderActions.m @@ -28,15 +28,20 @@ #import #import #import +#import #import #import #import +#import #import "UIxFolderActions.h" @implementation UIxFolderActions +#warning some of this code could probably be moved in one of the \ + clientObject classes... + - (void) _setupContext { NSString *clientClass; @@ -134,4 +139,65 @@ return [self _realActionWithFolderName: nil]; } +- (WOResponse *) canAccessContentAction +{ + WOResponse *response; + SoSecurityManager *securityManager; + BOOL result; + + securityManager = [SoSecurityManager sharedSecurityManager]; + result = (![securityManager validatePermission: SoPerm_AccessContentsInformation + onObject: [self clientObject] + inContext: context]); + + response = [context response]; + [response setStatus: 200]; + [response setHeader: @"text/plain; charset=\"ascii\"" + forKey: @"content-type"]; + [response appendContentString: (result) ? @"1" : @"0"]; + + return response; +} + +- (WOResponse *) _realFolderActivation: (BOOL) makeActive +{ + WOResponse *response; + NSMutableDictionary *folderSubscription, *folderDict; + NSNumber *active; + + response = [context response]; + + [self _setupContext]; + active = [NSNumber numberWithBool: makeActive]; + if ([owner isEqualToString: login]) + [moduleSettings setObject: active forKey: @"activateUserFolder"]; + else + { + folderSubscription + = [moduleSettings objectForKey: @"SubscribedFolders"]; + if (folderSubscription) + { + folderDict = [folderSubscription objectForKey: subscriptionPointer]; + if (folderDict) + [folderDict setObject: active + forKey: @"active"]; + } + } + + [ud synchronize]; + [response setStatus: 204]; + + return response; +} + +- (WOResponse *) activateFolderAction +{ + return [self _realFolderActivation: YES]; +} + +- (WOResponse *) deactivateFolderAction +{ + return [self _realFolderActivation: NO]; +} + @end diff --git a/UI/Common/product.plist b/UI/Common/product.plist index 9aff3ee09..d0166ea5a 100644 --- a/UI/Common/product.plist +++ b/UI/Common/product.plist @@ -42,6 +42,21 @@ actionClass = "UIxFolderActions"; actionName = "unsubscribe"; }; + canAccessContent = { + protectedBy = "View"; + actionClass = "UIxFolderActions"; + actionName = "canAccessContent"; + }; + activateFolder = { + protectedBy = "View"; + actionClass = "UIxFolderActions"; + actionName = "activateFolder"; + }; + deactivateFolder = { + protectedBy = "View"; + actionClass = "UIxFolderActions"; + actionName = "deactivateFolder"; + }; acls = { protectedBy = "ReadAcls"; pageName = "UIxAclEditor";