From 4c99400a587c1c830cca95f6353e96952ef71ce3 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Thu, 4 Jan 2007 14:42:10 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1007 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 10 +++ .../Appointments/SOGoAppointmentFolder.h | 1 + .../Appointments/SOGoAppointmentFolder.m | 25 ++++++-- UI/Scheduler/UIxCalMainView.m | 61 +++++++++++++------ UI/Scheduler/UIxCalView.h | 1 - UI/Scheduler/UIxCalView.m | 34 +++-------- 6 files changed, 79 insertions(+), 53 deletions(-) diff --git a/ChangeLog b/ChangeLog index e22af632..8763230a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-01-04 Wolfgang Sourdeau + + * SoObjects/Appointments/SOGoAppointmentFolder.m + ([SOGoAppointmentFolder -lookupCalendarFolderForUID:uid]): method + moved from UI/Scheduler/UIxCalView:calendarFolderForUID:. + ([SOGoAppointmentFolder + -lookupCalendarFoldersForUIDs:_uidsinContext:]): now use the new + lookupCalendarFolderForUID: method, which doesn't do security + checks. + 2007-01-03 Wolfgang Sourdeau * UI/Common/UIxAclEditor.m ([UIxAclEditor -assistantsValue]): new diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.h b/SoObjects/Appointments/SOGoAppointmentFolder.h index 4d609ab2..48eac1d0 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.h +++ b/SoObjects/Appointments/SOGoAppointmentFolder.h @@ -87,6 +87,7 @@ - (id) lookupHomeFolderForUID: (NSString *) _uid inContext: (id) _ctx; +- (SOGoAppointmentFolder *) lookupCalendarFolderForUID: (NSString *) uid; - (NSArray *) lookupCalendarFoldersForUIDs: (NSArray *) _uids inContext: (id) _ctx; - (NSArray *) lookupFreeBusyObjectsForUIDs: (NSArray *) _uids diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 3fe48dba..3d39ef3a 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -903,6 +903,24 @@ static NSNumber *sharedYes = nil; return result; } +- (SOGoAppointmentFolder *) lookupCalendarFolderForUID: (NSString *) uid +{ + SOGoFolder *upperContainer; + SOGoUserFolder *userFolder; + SOGoAppointmentFolder *calendarFolder; + + upperContainer = [[self container] container]; + userFolder = [SOGoUserFolder objectWithName: uid + inContainer: upperContainer]; + calendarFolder = [SOGoAppointmentFolder objectWithName: @"Calendar" + inContainer: userFolder]; + [calendarFolder + setOCSPath: [NSString stringWithFormat: @"/Users/%@/Calendar", uid]]; + [calendarFolder setOwner: uid]; + + return calendarFolder; +} + - (NSArray *) lookupCalendarFoldersForUIDs: (NSArray *) _uids inContext: (id)_ctx { @@ -917,12 +935,7 @@ static NSNumber *sharedYes = nil; while ((uid = [e nextObject])) { id folder; - folder = [self lookupHomeFolderForUID:uid inContext:nil]; - if ([folder isNotNull]) { - folder = [folder lookupName:@"Calendar" inContext:nil acquire:NO]; - if ([folder isKindOfClass:[NSException class]]) - folder = nil; - } + folder = [self lookupCalendarFolderForUID: uid]; if (![folder isNotNull]) [self logWithFormat:@"Note: did not find folder for uid: '%@'", uid]; diff --git a/UI/Scheduler/UIxCalMainView.m b/UI/Scheduler/UIxCalMainView.m index 35eef413..fc2bcad5 100644 --- a/UI/Scheduler/UIxCalMainView.m +++ b/UI/Scheduler/UIxCalMainView.m @@ -26,8 +26,10 @@ #import #import +#import #import +#import #import #import "UIxCalMainView.h" @@ -128,40 +130,59 @@ static NSMutableArray *yearMenuItems = nil; return response; } -- (id ) checkRightsAction +- (NSString *) _rightsForUIDs: (NSString *) uids { - WOResponse *response; - NSUserDefaults *ud; - NSString *uids, *uid; + NSEnumerator *ids; + NSString *uid; NSMutableString *rights; - NSArray *ids; - unsigned int count, max; + SOGoAppointmentFolder *refFolder, *currentFolder; + SoSecurityManager *securityManager; BOOL result; - ud = [[context activeUser] userDefaults]; - uids = [ud stringForKey: @"calendaruids"]; + securityManager = [SoSecurityManager sharedSecurityManager]; + refFolder = [self clientObject]; - response = [context response]; - [response setStatus: 200]; - [response setHeader: @"text/plain; charset=\"utf-8\"" - forKey: @"content-type"]; rights = [NSMutableString string]; if ([uids length] > 0) { - ids = [uids componentsSeparatedByString: @","]; - max = [ids count]; - for (count = 0; count < max; count++) + ids = [[uids componentsSeparatedByString: @","] objectEnumerator]; + uid = [ids nextObject]; + while (uid) { - uid = [ids objectAtIndex: count]; - if ([uid hasPrefix: @"-"]) - uid = [uid substringFromIndex: 1]; - result = ([self calendarFolderForUID: uid] != nil); - if (count == 0) + currentFolder + = [refFolder + lookupCalendarFolderForUID: (([uid hasPrefix: @"-"]) + ? [uid substringFromIndex: 1] + : uid)]; + result = (![securityManager validatePermission: SoPerm_AccessContentsInformation + onObject: currentFolder + inContext: context]); + if ([rights length] == 0) [rights appendFormat: @"%d", result]; else [rights appendFormat: @",%d", result]; + uid = [ids nextObject]; } } + + return rights; +} + +- (id ) checkRightsAction +{ + WOResponse *response; + NSUserDefaults *ud; + NSString *uids, *rights; + + ud = [[context activeUser] userDefaults]; + uids = [ud stringForKey: @"calendaruids"]; + + response = [context response]; + [response setStatus: 200]; + [response setHeader: @"text/plain; charset=\"utf-8\"" + forKey: @"content-type"]; + + rights = [self _rightsForUIDs: uids]; [response appendContentString: rights]; return response; diff --git a/UI/Scheduler/UIxCalView.h b/UI/Scheduler/UIxCalView.h index 4195bb2b..9446c0ad 100644 --- a/UI/Scheduler/UIxCalView.h +++ b/UI/Scheduler/UIxCalView.h @@ -102,7 +102,6 @@ /* calendarUIDs */ - (NSString *)formattedCalendarUIDs; -- (SOGoAppointmentFolder *) calendarFolderForUID: (NSString *) uid; /* CSS related */ diff --git a/UI/Scheduler/UIxCalView.m b/UI/Scheduler/UIxCalView.m index 9a0c74d4..48fda46f 100644 --- a/UI/Scheduler/UIxCalView.m +++ b/UI/Scheduler/UIxCalView.m @@ -440,30 +440,6 @@ static BOOL shouldDisplayWeekend = NO; return [[self startDate] tomorrow]; } -- (SOGoAppointmentFolder *) calendarFolderForUID: (NSString *) uid -{ - SOGoFolder *upperContainer; - SOGoUserFolder *userFolder; - SOGoAppointmentFolder *calendarFolder; - SoSecurityManager *securityManager; - - upperContainer = [[[self clientObject] container] container]; - userFolder = [SOGoUserFolder objectWithName: uid - inContainer: upperContainer]; - calendarFolder = [SOGoAppointmentFolder objectWithName: @"Calendar" - inContainer: userFolder]; - [calendarFolder - setOCSPath: [NSString stringWithFormat: @"/Users/%@/Calendar", uid]]; - [calendarFolder setOwner: uid]; - - securityManager = [SoSecurityManager sharedSecurityManager]; - - return (([securityManager validatePermission: SoPerm_AccessContentsInformation - onObject: calendarFolder - inContext: context] == nil) - ? calendarFolder : nil); -} - - (NSArray *) activeCalendarFolders { NSUserDefaults *ud; @@ -471,6 +447,9 @@ static BOOL shouldDisplayWeekend = NO; SOGoAppointmentFolder *currentFolder; NSMutableArray *folders; NSString *currentUID; + SoSecurityManager *securityManager; + + securityManager = [SoSecurityManager sharedSecurityManager]; folders = [NSMutableArray array]; ud = [[context activeUser] userDefaults]; @@ -481,8 +460,11 @@ static BOOL shouldDisplayWeekend = NO; { if (![currentUID hasPrefix: @"-"]) { - currentFolder = [self calendarFolderForUID: currentUID]; - if (currentFolder) + currentFolder = [[self clientObject] lookupCalendarFolderForUID: currentUID]; + if (currentFolder + && ![securityManager validatePermission: SoPerm_AccessContentsInformation + onObject: currentFolder + inContext: context]) [folders addObject: currentFolder]; } currentUID = [calendarUIDs nextObject]; -- 2.39.5