From: wolfgang Date: Wed, 4 Jul 2007 20:33:18 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1099 d1b88da0-ebda-0310... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2d52aae2dc9ef7fb8470a26ebf74d7bf89f3215;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1099 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/ChangeLog b/ChangeLog index 85d34b25..f64b2b05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,36 @@ 2007-07-04 Wolfgang Sourdeau + * SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject + -contentAsString]): returns the message encoded in ISO Latin 1 + again. + + * SoObjects/SOGo/SOGoUser.m ([SOGoUser +initialize]): read the + SOGoSuperUsername user defaults. + ([SOGoUser -initWithLogin:newLoginroles:newRoles]): simplified + method. + ([SOGoUser -rolesForObject:objectinContext:context]): if the + current user is the superuser, grant him/her the "owner" role. + + * SoObjects/SOGo/SOGoFolder.m ([SOGoFolder -ocsFolder]): create + the folder only if the current user is the owner of the future + folder. + + * SoObjects/Appointments/SOGoCalendarComponent.m + ([SOGoCalendarComponent -contentAsString]): we return the content + based on the permissions returned by the security manager instead + of by looking at the user roles. + + * SoObjects/Appointments/SOGoAppointmentFolder.m + ([SOGoAppointmentFolder -calendarFolders]): read the calendar + folders of the user to whom this folder belongs instead of the + active user. This way, a delegate user will be able to have the + same view that the original user has if he connects from his user + directory. + + * Main/SOGo.m ([SOGo -lookupUser:_keyinContext:]): check if the + user exists before creating the SOGoUserFolder instance. If not, + returns nil. + * UI/MailerUI/UIxMailSourceView.[hm]: new class module designed to return the message source code in plain text. diff --git a/Main/SOGo.m b/Main/SOGo.m index efe2accf..0ee12f43 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -43,6 +43,7 @@ #import #import +#import #import #import "SOGoProductLoader.h" @@ -241,9 +242,20 @@ static BOOL debugObjectAllocation = NO; return YES; } -- (id)lookupUser:(NSString *)_key inContext:(id)_ctx { - return [$(@"SOGoUserFolder") objectWithName:_key - inContainer: self]; +- (id) lookupUser: (NSString *) _key + inContext: (id)_ctx +{ + SOGoUser *user; + id userFolder; + + user = [SOGoUser userWithLogin: _key roles: nil]; + if (user) + userFolder = [$(@"SOGoUserFolder") objectWithName: _key + inContainer: self]; + else + userFolder = nil; + + return userFolder; } - (void) _setupLocaleInContext: (WOContext *) _ctx @@ -289,7 +301,7 @@ static BOOL debugObjectAllocation = NO; if ([self isUserName:_key inContext:_ctx]) return [self lookupUser:_key inContext:_ctx]; - + return nil; } diff --git a/NEWS b/NEWS new file mode 100644 index 00000000..4d5694a2 --- /dev/null +++ b/NEWS @@ -0,0 +1,6 @@ +0.9.0 (200707XX) +---------------- +- added the ability to specify a super user through the SOGoSuperUsername user default; +- added the ability to view the message source; +- no longer autocreate folders if we are not their owners; +- made compatible with PostgreSQL 8.2; diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 6f098b7b..4e7257c3 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1229,20 +1229,21 @@ static NSNumber *sharedYes = nil; { NSMutableDictionary *userCalendar, *calendarDict; NSMutableArray *calendarFolders; - SOGoUser *activeUser; + SOGoUser *calendarUser; BOOL firstActive; calendarFolders = [NSMutableArray new]; [calendarFolders autorelease]; - activeUser = [context activeUser]; + calendarUser = [SOGoUser userWithLogin: [self ownerInContext: context] + roles: nil]; userCalendar = [NSMutableDictionary new]; [userCalendar autorelease]; [userCalendar setObject: @"/" forKey: @"folder"]; [userCalendar setObject: @"Calendar" forKey: @"displayName"]; [calendarFolders addObject: userCalendar]; - calendarDict = [[activeUser userSettings] objectForKey: @"Calendar"]; + calendarDict = [[calendarUser userSettings] objectForKey: @"Calendar"]; firstActive = [[calendarDict objectForKey: @"activateUserFolder"] boolValue]; firstActive = ([self _appendSubscribedFolders: [calendarDict objectForKey: @"SubscribedFolders"] diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index 5f707b18..5f987aa5 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -111,23 +111,38 @@ static BOOL sendEMailNotifications = NO; - (NSString *) contentAsString { - NSString *uid; iCalCalendar *tmpCalendar; iCalRepeatableEntityObject *tmpComponent; - NSArray *roles; +// NSArray *roles; +// NSString *uid; + SoSecurityManager *sm; if (!calContent) { - uid = [[context activeUser] login]; - roles = [self aclsForUser: uid]; - if ([roles containsObject: SOGoCalendarRole_Organizer] - || [roles containsObject: SOGoCalendarRole_Participant] - || [roles containsObject: SOGoCalendarRole_ComponentViewer]) - { - calContent = content; - [calContent retain]; - } - else if ([roles containsObject: SOGoCalendarRole_ComponentDAndTViewer]) +// uid = [[context activeUser] login]; +// roles = [self aclsForUser: uid]; +// if ([roles containsObject: SOGoCalendarRole_Organizer] +// || [roles containsObject: SOGoCalendarRole_Participant] +// || [roles containsObject: SOGoCalendarRole_ComponentViewer]) +// calContent = content; +// else if ([roles containsObject: SOGoCalendarRole_ComponentDAndTViewer]) +// { +// tmpCalendar = [[self calendar: NO] copy]; +// tmpComponent = (iCalRepeatableEntityObject *) +// [tmpCalendar firstChildWithTag: [self componentTag]]; +// [self _filterComponent: tmpComponent]; +// calContent = [tmpCalendar versitString]; +// [tmpCalendar release]; +// } +// else +// calContent = nil; + + sm = [SoSecurityManager sharedSecurityManager]; + if (![sm validatePermission: SOGoCalendarPerm_ViewAllComponent + onObject: self inContext: context]) + calContent = content; + else if (![sm validatePermission: SOGoCalendarPerm_ViewDAndT + onObject: self inContext: context]) { tmpCalendar = [[self calendar: NO] copy]; tmpComponent = (iCalRepeatableEntityObject *) @@ -606,7 +621,6 @@ static BOOL sendEMailNotifications = NO; else if ([roles containsObject: SOGoRole_ObjectCreator]) [roles addObject: SOGoCalendarRole_Organizer]; } -// } return roles; } diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index a8b76bdb..29c6a0ea 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -435,9 +435,8 @@ static BOOL debugSoParts = NO; if ([content isKindOfClass:[NSException class]]) return (id)content; -#warning the encoding here might be wrong... - s = [[NSString alloc] initWithData: content - encoding: NSUTF8StringEncoding]; + s = [[NSString alloc] initWithData: content + encoding: NSISOLatin1StringEncoding]; if (s == nil) { [self logWithFormat: @"ERROR: could not convert data of length %d to string", diff --git a/SoObjects/SOGo/SOGoAuthenticator.m b/SoObjects/SOGo/SOGoAuthenticator.m index fa9a0526..cb67ba4c 100644 --- a/SoObjects/SOGo/SOGoAuthenticator.m +++ b/SoObjects/SOGo/SOGoAuthenticator.m @@ -41,7 +41,7 @@ if (!auth) auth = [self new]; - + return auth; } @@ -112,10 +112,6 @@ anonymous = [[SOGoUser alloc] initWithLogin: @"anonymous" roles: [NSArray arrayWithObject: SoRole_Anonymous]]; -// if (!freebusy) -// freebusy -// = [[SOGoUser alloc] initWithLogin: @"freebusy" -// roles: [NSArray arrayWithObject: SOGoRole_FreeBusy]]; login = [self checkCredentialsInContext:_ctx]; if (login) @@ -123,9 +119,6 @@ if ([login isEqualToString: @"anonymous"]) { traversalPath = [_ctx objectForKey: @"SoRequestTraversalPath"]; -// if ([[traversalPath lastObject] isEqualToString: @"freebusy.ifb"]) -// user = freebusy; -// else user = anonymous; } else diff --git a/SoObjects/SOGo/SOGoFolder.m b/SoObjects/SOGo/SOGoFolder.m index 5eb8adb8..d3f73984 100644 --- a/SoObjects/SOGo/SOGoFolder.m +++ b/SoObjects/SOGo/SOGoFolder.m @@ -28,6 +28,7 @@ #import #import +#import #import #import #import @@ -38,6 +39,7 @@ #import #import "SOGoPermissions.h" +#import "SOGoUser.h" #import "SOGoFolder.h" @@ -151,11 +153,14 @@ static NSString *defaultUserID = @""; - (GCSFolder *) ocsFolder { GCSFolder *folder; + NSString *userLogin; if (!ocsFolder) { ocsFolder = [self ocsFolderForPath: [self ocsPath]]; + userLogin = [[context activeUser] login]; if (!ocsFolder + && [userLogin isEqualToString: [self ownerInContext: context]] && [self folderIsMandatory] && [self create]) ocsFolder = [self ocsFolderForPath: [self ocsPath]]; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 87383f4d..17f20876 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -39,6 +39,7 @@ static NSTimeZone *serverTimeZone = nil; static NSString *fallbackIMAP4Server = nil; static NSString *defaultLanguage = nil; +static NSString *superUsername = nil; static NSURL *AgenorProfileURL = nil; static BOOL acceptAnyUser = NO; @@ -57,7 +58,7 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; + (void) initialize { - NSString *tzName; + NSString *tzName, *nsUsername; NSUserDefaults *ud; NSString *profileURL; @@ -84,6 +85,12 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; if (!defaultLanguage) ASSIGN (defaultLanguage, @"English"); } + if (!superUsername) + { + nsUsername = [ud stringForKey: @"SOGoSuperUsername"]; + if ([nsUsername length] > 0) + ASSIGN (superUsername, nsUsername); + } acceptAnyUser = (![ud stringForKey: @"AuthentificationMethod"]); } @@ -120,21 +127,17 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; LDAPUserManager *um; NSString *realUID; - if ([newLogin isEqualToString: @"anonymous"] + if (acceptAnyUser + || [newLogin isEqualToString: @"anonymous"] || [newLogin isEqualToString: @"freebusy"]) - self = [super initWithLogin: newLogin roles: newRoles]; + realUID = newLogin; else { - if (acceptAnyUser) - realUID = newLogin; - else - { - um = [LDAPUserManager sharedUserManager]; - realUID = [[um contactInfosForUserWithUIDorEmail: newLogin] - objectForKey: @"c_uid"]; - } - self = [super initWithLogin: realUID roles: newRoles]; + um = [LDAPUserManager sharedUserManager]; + realUID = [[um contactInfosForUserWithUIDorEmail: newLogin] + objectForKey: @"c_uid"]; } + self = [super initWithLogin: realUID roles: newRoles]; return self; } @@ -289,9 +292,10 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; - (NSUserDefaults *) userDefaults { if (!userDefaults) - userDefaults = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL - uid: login - fieldName: @"defaults"]; + userDefaults + = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL + uid: login + fieldName: @"defaults"]; return userDefaults; } @@ -299,9 +303,10 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; - (NSUserDefaults *) userSettings { if (!userSettings) - userSettings = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL - uid: login - fieldName: @"settings"]; + userSettings + = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL + uid: login + fieldName: @"settings"]; return userSettings; } @@ -356,8 +361,9 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; if (folder != nil) return [folder isNotNull] ? folder : nil; - folder = [[WOApplication application] lookupName:[self login] - inContext:_ctx acquire:NO]; + folder = [[WOApplication application] lookupName: [self login] + inContext: _ctx + acquire: NO]; if ([folder isKindOfClass:[NSException class]]) return folder; @@ -403,7 +409,8 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; if (sogoRoles) [rolesForObject addObjectsFromArray: sogoRoles]; - if ([[object ownerInContext: context] isEqualToString: [self login]]) + if ((superUsername && [login isEqualToString: superUsername]) + || [[object ownerInContext: context] isEqualToString: login]) [rolesForObject addObject: SoRole_Owner]; if ([object isKindOfClass: [SOGoObject class]]) {