2007-11-07 23:27:44 +01:00
|
|
|
/* SOGoFolder.m - this file is part of SOGo
|
|
|
|
*
|
2015-01-06 16:59:56 +01:00
|
|
|
* Copyright (C) 2007-2015 Inverse inc.
|
2007-11-07 23:27:44 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/NSArray.h>
|
2008-07-04 18:06:09 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSEnumerator.h>
|
2007-11-07 23:27:44 +01:00
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
#import <Foundation/NSURL.h>
|
2010-01-15 00:19:19 +01:00
|
|
|
#import <Foundation/NSValue.h>
|
|
|
|
|
2012-01-04 16:26:30 +01:00
|
|
|
#import <NGObjWeb/WOApplication.h>
|
2010-01-15 00:19:19 +01:00
|
|
|
#import <NGObjWeb/WOContext.h>
|
2010-04-20 23:30:17 +02:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
2010-01-15 00:19:19 +01:00
|
|
|
#import <NGObjWeb/SoWebDAVValue.h>
|
|
|
|
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
|
|
|
|
#import <DOM/DOMElement.h>
|
2007-11-07 23:27:44 +01:00
|
|
|
|
2007-11-09 21:12:07 +01:00
|
|
|
#import <SaxObjC/XMLNamespaces.h>
|
|
|
|
|
2012-01-04 16:26:30 +01:00
|
|
|
#import <SOGoUI/SOGoFolderAdvisory.h>
|
|
|
|
|
2010-01-15 00:19:19 +01:00
|
|
|
#import "DOMNode+SOGo.h"
|
|
|
|
#import "NSArray+Utilities.h"
|
2008-05-03 01:08:15 +02:00
|
|
|
#import "NSObject+DAV.h"
|
2010-01-15 00:19:19 +01:00
|
|
|
#import "NSString+DAV.h"
|
2007-11-07 23:27:44 +01:00
|
|
|
#import "NSString+Utilities.h"
|
2007-11-29 17:14:11 +01:00
|
|
|
#import "SOGoPermissions.h"
|
2012-01-04 16:26:30 +01:00
|
|
|
#import "SOGoUser.h"
|
|
|
|
#import "SOGoDomainDefaults.h"
|
2008-05-03 01:08:15 +02:00
|
|
|
#import "SOGoWebDAVAclManager.h"
|
2011-11-30 15:54:41 +01:00
|
|
|
#import "WORequest+SOGo.h"
|
2010-01-15 00:19:19 +01:00
|
|
|
#import "WOResponse+SOGo.h"
|
2008-05-03 01:08:15 +02:00
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
#import "SOGoFolder.h"
|
|
|
|
|
2008-05-03 01:08:15 +02:00
|
|
|
@interface SOGoObject (SOGoDAVHelpers)
|
|
|
|
|
|
|
|
- (void) _fillArrayWithPrincipalsOwnedBySelf: (NSMutableArray *) hrefs;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2010-01-15 00:19:19 +01:00
|
|
|
@interface SOGoFolder (private)
|
|
|
|
|
|
|
|
- (NSArray *) _interpretWebDAVArrayValue: (id) value;
|
|
|
|
- (NSDictionary *) _expandPropertyResponse: (NGDOMElement *) property
|
|
|
|
forHREF: (NSString *) href;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
@implementation SOGoFolder
|
|
|
|
|
2008-05-03 01:08:15 +02:00
|
|
|
+ (SOGoWebDAVAclManager *) webdavAclManager
|
|
|
|
{
|
2010-04-20 23:30:17 +02:00
|
|
|
static SOGoWebDAVAclManager *aclManager = nil;
|
2008-05-03 01:08:15 +02:00
|
|
|
|
2010-04-20 23:30:17 +02:00
|
|
|
if (!aclManager)
|
2008-05-03 01:08:15 +02:00
|
|
|
{
|
2010-04-20 23:30:17 +02:00
|
|
|
aclManager = [SOGoWebDAVAclManager new];
|
|
|
|
[aclManager registerDAVPermission: davElement (@"read", XMLNS_WEBDAV)
|
2008-05-03 01:08:15 +02:00
|
|
|
abstract: YES
|
|
|
|
withEquivalent: SoPerm_WebDAVAccess
|
2010-01-15 00:19:19 +01:00
|
|
|
asChildOf: davElement (@"all", XMLNS_WEBDAV)];
|
2010-04-20 23:30:17 +02:00
|
|
|
[aclManager registerDAVPermission: davElement (@"read-current-user-privilege-set", XMLNS_WEBDAV)
|
2008-05-03 01:08:15 +02:00
|
|
|
abstract: YES
|
|
|
|
withEquivalent: nil
|
2010-01-15 00:19:19 +01:00
|
|
|
asChildOf: davElement (@"read", XMLNS_WEBDAV)];
|
2008-05-03 01:08:15 +02:00
|
|
|
}
|
|
|
|
|
2010-04-20 23:30:17 +02:00
|
|
|
return aclManager;
|
2008-05-03 01:08:15 +02:00
|
|
|
}
|
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
2008-05-16 22:33:55 +02:00
|
|
|
{
|
|
|
|
displayName = nil;
|
|
|
|
isSubscription = NO;
|
|
|
|
}
|
2007-11-07 23:27:44 +01:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[displayName release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setDisplayName: (NSString *) newDisplayName
|
|
|
|
{
|
|
|
|
ASSIGN (displayName, newDisplayName);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) displayName
|
|
|
|
{
|
2009-04-01 15:49:24 +02:00
|
|
|
return ((id)displayName ? (id)displayName : (id)nameInContainer);
|
2007-11-07 23:27:44 +01:00
|
|
|
}
|
|
|
|
|
2008-05-16 22:33:55 +02:00
|
|
|
- (void) setIsSubscription: (BOOL) newIsSubscription
|
|
|
|
{
|
|
|
|
isSubscription = newIsSubscription;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isSubscription
|
|
|
|
{
|
|
|
|
return isSubscription;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) realNameInContainer
|
|
|
|
{
|
|
|
|
NSString *realNameInContainer, *ownerName;
|
|
|
|
|
|
|
|
if (isSubscription)
|
|
|
|
{
|
2009-01-21 18:01:06 +01:00
|
|
|
ownerName = [[self ownerInContext: context] asCSSIdentifier];
|
2008-05-16 22:33:55 +02:00
|
|
|
realNameInContainer
|
|
|
|
= [nameInContainer substringFromIndex: [ownerName length] + 1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
realNameInContainer = nameInContainer;
|
|
|
|
|
|
|
|
return realNameInContainer;
|
|
|
|
}
|
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
- (NSString *) folderType
|
|
|
|
{
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2008-02-12 16:48:53 +01:00
|
|
|
- (NSArray *) toOneRelationshipKeys
|
|
|
|
{
|
2010-06-01 19:45:53 +02:00
|
|
|
return nil;
|
2008-02-12 16:48:53 +01:00
|
|
|
}
|
|
|
|
|
2008-05-03 01:08:15 +02:00
|
|
|
- (NSArray *) toManyRelationshipKeys
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2008-03-07 23:14:44 +01:00
|
|
|
- (BOOL) isValidContentName: (NSString *) name
|
|
|
|
{
|
|
|
|
return ([name length] > 0);
|
|
|
|
}
|
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
- (BOOL) isFolderish
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2010-01-15 00:19:19 +01:00
|
|
|
- (NSString *) davURLAsString
|
|
|
|
{
|
|
|
|
return [[container davURLAsString]
|
|
|
|
stringByAppendingFormat: @"%@/", nameInContainer];
|
|
|
|
}
|
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
- (NSString *) httpURLForAdvisoryToUser: (NSString *) uid
|
|
|
|
{
|
|
|
|
return [[self soURL] absoluteString];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) resourceURLForAdvisoryToUser: (NSString *) uid
|
|
|
|
{
|
|
|
|
return [[self davURL] absoluteString];
|
|
|
|
}
|
|
|
|
|
2007-11-08 00:35:56 +01:00
|
|
|
/* sorting */
|
|
|
|
- (NSComparisonResult) _compareByOrigin: (SOGoFolder *) otherFolder
|
|
|
|
{
|
|
|
|
NSComparisonResult comparison;
|
|
|
|
|
2008-05-16 22:33:55 +02:00
|
|
|
if (isSubscription == [otherFolder isSubscription])
|
|
|
|
comparison = NSOrderedSame;
|
2007-11-08 00:35:56 +01:00
|
|
|
else
|
|
|
|
{
|
2008-05-16 22:33:55 +02:00
|
|
|
if (isSubscription)
|
2007-11-08 00:35:56 +01:00
|
|
|
comparison = NSOrderedDescending;
|
|
|
|
else
|
|
|
|
comparison = NSOrderedAscending;
|
|
|
|
}
|
|
|
|
|
|
|
|
return comparison;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSComparisonResult) _compareByNameInContainer: (SOGoFolder *) otherFolder
|
|
|
|
{
|
2008-05-16 22:33:55 +02:00
|
|
|
NSString *selfName, *otherName;
|
2007-11-08 00:35:56 +01:00
|
|
|
NSComparisonResult comparison;
|
|
|
|
|
2008-05-16 22:33:55 +02:00
|
|
|
selfName = [self realNameInContainer];
|
|
|
|
otherName = [otherFolder realNameInContainer];
|
|
|
|
if ([selfName isEqualToString: @"personal"])
|
2007-11-08 00:35:56 +01:00
|
|
|
{
|
2008-05-16 22:33:55 +02:00
|
|
|
if ([otherName isEqualToString: @"personal"])
|
|
|
|
comparison = NSOrderedSame;
|
2007-11-08 00:35:56 +01:00
|
|
|
else
|
|
|
|
comparison = NSOrderedAscending;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-16 22:33:55 +02:00
|
|
|
if ([otherName isEqualToString: @"personal"])
|
2007-11-08 00:35:56 +01:00
|
|
|
comparison = NSOrderedDescending;
|
|
|
|
else
|
2008-08-25 22:52:48 +02:00
|
|
|
comparison = NSOrderedSame;
|
2007-11-08 00:35:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return comparison;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSComparisonResult) compare: (id) otherFolder
|
|
|
|
{
|
|
|
|
NSComparisonResult comparison;
|
|
|
|
|
|
|
|
comparison = [self _compareByOrigin: otherFolder];
|
|
|
|
if (comparison == NSOrderedSame)
|
|
|
|
{
|
|
|
|
comparison = [self _compareByNameInContainer: otherFolder];
|
|
|
|
if (comparison == NSOrderedSame)
|
2011-11-30 15:54:41 +01:00
|
|
|
{
|
|
|
|
if ([self displayName] == nil)
|
|
|
|
comparison = NSOrderedAscending;
|
|
|
|
else if ([otherFolder displayName] == nil)
|
|
|
|
comparison = NSOrderedDescending;
|
|
|
|
else
|
|
|
|
comparison
|
|
|
|
= [[self displayName]
|
|
|
|
localizedCaseInsensitiveCompare: [otherFolder displayName]];
|
|
|
|
}
|
2007-11-08 00:35:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return comparison;
|
|
|
|
}
|
|
|
|
|
2012-01-04 16:26:30 +01:00
|
|
|
/* email advisories */
|
|
|
|
|
|
|
|
- (void) sendFolderAdvisoryTemplate: (NSString *) template
|
|
|
|
{
|
|
|
|
NSString *pageName;
|
|
|
|
SOGoUser *user;
|
|
|
|
SOGoFolderAdvisory *page;
|
|
|
|
NSString *language;
|
|
|
|
|
|
|
|
user = [SOGoUser userWithLogin: [self ownerInContext: context]];
|
|
|
|
if ([[user domainDefaults] foldersSendEMailNotifications])
|
|
|
|
{
|
|
|
|
language = [[user userDefaults] language];
|
|
|
|
pageName = [NSString stringWithFormat: @"SOGoFolder%@%@Advisory",
|
|
|
|
language, template];
|
|
|
|
|
|
|
|
page = [[WOApplication application] pageWithName: pageName
|
|
|
|
inContext: context];
|
|
|
|
[page setFolderObject: self];
|
|
|
|
[page setRecipientUID: [user login]];
|
|
|
|
[page send];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
/* WebDAV */
|
|
|
|
|
2010-08-20 14:37:09 +02:00
|
|
|
- (NSString *) davEntityTag
|
|
|
|
{
|
|
|
|
return @"\"None\"";
|
|
|
|
}
|
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
- (NSString *) davContentType
|
|
|
|
{
|
|
|
|
return @"httpd/unix-directory";
|
|
|
|
}
|
|
|
|
|
2007-11-09 21:12:07 +01:00
|
|
|
- (NSArray *) davResourceType
|
|
|
|
{
|
|
|
|
NSArray *rType, *groupDavCollection;
|
|
|
|
|
|
|
|
if ([self respondsToSelector: @selector (groupDavResourceType)])
|
|
|
|
{
|
|
|
|
groupDavCollection
|
|
|
|
= [NSArray arrayWithObjects: [self groupDavResourceType],
|
|
|
|
XMLNS_GROUPDAV, nil];
|
|
|
|
rType = [NSArray arrayWithObjects: @"collection", groupDavCollection,
|
|
|
|
nil];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rType = [NSArray arrayWithObject: @"collection"];
|
|
|
|
|
|
|
|
return rType;
|
|
|
|
}
|
|
|
|
|
2009-08-27 23:14:54 +02:00
|
|
|
- (BOOL) davIsCollection
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2010-01-15 00:19:19 +01:00
|
|
|
- (NSArray *) _extractHREFSFromPropertyValues: (NSArray *) values
|
|
|
|
{
|
|
|
|
NSMutableArray *hrefs;
|
|
|
|
NSDictionary *value;
|
|
|
|
int count, max;
|
|
|
|
|
|
|
|
max = [values count];
|
|
|
|
hrefs = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
value = [values objectAtIndex: count];
|
|
|
|
if ([value isKindOfClass: [NSDictionary class]])
|
|
|
|
{
|
|
|
|
if ([[value objectForKey: @"method"] isEqualToString: @"href"])
|
|
|
|
[hrefs addObject: [value objectForKey: @"content"]];
|
|
|
|
else
|
|
|
|
[self errorWithFormat: @"value is not an href"];
|
|
|
|
}
|
|
|
|
else if ([value isKindOfClass: [NSString class]])
|
|
|
|
{
|
|
|
|
/* we extract the text between <href>XXX</href>, but in a bad way */
|
|
|
|
[hrefs addObject: [(NSString *) value removeOutsideTags]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[self errorWithFormat: @"value class is '%@' instead of NSDictionary",
|
|
|
|
NSStringFromClass ([value class])];
|
|
|
|
}
|
|
|
|
|
|
|
|
return hrefs;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) _interpretSoWebDAVValue: (SoWebDAVValue *) value
|
|
|
|
{
|
|
|
|
NSString *valueString;
|
|
|
|
|
|
|
|
valueString = [value stringForTag: @"" rawName: @""
|
|
|
|
inContext: context prefixes: nil];
|
|
|
|
|
|
|
|
return [NSArray arrayWithObject: [valueString removeOutsideTags]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) _interpretWebDAVValue: (id) value
|
|
|
|
{
|
|
|
|
NSArray *result;
|
|
|
|
|
|
|
|
if ([value isKindOfClass: [NSString class]])
|
|
|
|
result = [NSArray arrayWithObject: value];
|
|
|
|
else if ([value isKindOfClass: [SoWebDAVValue class]])
|
|
|
|
result = [self _interpretSoWebDAVValue: value];
|
|
|
|
else if ([value isKindOfClass: [NSArray class]])
|
|
|
|
result = [self _interpretWebDAVArrayValue: value];
|
|
|
|
else
|
|
|
|
result = nil;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) _interpretWebDAVArrayValue: (id) value
|
|
|
|
{
|
|
|
|
int count, max;
|
|
|
|
NSMutableArray *results;
|
|
|
|
id subValue, subResults;
|
|
|
|
|
|
|
|
max = [value count];
|
|
|
|
results = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
if (max > 0)
|
|
|
|
{
|
|
|
|
subValue = [value objectAtIndex: 0];
|
|
|
|
if ([subValue isKindOfClass: [NSString class]])
|
|
|
|
[results addObject:
|
|
|
|
davElementWithContent (subValue,
|
|
|
|
[value objectAtIndex: 1],
|
|
|
|
[value objectAtIndex: 3])];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
subResults
|
|
|
|
= [self _interpretWebDAVValue: [value objectAtIndex: count]];
|
|
|
|
[results addObjectsFromArray: subResults];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) _expandedPropertyValue: (NGDOMElement *) property
|
|
|
|
forObject: (SOGoObject *) currentObject
|
|
|
|
{
|
|
|
|
NSString *propertyTag;
|
|
|
|
SEL propertySel;
|
|
|
|
id value;
|
|
|
|
|
|
|
|
propertyTag = [property asPropertyPropertyName];
|
|
|
|
propertySel = [self davPropertySelectorForKey: propertyTag];
|
|
|
|
if (propertySel)
|
|
|
|
value = [currentObject performSelector: propertySel];
|
|
|
|
else
|
|
|
|
value = nil;
|
|
|
|
|
|
|
|
return [self _interpretWebDAVValue: value];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) _expandPropertyValue: (NGDOMElement *) property
|
|
|
|
forObject: (SOGoObject *) currentObject
|
|
|
|
{
|
|
|
|
NSArray *values, *hrefs;
|
|
|
|
NSString *href;
|
|
|
|
NSMutableArray *expandedValues;
|
|
|
|
int count, max;
|
|
|
|
BOOL needsExpansion;
|
|
|
|
|
|
|
|
needsExpansion = ([[property childElementsWithTag: @"property"] length] > 0);
|
|
|
|
values = [self _expandedPropertyValue: property
|
|
|
|
forObject: currentObject];
|
|
|
|
max = [values count];
|
|
|
|
expandedValues = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
if (max)
|
|
|
|
{
|
|
|
|
if (needsExpansion)
|
|
|
|
{
|
|
|
|
hrefs = [self _extractHREFSFromPropertyValues: values];
|
|
|
|
max = [hrefs count];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
href = [hrefs objectAtIndex: count];
|
|
|
|
[expandedValues addObject: [self _expandPropertyResponse: property
|
|
|
|
forHREF: href]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[expandedValues setArray: values];
|
|
|
|
}
|
|
|
|
|
|
|
|
return expandedValues;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *) _expandPropertyResponse: (NGDOMElement *) property
|
|
|
|
forObject: (SOGoObject *) currentObject
|
|
|
|
{
|
|
|
|
id <DOMNodeList> properties;
|
|
|
|
NSArray *childValue;
|
|
|
|
NGDOMElement *childProperty;
|
|
|
|
NSDictionary *response;
|
|
|
|
NSMutableArray *properties200, *properties404;
|
|
|
|
int count, max;
|
|
|
|
NSString *tagName, *tagNS;
|
|
|
|
|
|
|
|
properties = [property childElementsWithTag: @"property"];
|
|
|
|
max = [properties length];
|
|
|
|
properties200 = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
properties404 = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
childProperty = [properties objectAtIndex: count];
|
|
|
|
childValue = [self _expandPropertyValue: childProperty
|
|
|
|
forObject: currentObject];
|
|
|
|
tagNS = [childProperty attribute: @"namespace"];
|
|
|
|
if (!tagNS)
|
|
|
|
tagNS = XMLNS_WEBDAV;
|
|
|
|
tagName = [childProperty attribute: @"name"];
|
2011-11-30 15:53:15 +01:00
|
|
|
if (childValue)
|
2010-01-15 00:19:19 +01:00
|
|
|
[properties200 addObject: davElementWithContent (tagName,
|
|
|
|
tagNS,
|
|
|
|
childValue)];
|
|
|
|
else
|
|
|
|
[properties404 addObject: davElement (tagName, tagNS)];
|
|
|
|
}
|
|
|
|
response = [self responseForURL: [currentObject davURLAsString]
|
|
|
|
withProperties200: properties200
|
|
|
|
andProperties404: properties404];
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *) _expandPropertyResponse: (NGDOMElement *) property
|
|
|
|
forHREF: (NSString *) href
|
|
|
|
{
|
|
|
|
SOGoObject *lookupObject;
|
|
|
|
NSDictionary *response;
|
|
|
|
|
|
|
|
lookupObject = [self lookupObjectAtDAVUrl: href];
|
|
|
|
if (lookupObject)
|
|
|
|
response = [self _expandPropertyResponse: property
|
|
|
|
forObject: lookupObject];
|
|
|
|
else
|
|
|
|
response = nil;
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (WOResponse *) davExpandProperty: (WOContext *) localContext
|
|
|
|
{
|
|
|
|
WOResponse *r;
|
|
|
|
id <DOMDocument> document;
|
|
|
|
NSDictionary *response, *multistatus;
|
|
|
|
NGDOMElement *documentElement;
|
|
|
|
|
|
|
|
r = [localContext response];
|
|
|
|
[r prepareDAVResponse];
|
|
|
|
|
|
|
|
document = [[context request] contentAsDOMDocument];
|
|
|
|
documentElement = (NGDOMElement *) [document documentElement];
|
|
|
|
response = [self _expandPropertyResponse: documentElement forObject: self];
|
|
|
|
multistatus = davElementWithContent (@"multistatus", XMLNS_WEBDAV,
|
|
|
|
response);
|
|
|
|
[r appendContentString: [multistatus asWebDavStringWithNamespaces: nil]];
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2008-05-03 01:08:15 +02:00
|
|
|
/* web dav acl helper */
|
|
|
|
- (void) _fillArrayWithPrincipalsOwnedBySelf: (NSMutableArray *) hrefs
|
|
|
|
{
|
|
|
|
NSEnumerator *children;
|
|
|
|
NSString *currentKey;
|
|
|
|
|
|
|
|
[super _fillArrayWithPrincipalsOwnedBySelf: hrefs];
|
|
|
|
children = [[self toOneRelationshipKeys] objectEnumerator];
|
|
|
|
while ((currentKey = [children nextObject]))
|
|
|
|
[[self lookupName: currentKey inContext: context
|
|
|
|
acquire: NO] _fillArrayWithPrincipalsOwnedBySelf: hrefs];
|
|
|
|
|
|
|
|
children = [[self toManyRelationshipKeys] objectEnumerator];
|
|
|
|
while ((currentKey = [children nextObject]))
|
|
|
|
[[self lookupName: currentKey inContext: context
|
|
|
|
acquire: NO] _fillArrayWithPrincipalsOwnedBySelf: hrefs];
|
|
|
|
}
|
|
|
|
|
2009-08-27 23:14:54 +02:00
|
|
|
|
|
|
|
- (NSArray *) davGroupMemberSet
|
|
|
|
{
|
|
|
|
return [NSArray array];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) davGroupMembership
|
|
|
|
{
|
|
|
|
return [NSArray array];
|
|
|
|
}
|
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
/* folder type */
|
|
|
|
|
2007-11-20 20:15:26 +01:00
|
|
|
- (BOOL) isEqual: (id) otherFolder
|
|
|
|
{
|
|
|
|
return ([otherFolder class] == [self class]
|
|
|
|
&& [container isEqual: [otherFolder container]]
|
|
|
|
&& [nameInContainer
|
|
|
|
isEqualToString: [otherFolder nameInContainer]]);
|
|
|
|
}
|
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
/* acls */
|
|
|
|
|
2008-05-03 01:08:15 +02:00
|
|
|
- (NSString *) defaultUserID
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2007-11-29 17:14:11 +01:00
|
|
|
- (NSArray *) subscriptionRoles
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: SoRole_Owner, SOGoRole_ObjectViewer,
|
|
|
|
SOGoRole_ObjectEditor, SOGoRole_ObjectCreator,
|
2008-02-20 18:35:11 +01:00
|
|
|
SOGoRole_ObjectEraser, nil];
|
2007-11-29 17:14:11 +01:00
|
|
|
}
|
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
- (NSArray *) aclsForUser: (NSString *) uid
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2008-05-03 01:08:15 +02:00
|
|
|
- (NSArray *) aclUsers
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2011-11-30 15:30:53 +01:00
|
|
|
- (NSArray *) davPrincipalURL
|
|
|
|
{
|
|
|
|
NSArray *principalURL;
|
|
|
|
NSString *classes;
|
|
|
|
|
|
|
|
if ([[context request] isICal4])
|
|
|
|
{
|
|
|
|
classes = [[self davComplianceClassesInContext: context]
|
|
|
|
componentsJoinedByString: @", "];
|
|
|
|
[[context response] setHeader: classes forKey: @"DAV"];
|
|
|
|
}
|
|
|
|
|
|
|
|
principalURL = [NSArray arrayWithObjects: @"href", @"DAV:", @"D",
|
|
|
|
[self davURLAsString], nil];
|
|
|
|
|
|
|
|
return [NSArray arrayWithObject: principalURL];
|
|
|
|
}
|
|
|
|
|
2007-11-07 23:27:44 +01:00
|
|
|
@end
|