]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1060 d1b88da0-ebda-0310...
authorwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 10 May 2007 19:03:57 +0000 (19:03 +0000)
committerwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 10 May 2007 19:03:57 +0000 (19:03 +0000)
ChangeLog
SoObjects/SOGo/AgenorUserDefaults.m
SoObjects/SOGo/LDAPUserManager.m
UI/Contacts/UIxContactFoldersView.m
UI/WebServerResources/UIxAttendeesEditor.js
UI/WebServerResources/generic.js

index ad92d7c786dbd6f1e489a7adb2de93be10162137..d0592e30de6e8ab6c8ad5313dd81555bd59cde21 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,19 @@
 2007-05-10  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
 
+       * 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
index ff553d75dd32ee8cbdbd4200655fc5fdc95526c9..e7031c7c7269cb4a16e67631b3a7716a451da3e1 100644 (file)
@@ -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;
index 66b1935643bc364fa3a5e1627c657cc98dfe3594..6b0379d1e6da973ca9c03dea4ff79152e2414662 100644 (file)
@@ -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"];
 }
 
index de17b892a0b67df739159e0f03cb1ede0e02346b..400eb6df205f8dba8d90ea7ec292f3efe7ad4d9c 100644 (file)
     }
 }
 
-- (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];
index 60f415943e1493c85cf3e74a43e02ccd81cb5bfb..2735ebb078d8aeede4fa2159f8fb30c1e4a77fe7 100644 (file)
@@ -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 = ('<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) {
@@ -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);
index df12e456f6ee6328a23a2e2225bdc3ef6492a6ed..89cce21d5d12a715159f04f15c3096c9f9eb87e9 100644 (file)
@@ -582,7 +582,7 @@ function log(message) {
   }
   var logConsole = logWindow.document.getElementById("logConsole");
   if (logConsole)
-    logConsole.innerHTML += message + '<br />' + "\n";
+    logConsole.innerHTML += message.replace("<", "&lt;") + '<br />' + "\n";
 }
 
 function backtrace() {