From a25fde890c2632238191fdabe6cc9a182c44c788 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 22 Feb 2008 21:25:34 +0000 Subject: [PATCH] Monotone-Parent: c929688878bd9190268ea59876cf0ef2253c60f9 Monotone-Revision: 4c60fbb40c38396a4af6c229183ea0a535a704e3 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-02-22T21:25:34 Monotone-Branch: ca.inverse.sogo --- SoObjects/SOGo/SOGoGCSFolder.m | 110 +++++++++------------------------ 1 file changed, 29 insertions(+), 81 deletions(-) diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index fa2bebda8..3ff9e041d 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -1,23 +1,28 @@ -/* - Copyright (C) 2004-2005 SKYRIX Software AG +/* 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 + * + * 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. + */ - 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. -*/ +#import +#import "SOGoDAVRendererTypes.h" #import #import @@ -33,6 +38,7 @@ #import #import #import +#import #import #import #import @@ -488,14 +494,15 @@ static BOOL sendFolderAdvisories = NO; { EOQualifier *qualifier; NSString *qs; - NSArray *records; + NSArray *records, *uids; qs = [NSString stringWithFormat: @"c_object = '/%@'", [objectPathArray componentsJoinedByString: @"/"]]; qualifier = [EOQualifier qualifierWithQualifierFormat: qs]; records = [[self ocsFolder] fetchAclMatchingQualifier: qualifier]; + uids = [[records valueForKey: @"c_uid"] uniqueObjects]; - return [records valueForKey: @"c_uid"]; + return uids; } - (NSArray *) _fetchAclsForUser: (NSString *) uid @@ -515,7 +522,7 @@ static BOOL sendFolderAdvisories = NO; if ([records count] > 0) [acls addObjectsFromArray: [records valueForKey: @"c_role"]]; - return acls; + return [acls uniqueObjects]; } - (void) _cacheRoles: (NSArray *) roles @@ -682,65 +689,6 @@ static BOOL sendFolderAdvisories = NO; return defaultUserID; } -- (void) _appendACLUserData: (NSString *) user - toString: (NSMutableString *) aclAnswer -{ - SOGoUser *aclUser; - - [aclAnswer appendFormat: @"%@", user]; - aclUser = [SOGoUser userWithLogin: user roles: nil]; - [aclAnswer appendFormat: @"%@", - [aclUser cn]]; -} - -- (void) _appendACL: (NSArray *) userAcl - toString: (NSMutableString *) aclAnswer -{ - NSEnumerator *aclForUser; - NSString *currentAcl; - - [aclAnswer appendString: @""]; - aclForUser = [userAcl objectEnumerator]; - while ((currentAcl = [aclForUser nextObject])) - [aclAnswer appendFormat: @"<%@/>", currentAcl]; - [aclAnswer appendString: @""]; -} - -- (NSString *) davInverseACL -{ - NSMutableArray *aclAnswer; - NSEnumerator *aclUsers; - NSMutableDictionary *data; - NSString *currentUser, *cn; - SOGoUser *sogoUser; - - aclAnswer = [NSMutableArray array]; - currentUser = [self defaultUserID]; - - data = [NSMutableDictionary new]; - [data setObject: [self aclsForUser: currentUser] - forKey: @"acl"]; - [aclAnswer addObject: [NSDictionary dictionaryWithObject: data forKey: @"defaultUser"]]; - [data release]; - - aclUsers = [[self aclUsers] objectEnumerator]; - while ((currentUser = [aclUsers nextObject])) - { - data = [NSMutableDictionary new]; - [data setObject: currentUser forKey: @"id"]; - sogoUser = [SOGoUser userWithLogin: currentUser roles: nil]; - cn = [sogoUser cn]; - if (!cn) - cn = currentUser; - [data setObject: cn forKey: @"displayName"]; - [data setObject: [self aclsForUser: currentUser] forKey: @"acl"]; - [aclAnswer addObject: [NSDictionary dictionaryWithObject: data forKey: @"user"]]; - [data release]; - } - - return [aclAnswer jsonRepresentation]; -} - /* description */ - (void) appendAttributesToDescription: (NSMutableString *) _ms