+2007-01-04 Wolfgang Sourdeau <wsourdeau@inverse.ca>
+
+ * 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 <wsourdeau@inverse.ca>
* UI/Common/UIxAclEditor.m ([UIxAclEditor -assistantsValue]): new
- (id) lookupHomeFolderForUID: (NSString *) _uid
inContext: (id) _ctx;
+- (SOGoAppointmentFolder *) lookupCalendarFolderForUID: (NSString *) uid;
- (NSArray *) lookupCalendarFoldersForUIDs: (NSArray *) _uids
inContext: (id) _ctx;
- (NSArray *) lookupFreeBusyObjectsForUIDs: (NSArray *) _uids
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
{
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];
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSValue.h>
+#import <NGObjWeb/SoSecurityManager.h>
#import <NGObjWeb/WOResponse.h>
+#import <SOGo/SOGoPermissions.h>
#import <SOGo/SOGoUser.h>
#import "UIxCalMainView.h"
return response;
}
-- (id <WOActionResults>) 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 <WOActionResults>) 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;
/* calendarUIDs */
- (NSString *)formattedCalendarUIDs;
-- (SOGoAppointmentFolder *) calendarFolderForUID: (NSString *) uid;
/* CSS related */
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;
SOGoAppointmentFolder *currentFolder;
NSMutableArray *folders;
NSString *currentUID;
+ SoSecurityManager *securityManager;
+
+ securityManager = [SoSecurityManager sharedSecurityManager];
folders = [NSMutableArray array];
ud = [[context activeUser] userDefaults];
{
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];