2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2005 SKYRIX Software AG
|
|
|
|
|
|
|
|
This file is part of OpenGroupware.org.
|
|
|
|
|
|
|
|
OGo is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2007-04-17 16:34:31 +02:00
|
|
|
#import <Foundation/NSArray.h>
|
2008-07-18 21:25:26 +02:00
|
|
|
#import <Foundation/NSCalendarDate.h>
|
2008-07-04 18:06:09 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSEnumerator.h>
|
2007-04-17 16:34:31 +02:00
|
|
|
#import <Foundation/NSNull.h>
|
|
|
|
#import <Foundation/NSTimeZone.h>
|
|
|
|
#import <Foundation/NSUserDefaults.h>
|
2007-08-15 22:30:37 +02:00
|
|
|
#import <Foundation/NSValue.h>
|
2007-04-17 16:34:31 +02:00
|
|
|
#import <NGObjWeb/WOApplication.h>
|
2007-08-22 17:16:35 +02:00
|
|
|
#import <NGObjWeb/WOContext.h>
|
|
|
|
#import <NGObjWeb/WORequest.h>
|
2006-12-14 22:20:13 +01:00
|
|
|
#import <NGObjWeb/SoObject.h>
|
2008-07-18 21:25:26 +02:00
|
|
|
#import <NGExtensions/NSCalendarDate+misc.h>
|
2007-04-17 16:34:31 +02:00
|
|
|
#import <NGExtensions/NSNull+misc.h>
|
2008-02-07 17:53:19 +01:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
#import "LDAPUserManager.h"
|
2008-01-16 19:57:58 +01:00
|
|
|
#import "NSArray+Utilities.h"
|
|
|
|
#import "SOGoCache.h"
|
2007-06-19 20:06:18 +02:00
|
|
|
#import "SOGoDateFormatter.h"
|
|
|
|
#import "SOGoObject.h"
|
2007-04-17 16:34:31 +02:00
|
|
|
#import "SOGoPermissions.h"
|
2008-07-29 18:36:16 +02:00
|
|
|
#import "SOGoUserDefaults.h"
|
|
|
|
#import "SOGoUserFolder.h"
|
2007-06-01 07:10:07 +02:00
|
|
|
|
|
|
|
#import "SOGoUser.h"
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2007-04-11 21:07:54 +02:00
|
|
|
static NSTimeZone *serverTimeZone = nil;
|
2007-05-09 21:23:09 +02:00
|
|
|
static NSString *fallbackIMAP4Server = nil;
|
2008-02-07 17:53:19 +01:00
|
|
|
static BOOL fallbackIsConfigured = NO;
|
2007-05-30 22:20:02 +02:00
|
|
|
static NSString *defaultLanguage = nil;
|
2008-10-29 20:23:31 +01:00
|
|
|
static NSString *defaultReplyPlacement = nil;
|
|
|
|
static NSString *defaultSignaturePlacement = nil;
|
|
|
|
static NSString *defaultMessageForwarding = nil;
|
|
|
|
static NSString *defaultMessageCheck = nil;
|
2007-10-19 21:03:21 +02:00
|
|
|
static NSArray *superUsernames = nil;
|
2008-07-25 19:52:49 +02:00
|
|
|
static NSURL *SOGoProfileURL = nil;
|
2008-07-24 20:00:21 +02:00
|
|
|
// static BOOL acceptAnyUser = NO;
|
2008-07-18 21:25:26 +02:00
|
|
|
static int sogoFirstDayOfWeek = -1;
|
|
|
|
static int defaultDayStartTime = -1;
|
|
|
|
static int defaultDayEndTime = -1;
|
2007-04-11 21:07:54 +02:00
|
|
|
|
2007-06-19 20:06:18 +02:00
|
|
|
NSString *SOGoWeekStartJanuary1 = @"January1";
|
|
|
|
NSString *SOGoWeekStartFirst4DayWeek = @"First4DayWeek";
|
|
|
|
NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
@interface NSObject (SOGoRoles)
|
|
|
|
|
2007-04-11 21:07:54 +02:00
|
|
|
- (NSArray *) rolesOfUser: (NSString *) uid;
|
2006-12-14 22:20:13 +01:00
|
|
|
|
|
|
|
@end
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-10-18 19:17:29 +02:00
|
|
|
@implementation SoUser (SOGoExtension)
|
|
|
|
|
|
|
|
- (NSString *) language
|
|
|
|
{
|
2007-10-23 00:24:08 +02:00
|
|
|
return [SOGoUser language];
|
2007-10-18 19:17:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@implementation SOGoUser
|
|
|
|
|
2008-07-18 21:25:26 +02:00
|
|
|
static int
|
|
|
|
_timeValue (NSString *key)
|
|
|
|
{
|
|
|
|
int time;
|
|
|
|
|
|
|
|
if (key && [key length] > 1)
|
|
|
|
time = [[key substringToIndex: 2] intValue];
|
|
|
|
else
|
|
|
|
time = -1;
|
|
|
|
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
2007-04-11 21:07:54 +02:00
|
|
|
+ (void) initialize
|
|
|
|
{
|
2007-10-19 21:03:21 +02:00
|
|
|
NSString *tzName;
|
2007-05-09 21:23:09 +02:00
|
|
|
NSUserDefaults *ud;
|
|
|
|
NSString *profileURL;
|
2007-04-11 21:07:54 +02:00
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
ud = [NSUserDefaults standardUserDefaults];
|
2007-04-11 21:07:54 +02:00
|
|
|
if (!serverTimeZone)
|
|
|
|
{
|
2007-05-09 21:23:09 +02:00
|
|
|
tzName = [ud stringForKey: @"SOGoServerTimeZone"];
|
2007-04-11 21:07:54 +02:00
|
|
|
if (!tzName)
|
2007-06-01 07:10:07 +02:00
|
|
|
tzName = @"UTC";
|
2007-04-11 21:07:54 +02:00
|
|
|
serverTimeZone = [NSTimeZone timeZoneWithName: tzName];
|
|
|
|
[serverTimeZone retain];
|
|
|
|
}
|
2008-07-18 21:25:26 +02:00
|
|
|
if (sogoFirstDayOfWeek == -1)
|
|
|
|
sogoFirstDayOfWeek = [ud integerForKey: @"SOGoFirstDayOfWeek"];
|
|
|
|
if (defaultDayStartTime == -1)
|
|
|
|
{
|
|
|
|
defaultDayStartTime
|
|
|
|
= _timeValue ([ud stringForKey: @"SOGoDayStartTime"]);
|
|
|
|
if (defaultDayStartTime == -1)
|
|
|
|
defaultDayStartTime = 8;
|
|
|
|
}
|
|
|
|
if (defaultDayEndTime == -1)
|
|
|
|
{
|
|
|
|
defaultDayEndTime
|
|
|
|
= _timeValue ([ud stringForKey: @"SOGoDayEndTime"]);
|
|
|
|
if (defaultDayEndTime == -1)
|
|
|
|
defaultDayEndTime = 18;
|
|
|
|
}
|
|
|
|
|
2008-07-25 19:52:49 +02:00
|
|
|
if (!SOGoProfileURL)
|
2007-05-09 21:23:09 +02:00
|
|
|
{
|
2008-07-25 19:52:49 +02:00
|
|
|
profileURL = [ud stringForKey: @"SOGoProfileURL"];
|
|
|
|
if (!profileURL)
|
2008-08-05 02:32:26 +02:00
|
|
|
{
|
|
|
|
profileURL = [ud stringForKey: @"AgenorProfileURL"];
|
|
|
|
if (profileURL)
|
|
|
|
{
|
|
|
|
[ud setObject: profileURL forKey: @"SOGoProfileURL"];
|
|
|
|
[ud removeObjectForKey: @"AgenorProfileURL"];
|
|
|
|
[ud synchronize];
|
|
|
|
[self warnWithFormat: @"the user defaults key 'AgenorProfileURL'"
|
|
|
|
@" was renamed to 'SOGoProfileURL'"];
|
|
|
|
}
|
|
|
|
}
|
2008-07-25 19:52:49 +02:00
|
|
|
SOGoProfileURL = [[NSURL alloc] initWithString: profileURL];
|
2007-05-09 21:23:09 +02:00
|
|
|
}
|
|
|
|
if (!fallbackIMAP4Server)
|
2007-05-30 22:20:02 +02:00
|
|
|
ASSIGN (fallbackIMAP4Server,
|
|
|
|
[ud stringForKey: @"SOGoFallbackIMAP4Server"]);
|
2008-02-07 17:53:19 +01:00
|
|
|
if (fallbackIMAP4Server)
|
|
|
|
fallbackIsConfigured = YES;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self warnWithFormat:
|
|
|
|
@"no server specified for SOGoFallbackIMAP4Server,"
|
|
|
|
@" value set to 'localhost'"];
|
|
|
|
fallbackIMAP4Server = @"localhost";
|
|
|
|
}
|
2007-05-30 22:20:02 +02:00
|
|
|
if (!defaultLanguage)
|
|
|
|
{
|
|
|
|
ASSIGN (defaultLanguage, [ud stringForKey: @"SOGoDefaultLanguage"]);
|
|
|
|
if (!defaultLanguage)
|
|
|
|
ASSIGN (defaultLanguage, @"English");
|
|
|
|
}
|
2008-10-29 20:23:31 +01:00
|
|
|
if (!defaultReplyPlacement)
|
|
|
|
{
|
|
|
|
ASSIGN (defaultReplyPlacement, [ud stringForKey: @"SOGoMailReplyPlacement"]);
|
|
|
|
if (!defaultReplyPlacement)
|
|
|
|
ASSIGN (defaultReplyPlacement, @"below");
|
|
|
|
}
|
|
|
|
if (!defaultSignaturePlacement)
|
|
|
|
{
|
|
|
|
ASSIGN (defaultSignaturePlacement, [ud stringForKey: @"SOGoMailSignaturePlacement"]);
|
|
|
|
if (!defaultSignaturePlacement)
|
|
|
|
ASSIGN (defaultSignaturePlacement, @"below");
|
|
|
|
}
|
|
|
|
if (!defaultMessageForwarding)
|
|
|
|
{
|
|
|
|
ASSIGN (defaultMessageForwarding, [ud stringForKey: @"SOGoMailMessageForwarding"]);
|
|
|
|
if (!defaultMessageForwarding)
|
|
|
|
ASSIGN (defaultMessageForwarding, @"inline");
|
|
|
|
}
|
|
|
|
if (!defaultMessageCheck)
|
|
|
|
{
|
|
|
|
ASSIGN (defaultMessageCheck, [ud stringForKey: @"SOGoMailMessageCheck"]);
|
|
|
|
if (!defaultMessageCheck)
|
|
|
|
ASSIGN (defaultMessageCheck, @"manually");
|
|
|
|
}
|
|
|
|
|
2007-10-19 21:03:21 +02:00
|
|
|
if (!superUsernames)
|
2007-10-31 15:18:17 +01:00
|
|
|
ASSIGN (superUsernames, [ud arrayForKey: @"SOGoSuperUsernames"]);
|
2007-06-22 21:58:31 +02:00
|
|
|
|
2008-07-24 20:00:21 +02:00
|
|
|
// acceptAnyUser = ([[ud stringForKey: @"SOGoAuthentificationMethod"]
|
|
|
|
// isEqualToString: @"bypass"]);
|
2007-04-11 21:07:54 +02:00
|
|
|
}
|
|
|
|
|
2007-10-23 00:24:08 +02:00
|
|
|
+ (NSString *) language
|
|
|
|
{
|
|
|
|
NSArray *bLanguages;
|
|
|
|
WOContext *context;
|
2007-11-08 21:35:09 +01:00
|
|
|
NSString *lng;
|
2007-10-23 00:24:08 +02:00
|
|
|
|
|
|
|
context = [[WOApplication application] context];
|
|
|
|
bLanguages = [[context request] browserLanguages];
|
|
|
|
if ([bLanguages count] > 0)
|
2007-11-08 21:35:09 +01:00
|
|
|
lng = [bLanguages objectAtIndex: 0];
|
2007-10-23 00:24:08 +02:00
|
|
|
|
2007-11-08 21:35:09 +01:00
|
|
|
if (![lng length])
|
|
|
|
lng = defaultLanguage;
|
2007-10-23 00:24:08 +02:00
|
|
|
|
2007-11-08 21:35:09 +01:00
|
|
|
return lng;
|
2007-10-23 00:24:08 +02:00
|
|
|
}
|
|
|
|
|
2008-02-07 17:53:19 +01:00
|
|
|
+ (NSString *) fallbackIMAP4Server
|
|
|
|
{
|
|
|
|
return fallbackIMAP4Server;
|
|
|
|
}
|
|
|
|
|
2007-05-11 23:44:47 +02:00
|
|
|
+ (SOGoUser *) userWithLogin: (NSString *) newLogin
|
|
|
|
roles: (NSArray *) newRoles
|
2007-04-11 21:07:54 +02:00
|
|
|
{
|
2008-01-16 19:57:58 +01:00
|
|
|
SOGoCache *cache;
|
2007-04-11 21:07:54 +02:00
|
|
|
SOGoUser *user;
|
|
|
|
|
2008-01-16 19:57:58 +01:00
|
|
|
cache = [SOGoCache sharedCache];
|
|
|
|
user = [cache userNamed: newLogin];
|
|
|
|
if (!user)
|
|
|
|
{
|
|
|
|
user = [[self alloc] initWithLogin: newLogin roles: newRoles];
|
2008-01-24 18:11:29 +01:00
|
|
|
if (user)
|
|
|
|
{
|
|
|
|
[user autorelease];
|
2008-09-02 04:52:55 +02:00
|
|
|
[cache registerUser: user];
|
2008-01-24 18:11:29 +01:00
|
|
|
}
|
2008-01-16 19:57:58 +01:00
|
|
|
}
|
|
|
|
[user setPrimaryRoles: newRoles];
|
2007-04-11 21:07:54 +02:00
|
|
|
|
|
|
|
return user;
|
|
|
|
}
|
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
- (id) initWithLogin: (NSString *) newLogin
|
|
|
|
roles: (NSArray *) newRoles
|
|
|
|
{
|
|
|
|
LDAPUserManager *um;
|
2007-06-22 21:58:31 +02:00
|
|
|
NSString *realUID;
|
2007-05-09 21:23:09 +02:00
|
|
|
|
2008-07-24 20:00:21 +02:00
|
|
|
if (// acceptAnyUser
|
|
|
|
// ||
|
|
|
|
[newLogin isEqualToString: @"anonymous"]
|
2007-05-09 21:23:09 +02:00
|
|
|
|| [newLogin isEqualToString: @"freebusy"])
|
2007-07-04 22:15:42 +02:00
|
|
|
realUID = newLogin;
|
2007-05-09 21:23:09 +02:00
|
|
|
else
|
|
|
|
{
|
2007-07-04 22:15:42 +02:00
|
|
|
um = [LDAPUserManager sharedUserManager];
|
|
|
|
realUID = [[um contactInfosForUserWithUIDorEmail: newLogin]
|
|
|
|
objectForKey: @"c_uid"];
|
2007-03-27 20:16:52 +02:00
|
|
|
}
|
2008-02-07 17:53:19 +01:00
|
|
|
|
2008-04-24 03:09:08 +02:00
|
|
|
if ([realUID length])
|
2008-09-02 04:52:55 +02:00
|
|
|
{
|
|
|
|
if ((self = [super initWithLogin: realUID roles: newRoles]))
|
|
|
|
{
|
|
|
|
allEmails = nil;
|
|
|
|
language = nil;
|
|
|
|
currentPassword = nil;
|
|
|
|
dateFormatter = nil;
|
|
|
|
homeFolder = nil;
|
|
|
|
cn = nil;
|
|
|
|
userTimeZone = nil;
|
|
|
|
mailAccounts = nil;
|
|
|
|
}
|
|
|
|
}
|
2008-01-24 18:11:29 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[self release];
|
|
|
|
self = nil;
|
|
|
|
}
|
2007-03-27 20:16:52 +02:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2007-04-11 21:07:54 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
2007-05-30 22:20:02 +02:00
|
|
|
[allEmails release];
|
|
|
|
[language release];
|
2008-08-29 02:31:27 +02:00
|
|
|
[currentPassword release];
|
2007-06-19 20:06:18 +02:00
|
|
|
[dateFormatter release];
|
2007-11-18 11:16:25 +01:00
|
|
|
[homeFolder release];
|
2008-08-29 02:31:27 +02:00
|
|
|
[cn release];
|
|
|
|
[userTimeZone release];
|
|
|
|
[mailAccounts release];
|
2006-06-15 21:34:10 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2008-01-16 19:57:58 +01:00
|
|
|
- (void) setPrimaryRoles: (NSArray *) newRoles
|
|
|
|
{
|
|
|
|
ASSIGN (roles, newRoles);
|
|
|
|
}
|
|
|
|
|
2007-06-19 20:06:18 +02:00
|
|
|
- (void) setCurrentPassword: (NSString *) newPassword
|
|
|
|
{
|
|
|
|
ASSIGN (currentPassword, newPassword);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) currentPassword
|
|
|
|
{
|
|
|
|
return currentPassword;
|
|
|
|
}
|
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
- (id) _fetchFieldForUser: (NSString *) field
|
|
|
|
{
|
|
|
|
NSDictionary *contactInfos;
|
|
|
|
LDAPUserManager *um;
|
|
|
|
|
|
|
|
um = [LDAPUserManager sharedUserManager];
|
|
|
|
contactInfos = [um contactInfosForUserWithUIDorEmail: login];
|
|
|
|
|
|
|
|
return [contactInfos objectForKey: field];
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
- (void) _fetchAllEmails
|
2007-04-11 21:07:54 +02:00
|
|
|
{
|
2007-05-09 21:23:09 +02:00
|
|
|
allEmails = [self _fetchFieldForUser: @"emails"];
|
|
|
|
[allEmails retain];
|
|
|
|
}
|
2007-04-11 21:07:54 +02:00
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
- (void) _fetchCN
|
|
|
|
{
|
|
|
|
cn = [self _fetchFieldForUser: @"cn"];
|
|
|
|
[cn retain];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
2007-08-15 22:30:37 +02:00
|
|
|
// - (NSString *) fullEmail
|
|
|
|
// {
|
|
|
|
// return [[LDAPUserManager sharedUserManager] getFullEmailForUID: login];
|
|
|
|
// }
|
2007-05-30 22:20:02 +02:00
|
|
|
|
2007-08-15 22:30:37 +02:00
|
|
|
// - (NSString *) primaryEmail
|
|
|
|
// {
|
|
|
|
// if (!allEmails)
|
|
|
|
// [self _fetchAllEmails];
|
2007-04-11 21:07:54 +02:00
|
|
|
|
2007-08-15 22:30:37 +02:00
|
|
|
// return [allEmails objectAtIndex: 0];
|
|
|
|
// }
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-08-15 22:30:37 +02:00
|
|
|
- (NSArray *) allEmails
|
2007-05-03 20:39:03 +02:00
|
|
|
{
|
2007-05-09 21:23:09 +02:00
|
|
|
if (!allEmails)
|
|
|
|
[self _fetchAllEmails];
|
2007-05-03 20:39:03 +02:00
|
|
|
|
2007-08-15 22:30:37 +02:00
|
|
|
return allEmails;
|
2007-05-03 20:39:03 +02:00
|
|
|
}
|
|
|
|
|
2007-08-15 22:30:37 +02:00
|
|
|
- (NSString *) systemEmail
|
2007-04-11 21:07:54 +02:00
|
|
|
{
|
2007-05-09 21:23:09 +02:00
|
|
|
if (!allEmails)
|
|
|
|
[self _fetchAllEmails];
|
2007-04-11 21:07:54 +02:00
|
|
|
|
2007-08-15 22:30:37 +02:00
|
|
|
return [allEmails lastObject];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
- (BOOL) hasEmail: (NSString *) email
|
2007-04-11 21:07:54 +02:00
|
|
|
{
|
2007-05-09 21:23:09 +02:00
|
|
|
if (!allEmails)
|
|
|
|
[self _fetchAllEmails];
|
2007-06-01 07:10:07 +02:00
|
|
|
|
|
|
|
return [allEmails containsCaseInsensitiveString: email];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
2007-04-11 21:07:54 +02:00
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
- (NSString *) cn
|
2007-04-11 21:07:54 +02:00
|
|
|
{
|
2007-05-09 21:23:09 +02:00
|
|
|
if (!cn)
|
|
|
|
[self _fetchCN];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
return cn;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
2007-04-11 21:07:54 +02:00
|
|
|
|
2008-02-07 17:53:19 +01:00
|
|
|
- (NSMutableDictionary *) defaultIdentity
|
|
|
|
{
|
|
|
|
NSMutableDictionary *currentIdentity, *defaultIdentity;
|
|
|
|
NSEnumerator *identities;
|
|
|
|
|
|
|
|
defaultIdentity = nil;
|
|
|
|
|
|
|
|
identities = [[self allIdentities] objectEnumerator];
|
|
|
|
while (!defaultIdentity
|
|
|
|
&& (currentIdentity = [identities nextObject]))
|
|
|
|
if ([[currentIdentity objectForKey: @"isDefault"] boolValue])
|
|
|
|
defaultIdentity = currentIdentity;
|
|
|
|
|
|
|
|
return defaultIdentity;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) saveMailAccounts
|
|
|
|
{
|
|
|
|
BOOL doSave;
|
|
|
|
|
|
|
|
doSave = YES;
|
|
|
|
if (!fallbackIsConfigured)
|
|
|
|
{
|
|
|
|
[self logWithFormat: @"'SOGoFallbackIMAP4Server' is not set"];
|
|
|
|
doSave = NO;
|
|
|
|
}
|
|
|
|
if (![LDAPUserManager defaultMailDomainIsConfigured])
|
|
|
|
{
|
|
|
|
[self logWithFormat: @"'SOGoDefaultMailDomain' is not set"];
|
|
|
|
doSave = NO;
|
|
|
|
}
|
|
|
|
if (doSave)
|
2008-11-11 01:17:35 +01:00
|
|
|
[[self userDefaults] setObject: [self mailAccounts]
|
|
|
|
forKey: @"MailAccounts"];
|
2008-02-07 17:53:19 +01:00
|
|
|
else
|
|
|
|
[self logWithFormat: @"saving mail accounts is disabled until the"
|
|
|
|
@" variable(s) mentionned above are configured"];
|
|
|
|
}
|
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
// - (NSString *) primaryMailServer
|
|
|
|
// {
|
|
|
|
// return [[self userManager] getServerForUID: [self login]];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSArray *) additionalIMAP4AccountStrings
|
|
|
|
// {
|
|
|
|
// return [[self userManager]getSharedMailboxAccountStringsForUID: [self login]];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSArray *) additionalEMailAddresses
|
|
|
|
// {
|
|
|
|
// return [[self userManager] getSharedMailboxEMailsForUID: [self login]];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSDictionary *) additionalIMAP4AccountsAndEMails
|
|
|
|
// {
|
|
|
|
// return [[self userManager] getSharedMailboxesAndEMailsForUID: [self login]];
|
|
|
|
// }
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-04-11 21:07:54 +02:00
|
|
|
- (NSURL *) freeBusyURL
|
|
|
|
{
|
2007-05-09 21:23:09 +02:00
|
|
|
return nil;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-06-19 20:06:18 +02:00
|
|
|
- (SOGoDateFormatter *) dateFormatterInContext: (WOContext *) context
|
|
|
|
{
|
|
|
|
NSString *format;
|
|
|
|
NSUserDefaults *ud;
|
|
|
|
|
|
|
|
if (!dateFormatter)
|
|
|
|
{
|
|
|
|
dateFormatter = [SOGoDateFormatter new];
|
|
|
|
[dateFormatter setLocale: [context valueForKey: @"locale"]];
|
|
|
|
ud = [self userDefaults];
|
|
|
|
format = [ud stringForKey: @"ShortDateFormat"];
|
|
|
|
if (format)
|
|
|
|
[dateFormatter setShortDateFormat: format];
|
|
|
|
format = [ud stringForKey: @"LongDateFormat"];
|
|
|
|
if (format)
|
|
|
|
[dateFormatter setLongDateFormat: format];
|
|
|
|
format = [ud stringForKey: @"TimeFormat"];
|
|
|
|
if (format)
|
|
|
|
[dateFormatter setTimeFormat: format];
|
|
|
|
}
|
|
|
|
|
|
|
|
return dateFormatter;
|
|
|
|
}
|
|
|
|
|
2007-03-27 20:16:52 +02:00
|
|
|
- (NSUserDefaults *) userDefaults
|
|
|
|
{
|
2008-11-11 01:17:35 +01:00
|
|
|
id o;
|
|
|
|
|
2008-11-12 04:30:13 +01:00
|
|
|
o = [[SOGoCache cachedUserDefaults] objectForKey: login];
|
|
|
|
|
2008-11-11 01:17:35 +01:00
|
|
|
if (!o)
|
2008-11-11 02:52:56 +01:00
|
|
|
{
|
2008-11-11 01:17:35 +01:00
|
|
|
o = [[SOGoUserDefaults alloc] initWithTableURL: SOGoProfileURL
|
2008-10-29 20:23:31 +01:00
|
|
|
uid: login
|
|
|
|
fieldName: @"c_defaults"];
|
|
|
|
/* Required parameters for the web interface */
|
2008-11-11 01:17:35 +01:00
|
|
|
if (![[o stringForKey: @"ReplyPlacement"] length])
|
|
|
|
[o setObject: defaultReplyPlacement forKey: @"ReplyPlacement"];
|
|
|
|
if (![[o stringForKey: @"SignaturePlacement"] length])
|
|
|
|
[o setObject: defaultSignaturePlacement forKey: @"SignaturePlacement"];
|
|
|
|
if (![[o stringForKey: @"MessageForwarding"] length])
|
|
|
|
[o setObject: defaultMessageForwarding forKey: @"MessageForwarding"];
|
|
|
|
if (![[o stringForKey: @"MessageCheck"] length])
|
|
|
|
[o setObject: defaultMessageCheck forKey: @"MessageCheck"];
|
|
|
|
|
2008-11-12 04:30:13 +01:00
|
|
|
[SOGoCache setCachedUserDefaults: o user: login];
|
|
|
|
[o release];
|
2008-11-11 02:52:56 +01:00
|
|
|
|
|
|
|
return o;
|
2008-10-29 20:23:31 +01:00
|
|
|
}
|
2007-03-27 20:16:52 +02:00
|
|
|
|
2008-11-11 02:52:56 +01:00
|
|
|
return [o objectForKey: @"dictionary"];
|
2007-03-27 20:16:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSUserDefaults *) userSettings
|
|
|
|
{
|
2008-11-11 01:17:35 +01:00
|
|
|
id o;
|
|
|
|
|
2008-11-12 04:30:13 +01:00
|
|
|
o = [[SOGoCache cachedUserSettings] objectForKey: login];
|
2008-11-11 01:17:35 +01:00
|
|
|
|
|
|
|
if (!o)
|
2008-11-11 02:52:56 +01:00
|
|
|
{
|
2008-11-11 01:17:35 +01:00
|
|
|
o = [[SOGoUserDefaults alloc] initWithTableURL: SOGoProfileURL
|
|
|
|
uid: login
|
|
|
|
fieldName: @"c_settings"];
|
2008-11-12 04:30:13 +01:00
|
|
|
[SOGoCache setCachedUserSettings: o user: login];
|
|
|
|
[o release];
|
2008-11-11 02:52:56 +01:00
|
|
|
|
|
|
|
return o;
|
2008-11-11 01:17:35 +01:00
|
|
|
}
|
2007-03-27 20:16:52 +02:00
|
|
|
|
2008-11-11 02:52:56 +01:00
|
|
|
return [o objectForKey: @"dictionary"];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-05-30 22:20:02 +02:00
|
|
|
- (NSString *) language
|
|
|
|
{
|
|
|
|
if (!language)
|
|
|
|
{
|
|
|
|
language = [[self userDefaults] stringForKey: @"Language"];
|
2007-08-22 17:16:35 +02:00
|
|
|
if (![language length])
|
2007-10-23 00:24:08 +02:00
|
|
|
language = [SOGoUser language];
|
2007-05-30 22:20:02 +02:00
|
|
|
[language retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return language;
|
|
|
|
}
|
|
|
|
|
2007-04-11 21:07:54 +02:00
|
|
|
- (NSTimeZone *) timeZone
|
|
|
|
{
|
|
|
|
NSString *timeZoneName;
|
|
|
|
|
|
|
|
if (!userTimeZone)
|
|
|
|
{
|
|
|
|
timeZoneName = [[self userDefaults] stringForKey: @"TimeZone"];
|
|
|
|
if ([timeZoneName length] > 0)
|
|
|
|
userTimeZone = [NSTimeZone timeZoneWithName: timeZoneName];
|
|
|
|
if (!userTimeZone)
|
2007-04-27 21:02:01 +02:00
|
|
|
userTimeZone = serverTimeZone;
|
2007-04-11 21:07:54 +02:00
|
|
|
[userTimeZone retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return userTimeZone;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSTimeZone *) serverTimeZone
|
|
|
|
{
|
|
|
|
return serverTimeZone;
|
|
|
|
}
|
|
|
|
|
2008-07-18 21:25:26 +02:00
|
|
|
- (unsigned int) firstDayOfWeek
|
|
|
|
{
|
|
|
|
unsigned int firstDayOfWeek;
|
|
|
|
NSNumber *value;
|
|
|
|
|
|
|
|
value = [[self userDefaults] objectForKey: @"WeekStartDay"];
|
|
|
|
if (value)
|
|
|
|
firstDayOfWeek = [value unsignedIntValue];
|
|
|
|
else
|
|
|
|
firstDayOfWeek = sogoFirstDayOfWeek;
|
|
|
|
|
|
|
|
return firstDayOfWeek;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) firstDayOfWeekForDate: (NSCalendarDate *) date
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
NSCalendarDate *firstDay;
|
|
|
|
|
|
|
|
offset = ([self firstDayOfWeek] - [date dayOfWeek]);
|
|
|
|
if (offset > 0)
|
|
|
|
offset -= 7;
|
|
|
|
|
|
|
|
firstDay = [date addTimeInterval: offset * 86400];
|
|
|
|
|
|
|
|
return firstDay;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned int) dayOfWeekForDate: (NSCalendarDate *) date
|
|
|
|
{
|
|
|
|
unsigned int offset, baseDayOfWeek, dayOfWeek;
|
|
|
|
|
|
|
|
offset = [self firstDayOfWeek];
|
|
|
|
baseDayOfWeek = [date dayOfWeek];
|
|
|
|
if (offset > baseDayOfWeek)
|
|
|
|
baseDayOfWeek += 7;
|
|
|
|
|
|
|
|
dayOfWeek = baseDayOfWeek - offset;
|
|
|
|
|
|
|
|
return dayOfWeek;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned int) dayStartHour
|
|
|
|
{
|
|
|
|
int limit;
|
|
|
|
|
|
|
|
limit = _timeValue ([[self userDefaults] stringForKey: @"DayStartTime"]);
|
|
|
|
if (limit == -1)
|
|
|
|
limit = defaultDayStartTime;
|
|
|
|
|
|
|
|
return limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned int) dayEndHour
|
|
|
|
{
|
|
|
|
int limit;
|
|
|
|
|
|
|
|
limit = _timeValue ([[self userDefaults] stringForKey: @"DayEndTime"]);
|
|
|
|
if (limit == -1)
|
|
|
|
limit = defaultDayEndTime;
|
|
|
|
|
|
|
|
return limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) firstWeekOfYearForDate: (NSCalendarDate *) date
|
|
|
|
{
|
|
|
|
NSString *firstWeekRule;
|
|
|
|
NSCalendarDate *januaryFirst, *firstWeek;
|
|
|
|
unsigned int dayOfWeek;
|
|
|
|
|
2008-11-11 01:17:35 +01:00
|
|
|
firstWeekRule = [[self userDefaults] objectForKey: @"FirstWeek"];
|
2008-07-18 21:25:26 +02:00
|
|
|
|
|
|
|
januaryFirst = [NSCalendarDate dateWithYear: [date yearOfCommonEra]
|
|
|
|
month: 1 day: 1 hour: 0 minute: 0 second: 0
|
|
|
|
timeZone: [date timeZone]];
|
|
|
|
if ([firstWeekRule isEqualToString: SOGoWeekStartFirst4DayWeek])
|
|
|
|
{
|
|
|
|
dayOfWeek = [self dayOfWeekForDate: januaryFirst];
|
|
|
|
if (dayOfWeek < 4)
|
|
|
|
firstWeek = [self firstDayOfWeekForDate: januaryFirst];
|
|
|
|
else
|
|
|
|
firstWeek = [self firstDayOfWeekForDate: [januaryFirst
|
|
|
|
dateByAddingYears: 0
|
|
|
|
months: 0
|
|
|
|
days: 7]];
|
|
|
|
}
|
|
|
|
else if ([firstWeekRule isEqualToString: SOGoWeekStartFirstFullWeek])
|
|
|
|
{
|
|
|
|
dayOfWeek = [self dayOfWeekForDate: januaryFirst];
|
|
|
|
if (dayOfWeek == 0)
|
|
|
|
firstWeek = [self firstDayOfWeekForDate: januaryFirst];
|
|
|
|
else
|
|
|
|
firstWeek = [self firstDayOfWeekForDate: [januaryFirst
|
|
|
|
dateByAddingYears: 0
|
|
|
|
months: 0
|
|
|
|
days: 7]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
firstWeek = [self firstDayOfWeekForDate: januaryFirst];
|
|
|
|
|
|
|
|
return firstWeek;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned int) weekNumberForDate: (NSCalendarDate *) date
|
|
|
|
{
|
|
|
|
NSCalendarDate *firstWeek;
|
|
|
|
unsigned int weekNumber;
|
|
|
|
|
|
|
|
firstWeek = [self firstWeekOfYearForDate: date];
|
|
|
|
if ([firstWeek earlierDate: date] == firstWeek)
|
|
|
|
weekNumber = ([date timeIntervalSinceDate: firstWeek]
|
|
|
|
/ (86400 * 7) + 1);
|
|
|
|
else
|
|
|
|
weekNumber = 0;
|
|
|
|
|
|
|
|
return weekNumber;
|
|
|
|
}
|
|
|
|
|
2007-08-15 22:30:37 +02:00
|
|
|
/* mail */
|
2007-11-06 18:12:37 +01:00
|
|
|
- (void) _prepareDefaultMailAccounts
|
2007-08-15 22:30:37 +02:00
|
|
|
{
|
|
|
|
NSMutableDictionary *mailAccount, *identity;
|
|
|
|
NSMutableArray *identities;
|
2008-05-22 17:52:25 +02:00
|
|
|
NSString *name, *fullName, *imapLogin;
|
2007-11-06 18:12:37 +01:00
|
|
|
NSArray *mails;
|
|
|
|
unsigned int count, max;
|
|
|
|
|
2008-05-22 17:52:25 +02:00
|
|
|
imapLogin = [[LDAPUserManager sharedUserManager] getImapLoginForUID: login];
|
2007-11-06 18:12:37 +01:00
|
|
|
mailAccount = [NSMutableDictionary dictionary];
|
|
|
|
name = [NSString stringWithFormat: @"%@@%@",
|
2008-05-22 17:52:25 +02:00
|
|
|
imapLogin, fallbackIMAP4Server];
|
|
|
|
[mailAccount setObject: imapLogin forKey: @"userName"];
|
2007-11-06 18:12:37 +01:00
|
|
|
[mailAccount setObject: fallbackIMAP4Server forKey: @"serverName"];
|
|
|
|
[mailAccount setObject: name forKey: @"name"];
|
|
|
|
|
|
|
|
identities = [NSMutableArray array];
|
|
|
|
mails = [self allEmails];
|
|
|
|
|
|
|
|
max = [mails count];
|
|
|
|
if (max > 1)
|
|
|
|
max--;
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
identity = [NSMutableDictionary dictionary];
|
|
|
|
fullName = [self cn];
|
|
|
|
if (![fullName length])
|
|
|
|
fullName = login;
|
|
|
|
[identity setObject: fullName forKey: @"fullName"];
|
|
|
|
[identity setObject: [mails objectAtIndex: count] forKey: @"email"];
|
|
|
|
[identities addObject: identity];
|
|
|
|
}
|
|
|
|
[[identities objectAtIndex: 0] setObject: [NSNumber numberWithBool: YES]
|
|
|
|
forKey: @"isDefault"];
|
|
|
|
|
|
|
|
[mailAccount setObject: identities forKey: @"identities"];
|
|
|
|
|
|
|
|
mailAccounts = [NSMutableArray new];
|
|
|
|
[mailAccounts addObject: mailAccount];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) mailAccounts
|
|
|
|
{
|
|
|
|
NSUserDefaults *ud;
|
2007-08-15 22:30:37 +02:00
|
|
|
|
|
|
|
if (!mailAccounts)
|
|
|
|
{
|
2007-11-06 18:12:37 +01:00
|
|
|
ud = [self userDefaults];
|
|
|
|
mailAccounts = [ud objectForKey: @"MailAccounts"];
|
|
|
|
if (mailAccounts)
|
|
|
|
[mailAccounts retain];
|
|
|
|
else
|
|
|
|
[self _prepareDefaultMailAccounts];
|
2007-08-15 22:30:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return mailAccounts;
|
|
|
|
}
|
|
|
|
|
2008-02-08 00:09:12 +01:00
|
|
|
- (NSDictionary *) accountWithName: (NSString *) accountName;
|
|
|
|
{
|
|
|
|
NSEnumerator *accounts;
|
|
|
|
NSDictionary *mailAccount, *currentAccount;
|
|
|
|
|
|
|
|
mailAccount = nil;
|
|
|
|
|
|
|
|
accounts = [[self mailAccounts] objectEnumerator];
|
|
|
|
while (!mailAccount
|
|
|
|
&& ((currentAccount = [accounts nextObject])))
|
|
|
|
if ([[currentAccount objectForKey: @"name"]
|
|
|
|
isEqualToString: accountName])
|
|
|
|
mailAccount = currentAccount;
|
|
|
|
|
|
|
|
return mailAccount;
|
|
|
|
}
|
|
|
|
|
2007-08-15 22:30:37 +02:00
|
|
|
/*
|
|
|
|
@interface SOGoMailIdentity : NSObject
|
|
|
|
{
|
|
|
|
NSString *name;
|
|
|
|
NSString *email;
|
|
|
|
NSString *replyTo;
|
|
|
|
NSString *organization;
|
|
|
|
NSString *signature;
|
|
|
|
NSString *vCard;
|
|
|
|
NSString *sentFolderName;
|
|
|
|
NSString *sentBCC;
|
|
|
|
NSString *draftsFolderName;
|
|
|
|
NSString *templatesFolderName;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
int composeHTML:1;
|
|
|
|
int reserved:31;
|
|
|
|
} idFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setName: (NSString *) _value;
|
|
|
|
- (NSString *) name;
|
|
|
|
|
|
|
|
- (void) setEmail: (NSString *) _value;
|
|
|
|
- (NSString *) email;
|
|
|
|
|
|
|
|
- (void) setReplyTo: (NSString *) _value;
|
|
|
|
- (NSString *) replyTo;
|
|
|
|
|
|
|
|
- (void) setOrganization: (NSString *) _value;
|
|
|
|
- (NSString *) organization;
|
|
|
|
|
|
|
|
- (void) setSignature: (NSString *) _value;
|
|
|
|
- (NSString *) signature;
|
|
|
|
- (BOOL) hasSignature;
|
|
|
|
|
|
|
|
- (void) setVCard: (NSString *) _value;
|
|
|
|
- (NSString *) vCard;
|
|
|
|
- (BOOL) hasVCard;
|
|
|
|
|
|
|
|
- (void) setSentFolderName: (NSString *) _value;
|
|
|
|
- (NSString *) sentFolderName;
|
|
|
|
|
|
|
|
- (void) setSentBCC: (NSString *) _value;
|
|
|
|
- (NSString *) sentBCC;
|
|
|
|
|
|
|
|
- (void) setDraftsFolderName: (NSString *) _value;
|
|
|
|
- (NSString *) draftsFolderName;
|
|
|
|
|
|
|
|
- (void) setTemplatesFolderName: (NSString *) _value;
|
|
|
|
- (NSString *) templatesFolderName;
|
|
|
|
|
|
|
|
@end */
|
|
|
|
|
|
|
|
- (NSArray *) allIdentities
|
|
|
|
{
|
|
|
|
NSArray *identities;
|
|
|
|
|
2008-10-23 17:35:20 +02:00
|
|
|
identities = [[self mailAccounts] objectsForKey: @"identities"
|
|
|
|
notFoundMarker: nil];
|
2007-08-15 22:30:37 +02:00
|
|
|
|
|
|
|
return [identities flattenedArray];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *) primaryIdentity
|
|
|
|
{
|
|
|
|
NSDictionary *defaultAccount;
|
|
|
|
|
|
|
|
[self mailAccounts];
|
|
|
|
defaultAccount = [mailAccounts objectAtIndex: 0];
|
|
|
|
|
|
|
|
return [[defaultAccount objectForKey: @"identities"] objectAtIndex: 0];
|
|
|
|
}
|
|
|
|
|
2007-11-19 23:34:31 +01:00
|
|
|
- (NSString *) signature
|
|
|
|
{
|
|
|
|
return [[self primaryIdentity] objectForKey: @"signature"];
|
|
|
|
}
|
|
|
|
|
2008-09-28 21:49:17 +02:00
|
|
|
- (NSString *) replyPlacement
|
|
|
|
{
|
|
|
|
NSString *replyPlacement;
|
|
|
|
|
|
|
|
replyPlacement
|
|
|
|
= [[self userDefaults] stringForKey: @"ReplyPlacement"];
|
|
|
|
|
|
|
|
return replyPlacement;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) signaturePlacement
|
|
|
|
{
|
|
|
|
NSString *signaturePlacement;
|
|
|
|
|
|
|
|
signaturePlacement
|
|
|
|
= [[self userDefaults] stringForKey: @"SignaturePlacement"];
|
|
|
|
|
|
|
|
return signaturePlacement;
|
|
|
|
}
|
|
|
|
|
2007-08-22 17:16:35 +02:00
|
|
|
- (NSString *) messageForwarding
|
|
|
|
{
|
|
|
|
NSString *messageForwarding;
|
|
|
|
|
|
|
|
messageForwarding
|
|
|
|
= [[self userDefaults] stringForKey: @"MessageForwarding"];
|
|
|
|
|
|
|
|
return messageForwarding;
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* folders */
|
|
|
|
|
|
|
|
// TODO: those methods should check whether the traversal stack in the context
|
|
|
|
// already contains proper folders to improve caching behaviour
|
|
|
|
|
2007-11-18 11:16:25 +01:00
|
|
|
- (SOGoUserFolder *) homeFolderInContext: (id) context
|
2007-04-11 21:07:54 +02:00
|
|
|
{
|
2007-11-18 11:16:25 +01:00
|
|
|
if (!homeFolder)
|
|
|
|
{
|
|
|
|
homeFolder = [[WOApplication application] lookupName: [self login]
|
|
|
|
inContext: context
|
|
|
|
acquire: NO];
|
|
|
|
[homeFolder retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return homeFolder;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-11-13 23:38:05 +01:00
|
|
|
- (SOGoAppointmentFolders *) calendarsFolderInContext: (WOContext *) context
|
|
|
|
{
|
|
|
|
return [[self homeFolderInContext: context] lookupName: @"Calendar"
|
|
|
|
inContext: context
|
|
|
|
acquire: NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (SOGoAppointmentFolder *)
|
|
|
|
personalCalendarFolderInContext: (WOContext *) context
|
|
|
|
{
|
|
|
|
return [[self calendarsFolderInContext: context] lookupName: @"personal"
|
|
|
|
inContext: context
|
|
|
|
acquire: NO];
|
|
|
|
}
|
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
// - (id) schedulingCalendarInContext: (id) _ctx
|
|
|
|
// {
|
|
|
|
// /* Note: watch out for cyclic references */
|
|
|
|
// id folder;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
// folder = [(WOContext *)_ctx objectForKey:@"ActiveUserCalendar"];
|
|
|
|
// if (folder != nil)
|
|
|
|
// return [folder isNotNull] ? folder : nil;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
// folder = [self homeFolderInContext:_ctx];
|
|
|
|
// if ([folder isKindOfClass:[NSException class]])
|
|
|
|
// return folder;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
// folder = [folder lookupName:@"Calendar" inContext:_ctx acquire:NO];
|
|
|
|
// if ([folder isKindOfClass:[NSException class]])
|
|
|
|
// return folder;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-05-09 21:23:09 +02:00
|
|
|
// [(WOContext *)_ctx setObject:folder ? folder : [NSNull null]
|
|
|
|
// forKey:@"ActiveUserCalendar"];
|
|
|
|
// return folder;
|
|
|
|
// }
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
- (NSArray *) rolesForObject: (NSObject *) object
|
|
|
|
inContext: (WOContext *) context
|
|
|
|
{
|
|
|
|
NSMutableArray *rolesForObject;
|
|
|
|
NSArray *sogoRoles;
|
2008-04-22 17:56:51 +02:00
|
|
|
NSString *rqMethod;
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
rolesForObject = [NSMutableArray array];
|
2007-02-21 22:13:33 +01:00
|
|
|
|
|
|
|
sogoRoles = [super rolesForObject: object inContext: context];
|
|
|
|
if (sogoRoles)
|
|
|
|
[rolesForObject addObjectsFromArray: sogoRoles];
|
|
|
|
|
2007-10-19 21:03:21 +02:00
|
|
|
if ((superUsernames && [superUsernames containsObject: login])
|
2007-07-04 22:15:42 +02:00
|
|
|
|| [[object ownerInContext: context] isEqualToString: login])
|
2006-12-14 22:20:13 +01:00
|
|
|
[rolesForObject addObject: SoRole_Owner];
|
|
|
|
if ([object isKindOfClass: [SOGoObject class]])
|
|
|
|
{
|
2007-04-17 16:34:31 +02:00
|
|
|
sogoRoles = [(SOGoObject *) object aclsForUser: login];
|
2007-11-29 17:14:11 +01:00
|
|
|
if ([sogoRoles count])
|
2007-02-16 17:55:48 +01:00
|
|
|
[rolesForObject addObjectsFromArray: sogoRoles];
|
2007-11-29 17:14:11 +01:00
|
|
|
sogoRoles = [(SOGoObject *) object subscriptionRoles];
|
|
|
|
if ([sogoRoles firstObjectCommonWithArray: rolesForObject])
|
|
|
|
[rolesForObject addObject: SOGoRole_AuthorizedSubscriber];
|
2007-02-16 17:55:48 +01:00
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2008-04-22 17:56:51 +02:00
|
|
|
#warning this is a hack to work-around the poor implementation of PROPPATCH in SOPE
|
|
|
|
rqMethod = [[context request] method];
|
|
|
|
if ([rqMethod isEqualToString: @"PROPPATCH"])
|
|
|
|
[rolesForObject addObject: @"PROPPATCHer"];
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
return rolesForObject;
|
|
|
|
}
|
|
|
|
|
2007-11-19 17:37:20 +01:00
|
|
|
- (BOOL) isEqual: (id) otherUser
|
|
|
|
{
|
|
|
|
return ([otherUser isKindOfClass: [SoUser class]]
|
|
|
|
&& [login isEqualToString: [otherUser login]]);
|
|
|
|
}
|
|
|
|
|
2007-11-19 23:34:31 +01:00
|
|
|
- (BOOL) isSuperUser
|
|
|
|
{
|
|
|
|
return [superUsernames containsObject: login];
|
|
|
|
}
|
|
|
|
|
2007-11-26 21:41:59 +01:00
|
|
|
/* module access */
|
|
|
|
- (BOOL) canAccessModule: (NSString *) module
|
|
|
|
{
|
|
|
|
NSString *accessValue;
|
|
|
|
|
|
|
|
accessValue = [self _fetchFieldForUser:
|
|
|
|
[NSString stringWithFormat: @"%@Access", module]];
|
|
|
|
|
|
|
|
return [accessValue boolValue];
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@end /* SOGoUser */
|