mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-18 05:03:20 +00:00
propagate from branch 'ca.inverse.sogo.1_3_12' (head c241a8e1e716fa0db3e4f4e370c051096cc2c3e2)
to branch 'ca.inverse.sogo' (head d807738c8f35c5080fb2e1684404fb8d992c8032) Monotone-Parent: c241a8e1e716fa0db3e4f4e370c051096cc2c3e2 Monotone-Parent: d807738c8f35c5080fb2e1684404fb8d992c8032 Monotone-Revision: 62ee066ad239ea56d6f2dc0b73f12d399813d68c Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2012-01-12T21:01:06 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -38,11 +38,16 @@
|
||||
#import <EOControl/EOSortOrdering.h>
|
||||
#import <SaxObjC/XMLNamespaces.h>
|
||||
|
||||
#import <SOGo/SOGoPermissions.h>
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
#import <SOGo/NSDictionary+Utilities.h>
|
||||
#import <SOGo/NSString+Utilities.h>
|
||||
#import <SOGo/SOGoPermissions.h>
|
||||
#import <SOGo/SOGoSource.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
#import <SOGo/WORequest+SOGo.h>
|
||||
|
||||
#import "SOGoContactFolders.h"
|
||||
#import "SOGoContactGCSFolder.h"
|
||||
#import "SOGoContactLDIFEntry.h"
|
||||
#import "SOGoContactSourceFolder.h"
|
||||
|
||||
@@ -97,11 +102,26 @@
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setSource: (id) newSource
|
||||
- (void) setSource: (id <SOGoSource>) newSource
|
||||
{
|
||||
ASSIGN (source, newSource);
|
||||
}
|
||||
|
||||
- (id <SOGoSource>) source
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
- (void) setIsPersonalSource: (BOOL) isPersonal
|
||||
{
|
||||
isPersonalSource = isPersonal;
|
||||
}
|
||||
|
||||
- (BOOL) isPersonalSource
|
||||
{
|
||||
return isPersonalSource;
|
||||
}
|
||||
|
||||
- (NSString *) groupDavResourceType
|
||||
{
|
||||
return @"vcard-collection";
|
||||
@@ -127,7 +147,10 @@
|
||||
acquire: (BOOL) acquire
|
||||
{
|
||||
NSDictionary *ldifEntry;
|
||||
id obj;
|
||||
SOGoContactLDIFEntry *obj;
|
||||
NSString *url;
|
||||
BOOL isNew = NO;
|
||||
NSArray *baseClasses;
|
||||
|
||||
/* first check attributes directly bound to the application */
|
||||
obj = [super lookupName: objectName inContext: lookupContext acquire: NO];
|
||||
@@ -140,11 +163,28 @@
|
||||
ldifEntry = [source lookupContactEntry: objectName];
|
||||
if (ldifEntry)
|
||||
[childRecords setObject: ldifEntry forKey: objectName];
|
||||
else if ([self isValidContentName: objectName])
|
||||
{
|
||||
url = [[[lookupContext request] uri] urlWithoutParameters];
|
||||
if ([url hasSuffix: @"AsContact"])
|
||||
{
|
||||
baseClasses = [NSArray arrayWithObjects: @"inetorgperson",
|
||||
@"mozillaabpersonalpha", nil];
|
||||
ldifEntry = [NSMutableDictionary
|
||||
dictionaryWithObject: baseClasses
|
||||
forKey: @"objectclass"];
|
||||
isNew = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ldifEntry)
|
||||
obj = [SOGoContactLDIFEntry contactEntryWithName: objectName
|
||||
withLDIFEntry: ldifEntry
|
||||
inContainer: self];
|
||||
{
|
||||
obj = [SOGoContactLDIFEntry contactEntryWithName: objectName
|
||||
withLDIFEntry: ldifEntry
|
||||
inContainer: self];
|
||||
if (isNew)
|
||||
[obj setIsNew: YES];
|
||||
}
|
||||
else
|
||||
obj = [NSException exceptionWithHTTPStatus: 404];
|
||||
}
|
||||
@@ -157,6 +197,19 @@
|
||||
return [source allEntryIDs];
|
||||
}
|
||||
|
||||
- (NSException *) saveLDIFEntry: (SOGoContactLDIFEntry *) ldifEntry
|
||||
{
|
||||
return (([ldifEntry isNew])
|
||||
? [source addContactEntry: [ldifEntry ldifRecord]
|
||||
withID: [ldifEntry nameInContainer]]
|
||||
: [source updateContactEntry: [ldifEntry ldifRecord]]);
|
||||
}
|
||||
|
||||
- (NSException *) deleteLDIFEntry: (SOGoContactLDIFEntry *) ldifEntry
|
||||
{
|
||||
return [source removeContactEntryWithID: [ldifEntry nameInContainer]];
|
||||
}
|
||||
|
||||
- (NSDictionary *) _flattenedRecord: (NSDictionary *) oldRecord
|
||||
{
|
||||
NSMutableDictionary *newRecord;
|
||||
@@ -267,7 +320,8 @@
|
||||
|
||||
result = nil;
|
||||
|
||||
if ([filter length] > 0 && [criteria isEqualToString: @"name_or_address"])
|
||||
if (([filter length] > 0 && [criteria isEqualToString: @"name_or_address"])
|
||||
|| ![source listRequiresDot])
|
||||
{
|
||||
records = [source fetchContactsMatching: filter];
|
||||
[childRecords setObjects: records
|
||||
@@ -308,22 +362,88 @@
|
||||
- (NSComparisonResult) compare: (id) otherFolder
|
||||
{
|
||||
NSComparisonResult comparison;
|
||||
BOOL otherIsPersonal;
|
||||
|
||||
if ([NSStringFromClass([otherFolder class])
|
||||
isEqualToString: @"SOGoContactGCSFolder"])
|
||||
comparison = NSOrderedDescending;
|
||||
otherIsPersonal = ([otherFolder isKindOfClass: [SOGoContactGCSFolder class]]
|
||||
|| ([otherFolder isKindOfClass: isa] && [otherFolder isPersonalSource]));
|
||||
|
||||
if (isPersonalSource)
|
||||
{
|
||||
if (otherIsPersonal && ![nameInContainer isEqualToString: @"personal"])
|
||||
{
|
||||
if ([[otherFolder nameInContainer] isEqualToString: @"personal"])
|
||||
comparison = NSOrderedDescending;
|
||||
else
|
||||
comparison
|
||||
= [[self displayName]
|
||||
localizedCaseInsensitiveCompare: [otherFolder displayName]];
|
||||
}
|
||||
else
|
||||
comparison = NSOrderedAscending;
|
||||
}
|
||||
else
|
||||
comparison
|
||||
= [[self displayName]
|
||||
localizedCaseInsensitiveCompare: [otherFolder displayName]];
|
||||
{
|
||||
if (otherIsPersonal)
|
||||
comparison = NSOrderedDescending;
|
||||
else
|
||||
comparison
|
||||
= [[self displayName]
|
||||
localizedCaseInsensitiveCompare: [otherFolder displayName]];
|
||||
}
|
||||
|
||||
return comparison;
|
||||
}
|
||||
|
||||
/* common methods */
|
||||
|
||||
- (NSException *) delete
|
||||
{
|
||||
NSException *error;
|
||||
|
||||
if (isPersonalSource)
|
||||
{
|
||||
error = [(SOGoContactFolders *) container
|
||||
removeLDAPAddressBook: nameInContainer];
|
||||
if (!error && [[context request] handledByDefaultHandler])
|
||||
[self sendFolderAdvisoryTemplate: @"Removal"];
|
||||
}
|
||||
else
|
||||
error = [NSException exceptionWithHTTPStatus: 501 /* not implemented */
|
||||
reason: @"delete not available on system sources"];
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
- (void) renameTo: (NSString *) newName
|
||||
{
|
||||
NSException *error;
|
||||
|
||||
if (isPersonalSource)
|
||||
{
|
||||
if (![[source displayName] isEqualToString: newName])
|
||||
{
|
||||
error = [(SOGoContactFolders *) container
|
||||
renameLDAPAddressBook: nameInContainer
|
||||
withDisplayName: newName];
|
||||
if (!error)
|
||||
[self setDisplayName: newName];
|
||||
}
|
||||
}
|
||||
/* If public source then method is ignored, maybe we should return an
|
||||
NSException instead... */
|
||||
}
|
||||
|
||||
/* acls */
|
||||
- (NSString *) ownerInContext: (WOContext *) noContext
|
||||
{
|
||||
return @"nobody";
|
||||
NSString *sourceOwner;
|
||||
|
||||
if (isPersonalSource)
|
||||
sourceOwner = [[source modifiers] objectAtIndex: 0];
|
||||
else
|
||||
sourceOwner = @"nobody";
|
||||
|
||||
return sourceOwner;
|
||||
}
|
||||
|
||||
- (NSArray *) subscriptionRoles
|
||||
@@ -331,10 +451,26 @@
|
||||
return [NSArray arrayWithObject: SoRole_Authenticated];
|
||||
}
|
||||
|
||||
/* TODO: this might change one day when we support LDAP acls */
|
||||
- (NSArray *) aclsForUser: (NSString *) uid
|
||||
{
|
||||
return nil;
|
||||
NSArray *acls, *modifiers;
|
||||
static NSArray *modifierRoles = nil;
|
||||
|
||||
if (!modifierRoles)
|
||||
modifierRoles = [[NSArray alloc] initWithObjects: @"Owner",
|
||||
@"ObjectViewer",
|
||||
@"ObjectEditor", @"ObjectCreator",
|
||||
@"ObjectEraser", nil];
|
||||
|
||||
modifiers = [source modifiers];
|
||||
if ([modifiers containsObject: uid])
|
||||
acls = [modifierRoles copy];
|
||||
else
|
||||
acls = [NSArray new];
|
||||
|
||||
[acls autorelease];
|
||||
|
||||
return acls;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user