From 41d5d3793ff41b79cb8cae5cd3e2ad7ba472f8bf Mon Sep 17 00:00:00 2001 From: wolfgang Date: Fri, 11 May 2007 21:46:53 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1064 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 15 ++++++++++ SoObjects/SOGo/AgenorUserDefaults.m | 15 +++++++++- SoObjects/SOGo/SOGoUser.m | 6 ++-- UI/Common/UIxFolderActions.m | 2 +- UI/Common/UIxObjectActions.m | 32 +++++++++++++++++++-- UI/Common/product.plist | 5 ++++ UI/Scheduler/UIxTaskEditor.m | 1 - UI/Scheduler/UIxTimeDateControl.m | 2 -- UI/WebServerResources/UIxAclEditor.js | 22 ++++++++++++-- UI/WebServerResources/UIxComponentEditor.js | 2 +- 10 files changed, 88 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d86d528..fefc4345 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2007-05-11 Wolfgang Sourdeau + * UI/Common/UIxObjectActions.m ([UIxObjectActions + -removeUserFromAclsAction]): implemented this method which was + missing and is required to remove users from ACLs. + + * UI/Common/UIxFolderActions.m ([UIxFolderActions + -subscribeAction]): folderDict was not autoreleased, resulting in + a leak... + + * SoObjects/SOGo/AgenorUserDefaults.m ([AgenorUserDefaults + -primaryFetchProfile]): when building with libFoundation, don't + use the "propertyList" method from NSString. Rather, we convert + the string to an NSData instance and passit as parameter to + NSDeserializer. This way, we obtain a mutable dictionary rather + than an immutable one. + * SoObjects/Mailer/SOGoDraftObject.m ([SOGoDraftObject -bodyPartForText]) ([SOGoDraftObject -mimeMessageForContentWithHeaderMap:]): use the constant string "contentTypeValue". diff --git a/SoObjects/SOGo/AgenorUserDefaults.m b/SoObjects/SOGo/AgenorUserDefaults.m index e7031c7c..d904acbc 100644 --- a/SoObjects/SOGo/AgenorUserDefaults.m +++ b/SoObjects/SOGo/AgenorUserDefaults.m @@ -109,6 +109,9 @@ static NSString *uidColumnName = @"uid"; NSString *sql, *value; NSArray *attrs; BOOL rc; +#if LIB_FOUNDATION_LIBRARY + NSData *plistData; +#endif rc = NO; @@ -144,7 +147,17 @@ static NSString *uidColumnName = @"uid"; /* remember values */ value = [row objectForKey: fieldName]; if ([value isNotNull]) - [values setDictionary: [value propertyList]]; + { +#if LIB_FOUNDATION_LIBRARY + plistData = [value dataUsingEncoding: NSUTF8StringEncoding]; + [values setDictionary: [NSDeserializer + deserializePropertyListFromData: plistData + mutableContainers: YES]]; + +#else + [values setDictionary: [value propertyList]]; +#endif + } ASSIGN (lastFetch, [NSCalendarDate date]); defFlags.modified = NO; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index c91e7573..f84d3065 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -69,12 +69,12 @@ static NSURL *AgenorProfileURL = nil; ASSIGN (fallbackIMAP4Server, [ud stringForKey: @"SOGoFallbackIMAP4Server"]); } -+ (SOGoUser *) userWithLogin: (NSString *) login - roles: (NSArray *) roles ++ (SOGoUser *) userWithLogin: (NSString *) newLogin + roles: (NSArray *) newRoles { SOGoUser *user; - user = [[self alloc] initWithLogin: login roles: roles]; + user = [[self alloc] initWithLogin: newLogin roles: newRoles]; [user autorelease]; return user; diff --git a/UI/Common/UIxFolderActions.m b/UI/Common/UIxFolderActions.m index 25480d1b..fdd9f801 100644 --- a/UI/Common/UIxFolderActions.m +++ b/UI/Common/UIxFolderActions.m @@ -129,7 +129,7 @@ else folderName = email; - folderDict = [NSMutableDictionary new]; + folderDict = [NSMutableDictionary dictionary]; [folderDict setObject: folderName forKey: @"displayName"]; [folderDict setObject: [NSNumber numberWithBool: NO] forKey: @"active"]; diff --git a/UI/Common/UIxObjectActions.m b/UI/Common/UIxObjectActions.m index 277d1ac6..1d154a66 100644 --- a/UI/Common/UIxObjectActions.m +++ b/UI/Common/UIxObjectActions.m @@ -36,7 +36,7 @@ { WOResponse *response; WORequest *request; - NSString *uid, *email; + NSString *uid; unsigned int code; LDAPUserManager *um; SOGoObject *clientObject; @@ -47,8 +47,7 @@ if ([uid length] > 0) { um = [LDAPUserManager sharedUserManager]; - email = [um getEmailForUID: uid]; - if ([email length] > 0) + if ([um contactInfosForUserWithUIDorEmail: uid]) { clientObject = [self clientObject]; [clientObject setRoles: [clientObject defaultAclRoles] @@ -63,4 +62,31 @@ return response; } +- (WOResponse *) removeUserFromAclsAction +{ + WOResponse *response; + WORequest *request; + NSString *uid; + unsigned int code; + LDAPUserManager *um; + + code = 403; + request = [context request]; + uid = [request formValueForKey: @"uid"]; + if ([uid length] > 0) + { + um = [LDAPUserManager sharedUserManager]; + if ([um contactInfosForUserWithUIDorEmail: uid]) + { + [[self clientObject] removeAclsForUsers: [NSArray arrayWithObject: uid]]; + code = 204; + } + } + + response = [context response]; + [response setStatus: code]; + + return response; +} + @end diff --git a/UI/Common/product.plist b/UI/Common/product.plist index 0d94f25e..9e014e8e 100644 --- a/UI/Common/product.plist +++ b/UI/Common/product.plist @@ -37,6 +37,11 @@ actionClass = "UIxObjectActions"; actionName = "addUserInAcls"; }; + removeUserFromAcls = { + protectedBy = "SaveAcls"; + actionClass = "UIxObjectActions"; + actionName = "removeUserFromAcls"; + }; acls = { protectedBy = "ReadAcls"; pageName = "UIxAclEditor"; diff --git a/UI/Scheduler/UIxTaskEditor.m b/UI/Scheduler/UIxTaskEditor.m index 607e0adf..c2764a39 100644 --- a/UI/Scheduler/UIxTaskEditor.m +++ b/UI/Scheduler/UIxTaskEditor.m @@ -230,7 +230,6 @@ - (BOOL) statusPercentDisabled { - NSLog (@"status: '%@'", status); return ([status length] == 0 || [status isEqualToString: @"CANCELLED"]); } diff --git a/UI/Scheduler/UIxTimeDateControl.m b/UI/Scheduler/UIxTimeDateControl.m index 5b364665..e8b84a39 100644 --- a/UI/Scheduler/UIxTimeDateControl.m +++ b/UI/Scheduler/UIxTimeDateControl.m @@ -99,7 +99,6 @@ } - (void)setHour:(id)_hour { - NSLog (@"---------------- setHour:"); ASSIGN(hour, _hour); } @@ -140,7 +139,6 @@ - (void) setDayStartHour: (unsigned int) aStartHour { - NSLog (@"******************** setDayStartHour..."); startHour = aStartHour; } diff --git a/UI/WebServerResources/UIxAclEditor.js b/UI/WebServerResources/UIxAclEditor.js index 18eaab99..d7a3c6d0 100644 --- a/UI/WebServerResources/UIxAclEditor.js +++ b/UI/WebServerResources/UIxAclEditor.js @@ -50,11 +50,29 @@ function onUserAdd(event) { event.preventDefault(); } +function removeUserCallback(http) { + var node = http.callbackData; + + if (http.readyState == 4 + && http.status == 204) + node.parentNode.removeChild(node); + else + log("error deleting user: " + node.getAttribute("id")); +} + function onUserRemove(event) { var userList = $("userList"); var nodes = userList.getSelectedRows(); - for (var i = 0; i < nodes.length; i++) - userList.removeChild(nodes[i]); + + var url = window.location.href; + var elements = url.split("/"); + elements[elements.length-1] = "removeUserFromAcls?uid="; + var baseURL = elements.join("/"); + + for (var i = 0; i < nodes.length; i++) { + var userId = nodes[i].getAttribute("id"); + triggerAjaxRequest(baseURL + userId, removeUserCallback, nodes[i]); + } event.preventDefault(); } diff --git a/UI/WebServerResources/UIxComponentEditor.js b/UI/WebServerResources/UIxComponentEditor.js index fb8725e0..beeac618 100644 --- a/UI/WebServerResources/UIxComponentEditor.js +++ b/UI/WebServerResources/UIxComponentEditor.js @@ -58,7 +58,7 @@ function onMenuSetClassification(event) { this.addClassName("_chosen"); this.parentNode.chosenNode = this; - log("classification: " + classification); +// log("classification: " + classification); var privacyInput = document.getElementById("privacy"); privacyInput.value = classification; } -- 2.39.5