}
}
-- (NSDictionary *) _searchResults: (NSString *) contact
- ldapFoldersOnly: (BOOL) ldapOnly
-{
- NSMutableDictionary *results;
- SOGoContactFolders *topFolder;
- NSEnumerator *sogoContactFolders;
- id <SOGoContactFolder> 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;
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
{
NSString *contact;
id <WOActionResults> 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"];
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];
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
}
}
}
}
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 = ('<span class="freeBusyZoneElement"></span>'
- + '<span class="freeBusyZoneElement"></span>'
- + '<span class="freeBusyZoneElement"></span>'
- + '<span class="freeBusyZoneElement"></span>');
- }
- 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 = ('<span class="freeBusyZoneElement"></span>'
+ + '<span class="freeBusyZoneElement"></span>'
+ + '<span class="freeBusyZoneElement"></span>'
+ + '<span class="freeBusyZoneElement"></span>');
+ }
+ 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) {
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");
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);
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() {
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() {
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);
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 {
}
}
+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();
prepareTableRows();
redisplayFreeBusyZone();
resetAttendeesValue();
- resetAllFreeBusys();
+ initializeFreebusys();
}
window.addEventListener("load", onFreeBusyLoadHandler, false);