From 995e73578ca66ae8b9015060b285adf9e622e2cf Mon Sep 17 00:00:00 2001 From: wolfgang Date: Thu, 12 Apr 2007 00:37:29 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1046 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SoObjects/Contacts/SOGoContactFolders.m | 44 ++++++++++++------------- SoObjects/Contacts/product.plist | 11 +++---- SoObjects/Mailer/SOGoMailAccounts.m | 26 ++++++++------- SoObjects/SOGo/SOGoUser.m | 4 +-- UI/MainUI/product.plist | 9 +++++ 5 files changed, 52 insertions(+), 42 deletions(-) diff --git a/SoObjects/Contacts/SOGoContactFolders.m b/SoObjects/Contacts/SOGoContactFolders.m index 6e61cc67..c2f0a717 100644 --- a/SoObjects/Contacts/SOGoContactFolders.m +++ b/SoObjects/Contacts/SOGoContactFolders.m @@ -218,28 +218,28 @@ return [contactFolders allValues]; } -- (NSString *) roleOfUser: (NSString *) uid -{ - NSArray *roles, *traversalPath; - NSString *objectName, *role; - - role = nil; - traversalPath = [context objectForKey: @"SoRequestTraversalPath"]; - if ([traversalPath count] > 2) - { - objectName = [traversalPath objectAtIndex: 2]; - roles = [[context activeUser] - rolesForObject: [self lookupName: objectName - inContext: context - acquire: NO] - inContext: context]; - if ([roles containsObject: SOGoRole_Assistant] - || [roles containsObject: SOGoRole_Delegate]) - role = SOGoRole_Assistant; - } - - return role; -} +// - (NSString *) roleOfUser: (NSString *) uid +// { +// NSArray *roles, *traversalPath; +// NSString *objectName, *role; + +// role = nil; +// traversalPath = [context objectForKey: @"SoRequestTraversalPath"]; +// if ([traversalPath count] > 2) +// { +// objectName = [traversalPath objectAtIndex: 2]; +// roles = [[context activeUser] +// rolesForObject: [self lookupName: objectName +// inContext: context +// acquire: NO] +// inContext: context]; +// if ([roles containsObject: SOGoRole_Assistant] +// || [roles containsObject: SOGoRole_Delegate]) +// role = SOGoRole_Assistant; +// } + +// return role; +// } - (BOOL) davIsCollection { diff --git a/SoObjects/Contacts/product.plist b/SoObjects/Contacts/product.plist index 6766efe0..349d27ec 100644 --- a/SoObjects/Contacts/product.plist +++ b/SoObjects/Contacts/product.plist @@ -9,14 +9,11 @@ classes = { SOGoContactFolders = { - superclass = "SOGoObject"; + superclass = "SOGoFolder"; + protectedBy = ""; + defaultAccess = "allow"; defaultRoles = { - "Add Documents, Images, and Files" = ( "Owner", "Delegate" ); - "View" = ( "Owner", "Delegate", "Assistant" ); - "WebDAV Access" = ( "Owner", "Delegate", "Assistant" ); - "Access Contents Information" = ( "Owner", "Assistant", "Delegate" ); - "ReadAcls" = ( "Owner", "Delegate", "Assistant" ); - "SaveAcls" = ( "Owner" ); + "View" = ( "Owner" ); }; }; diff --git a/SoObjects/Mailer/SOGoMailAccounts.m b/SoObjects/Mailer/SOGoMailAccounts.m index ed041aa3..d33c58c9 100644 --- a/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SoObjects/Mailer/SOGoMailAccounts.m @@ -37,17 +37,16 @@ static NSString *AgenorShareLoginMarker = @".-."; /* listing the available mailboxes */ -- (BOOL)isInHomeFolderBranchOfLoggedInAccount:(id)_ctx { - id user; - - user = [_ctx activeUser]; - return [[[self container] nameInContainer] isEqualToString:[user login]]; +- (BOOL) isInHomeFolderBranchOfLoggedInAccount: (NSString *) userLogin +{ + return [[[self container] nameInContainer] isEqualToString: userLogin]; } - (NSArray *)toManyRelationshipKeys { - id user; + SOGoUser *user; id account; NSArray *shares; + NSString *userLogin; /* Note: this is not strictly correct. The accounts being retrieved should be @@ -60,15 +59,16 @@ static NSString *AgenorShareLoginMarker = @".-."; => TODO */ user = [context activeUser]; + userLogin = [user login]; /* for now: return nothing if the home-folder does not belong to the login */ - if (![self isInHomeFolderBranchOfLoggedInAccount: context]) { + if (![self isInHomeFolderBranchOfLoggedInAccount: userLogin]) { [self warnWithFormat:@"User %@ tried to access mail hierarchy of %@", [user login], [[self container] nameInContainer]]; return nil; } - account = [user valueForKey:@"primaryIMAP4AccountString"]; + account = [user primaryIMAP4AccountString]; if ([account isNotNull]) account = [NSArray arrayWithObject:account]; if ([self isInternetRequest]) /* only show primary mailbox in Internet */ @@ -141,16 +141,20 @@ static NSString *AgenorShareLoginMarker = @".-."; return [ct autorelease]; } -- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { +- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag +{ id obj; + NSString *userLogin; + + userLogin = [[context activeUser] login]; /* first check attributes directly bound to the application */ if ((obj = [super lookupName:_key inContext:_ctx acquire:NO])) return obj; - if (![self isInHomeFolderBranchOfLoggedInAccount:_ctx]) { + if (![self isInHomeFolderBranchOfLoggedInAccount: userLogin]) { [self warnWithFormat:@"User %@ tried to access mail hierarchy of %@", - [[_ctx activeUser] login], [[self container] nameInContainer]]; + userLogin, [[self container] nameInContainer]]; return [NSException exceptionWithHTTPStatus:403 /* Forbidden */ reason:@"Tried to access the mail of another user"]; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index e10b9931..d2e9829e 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -267,13 +267,13 @@ static NSTimeZone *serverTimeZone = nil; if (sogoRoles) [rolesForObject addObjectsFromArray: sogoRoles]; } - if ([object respondsToSelector: @selector (rolesOfUser:inContext:)]) + if ([object respondsToSelector: @selector (rolesOfUser:)]) { sogoRoles = [object rolesOfUser: login]; if (sogoRoles) [rolesForObject addObjectsFromArray: sogoRoles]; } - if ([object respondsToSelector: @selector (roleOfUser:inContext:)]) + if ([object respondsToSelector: @selector (roleOfUser:)]) { role = [object roleOfUser: login]; if (role) diff --git a/UI/MainUI/product.plist b/UI/MainUI/product.plist index 8cca37cd..a189d3c3 100644 --- a/UI/MainUI/product.plist +++ b/UI/MainUI/product.plist @@ -19,6 +19,9 @@ superclass = "SOGoFolder"; protectedBy = ""; defaultAccess = "allow"; + defaultRoles = { + "View" = ( "Owner" ); + }; /* protectedBy = "HomePage Access"; */ }; SOGoFolder = { @@ -64,6 +67,12 @@ SOGoRootPage = { }; SOGoUserFolder = { + methods = { + view = { + protectedBy = "View"; + pageName = "SOGoUserHomePage"; + }; + }; }; SOGoGroupsFolder = { methods = { -- 2.39.5