Monotone-Parent: 991fa5d50c1c078407d84332831b1f0c32190152

Monotone-Revision: c37bbff8f7a0f029635c72cfa745ff24e2b2220c

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-01-04T14:37:07
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-01-04 14:37:07 +00:00
parent 6e81fe733e
commit 7b8f76937c
6 changed files with 81 additions and 55 deletions

View File

@@ -26,8 +26,10 @@
#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"
@@ -128,15 +130,49 @@ static NSMutableArray *yearMenuItems = nil;
return response;
}
- (NSString *) _rightsForUIDs: (NSString *) uids
{
NSEnumerator *ids;
NSString *uid;
NSMutableString *rights;
SOGoAppointmentFolder *refFolder, *currentFolder;
SoSecurityManager *securityManager;
BOOL result;
securityManager = [SoSecurityManager sharedSecurityManager];
refFolder = [self clientObject];
rights = [NSMutableString string];
if ([uids length] > 0)
{
ids = [[uids componentsSeparatedByString: @","] objectEnumerator];
uid = [ids nextObject];
while (uid)
{
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, *uid;
NSMutableString *rights;
NSArray *ids;
unsigned int count, max;
BOOL result;
NSString *uids, *rights;
ud = [[context activeUser] userDefaults];
uids = [ud stringForKey: @"calendaruids"];
@@ -145,23 +181,8 @@ static NSMutableArray *yearMenuItems = nil;
[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++)
{
uid = [ids objectAtIndex: count];
if ([uid hasPrefix: @"-"])
uid = [uid substringFromIndex: 1];
result = ([self calendarFolderForUID: uid] != nil);
if (count == 0)
[rights appendFormat: @"%d", result];
else
[rights appendFormat: @",%d", result];
}
}
rights = [self _rightsForUIDs: uids];
[response appendContentString: rights];
return response;