2008-02-22 22:25:34 +01:00
|
|
|
/* SOGoGCSFolder.m - this file is part of SOGo
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2005 SKYRIX Software AG
|
|
|
|
* Copyright (C) 2006-2008 Inverse groupe conseil
|
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2007-06-18 17:37:37 +02:00
|
|
|
#import <Foundation/NSArray.h>
|
2007-08-15 22:27:32 +02:00
|
|
|
#import <Foundation/NSDate.h>
|
2007-06-18 17:37:37 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSException.h>
|
2007-08-15 22:27:32 +02:00
|
|
|
#import <Foundation/NSKeyValueCoding.h>
|
2007-06-18 17:37:37 +02:00
|
|
|
#import <Foundation/NSURL.h>
|
2007-12-05 00:28:52 +01:00
|
|
|
#import <Foundation/NSUserDefaults.h>
|
2007-06-18 17:37:37 +02:00
|
|
|
|
2007-09-11 22:25:57 +02:00
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
2006-12-14 22:20:13 +01:00
|
|
|
#import <NGObjWeb/SoObject.h>
|
2007-07-22 22:40:34 +02:00
|
|
|
#import <NGObjWeb/SoObject+SoDAV.h>
|
2007-07-04 22:13:49 +02:00
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
2007-10-14 18:07:22 +02:00
|
|
|
#import <NGObjWeb/WOApplication.h>
|
2007-12-05 00:28:52 +01:00
|
|
|
#import <NGObjWeb/WOResponse.h>
|
2008-02-22 22:25:34 +01:00
|
|
|
#import <NGExtensions/NSString+misc.h>
|
2007-06-18 17:37:37 +02:00
|
|
|
#import <NGExtensions/NSNull+misc.h>
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2008-02-25 22:59:25 +01:00
|
|
|
#import <DOM/DOMProtocols.h>
|
2007-06-18 17:37:37 +02:00
|
|
|
#import <EOControl/EOQualifier.h>
|
2007-04-17 16:30:12 +02:00
|
|
|
#import <GDLAccess/EOAdaptorChannel.h>
|
2007-09-15 00:01:02 +02:00
|
|
|
#import <GDLContentStore/GCSChannelManager.h>
|
2007-02-09 22:21:35 +01:00
|
|
|
#import <GDLContentStore/GCSFolderManager.h>
|
|
|
|
#import <GDLContentStore/GCSFolder.h>
|
|
|
|
#import <GDLContentStore/GCSFolderType.h>
|
2007-09-15 00:01:02 +02:00
|
|
|
#import <GDLContentStore/NSURL+GCS.h>
|
2007-06-05 00:38:43 +02:00
|
|
|
#import <SaxObjC/XMLNamespaces.h>
|
2007-10-14 18:07:22 +02:00
|
|
|
#import <UI/SOGoUI/SOGoFolderAdvisory.h>
|
2007-11-09 00:07:30 +01:00
|
|
|
#import "NSDictionary+Utilities.h"
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2007-08-24 22:38:44 +02:00
|
|
|
#import "NSArray+Utilities.h"
|
2008-05-03 01:11:21 +02:00
|
|
|
#import "NSObject+DAV.h"
|
2007-07-22 22:40:34 +02:00
|
|
|
#import "NSString+Utilities.h"
|
|
|
|
|
2007-09-15 01:16:48 +02:00
|
|
|
#import "SOGoContentObject.h"
|
2007-11-20 20:15:26 +01:00
|
|
|
#import "SOGoParentFolder.h"
|
2007-04-26 03:16:19 +02:00
|
|
|
#import "SOGoPermissions.h"
|
2007-07-04 22:13:49 +02:00
|
|
|
#import "SOGoUser.h"
|
2008-05-03 01:11:21 +02:00
|
|
|
#import "SOGoWebDAVAclManager.h"
|
2008-02-07 17:51:41 +01:00
|
|
|
#import "WORequest+SOGo.h"
|
2007-06-18 17:37:37 +02:00
|
|
|
|
2007-11-07 16:58:43 +01:00
|
|
|
#import "SOGoGCSFolder.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-05-22 20:35:17 +02:00
|
|
|
static NSString *defaultUserID = @"<default>";
|
2007-12-03 15:13:10 +01:00
|
|
|
static BOOL sendFolderAdvisories = NO;
|
2007-05-22 20:35:17 +02:00
|
|
|
|
2007-11-07 16:58:43 +01:00
|
|
|
@implementation SOGoGCSFolder
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-05-03 01:11:21 +02:00
|
|
|
+ (SOGoWebDAVAclManager *) webdavAclManager
|
|
|
|
{
|
|
|
|
SOGoWebDAVAclManager *webdavAclManager = nil;
|
|
|
|
|
|
|
|
if (!webdavAclManager)
|
|
|
|
{
|
|
|
|
webdavAclManager = [SOGoWebDAVAclManager new];
|
|
|
|
[webdavAclManager registerDAVPermission: davElement (@"read", @"DAV:")
|
|
|
|
abstract: YES
|
|
|
|
withEquivalent: SoPerm_WebDAVAccess
|
|
|
|
asChildOf: davElement (@"all", @"DAV:")];
|
|
|
|
[webdavAclManager registerDAVPermission: davElement (@"read-current-user-privilege-set", @"DAV:")
|
|
|
|
abstract: YES
|
|
|
|
withEquivalent: SoPerm_WebDAVAccess
|
|
|
|
asChildOf: davElement (@"read", @"DAV:")];
|
|
|
|
[webdavAclManager registerDAVPermission: davElement (@"write", @"DAV:")
|
|
|
|
abstract: YES
|
|
|
|
withEquivalent: nil
|
|
|
|
asChildOf: davElement (@"all", @"DAV:")];
|
|
|
|
[webdavAclManager registerDAVPermission: davElement (@"bind", @"DAV:")
|
|
|
|
abstract: NO
|
|
|
|
withEquivalent: SoPerm_AddDocumentsImagesAndFiles
|
|
|
|
asChildOf: davElement (@"write", @"DAV:")];
|
|
|
|
[webdavAclManager registerDAVPermission: davElement (@"unbind", @"DAV:")
|
|
|
|
abstract: NO
|
|
|
|
withEquivalent: SoPerm_DeleteObjects
|
|
|
|
asChildOf: davElement (@"write", @"DAV:")];
|
|
|
|
[webdavAclManager
|
|
|
|
registerDAVPermission: davElement (@"write-properties", @"DAV:")
|
|
|
|
abstract: YES
|
|
|
|
withEquivalent: SoPerm_ChangePermissions /* hackish */
|
|
|
|
asChildOf: davElement (@"write", @"DAV:")];
|
|
|
|
[webdavAclManager
|
|
|
|
registerDAVPermission: davElement (@"write-content", @"DAV:")
|
|
|
|
abstract: YES
|
|
|
|
withEquivalent: nil
|
|
|
|
asChildOf: davElement (@"write", @"DAV:")];
|
|
|
|
[webdavAclManager registerDAVPermission: davElement (@"admin", @"urn:inverse:params:xml:ns:inverse-dav")
|
|
|
|
abstract: YES
|
|
|
|
withEquivalent: nil
|
|
|
|
asChildOf: davElement (@"all", @"DAV:")];
|
|
|
|
[webdavAclManager
|
|
|
|
registerDAVPermission: davElement (@"read-acl", @"DAV:")
|
|
|
|
abstract: YES
|
|
|
|
withEquivalent: SOGoPerm_ReadAcls
|
|
|
|
asChildOf: davElement (@"admin", @"urn:inverse:params:xml:ns:inverse-dav")];
|
|
|
|
[webdavAclManager
|
|
|
|
registerDAVPermission: davElement (@"write-acl", @"DAV:")
|
|
|
|
abstract: YES
|
|
|
|
withEquivalent: SoPerm_ChangePermissions
|
|
|
|
asChildOf: davElement (@"admin", @"urn:inverse:params:xml:ns:inverse-dav")];
|
|
|
|
}
|
|
|
|
|
|
|
|
return webdavAclManager;
|
|
|
|
}
|
|
|
|
|
2007-12-03 15:13:10 +01:00
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
NSUserDefaults *ud;
|
|
|
|
|
|
|
|
ud = [NSUserDefaults standardUserDefaults];
|
2008-04-02 16:17:53 +02:00
|
|
|
|
2007-12-03 15:13:10 +01:00
|
|
|
sendFolderAdvisories = [ud boolForKey: @"SOGoFoldersSendEMailNotifications"];
|
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
+ (id) folderWithSubscriptionReference: (NSString *) reference
|
|
|
|
inContainer: (id) aContainer
|
2007-09-11 22:25:57 +02:00
|
|
|
{
|
|
|
|
id newFolder;
|
2007-09-15 00:01:02 +02:00
|
|
|
NSArray *elements, *pathElements;
|
2008-05-16 22:33:55 +02:00
|
|
|
NSString *path, *objectPath, *login, *currentUser, *ocsName, *folderName;
|
|
|
|
WOContext *context;
|
2007-09-15 00:01:02 +02:00
|
|
|
|
|
|
|
elements = [reference componentsSeparatedByString: @":"];
|
2007-11-08 21:35:09 +01:00
|
|
|
login = [elements objectAtIndex: 0];
|
2008-05-16 22:33:55 +02:00
|
|
|
context = [[WOApplication application] context];
|
|
|
|
currentUser = [[context activeUser] login];
|
2007-09-15 00:01:02 +02:00
|
|
|
objectPath = [elements objectAtIndex: 1];
|
|
|
|
pathElements = [objectPath componentsSeparatedByString: @"/"];
|
|
|
|
if ([pathElements count] > 1)
|
|
|
|
ocsName = [pathElements objectAtIndex: 1];
|
|
|
|
else
|
|
|
|
ocsName = @"personal";
|
2007-09-11 22:25:57 +02:00
|
|
|
|
2007-11-09 00:04:42 +01:00
|
|
|
path = [NSString stringWithFormat: @"/Users/%@/%@/%@",
|
|
|
|
login, [pathElements objectAtIndex: 0], ocsName];
|
2007-11-08 21:35:09 +01:00
|
|
|
folderName = [NSString stringWithFormat: @"%@_%@", login, ocsName];
|
2007-11-09 00:04:42 +01:00
|
|
|
newFolder = [self objectWithName: folderName inContainer: aContainer];
|
|
|
|
[newFolder setOCSPath: path];
|
2007-11-08 21:35:09 +01:00
|
|
|
[newFolder setOwner: login];
|
2008-05-16 22:33:55 +02:00
|
|
|
[newFolder setIsSubscription: ![login isEqualToString: currentUser]];
|
2007-11-29 22:10:39 +01:00
|
|
|
if (![newFolder displayName])
|
|
|
|
newFolder = nil;
|
2007-09-11 22:25:57 +02:00
|
|
|
|
|
|
|
return newFolder;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-04-27 21:45:12 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
ocsPath = nil;
|
|
|
|
ocsFolder = nil;
|
|
|
|
aclCache = [NSMutableDictionary new];
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[ocsFolder release];
|
|
|
|
[ocsPath release];
|
|
|
|
[aclCache release];
|
2006-06-15 21:34:10 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* accessors */
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
- (void) _setDisplayNameFromRow: (NSDictionary *) row
|
|
|
|
{
|
2007-11-20 20:15:26 +01:00
|
|
|
NSString *currentLogin, *ownerLogin, *primaryDN;
|
2007-09-15 00:01:02 +02:00
|
|
|
NSDictionary *ownerIdentity;
|
2007-06-29 23:58:23 +02:00
|
|
|
|
2007-11-20 20:15:26 +01:00
|
|
|
primaryDN = [row objectForKey: @"c_foldername"];
|
2007-11-30 17:43:55 +01:00
|
|
|
if ([primaryDN length])
|
2007-09-15 00:01:02 +02:00
|
|
|
{
|
2007-11-30 17:43:55 +01:00
|
|
|
displayName = [NSMutableString new];
|
|
|
|
if ([primaryDN isEqualToString: [container defaultFolderName]])
|
|
|
|
[displayName appendString: [self labelForKey: primaryDN]];
|
|
|
|
else
|
|
|
|
[displayName appendString: primaryDN];
|
|
|
|
|
|
|
|
currentLogin = [[context activeUser] login];
|
|
|
|
ownerLogin = [self ownerInContext: context];
|
|
|
|
if (![currentLogin isEqualToString: ownerLogin])
|
|
|
|
{
|
|
|
|
ownerIdentity = [[SOGoUser userWithLogin: ownerLogin roles: nil]
|
|
|
|
primaryIdentity];
|
|
|
|
[displayName
|
|
|
|
appendString: [ownerIdentity keysWithFormat:
|
|
|
|
@" (%{fullName} <%{email}>)"]];
|
|
|
|
}
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _fetchDisplayName
|
|
|
|
{
|
|
|
|
GCSChannelManager *cm;
|
|
|
|
EOAdaptorChannel *fc;
|
|
|
|
NSURL *folderLocation;
|
|
|
|
NSString *sql;
|
|
|
|
NSArray *attrs;
|
|
|
|
NSDictionary *row;
|
|
|
|
|
|
|
|
cm = [GCSChannelManager defaultChannelManager];
|
|
|
|
folderLocation
|
|
|
|
= [[GCSFolderManager defaultFolderManager] folderInfoLocation];
|
|
|
|
fc = [cm acquireOpenChannelForURL: folderLocation];
|
|
|
|
if (fc)
|
|
|
|
{
|
|
|
|
sql
|
|
|
|
= [NSString stringWithFormat: (@"SELECT c_foldername FROM %@"
|
|
|
|
@" WHERE c_path = '%@'"),
|
|
|
|
[folderLocation gcsTableName], ocsPath];
|
|
|
|
[fc evaluateExpressionX: sql];
|
|
|
|
attrs = [fc describeResults: NO];
|
|
|
|
row = [fc fetchAttributes: attrs withZone: NULL];
|
|
|
|
if (row)
|
|
|
|
[self _setDisplayNameFromRow: row];
|
|
|
|
[fc cancelFetch];
|
|
|
|
[cm releaseChannel: fc];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-11 22:25:57 +02:00
|
|
|
- (NSString *) displayName
|
|
|
|
{
|
2007-11-30 17:43:55 +01:00
|
|
|
if (!displayName)
|
|
|
|
[self _fetchDisplayName];
|
|
|
|
|
2007-09-11 22:25:57 +02:00
|
|
|
return displayName;
|
|
|
|
}
|
|
|
|
|
2007-11-07 16:58:43 +01:00
|
|
|
- (void) setOCSPath: (NSString *) _path
|
|
|
|
{
|
|
|
|
if (![ocsPath isEqualToString:_path])
|
|
|
|
{
|
|
|
|
if (ocsPath)
|
|
|
|
[self warnWithFormat: @"GCS path is already set! '%@'", _path];
|
|
|
|
ASSIGN (ocsPath, _path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) ocsPath
|
|
|
|
{
|
|
|
|
return ocsPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (GCSFolderManager *) folderManager
|
|
|
|
{
|
|
|
|
static GCSFolderManager *folderManager = nil;
|
|
|
|
|
|
|
|
if (!folderManager)
|
|
|
|
folderManager = [GCSFolderManager defaultFolderManager];
|
|
|
|
|
|
|
|
return folderManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (GCSFolder *) ocsFolderForPath: (NSString *) _path
|
|
|
|
{
|
|
|
|
return [[self folderManager] folderAtPath: _path];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) folderIsMandatory
|
|
|
|
{
|
|
|
|
return [nameInContainer isEqualToString: @"personal"];
|
|
|
|
}
|
|
|
|
|
2008-04-22 01:03:48 +02:00
|
|
|
- (NSString *) folderReference
|
|
|
|
{
|
2008-05-16 22:33:55 +02:00
|
|
|
return [NSString stringWithFormat: @"%@:%@/%@",
|
|
|
|
owner,
|
|
|
|
[container nameInContainer],
|
|
|
|
[self realNameInContainer]];
|
|
|
|
}
|
2008-04-22 01:03:48 +02:00
|
|
|
|
2008-05-16 22:33:55 +02:00
|
|
|
- (NSArray *) pathArrayToFolder
|
|
|
|
{
|
|
|
|
NSArray *basePathElements;
|
|
|
|
unsigned int max;
|
2008-04-22 01:03:48 +02:00
|
|
|
|
2008-05-16 22:33:55 +02:00
|
|
|
basePathElements = [[self ocsPath] componentsSeparatedByString: @"/"];
|
|
|
|
max = [basePathElements count];
|
2008-04-22 01:03:48 +02:00
|
|
|
|
2008-05-16 22:33:55 +02:00
|
|
|
return [basePathElements subarrayWithRange: NSMakeRange (2, max - 2)];
|
2008-04-22 01:03:48 +02:00
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
- (NSString *) davDisplayName
|
|
|
|
{
|
|
|
|
return [self displayName];
|
|
|
|
}
|
|
|
|
|
2008-04-22 01:03:48 +02:00
|
|
|
- (NSException *) setDavDisplayName: (NSString *) newName
|
|
|
|
{
|
|
|
|
NSException *error;
|
2008-04-22 16:50:40 +02:00
|
|
|
NSArray *currentRoles;
|
2008-04-22 01:03:48 +02:00
|
|
|
|
2008-04-22 16:50:40 +02:00
|
|
|
currentRoles = [[context activeUser] rolesForObject: self
|
|
|
|
inContext: context];
|
|
|
|
if ([currentRoles containsObject: SoRole_Owner])
|
2008-04-22 01:03:48 +02:00
|
|
|
{
|
2008-04-22 16:50:40 +02:00
|
|
|
if ([newName length])
|
|
|
|
{
|
|
|
|
[self renameTo: newName];
|
|
|
|
error = nil;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
error = [NSException exceptionWithHTTPStatus: 400
|
2008-05-03 01:11:21 +02:00
|
|
|
reason: @"Empty string"];
|
2008-04-22 01:03:48 +02:00
|
|
|
}
|
|
|
|
else
|
2008-04-22 16:50:40 +02:00
|
|
|
error = [NSException exceptionWithHTTPStatus: 403
|
|
|
|
reason: @"Modification denied."];
|
2008-04-22 01:03:48 +02:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2007-04-27 21:45:12 +02:00
|
|
|
- (GCSFolder *) ocsFolder
|
|
|
|
{
|
2006-09-29 20:26:29 +02:00
|
|
|
GCSFolder *folder;
|
2007-07-04 22:13:49 +02:00
|
|
|
NSString *userLogin;
|
2006-09-29 20:26:29 +02:00
|
|
|
|
|
|
|
if (!ocsFolder)
|
2007-06-29 23:58:23 +02:00
|
|
|
{
|
|
|
|
ocsFolder = [self ocsFolderForPath: [self ocsPath]];
|
2007-07-04 22:13:49 +02:00
|
|
|
userLogin = [[context activeUser] login];
|
2007-06-29 23:58:23 +02:00
|
|
|
if (!ocsFolder
|
2007-11-07 16:58:43 +01:00
|
|
|
&& [userLogin isEqualToString: [self ownerInContext: context]]
|
2007-06-29 23:58:23 +02:00
|
|
|
&& [self folderIsMandatory]
|
|
|
|
&& [self create])
|
|
|
|
ocsFolder = [self ocsFolderForPath: [self ocsPath]];
|
|
|
|
[ocsFolder retain];
|
|
|
|
}
|
2006-09-29 20:26:29 +02:00
|
|
|
|
|
|
|
if ([ocsFolder isNotNull])
|
|
|
|
folder = ocsFolder;
|
|
|
|
else
|
|
|
|
folder = nil;
|
|
|
|
|
|
|
|
return folder;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-10-14 18:07:22 +02:00
|
|
|
- (void) sendFolderAdvisoryTemplate: (NSString *) template
|
|
|
|
{
|
2007-10-22 23:52:13 +02:00
|
|
|
NSString *pageName;
|
2007-10-14 18:07:22 +02:00
|
|
|
SOGoUser *user;
|
|
|
|
SOGoFolderAdvisory *page;
|
|
|
|
|
2007-10-22 23:52:13 +02:00
|
|
|
user = [context activeUser];
|
2007-10-14 18:07:22 +02:00
|
|
|
pageName = [NSString stringWithFormat: @"SOGoFolder%@%@Advisory",
|
2007-10-22 23:52:13 +02:00
|
|
|
[user language], template];
|
2007-10-14 18:07:22 +02:00
|
|
|
|
2007-10-22 23:52:13 +02:00
|
|
|
page = [[WOApplication application] pageWithName: pageName
|
|
|
|
inContext: context];
|
2007-10-14 18:07:22 +02:00
|
|
|
[page setFolderObject: self];
|
2007-10-22 23:52:13 +02:00
|
|
|
[page setRecipientUID: [user login]];
|
2007-10-14 18:07:22 +02:00
|
|
|
[page send];
|
|
|
|
}
|
|
|
|
|
2007-02-09 22:21:35 +01:00
|
|
|
- (BOOL) create
|
|
|
|
{
|
|
|
|
NSException *result;
|
|
|
|
|
|
|
|
result = [[self folderManager] createFolderOfType: [self folderType]
|
2007-09-15 00:01:02 +02:00
|
|
|
withName: displayName
|
2007-02-09 22:21:35 +01:00
|
|
|
atPath: ocsPath];
|
|
|
|
|
2008-02-06 17:20:59 +01:00
|
|
|
if (!result
|
|
|
|
&& [[context request] handledByDefaultHandler]
|
|
|
|
&& sendFolderAdvisories)
|
|
|
|
[self sendFolderAdvisoryTemplate: @"Addition"];
|
2007-12-03 15:13:10 +01:00
|
|
|
|
2007-02-09 22:21:35 +01:00
|
|
|
return (result == nil);
|
|
|
|
}
|
|
|
|
|
2007-03-21 15:27:04 +01:00
|
|
|
- (NSException *) delete
|
|
|
|
{
|
2007-09-11 22:25:57 +02:00
|
|
|
NSException *error;
|
|
|
|
|
2007-10-14 18:07:22 +02:00
|
|
|
// We just fetch our displayName since our table will use it!
|
|
|
|
[self displayName];
|
|
|
|
|
2007-09-11 22:25:57 +02:00
|
|
|
if ([nameInContainer isEqualToString: @"personal"])
|
|
|
|
error = [NSException exceptionWithHTTPStatus: 403
|
2007-09-15 00:01:02 +02:00
|
|
|
reason: @"folder 'personal' cannot be deleted"];
|
2007-09-11 22:25:57 +02:00
|
|
|
else
|
|
|
|
error = [[self folderManager] deleteFolderAtPath: ocsPath];
|
|
|
|
|
2008-02-06 17:20:59 +01:00
|
|
|
if (!error && sendFolderAdvisories
|
|
|
|
&& [[context request] handledByDefaultHandler])
|
|
|
|
[self sendFolderAdvisoryTemplate: @"Removal"];
|
2007-12-03 15:13:10 +01:00
|
|
|
|
2007-09-11 22:25:57 +02:00
|
|
|
return error;
|
2007-03-21 15:27:04 +01:00
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
- (void) renameTo: (NSString *) newName
|
|
|
|
{
|
|
|
|
GCSChannelManager *cm;
|
|
|
|
EOAdaptorChannel *fc;
|
|
|
|
NSURL *folderLocation;
|
|
|
|
NSString *sql;
|
|
|
|
|
|
|
|
[displayName release];
|
|
|
|
displayName = nil;
|
|
|
|
|
|
|
|
cm = [GCSChannelManager defaultChannelManager];
|
|
|
|
folderLocation
|
|
|
|
= [[GCSFolderManager defaultFolderManager] folderInfoLocation];
|
|
|
|
fc = [cm acquireOpenChannelForURL: folderLocation];
|
|
|
|
if (fc)
|
|
|
|
{
|
|
|
|
sql
|
|
|
|
= [NSString stringWithFormat: (@"UPDATE %@ SET c_foldername = '%@'"
|
|
|
|
@" WHERE c_path = '%@'"),
|
|
|
|
[folderLocation gcsTableName], newName, ocsPath];
|
|
|
|
[fc evaluateExpressionX: sql];
|
|
|
|
[cm releaseChannel: fc];
|
|
|
|
// sql = [sql stringByAppendingFormat:@" WHERE %@ = '%@'",
|
|
|
|
// uidColumnName, [self uid]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-29 23:58:23 +02:00
|
|
|
- (NSArray *) fetchContentObjectNames
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
NSArray *fields, *records;
|
|
|
|
|
2007-06-29 23:58:23 +02:00
|
|
|
fields = [NSArray arrayWithObject: @"c_name"];
|
2006-06-15 21:34:10 +02:00
|
|
|
records = [[self ocsFolder] fetchFields:fields matchingQualifier:nil];
|
2007-06-29 23:58:23 +02:00
|
|
|
if (![records isNotNull])
|
|
|
|
{
|
|
|
|
[self errorWithFormat: @"(%s): fetch failed!", __PRETTY_FUNCTION__];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
if ([records isKindOfClass: [NSException class]])
|
2006-06-15 21:34:10 +02:00
|
|
|
return records;
|
2008-02-12 16:48:53 +01:00
|
|
|
|
2007-08-24 22:38:44 +02:00
|
|
|
return [records objectsForKey: @"c_name"];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
2006-08-09 23:32:39 +02:00
|
|
|
|
2007-02-21 22:11:40 +01:00
|
|
|
- (BOOL) nameExistsInFolder: (NSString *) objectName
|
|
|
|
{
|
|
|
|
NSArray *fields, *records;
|
|
|
|
EOQualifier *qualifier;
|
|
|
|
|
|
|
|
qualifier
|
|
|
|
= [EOQualifier qualifierWithQualifierFormat:
|
|
|
|
[NSString stringWithFormat: @"c_name='%@'", objectName]];
|
|
|
|
|
|
|
|
fields = [NSArray arrayWithObject: @"c_name"];
|
|
|
|
records = [[self ocsFolder] fetchFields: fields
|
|
|
|
matchingQualifier: qualifier];
|
|
|
|
return (records
|
|
|
|
&& ![records isKindOfClass:[NSException class]]
|
|
|
|
&& [records count] > 0);
|
|
|
|
}
|
|
|
|
|
2007-09-15 01:16:48 +02:00
|
|
|
- (void) deleteEntriesWithIds: (NSArray *) ids
|
|
|
|
{
|
|
|
|
unsigned int count, max;
|
|
|
|
NSString *currentID;
|
|
|
|
SOGoContentObject *deleteObject;
|
|
|
|
|
|
|
|
max = [ids count];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
currentID = [ids objectAtIndex: count];
|
|
|
|
deleteObject = [self lookupName: currentID
|
|
|
|
inContext: context acquire: NO];
|
2007-11-04 20:51:09 +01:00
|
|
|
if (![deleteObject isKindOfClass: [NSException class]])
|
2007-11-18 11:16:25 +01:00
|
|
|
{
|
|
|
|
if ([deleteObject respondsToSelector: @selector (prepareDelete)])
|
|
|
|
[deleteObject prepareDelete];
|
|
|
|
[deleteObject delete];
|
|
|
|
}
|
2007-09-15 01:16:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-29 23:58:23 +02:00
|
|
|
- (NSDictionary *) fetchContentStringsAndNamesOfAllObjects
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
NSDictionary *files;
|
|
|
|
|
|
|
|
files = [[self ocsFolder] fetchContentsOfAllFiles];
|
2007-06-29 23:58:23 +02:00
|
|
|
if (![files isNotNull])
|
|
|
|
{
|
|
|
|
[self errorWithFormat:@"(%s): fetch failed!", __PRETTY_FUNCTION__];
|
|
|
|
return nil;
|
|
|
|
}
|
2008-05-16 22:33:55 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
2007-12-05 00:28:52 +01:00
|
|
|
#warning this code should be cleaned up
|
2008-02-25 22:59:25 +01:00
|
|
|
- (void) _subscribeUser: (SOGoUser *) subscribingUser
|
|
|
|
reallyDo: (BOOL) reallyDo
|
2008-05-16 22:33:55 +02:00
|
|
|
fromMailInvitation: (BOOL) isMailInvitation
|
2008-02-25 22:59:25 +01:00
|
|
|
inResponse: (WOResponse *) response
|
2007-12-05 00:28:52 +01:00
|
|
|
{
|
|
|
|
NSMutableArray *folderSubscription;
|
2008-05-16 22:33:55 +02:00
|
|
|
NSString *subscriptionPointer, *mailInvitationURL;
|
2007-12-05 00:28:52 +01:00
|
|
|
NSUserDefaults *ud;
|
|
|
|
NSMutableDictionary *moduleSettings;
|
|
|
|
|
2008-02-25 22:59:25 +01:00
|
|
|
ud = [subscribingUser userSettings];
|
2008-05-16 22:33:55 +02:00
|
|
|
moduleSettings = [ud objectForKey: [container nameInContainer]];
|
2007-12-05 00:28:52 +01:00
|
|
|
|
2008-02-25 22:59:25 +01:00
|
|
|
if ([owner isEqualToString: [subscribingUser login]])
|
2007-12-05 00:28:52 +01:00
|
|
|
{
|
|
|
|
[response setStatus: 403];
|
|
|
|
[response appendContentString:
|
|
|
|
@"You cannot (un)subscribe to a folder that you own!"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
folderSubscription
|
|
|
|
= [moduleSettings objectForKey: @"SubscribedFolders"];
|
|
|
|
if (!(folderSubscription
|
|
|
|
&& [folderSubscription isKindOfClass: [NSMutableArray class]]))
|
|
|
|
{
|
|
|
|
folderSubscription = [NSMutableArray array];
|
|
|
|
[moduleSettings setObject: folderSubscription
|
|
|
|
forKey: @"SubscribedFolders"];
|
|
|
|
}
|
|
|
|
|
2008-04-22 01:03:48 +02:00
|
|
|
subscriptionPointer = [self folderReference];
|
2007-12-05 00:28:52 +01:00
|
|
|
if (reallyDo)
|
|
|
|
[folderSubscription addObjectUniquely: subscriptionPointer];
|
|
|
|
else
|
|
|
|
[folderSubscription removeObject: subscriptionPointer];
|
|
|
|
|
|
|
|
[ud synchronize];
|
|
|
|
|
2008-05-16 22:33:55 +02:00
|
|
|
if (isMailInvitation)
|
|
|
|
{
|
|
|
|
mailInvitationURL = [[self soURLToBaseContainerForCurrentUser]
|
|
|
|
absoluteString];
|
|
|
|
[response setStatus: 302];
|
|
|
|
[response setHeader: mailInvitationURL
|
|
|
|
forKey: @"location"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[response setStatus: 204];
|
2007-12-05 00:28:52 +01:00
|
|
|
}
|
2008-02-25 22:59:25 +01:00
|
|
|
}
|
|
|
|
|
2008-05-16 22:33:55 +02:00
|
|
|
- (WOResponse *) subscribe: (BOOL) reallyDo
|
|
|
|
inTheNameOf: (NSString *) delegatedUser
|
|
|
|
fromMailInvitation: (BOOL) isMailInvitation
|
|
|
|
inContext: (WOContext *) localContext
|
2008-02-25 22:59:25 +01:00
|
|
|
{
|
|
|
|
WOResponse *response;
|
|
|
|
SOGoUser *currentUser, *subscriptionUser;
|
|
|
|
BOOL validRequest;
|
|
|
|
|
|
|
|
response = [localContext response];
|
|
|
|
currentUser = [localContext activeUser];
|
|
|
|
|
|
|
|
if ([delegatedUser length])
|
|
|
|
{
|
|
|
|
validRequest = ([currentUser isSuperUser]);
|
|
|
|
subscriptionUser = [SOGoUser userWithLogin: delegatedUser roles: nil];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
validRequest = YES;
|
|
|
|
subscriptionUser = currentUser;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (validRequest)
|
|
|
|
[self _subscribeUser: subscriptionUser
|
|
|
|
reallyDo: reallyDo
|
2008-05-16 22:33:55 +02:00
|
|
|
fromMailInvitation: isMailInvitation
|
2008-02-25 22:59:25 +01:00
|
|
|
inResponse: response];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[response setStatus: 403];
|
|
|
|
[response appendContentString:
|
|
|
|
@"You cannot subscribe another user to any folder"
|
|
|
|
@" unless you are a super-user."];
|
|
|
|
}
|
2007-12-05 00:28:52 +01:00
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2008-02-25 22:59:25 +01:00
|
|
|
- (NSString *) _parseDAVDelegatedUser: (WOContext *) queryContext
|
|
|
|
{
|
|
|
|
id <DOMDocument> document;
|
|
|
|
id <DOMNamedNodeMap> attrs;
|
|
|
|
|
|
|
|
document = [[queryContext request] contentAsDOMDocument];
|
|
|
|
attrs = [[document documentElement] attributes];
|
|
|
|
|
|
|
|
return [[attrs namedItem: @"user"] nodeValue];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id <WOActionResults>) davSubscribe: (WOContext *) queryContext
|
2007-12-05 00:28:52 +01:00
|
|
|
{
|
2008-05-16 22:33:55 +02:00
|
|
|
return [self subscribe: YES
|
2008-02-25 22:59:25 +01:00
|
|
|
inTheNameOf: [self _parseDAVDelegatedUser: queryContext]
|
2008-05-16 22:33:55 +02:00
|
|
|
fromMailInvitation: NO
|
2008-02-25 22:59:25 +01:00
|
|
|
inContext: queryContext];
|
2007-12-05 00:28:52 +01:00
|
|
|
}
|
|
|
|
|
2008-02-25 22:59:25 +01:00
|
|
|
- (id <WOActionResults>) davUnsubscribe: (WOContext *) queryContext
|
2007-12-05 00:28:52 +01:00
|
|
|
{
|
2008-05-16 22:33:55 +02:00
|
|
|
return [self subscribe: NO
|
2008-02-25 22:59:25 +01:00
|
|
|
inTheNameOf: [self _parseDAVDelegatedUser: queryContext]
|
2008-05-16 22:33:55 +02:00
|
|
|
fromMailInvitation: NO
|
2008-02-25 22:59:25 +01:00
|
|
|
inContext: queryContext];
|
2007-12-05 00:28:52 +01:00
|
|
|
}
|
|
|
|
|
2007-04-17 16:30:12 +02:00
|
|
|
/* acls as a container */
|
|
|
|
|
2007-05-19 02:49:05 +02:00
|
|
|
- (NSArray *) aclUsersForObjectAtPath: (NSArray *) objectPathArray;
|
2007-04-17 16:30:12 +02:00
|
|
|
{
|
|
|
|
EOQualifier *qualifier;
|
|
|
|
NSString *qs;
|
2008-02-22 22:25:34 +01:00
|
|
|
NSArray *records, *uids;
|
2007-04-17 16:30:12 +02:00
|
|
|
|
|
|
|
qs = [NSString stringWithFormat: @"c_object = '/%@'",
|
|
|
|
[objectPathArray componentsJoinedByString: @"/"]];
|
|
|
|
qualifier = [EOQualifier qualifierWithQualifierFormat: qs];
|
2007-05-19 02:49:05 +02:00
|
|
|
records = [[self ocsFolder] fetchAclMatchingQualifier: qualifier];
|
2008-02-22 22:25:34 +01:00
|
|
|
uids = [[records valueForKey: @"c_uid"] uniqueObjects];
|
2007-04-17 16:30:12 +02:00
|
|
|
|
2008-02-22 22:25:34 +01:00
|
|
|
return uids;
|
2007-04-17 16:30:12 +02:00
|
|
|
}
|
|
|
|
|
2007-04-27 21:45:12 +02:00
|
|
|
- (NSArray *) _fetchAclsForUser: (NSString *) uid
|
|
|
|
forObjectAtPath: (NSString *) objectPath
|
2007-04-17 16:30:12 +02:00
|
|
|
{
|
|
|
|
EOQualifier *qualifier;
|
|
|
|
NSArray *records;
|
2007-04-26 03:16:19 +02:00
|
|
|
NSMutableArray *acls;
|
2007-04-17 16:30:12 +02:00
|
|
|
NSString *qs;
|
|
|
|
|
|
|
|
qs = [NSString stringWithFormat: @"(c_object = '/%@') AND (c_uid = '%@')",
|
2007-04-27 21:45:12 +02:00
|
|
|
objectPath, uid];
|
2007-04-17 16:30:12 +02:00
|
|
|
qualifier = [EOQualifier qualifierWithQualifierFormat: qs];
|
|
|
|
records = [[self ocsFolder] fetchAclMatchingQualifier: qualifier];
|
|
|
|
|
2007-04-26 03:16:19 +02:00
|
|
|
acls = [NSMutableArray array];
|
|
|
|
if ([records count] > 0)
|
2007-11-29 17:14:11 +01:00
|
|
|
[acls addObjectsFromArray: [records valueForKey: @"c_role"]];
|
2007-04-26 03:16:19 +02:00
|
|
|
|
2008-02-22 22:25:34 +01:00
|
|
|
return [acls uniqueObjects];
|
2007-04-17 16:30:12 +02:00
|
|
|
}
|
|
|
|
|
2007-04-27 21:45:12 +02:00
|
|
|
- (void) _cacheRoles: (NSArray *) roles
|
|
|
|
forUser: (NSString *) uid
|
|
|
|
forObjectAtPath: (NSString *) objectPath
|
|
|
|
{
|
|
|
|
NSMutableDictionary *aclsForObject;
|
|
|
|
|
|
|
|
aclsForObject = [aclCache objectForKey: objectPath];
|
|
|
|
if (!aclsForObject)
|
|
|
|
{
|
|
|
|
aclsForObject = [NSMutableDictionary dictionary];
|
|
|
|
[aclCache setObject: aclsForObject
|
|
|
|
forKey: objectPath];
|
|
|
|
}
|
|
|
|
if (roles)
|
|
|
|
[aclsForObject setObject: roles forKey: uid];
|
|
|
|
else
|
|
|
|
[aclsForObject removeObjectForKey: uid];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) aclsForUser: (NSString *) uid
|
|
|
|
forObjectAtPath: (NSArray *) objectPathArray
|
|
|
|
{
|
|
|
|
NSArray *acls;
|
|
|
|
NSString *objectPath;
|
|
|
|
NSDictionary *aclsForObject;
|
|
|
|
|
|
|
|
objectPath = [objectPathArray componentsJoinedByString: @"/"];
|
|
|
|
aclsForObject = [aclCache objectForKey: objectPath];
|
|
|
|
if (aclsForObject)
|
|
|
|
acls = [aclsForObject objectForKey: uid];
|
|
|
|
else
|
|
|
|
acls = nil;
|
|
|
|
if (!acls)
|
|
|
|
{
|
|
|
|
acls = [self _fetchAclsForUser: uid forObjectAtPath: objectPath];
|
|
|
|
[self _cacheRoles: acls forUser: uid forObjectAtPath: objectPath];
|
|
|
|
}
|
|
|
|
|
2007-05-22 20:35:17 +02:00
|
|
|
if (!([acls count] || [uid isEqualToString: defaultUserID]))
|
|
|
|
acls = [self aclsForUser: defaultUserID
|
2007-05-18 01:09:46 +02:00
|
|
|
forObjectAtPath: objectPathArray];
|
2007-04-27 21:45:12 +02:00
|
|
|
|
|
|
|
return acls;
|
|
|
|
}
|
|
|
|
|
2007-04-17 16:30:12 +02:00
|
|
|
- (void) removeAclsForUsers: (NSArray *) users
|
|
|
|
forObjectAtPath: (NSArray *) objectPathArray
|
|
|
|
{
|
|
|
|
EOQualifier *qualifier;
|
2007-04-27 21:45:12 +02:00
|
|
|
NSString *uids, *qs, *objectPath;
|
|
|
|
NSMutableDictionary *aclsForObject;
|
2007-04-17 16:30:12 +02:00
|
|
|
|
|
|
|
if ([users count] > 0)
|
|
|
|
{
|
2007-04-27 21:45:12 +02:00
|
|
|
objectPath = [objectPathArray componentsJoinedByString: @"/"];
|
|
|
|
aclsForObject = [aclCache objectForKey: objectPath];
|
|
|
|
if (aclsForObject)
|
|
|
|
[aclsForObject removeObjectsForKeys: users];
|
2007-04-17 16:30:12 +02:00
|
|
|
uids = [users componentsJoinedByString: @"') OR (c_uid = '"];
|
|
|
|
qs = [NSString
|
|
|
|
stringWithFormat: @"(c_object = '/%@') AND ((c_uid = '%@'))",
|
2007-04-27 21:45:12 +02:00
|
|
|
objectPath, uids];
|
2007-04-17 16:30:12 +02:00
|
|
|
qualifier = [EOQualifier qualifierWithQualifierFormat: qs];
|
|
|
|
[[self ocsFolder] deleteAclMatchingQualifier: qualifier];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-18 01:09:46 +02:00
|
|
|
- (void) _commitRoles: (NSArray *) roles
|
|
|
|
forUID: (NSString *) uid
|
|
|
|
forObject: (NSString *) objectPath
|
2007-04-17 16:30:12 +02:00
|
|
|
{
|
|
|
|
EOAdaptorChannel *channel;
|
|
|
|
GCSFolder *folder;
|
2007-04-25 00:45:38 +02:00
|
|
|
NSEnumerator *userRoles;
|
2007-05-18 01:09:46 +02:00
|
|
|
NSString *SQL, *currentRole;
|
2007-04-27 21:45:12 +02:00
|
|
|
|
2007-04-17 16:30:12 +02:00
|
|
|
folder = [self ocsFolder];
|
|
|
|
channel = [folder acquireAclChannel];
|
2007-04-25 00:45:38 +02:00
|
|
|
userRoles = [roles objectEnumerator];
|
|
|
|
currentRole = [userRoles nextObject];
|
|
|
|
while (currentRole)
|
|
|
|
{
|
2007-05-18 01:09:46 +02:00
|
|
|
SQL = [NSString stringWithFormat: @"INSERT INTO %@"
|
|
|
|
@" (c_object, c_uid, c_role)"
|
|
|
|
@" VALUES ('/%@', '%@', '%@')",
|
|
|
|
[folder aclTableName],
|
|
|
|
objectPath, uid, currentRole];
|
|
|
|
[channel evaluateExpressionX: SQL];
|
2007-04-25 00:45:38 +02:00
|
|
|
currentRole = [userRoles nextObject];
|
|
|
|
}
|
2007-04-17 16:30:12 +02:00
|
|
|
|
|
|
|
[folder releaseChannel: channel];
|
|
|
|
}
|
|
|
|
|
2007-05-18 01:09:46 +02:00
|
|
|
- (void) setRoles: (NSArray *) roles
|
|
|
|
forUser: (NSString *) uid
|
|
|
|
forObjectAtPath: (NSArray *) objectPathArray
|
|
|
|
{
|
|
|
|
NSString *objectPath;
|
|
|
|
NSMutableArray *newRoles;
|
|
|
|
|
|
|
|
[self removeAclsForUsers: [NSArray arrayWithObject: uid]
|
|
|
|
forObjectAtPath: objectPathArray];
|
|
|
|
|
|
|
|
newRoles = [NSMutableArray arrayWithArray: roles];
|
|
|
|
[newRoles removeObject: SOGoRole_AuthorizedSubscriber];
|
|
|
|
[newRoles removeObject: SOGoRole_None];
|
|
|
|
objectPath = [objectPathArray componentsJoinedByString: @"/"];
|
|
|
|
[self _cacheRoles: newRoles forUser: uid
|
|
|
|
forObjectAtPath: objectPath];
|
|
|
|
if (![newRoles count])
|
|
|
|
[newRoles addObject: SOGoRole_None];
|
|
|
|
|
|
|
|
[self _commitRoles: newRoles forUID: uid forObject: objectPath];
|
|
|
|
}
|
|
|
|
|
2007-04-17 16:30:12 +02:00
|
|
|
/* acls */
|
2007-05-19 02:49:05 +02:00
|
|
|
- (NSArray *) aclUsers
|
2007-04-17 16:30:12 +02:00
|
|
|
{
|
2008-05-16 22:33:55 +02:00
|
|
|
return [self aclUsersForObjectAtPath: [self pathArrayToFolder]];
|
2007-04-17 16:30:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) aclsForUser: (NSString *) uid
|
|
|
|
{
|
2007-06-01 23:03:50 +02:00
|
|
|
NSMutableArray *acls;
|
|
|
|
NSArray *ownAcls, *containerAcls;
|
|
|
|
|
|
|
|
acls = [NSMutableArray array];
|
2008-05-16 22:33:55 +02:00
|
|
|
ownAcls = [self aclsForUser: uid forObjectAtPath: [self pathArrayToFolder]];
|
2007-06-01 23:03:50 +02:00
|
|
|
[acls addObjectsFromArray: ownAcls];
|
|
|
|
if ([container respondsToSelector: @selector (aclsForUser:)])
|
|
|
|
{
|
|
|
|
containerAcls = [container aclsForUser: uid];
|
|
|
|
if ([containerAcls count] > 0)
|
|
|
|
{
|
|
|
|
#warning this should be checked
|
|
|
|
if ([containerAcls containsObject: SOGoRole_ObjectEraser])
|
|
|
|
[acls addObject: SOGoRole_ObjectEraser];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return acls;
|
2007-04-17 16:30:12 +02:00
|
|
|
}
|
|
|
|
|
2007-04-25 00:45:38 +02:00
|
|
|
- (void) setRoles: (NSArray *) roles
|
2007-04-17 16:30:12 +02:00
|
|
|
forUser: (NSString *) uid
|
|
|
|
{
|
|
|
|
return [self setRoles: roles
|
|
|
|
forUser: uid
|
2008-05-16 22:33:55 +02:00
|
|
|
forObjectAtPath: [self pathArrayToFolder]];
|
2007-04-17 16:30:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) removeAclsForUsers: (NSArray *) users
|
|
|
|
{
|
|
|
|
return [self removeAclsForUsers: users
|
2008-05-16 22:33:55 +02:00
|
|
|
forObjectAtPath: [self pathArrayToFolder]];
|
2007-04-17 16:30:12 +02:00
|
|
|
}
|
|
|
|
|
2007-05-22 20:35:17 +02:00
|
|
|
- (NSString *) defaultUserID
|
|
|
|
{
|
|
|
|
return defaultUserID;
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* description */
|
|
|
|
|
2007-07-12 17:55:06 +02:00
|
|
|
- (void) appendAttributesToDescription: (NSMutableString *) _ms
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
[super appendAttributesToDescription:_ms];
|
|
|
|
|
|
|
|
[_ms appendFormat:@" ocs=%@", [self ocsPath]];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end /* SOGoFolder */
|