2007-07-04 Wolfgang Sourdeau <wsourdeau@inverse.ca>
+ * 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.
#import <SoObjects/SOGo/SOGoAuthenticator.h>
#import <SoObjects/SOGo/SOGoUserFolder.h>
+#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/SOGoPermissions.h>
#import "SOGoProductLoader.h"
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
if ([self isUserName:_key inContext:_ctx])
return [self lookupUser:_key inContext:_ctx];
-
+
return nil;
}
--- /dev/null
+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;
{
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"]
- (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 *)
else if ([roles containsObject: SOGoRole_ObjectCreator])
[roles addObject: SOGoCalendarRole_Organizer];
}
-// }
return roles;
}
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",
if (!auth)
auth = [self new];
-
+
return auth;
}
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)
if ([login isEqualToString: @"anonymous"])
{
traversalPath = [_ctx objectForKey: @"SoRequestTraversalPath"];
-// if ([[traversalPath lastObject] isEqualToString: @"freebusy.ifb"])
-// user = freebusy;
-// else
user = anonymous;
}
else
#import <Foundation/NSURL.h>
#import <NGObjWeb/SoObject.h>
+#import <NGObjWeb/WOContext+SoObjects.h>
#import <NGExtensions/NSNull+misc.h>
#import <NGExtensions/NSObject+Logs.h>
#import <EOControl/EOQualifier.h>
#import <SaxObjC/XMLNamespaces.h>
#import "SOGoPermissions.h"
+#import "SOGoUser.h"
#import "SOGoFolder.h"
- (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]];
static NSTimeZone *serverTimeZone = nil;
static NSString *fallbackIMAP4Server = nil;
static NSString *defaultLanguage = nil;
+static NSString *superUsername = nil;
static NSURL *AgenorProfileURL = nil;
static BOOL acceptAnyUser = NO;
+ (void) initialize
{
- NSString *tzName;
+ NSString *tzName, *nsUsername;
NSUserDefaults *ud;
NSString *profileURL;
if (!defaultLanguage)
ASSIGN (defaultLanguage, @"English");
}
+ if (!superUsername)
+ {
+ nsUsername = [ud stringForKey: @"SOGoSuperUsername"];
+ if ([nsUsername length] > 0)
+ ASSIGN (superUsername, nsUsername);
+ }
acceptAnyUser = (![ud stringForKey: @"AuthentificationMethod"]);
}
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;
}
- (NSUserDefaults *) userDefaults
{
if (!userDefaults)
- userDefaults = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL
- uid: login
- fieldName: @"defaults"];
+ userDefaults
+ = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL
+ uid: login
+ fieldName: @"defaults"];
return userDefaults;
}
- (NSUserDefaults *) userSettings
{
if (!userSettings)
- userSettings = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL
- uid: login
- fieldName: @"settings"];
+ userSettings
+ = [[AgenorUserDefaults alloc] initWithTableURL: AgenorProfileURL
+ uid: login
+ fieldName: @"settings"];
return userSettings;
}
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;
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]])
{