From e37a86b6eb86fcda7a82dfe12e60d97327d866b8 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Thu, 10 May 2007 19:03:57 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1060 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 12 +++ SoObjects/SOGo/AgenorUserDefaults.m | 9 +- SoObjects/SOGo/LDAPUserManager.m | 8 +- UI/Contacts/UIxContactFoldersView.m | 81 +++++---------- UI/WebServerResources/UIxAttendeesEditor.js | 106 ++++++++++---------- UI/WebServerResources/generic.js | 2 +- 6 files changed, 103 insertions(+), 115 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad92d7c7..d0592e30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,19 @@ 2007-05-10 Wolfgang Sourdeau + * UI/Contacts/UIxContactFoldersView.m ([UIxContactFoldersView + -contactSearchAction]): simplified method to use the facilities + provided by the LDAPUserManager. No longer takes care of the + "ldap-only" url parameter since all requests are handled by the + usermanager now. + + * SoObjects/SOGo/AgenorUserDefaults.m ([AgenorUserDefaults + -primaryFetchProfile]): check that the value returned is not null + before interpreting it. + * SoObjects/SOGo/LDAPUserManager.m ([LDAPUserManager -contactInfosForUserWithUIDorEmail:uid]): check that uid is not empty. + ([LDAPUserManager -_fillContactMailRecords:contact]): if the + system email is already present, remove it before adding it. * SoObjects/SOGo/LDAPSource.m ([LDAPSource -checkLogin:loginToCheckandPassword:passwordToCheck]): check that diff --git a/SoObjects/SOGo/AgenorUserDefaults.m b/SoObjects/SOGo/AgenorUserDefaults.m index ff553d75..e7031c7c 100644 --- a/SoObjects/SOGo/AgenorUserDefaults.m +++ b/SoObjects/SOGo/AgenorUserDefaults.m @@ -104,9 +104,9 @@ static NSString *uidColumnName = @"uid"; { GCSChannelManager *cm; EOAdaptorChannel *channel; - NSDictionary *row, *oldValues; + NSDictionary *row; NSException *ex; - NSString *sql; + NSString *sql, *value; NSArray *attrs; BOOL rc; @@ -142,8 +142,9 @@ static NSString *uidColumnName = @"uid"; [channel cancelFetch]; /* remember values */ - oldValues = [[row objectForKey: fieldName] propertyList]; - [values setDictionary: oldValues]; + value = [row objectForKey: fieldName]; + if ([value isNotNull]) + [values setDictionary: [value propertyList]]; ASSIGN (lastFetch, [NSCalendarDate date]); defFlags.modified = NO; diff --git a/SoObjects/SOGo/LDAPUserManager.m b/SoObjects/SOGo/LDAPUserManager.m index 66b19356..6b0379d1 100644 --- a/SoObjects/SOGo/LDAPUserManager.m +++ b/SoObjects/SOGo/LDAPUserManager.m @@ -265,12 +265,14 @@ static NSString *defaultMailDomain = nil; - (void) _fillContactMailRecords: (NSMutableDictionary *) contact { NSMutableArray *emails; - NSString *uid; + NSString *uid, *systemEmail; emails = [contact objectForKey: @"emails"]; uid = [contact objectForKey: @"c_uid"]; - [emails addObject: - [NSString stringWithFormat: @"%@@%@", uid, defaultMailDomain]]; + systemEmail = [NSString stringWithFormat: @"%@@%@", uid, defaultMailDomain]; + if ([emails containsObject: systemEmail]) + [emails removeObject: systemEmail]; + [emails addObject: systemEmail]; [contact setObject: [emails objectAtIndex: 0] forKey: @"c_email"]; } diff --git a/UI/Contacts/UIxContactFoldersView.m b/UI/Contacts/UIxContactFoldersView.m index de17b892..400eb6df 100644 --- a/UI/Contacts/UIxContactFoldersView.m +++ b/UI/Contacts/UIxContactFoldersView.m @@ -116,30 +116,6 @@ } } -- (NSDictionary *) _searchResults: (NSString *) contact - ldapFoldersOnly: (BOOL) ldapOnly -{ - NSMutableDictionary *results; - SOGoContactFolders *topFolder; - NSEnumerator *sogoContactFolders; - id currentFolder; - - results = [NSMutableDictionary dictionary]; - topFolder = [self clientObject]; - sogoContactFolders = [[topFolder contactFolders] objectEnumerator]; - currentFolder = [sogoContactFolders nextObject]; - while (currentFolder) - { - if (!ldapOnly || [currentFolder isKindOfClass: [SOGoContactLDAPFolder class]]) - [self _fillResults: results inFolder: currentFolder - withSearchOn: contact]; - currentFolder = [sogoContactFolders nextObject]; - } - [topFolder release]; - - return results; -} - - (NSString *) _emailForResult: (NSDictionary *) result { NSMutableString *email; @@ -158,33 +134,30 @@ return email; } -- (WOResponse *) _responseForResults: (NSDictionary *) results +- (WOResponse *) _responseForResults: (NSArray *) results { WOResponse *response; - NSEnumerator *uids; - NSString *responseString, *uid, *cn, *mail; - NSDictionary *result; + NSEnumerator *contacts; + NSString *responseString; + NSDictionary *contact; response = [context response]; - if ([results count]) + if ([results count] > 0) { - uids = [[results allKeys] objectEnumerator]; - uid = [uids nextObject]; - while (uid) + contacts = [results objectEnumerator]; + contact = [contacts nextObject]; + while (contact) { - result = [results objectForKey: uid]; - cn = [result objectForKey: @"displayName"]; - if (![cn length]) - cn = [result objectForKey: @"cn"]; - mail = [result objectForKey: @"mail"]; responseString = [NSString stringWithFormat: @"%@:%@:%@", - uid, cn, mail]; + [contact objectForKey: @"c_uid"], + [contact objectForKey: @"cn"], + [contact objectForKey: @"c_email"]]; [response setStatus: 200]; [response setHeader: @"text/plain; charset=iso-8859-1" forKey: @"Content-Type"]; [response appendContentString: responseString]; - uid = [uids nextObject]; + contact = [contacts nextObject]; } } else @@ -197,14 +170,15 @@ { NSString *contact; id result; - BOOL ldapFoldersOnly; - + LDAPUserManager *um; + contact = [self queryParameterForKey: @"search"]; - ldapFoldersOnly = [[self queryParameterForKey: @"ldap-only"] boolValue]; if ([contact length] > 0) - result - = [self _responseForResults: [self _searchResults: contact - ldapFoldersOnly: ldapFoldersOnly]]; + { + um = [LDAPUserManager sharedUserManager]; + result + = [self _responseForResults: [um fetchContactsMatching: contact]]; + } else result = [NSException exceptionWithHTTPStatus: 400 reason: @"missing 'search' parameter"]; @@ -328,16 +302,13 @@ while (contact) { uid = [contact objectForKey: @"c_uid"]; - if ([uid length] > 0) - { - folders = [self _foldersForUID: uid ofType: folderType]; - foldersString - = [self _foldersStringForFolders: [folders objectEnumerator]]; - [responseString appendFormat: @"%@:%@:%@%@\n", uid, - [contact objectForKey: @"cn"], - [contact objectForKey: @"c_email"], - foldersString]; - } + folders = [self _foldersForUID: uid ofType: folderType]; + foldersString + = [self _foldersStringForFolders: [folders objectEnumerator]]; + [responseString appendFormat: @"%@:%@:%@%@\n", uid, + [contact objectForKey: @"cn"], + [contact objectForKey: @"c_email"], + foldersString]; contact = [contacts nextObject]; } [response appendContentString: responseString]; diff --git a/UI/WebServerResources/UIxAttendeesEditor.js b/UI/WebServerResources/UIxAttendeesEditor.js index 60f41594..2735ebb0 100644 --- a/UI/WebServerResources/UIxAttendeesEditor.js +++ b/UI/WebServerResources/UIxAttendeesEditor.js @@ -97,10 +97,12 @@ function UIDLookupCallback(http) { var searchField = http.callbackData; var start = searchField.value.length; var text = http.responseText.split(":"); - if (text[0].length > 0) - searchField.uid = text[0]; + if (text[0].length > 0) { + searchField.uid = text[0]; + displayFreeBusyForNode(searchField); + } else - searchField.uid = null; + searchField.uid = null } } } @@ -212,33 +214,38 @@ function checkAttendee() { } function displayFreeBusyForNode(node) { - var nodes = node.parentNode.parentNode.cells; - if (node.uid) { - for (var i = 1; i < nodes.length; i++) { - nodes[i].removeClassName("noFreeBusy"); - nodes[i].innerHTML = ('' - + '' - + '' - + ''); - } - if (document.contactFreeBusyAjaxRequest) { - document.contactFreeBusyAjaxRequest.aborted = true; - document.contactFreeBusyAjaxRequest.abort(); - } - var sd = $('startTime_date').valueAsShortDateString(); - var ed = $('endTime_date').valueAsShortDateString(); - var urlstr = ( UserFolderURL + "../" + node.uid + "/freebusy.ifb/ajaxRead?" - + "sday=" + sd + "&eday=" + ed + "&additional=" + additionalDays ); - document.contactFreeBusyAjaxRequest - = triggerAjaxRequest(urlstr, - updateFreeBusyData, - node); - } else { - for (var i = 1; i < nodes.length; i++) { - nodes[i].addClassName("noFreeBusy"); - nodes[i].innerHTML = ''; - } - } + if (document.contactFreeBusyAjaxRequest) + awaitingFreeBusyRequests.push(node); + else { + var nodes = node.parentNode.parentNode.cells; + if (node.uid) { + for (var i = 1; i < nodes.length; i++) { + nodes[i].removeClassName("noFreeBusy"); + nodes[i].innerHTML = ('' + + '' + + '' + + ''); + } + if (document.contactFreeBusyAjaxRequest) { + document.contactFreeBusyAjaxRequest.aborted = true; + document.contactFreeBusyAjaxRequest.abort(); + } + var sd = $('startTime_date').valueAsShortDateString(); + var ed = $('endTime_date').valueAsShortDateString(); + var urlstr = ( UserFolderURL + "../" + node.uid + "/freebusy.ifb/ajaxRead?" + + "sday=" + sd + "&eday=" + ed + "&additional=" + + additionalDays ); + document.contactFreeBusyAjaxRequest + = triggerAjaxRequest(urlstr, + updateFreeBusyData, + node); + } else { + for (var i = 1; i < nodes.length; i++) { + nodes[i].addClassName("noFreeBusy"); + nodes[i].innerHTML = ''; + } + } + } } function setSlot(tds, nbr, status) { @@ -280,7 +287,6 @@ function updateFreeBusyData(http) { function resetAttendeesValue() { var table = $("freeBusy"); var inputs = table.getElementsByTagName("input"); - var uids = new Array(); for (var i = 0; i < inputs.length - 2; i++) { var currentInput = inputs[i]; var uid = currentInput.getAttribute("uid"); @@ -288,7 +294,6 @@ function resetAttendeesValue() { currentInput.uid = uid; currentInput.setAttribute("uid", null); } - uids.push(currentInput.uid); currentInput.setAttribute("autocomplete", "off"); currentInput.addEventListener("keydown", onContactKeydown, false); currentInput.addEventListener("blur", checkAttendee, false); @@ -304,11 +309,8 @@ function resetAllFreeBusys() { for (var i = 0; i < inputs.length - 2; i++) { var currentInput = inputs[i]; currentInput.hasfreebusy = false; -// log ("input: " + currentInput.uid); - awaitingFreeBusyRequests.push(currentInput); + displayFreeBusyForNode(inputs[i]); } - if (awaitingFreeBusyRequests.length > 0) - displayFreeBusyForNode(awaitingFreeBusyRequests.shift()); } function initializeWindowButtons() { @@ -478,14 +480,10 @@ function prepareTableRows() { var rows = $("freeBusy").tBodies[0].rows; var days = startDate.daysUpTo(endDate); - for (var i = 0; i < days.length; i++) { - for (var rowNbr = 0; rowNbr < rows.length; rowNbr++) { - for (var hour = dayStartHour; hour < (dayEndHour + 1); hour++) { - var cell = document.createElement("td"); - rows[rowNbr].appendChild(cell); - } - } - } + for (var i = 0; i < days.length; i++) + for (var rowNbr = 0; rowNbr < rows.length; rowNbr++) + for (var hour = dayStartHour; hour < (dayEndHour + 1); hour++) + rows[rowNbr].appendChild(document.createElement("td")); } function prepareAttendees() { @@ -494,8 +492,6 @@ function prepareAttendees() { attendeesNames = parent$("attendeesNames").value.split(","); attendeesEmails = parent$("attendeesEmails").value.split(","); - var baseUrl = UserFolderURL + "Contacts/contactSearch?search="; - var body = $("freeBusy").tBodies[0]; for (var i = 0; i < attendeesNames.length; i++) { var tr = body.insertRow(i); @@ -509,11 +505,9 @@ function prepareAttendees() { input.value = value; input.addClassName("textField"); input.setAttribute("modified", "0"); - triggerAjaxRequest(baseUrl + attendeesEmails[i], - UIDLookupCallback, input); - input.setAttribute("uid", attendeesNames[i]); - tr.appendChild(td) - td.appendChild(input) + tr.appendChild(td); + td.appendChild(input); + displayFreeBusyForNode(input); } } else { @@ -522,6 +516,14 @@ function prepareAttendees() { } } +function initializeFreebusys() { + var inputs = $("freeBusy").getElementsByTagName("input"); + var baseUrl = UserFolderURL + "Contacts/contactSearch?search="; + for (var i = 0; i < attendeesEmails.length; i++) + triggerAjaxRequest(baseUrl + attendeesEmails[i], + UIDLookupCallback, inputs[i]); +} + function onFreeBusyLoadHandler() { initializeWindowButtons(); initializeTimeWidgets(); @@ -530,7 +532,7 @@ function onFreeBusyLoadHandler() { prepareTableRows(); redisplayFreeBusyZone(); resetAttendeesValue(); - resetAllFreeBusys(); + initializeFreebusys(); } window.addEventListener("load", onFreeBusyLoadHandler, false); diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index df12e456..89cce21d 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -582,7 +582,7 @@ function log(message) { } var logConsole = logWindow.document.getElementById("logConsole"); if (logConsole) - logConsole.innerHTML += message + '
' + "\n"; + logConsole.innerHTML += message.replace("<", "<") + '
' + "\n"; } function backtrace() { -- 2.39.5