diff --git a/ChangeLog b/ChangeLog index 057c22cfa..06b9a6f5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2007-05-17 Wolfgang Sourdeau + + * UI/Common/UIxObjectActions.m ([UIxObjectActions + -addUserInAclsAction]): save the previous roles of the user + (unlikely) or the default roles, or None instead of saving the + roles that should appear the first time in the role editor when no + default has been set... + + * SoObjects/SOGo/SOGoObject.m: defined a new constant + "SOGoDefaultUserID". + + * SoObjects/SOGo/SOGoFolder.m ([SOGoFolder + -setRoles:rolesforUser:uidforObjectAtPath:objectPathArray]): + ignore the "AuthorizedSubscriber" role and add the "None" role + when no other role is found. + + * UI/Common/UIxAclEditor.m: added a button for the new default + user roles feature. + + * UI/Common/UIxUserRightsEditor.m ([UIxUserRightsEditor + -_initRights]): don't take the "None" role into account when + initializing the list of current roles. + + * SoObjects/SOGo/SOGoPermissions.m: added a new void role + "SOGoRole_None". + 2007-05-16 Wolfgang Sourdeau * SoObjects/SOGo/NSString+Utilities.m ([NSString diff --git a/SoObjects/SOGo/SOGoFolder.m b/SoObjects/SOGo/SOGoFolder.m index 43bc8e1c1..a55c3dad2 100644 --- a/SoObjects/SOGo/SOGoFolder.m +++ b/SoObjects/SOGo/SOGoFolder.m @@ -31,8 +31,6 @@ #import #import -static NSString *defaultUser = @""; - @implementation SOGoFolder + (int) version @@ -341,8 +339,9 @@ static NSString *defaultUser = @""; [self _cacheRoles: acls forUser: uid forObjectAtPath: objectPath]; } - if (!([acls count] || [uid isEqualToString: defaultUser])) - acls = [self aclsForUser: defaultUser forObjectAtPath: objectPathArray]; + if (!([acls count] || [uid isEqualToString: SOGoDefaultUserID])) + acls = [self aclsForUser: SOGoDefaultUserID + forObjectAtPath: objectPathArray]; return acls; } @@ -369,19 +368,14 @@ static NSString *defaultUser = @""; } } -- (void) setRoles: (NSArray *) roles - forUser: (NSString *) uid - forObjectAtPath: (NSArray *) objectPathArray +- (void) _commitRoles: (NSArray *) roles + forUID: (NSString *) uid + forObject: (NSString *) objectPath { EOAdaptorChannel *channel; GCSFolder *folder; NSEnumerator *userRoles; - NSString *SQL, *currentRole, *objectPath; - - [self removeAclsForUsers: [NSArray arrayWithObject: uid] - forObjectAtPath: objectPathArray]; - objectPath = [objectPathArray componentsJoinedByString: @"/"]; - [self _cacheRoles: roles forUser: uid forObjectAtPath: objectPath]; + NSString *SQL, *currentRole; folder = [self ocsFolder]; channel = [folder acquireAclChannel]; @@ -389,21 +383,40 @@ static NSString *defaultUser = @""; currentRole = [userRoles nextObject]; while (currentRole) { - if (![currentRole isEqualToString: SOGoRole_AuthorizedSubscriber]) - { - SQL = [NSString stringWithFormat: @"INSERT INTO %@" - @" (c_object, c_uid, c_role)" - @" VALUES ('/%@', '%@', '%@')", - [folder aclTableName], - objectPath, uid, currentRole]; - [channel evaluateExpressionX: SQL]; - } + SQL = [NSString stringWithFormat: @"INSERT INTO %@" + @" (c_object, c_uid, c_role)" + @" VALUES ('/%@', '%@', '%@')", + [folder aclTableName], + objectPath, uid, currentRole]; + [channel evaluateExpressionX: SQL]; currentRole = [userRoles nextObject]; } [folder releaseChannel: channel]; } +- (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]; +} + /* acls */ - (NSArray *) defaultAclRoles { diff --git a/SoObjects/SOGo/SOGoObject.h b/SoObjects/SOGo/SOGoObject.h index 5b4eeccec..e5a77e739 100644 --- a/SoObjects/SOGo/SOGoObject.h +++ b/SoObjects/SOGo/SOGoObject.h @@ -52,6 +52,8 @@ #define $(class) NSClassFromString(class) +extern NSString *SOGoDefaultUserID; + @interface SOGoObject : NSObject { WOContext *context; diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 5a0e50159..57b13cd78 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -20,8 +20,8 @@ */ #if LIB_FOUNDATION_LIBRARY -#error SOGo won't work properly with libFoundation. Please use gnustep-base \ - instead. +#error SOGo will not work properly with libFoundation. \ + Please use gnustep-base instead. #endif #import @@ -47,6 +47,8 @@ #import "SOGoObject.h" +NSString *SOGoDefaultUserID = @""; + @interface SOGoObject(Content) - (NSString *)contentAsString; @end diff --git a/SoObjects/SOGo/SOGoPermissions.h b/SoObjects/SOGo/SOGoPermissions.h index e6825554d..67ee64bee 100644 --- a/SoObjects/SOGo/SOGoPermissions.h +++ b/SoObjects/SOGo/SOGoPermissions.h @@ -32,6 +32,7 @@ extern NSString *SOGoRole_ObjectEraser; extern NSString *SOGoRole_ObjectViewer; extern NSString *SOGoRole_ObjectEditor; extern NSString *SOGoRole_AuthorizedSubscriber; +extern NSString *SOGoRole_None; extern NSString *SOGoRole_FreeBusy; extern NSString *SOGoRole_FreeBusyLookup; diff --git a/SoObjects/SOGo/SOGoPermissions.m b/SoObjects/SOGo/SOGoPermissions.m index a071f019f..e750ef31b 100644 --- a/SoObjects/SOGo/SOGoPermissions.m +++ b/SoObjects/SOGo/SOGoPermissions.m @@ -28,6 +28,7 @@ NSString *SOGoRole_ObjectEraser = @"ObjectEraser"; NSString *SOGoRole_ObjectViewer = @"ObjectViewer"; NSString *SOGoRole_ObjectEditor = @"ObjectEditor"; NSString *SOGoRole_AuthorizedSubscriber = @"AuthorizedSubscriber"; +NSString *SOGoRole_None = @"None"; NSString *SOGoRole_FreeBusy = @"FreeBusy"; /* for the "freebusy" special user */ diff --git a/UI/Common/English.lproj/Localizable.strings b/UI/Common/English.lproj/Localizable.strings index 119c9c328..4ac925e1e 100644 --- a/UI/Common/English.lproj/Localizable.strings +++ b/UI/Common/English.lproj/Localizable.strings @@ -3,6 +3,7 @@ /* toolbars */ "Save" = "Save"; "Close" = "Close"; +"Edit User Rights" = "Edit User Rights"; "Home" = "Home"; "Calendar" = "Calendar"; @@ -21,4 +22,6 @@ "Publish the Free/Busy information" = "Publish the Free/Busy information"; +"Default Roles" = "Default Roles"; + "Sorry, the user rights can not be configured for that object." = "Sorry, the user rights can not be configured for that object."; diff --git a/UI/Common/French.lproj/Localizable.strings b/UI/Common/French.lproj/Localizable.strings index dcf84ce14..c18c40680 100644 --- a/UI/Common/French.lproj/Localizable.strings +++ b/UI/Common/French.lproj/Localizable.strings @@ -1,8 +1,7 @@ -/* this file is in UTF-8 format! */ - /* toolbars */ "Save" = "Sauver"; "Close" = "Fermer"; +"Edit User Rights" = "Édition des droits"; "Home" = "Accueil"; "Calendar" = "Agenda"; @@ -24,4 +23,6 @@ "(Unchecked = assistant, checked = delegate)" = "(Coché = assistant, décoché = délégué)"; "Publish the Free/Busy information" = "Publier l'occupation du temps"; +"Default Roles" = "Rôles par défaut"; + "Sorry, the user rights can not be configured for that object." = "Sorry, the user rights can not be configured for that object."; diff --git a/UI/Common/UIxAclEditor.m b/UI/Common/UIxAclEditor.m index 12a45f503..e0328ace9 100644 --- a/UI/Common/UIxAclEditor.m +++ b/UI/Common/UIxAclEditor.m @@ -84,6 +84,11 @@ return [self _displayNameForUID: ownerLogin]; } +- (NSString *) defaultUserID +{ + return SOGoDefaultUserID; +} + - (void) _prepareUsers { NSEnumerator *aclsEnum; @@ -98,6 +103,7 @@ { currentUID = [currentAcl objectForKey: @"c_uid"]; if (!([currentUID isEqualToString: ownerLogin] + || [currentUID isEqualToString: SOGoDefaultUserID] || [users containsObject: currentUID])) [users addObject: currentUID]; currentAcl = [aclsEnum nextObject]; diff --git a/UI/Common/UIxObjectActions.m b/UI/Common/UIxObjectActions.m index 1d154a665..f3cf99306 100644 --- a/UI/Common/UIxObjectActions.m +++ b/UI/Common/UIxObjectActions.m @@ -27,6 +27,7 @@ #import #import #import +#import #import "UIxObjectActions.h" @@ -49,9 +50,9 @@ um = [LDAPUserManager sharedUserManager]; if ([um contactInfosForUserWithUIDorEmail: uid]) { - clientObject = [self clientObject]; - [clientObject setRoles: [clientObject defaultAclRoles] - forUser: uid]; + clientObject = [self clientObject]; + [clientObject setRoles: [clientObject aclsForUser: uid] + forUser: uid]; code = 204; } } @@ -78,7 +79,8 @@ um = [LDAPUserManager sharedUserManager]; if ([um contactInfosForUserWithUIDorEmail: uid]) { - [[self clientObject] removeAclsForUsers: [NSArray arrayWithObject: uid]]; + [[self clientObject] removeAclsForUsers: + [NSArray arrayWithObject: uid]]; code = 204; } } diff --git a/UI/Common/UIxUserRightsEditor.m b/UI/Common/UIxUserRightsEditor.m index 35b697612..8ec44dd46 100644 --- a/UI/Common/UIxUserRightsEditor.m +++ b/UI/Common/UIxUserRightsEditor.m @@ -24,6 +24,7 @@ #import #import #import +#import #import "UIxUserRightsEditor.h" @@ -52,10 +53,15 @@ return uid; } +- (BOOL) userIsDefaultUser +{ + return [uid isEqualToString: SOGoDefaultUserID]; +} + - (NSString *) userDisplayName { LDAPUserManager *um; - + um = [LDAPUserManager sharedUserManager]; return [NSString stringWithFormat: @"%@ <%@>", @@ -66,9 +72,10 @@ - (BOOL) _initRights { BOOL response; - NSString *newUID, *email; + NSString *newUID; LDAPUserManager *um; SOGoObject *clientObject; + unsigned int count; response = NO; @@ -76,15 +83,17 @@ if ([newUID length] > 0) { um = [LDAPUserManager sharedUserManager]; - email = [um getEmailForUID: newUID]; - if ([email length] > 0) + if ([newUID isEqualToString: SOGoDefaultUserID] + || [[um getEmailForUID: newUID] length] > 0) { ASSIGN (uid, newUID); clientObject = [self clientObject]; [userRights addObjectsFromArray: [clientObject aclsForUser: uid]]; - if (![userRights count]) - [userRights addObjectsFromArray: [clientObject defaultAclRoles]]; - + count = [userRights count]; + if (!count || (count == 1 && [[userRights objectAtIndex: 0] + isEqualToString: SOGoRole_None])) + [userRights setArray: [clientObject defaultAclRoles]]; + response = YES; } } @@ -118,8 +127,7 @@ else { [self updateRights]; - [[self clientObject] setRoles: userRights - forUser: uid]; + [[self clientObject] setRoles: userRights forUser: uid]; response = [self jsCloseWithRefreshMethod: nil]; } diff --git a/UI/Contacts/English.lproj/Localizable.strings b/UI/Contacts/English.lproj/Localizable.strings index 4233453d5..cca322a0b 100644 --- a/UI/Contacts/English.lproj/Localizable.strings +++ b/UI/Contacts/English.lproj/Localizable.strings @@ -102,6 +102,7 @@ "Unable to subscribe to that folder!" = "Unable to subscribe to that folder!"; +"Default Roles" = "Default Roles"; "User rights for:" = "User rights for:"; "This person can add cards to this addressbook." diff --git a/UI/Contacts/French.lproj/Localizable.strings b/UI/Contacts/French.lproj/Localizable.strings index 46f665719..aaf6e2075 100644 --- a/UI/Contacts/French.lproj/Localizable.strings +++ b/UI/Contacts/French.lproj/Localizable.strings @@ -115,6 +115,7 @@ "Unable to subscribe to that folder!" = "Impossible de vous inscrire à ce dossier!"; +"Default Roles" = "Rôles par défaut"; "User rights for:" = "Autorisations pour :"; "This person can add cards to this addressbook." diff --git a/UI/Scheduler/English.lproj/Localizable.strings b/UI/Scheduler/English.lproj/Localizable.strings index 1a370a3f0..050f12def 100644 --- a/UI/Scheduler/English.lproj/Localizable.strings +++ b/UI/Scheduler/English.lproj/Localizable.strings @@ -82,6 +82,7 @@ "Forbidden" = "Forbidden"; /* acls */ +"Default Roles" = "Default Roles"; "User rights for:" = "User rights for:"; "label_Public" = "Public"; "label_Private" = "Private"; diff --git a/UI/Scheduler/French.lproj/Localizable.strings b/UI/Scheduler/French.lproj/Localizable.strings index 266d9dfec..46b02d33a 100644 --- a/UI/Scheduler/French.lproj/Localizable.strings +++ b/UI/Scheduler/French.lproj/Localizable.strings @@ -83,6 +83,7 @@ "Forbidden" = "Accès non autorisée"; /* acls */ +"Default Roles" = "Rôles par défaut"; "User rights for:" = "Autorisations pour :"; "label_Public" = "Public"; "label_Private" = "Privé"; diff --git a/UI/Templates/ContactsUI/UIxContactsUserRightsEditor.wox b/UI/Templates/ContactsUI/UIxContactsUserRightsEditor.wox index e14ea785f..39b25787d 100644 --- a/UI/Templates/ContactsUI/UIxContactsUserRightsEditor.wox +++ b/UI/Templates/ContactsUI/UIxContactsUserRightsEditor.wox @@ -13,8 +13,13 @@
- + + + +