]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1059 d1b88da0-ebda-0310...
authorwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 10 May 2007 15:24:44 +0000 (15:24 +0000)
committerwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 10 May 2007 15:24:44 +0000 (15:24 +0000)
ChangeLog
SoObjects/SOGo/LDAPSource.m
SoObjects/SOGo/LDAPUserManager.m
UI/WebServerResources/HTMLElement.js
UI/WebServerResources/HTMLInputElement.js
UI/WebServerResources/SOGoDragHandles.js
UI/WebServerResources/generic.css
UI/WebServerResources/generic.js

index ad7219dc27a1773fe854cf4c1201351f7f8f718d..ad92d7c786dbd6f1e489a7adb2de93be10162137 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2007-05-10  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
+
+       * SoObjects/SOGo/LDAPUserManager.m ([LDAPUserManager
+       -contactInfosForUserWithUIDorEmail:uid]): check that uid is not empty.
+
+       * SoObjects/SOGo/LDAPSource.m ([LDAPSource
+       -checkLogin:loginToCheckandPassword:passwordToCheck]): check that
+       loginToCheck is not empty.
+       ([LDAPSource -fetchContactsMatching:match]): check that match is
+       not empty.
+       ([LDAPSource -lookupContactEntry:entryID]): check that entryID is
+       not empty.
+       ([LDAPSource -lookupContactEntryWithUIDorEmail:uid]): check that
+       uid is not empty.
+
 2007-05-09  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
 
        * SoObjects/SOGo/SOGoUser.m ([SOGoUser -primaryEmail]): new name
index 9b9390662984ed49edb8cdc5e27d698fd3673668..51fdadaf740fd43b3b900094400cd8c66dadbc2c 100644 (file)
@@ -215,18 +215,23 @@ static NSArray *commonSearchFields;
   NSString *userDN;
   NGLdapConnection *bindConnection;
 
-  bindConnection = [[NGLdapConnection alloc] initWithHostName: hostname
-                                            port: port];
-  userDN = [NSString stringWithFormat: @"%@=%@,%@",
-                    IDField, loginToCheck, baseDN];
-  NS_DURING
-    didBind = [bindConnection bindWithMethod: @"simple" binddn: userDN
-                             credentials: passwordToCheck];
-  NS_HANDLER
+  if ([loginToCheck length] > 0)
+    {
+      bindConnection = [[NGLdapConnection alloc] initWithHostName: hostname
+                                                port: port];
+      userDN = [NSString stringWithFormat: @"%@=%@,%@",
+                        IDField, loginToCheck, baseDN];
+      NS_DURING
+       didBind = [bindConnection bindWithMethod: @"simple" binddn: userDN
+                                 credentials: passwordToCheck];
+      NS_HANDLER
+       didBind = NO;
+      NS_ENDHANDLER
+
+      [bindConnection release];
+    }
+  else
     didBind = NO;
-  NS_ENDHANDLER
-
-  [bindConnection release];
 
   return didBind;
 }
@@ -237,7 +242,7 @@ static NSArray *commonSearchFields;
   NSString *qs;
   EOQualifier *qualifier;
 
-  if (filter && [filter length] > 0)
+  if ([filter length] > 0)
     {
       if ([filter isEqualToString: @"."])
         qs = @"(cn='*')";
@@ -355,19 +360,22 @@ static NSArray *commonSearchFields;
 
   contacts = [NSMutableArray array];
 
-  if (!ldapConnection)
-    [self _initLDAPConnection];
-  entries = [ldapConnection deepSearchAtBaseDN: baseDN
-                           qualifier: [self _qualifierForFilter: match]
-                           attributes: [self _searchAttributes]];
-  if (entries)
+  if ([match length] > 0)
     {
-      currentEntry = [entries nextObject];
-      while (currentEntry)
+      if (!ldapConnection)
+       [self _initLDAPConnection];
+      entries = [ldapConnection deepSearchAtBaseDN: baseDN
+                               qualifier: [self _qualifierForFilter: match]
+                               attributes: [self _searchAttributes]];
+      if (entries)
        {
-         [contacts addObject:
-                     [self _convertLDAPEntryToContact: currentEntry]];
          currentEntry = [entries nextObject];
+         while (currentEntry)
+           {
+             [contacts addObject:
+                         [self _convertLDAPEntryToContact: currentEntry]];
+             currentEntry = [entries nextObject];
+           }
        }
     }
 
@@ -379,16 +387,19 @@ static NSArray *commonSearchFields;
   NSDictionary *contactEntry;
   NGLdapEntry *ldapEntry;
 
-  if (!ldapConnection)
-    [self _initLDAPConnection];
-  ldapEntry
-    = [ldapConnection entryAtDN: [NSString stringWithFormat: @"%@=%@,%@",
-                                          IDField, entryID, baseDN]
-                     attributes: [self _searchAttributes]];
-  if (ldapEntry)
-    contactEntry = [self _convertLDAPEntryToContact: ldapEntry];
-  else
-    contactEntry = nil;
+  contactEntry = nil;
+
+  if ([entryID length] > 0)
+    {
+      if (!ldapConnection)
+       [self _initLDAPConnection];
+      ldapEntry
+       = [ldapConnection entryAtDN: [NSString stringWithFormat: @"%@=%@,%@",
+                                              IDField, entryID, baseDN]
+                         attributes: [self _searchAttributes]];
+      if (ldapEntry)
+       contactEntry = [self _convertLDAPEntryToContact: ldapEntry];
+    }
 
   return contactEntry;
 }
@@ -400,17 +411,20 @@ static NSArray *commonSearchFields;
   NSEnumerator *entries;
   EOQualifier *qualifier;
 
-  if (!ldapConnection)
-    [self _initLDAPConnection];
-  qualifier = [self _qualifierForUIDFilter: uid];
-  entries = [ldapConnection deepSearchAtBaseDN: baseDN
-                            qualifier: qualifier
-                           attributes: [self _searchAttributes]];
-  ldapEntry = [entries nextObject];
-  if (ldapEntry)
-    contactEntry = [self _convertLDAPEntryToContact: ldapEntry];
-  else
-    contactEntry = nil;
+  contactEntry = nil;
+
+  if ([uid length] > 0)
+    {
+      if (!ldapConnection)
+       [self _initLDAPConnection];
+      qualifier = [self _qualifierForUIDFilter: uid];
+      entries = [ldapConnection deepSearchAtBaseDN: baseDN
+                               qualifier: qualifier
+                               attributes: [self _searchAttributes]];
+      ldapEntry = [entries nextObject];
+      if (ldapEntry)
+       contactEntry = [self _convertLDAPEntryToContact: ldapEntry];
+    }
 
   return contactEntry;
 }
index 6cfe52c07279f7c3e935e3003d4fb5ee315b9e28..66b1935643bc364fa3a5e1627c657cc98dfe3594 100644 (file)
@@ -179,6 +179,7 @@ static NSString *defaultMailDomain = nil;
 {
   NSDictionary *contactInfos;
 
+//   NSLog (@"getCNForUID: %@", uid);
   contactInfos = [self contactInfosForUserWithUIDorEmail: uid];
 
   return [contactInfos objectForKey: @"cn"];
@@ -188,6 +189,7 @@ static NSString *defaultMailDomain = nil;
 {
   NSDictionary *contactInfos;
 
+//   NSLog (@"getEmailForUID: %@", uid);
   contactInfos = [self contactInfosForUserWithUIDorEmail: uid];
 
   return [contactInfos objectForKey: @"c_email"];
@@ -197,6 +199,7 @@ static NSString *defaultMailDomain = nil;
 {
   NSDictionary *contactInfos;
 
+//   NSLog (@"getUIDForEmail: %@", email);
   contactInfos = [self contactInfosForUserWithUIDorEmail: email];
 
   return [contactInfos objectForKey: @"c_uid"];
@@ -342,29 +345,39 @@ static NSString *defaultMailDomain = nil;
   NSDate *cleanupDate;
   BOOL newUser;
 
-  contactInfos = [NSMutableDictionary dictionary];
-  currentUser = [users objectForKey: uid];
-  if (!([currentUser objectForKey: @"emails"]
-       && [currentUser objectForKey: @"cn"]))
+  if ([uid length] > 0)
     {
-      if (!currentUser)
+      contactInfos = [NSMutableDictionary dictionary];
+      currentUser = [users objectForKey: uid];
+      if (!([currentUser objectForKey: @"emails"]
+           && [currentUser objectForKey: @"cn"]))
        {
-         newUser = YES;
-         currentUser = [NSMutableDictionary dictionary];
+         if (!currentUser)
+           {
+             newUser = YES;
+             currentUser = [NSMutableDictionary dictionary];
+           }
+         else
+           newUser = NO;
+         [self _fillContactInfosForUser: currentUser
+               withUIDorEmail: uid];
+         if (newUser)
+           {
+             if ([[currentUser objectForKey: @"c_uid"] length] > 0)
+               [self _retainUser: currentUser];
+             else
+               currentUser = nil;
+           }
        }
-      else
-       newUser = NO;
-      [self _fillContactInfosForUser: currentUser
-           withUIDorEmail: uid];
-      if (newUser)
-       [self _retainUser: currentUser];
-    }
 
-  if (cleanupInterval)
-    {
-      cleanupDate = [[NSDate date] addTimeInterval: cleanupInterval];
-      [currentUser setObject: cleanupDate forKey: @"cleanupDate"];
+      if (cleanupInterval && currentUser)
+       {
+         cleanupDate = [[NSDate date] addTimeInterval: cleanupInterval];
+         [currentUser setObject: cleanupDate forKey: @"cleanupDate"];
+       }
     }
+  else
+    currentUser = nil;
 
   return currentUser;
 }
@@ -438,7 +451,6 @@ static NSString *defaultMailDomain = nil;
   LDAPSource *currentSource;
 
   contacts = [NSMutableArray array];
-
   ldapSources = [sources objectEnumerator];
   currentSource = [ldapSources nextObject];
   while (currentSource)
index b59666eddc4949b51039929a50d20ead16e28b04..6168bfb9e77f21297f4937f23c8b8ca678b6bd9f 100644 (file)
@@ -1,3 +1,51 @@
+if (navigator.vendor == "Apple Computer, Inc." || navigator.vendor == "KDE") { // WebCore/KHTML  
+  /*
+    Crossbrowser HTMLElement Prototyping
+    Copyright (C) 2005  Jason Davis, http://www.browserland.org
+    Additional thanks to Brothercake, http://www.brothercake.com
+    
+    This code is licensed under the LGPL:
+    http://www.gnu.org/licenses/lgpl.html
+  */
+
+  (function(c) {
+    for (var i in c)
+      window["HTML" + i + "Element"] = document.createElement(c[ i ]).constructor;
+  })({
+               Html: "html", Head: "head", Link: "link", Title: "title", Meta: "meta",
+                       Base: "base", IsIndex: "isindex", Style: "style", Body: "body", Form: "form",
+                       Select: "select", OptGroup: "optgroup", Option: "option", Input: "input",
+                       TextArea: "textarea", Button: "button", Label: "label", FieldSet: "fieldset",
+                       Legend: "legend", UList: "ul", OList: "ol", DList: "dl", Directory: "dir",
+                       Menu: "menu", LI: "li", Div: "div", Paragraph: "p", Heading: "h1", Quote: "q",
+                       Pre: "pre", BR: "br", BaseFont: "basefont", Font: "font", HR: "hr", Mod: "ins",
+                       Anchor: "a", Image: "img", Object: "object", Param: "param", Applet: "applet",
+                       Map: "map", Area: "area", Script: "script", Table: "table", TableCaption: "caption",
+                       TableCol: "col", TableSection: "tbody", TableRow: "tr", TableCell: "td",
+                       FrameSet: "frameset", Frame: "frame", IFrame: "iframe"
+                       });
+  
+  function HTMLElement() {}
+  //HTMLElement.prototype     = HTMLHtmlElement.__proto__.__proto__;   
+  var HTMLDocument          = document.constructor;
+  var HTMLCollection        = document.links.constructor;
+  var HTMLOptionsCollection = document.createElement("select").options.constructor;
+  var Text                  = document.createTextNode("").constructor;
+  //var Node                  = Text;
+  
+  // More efficient for Safari 2
+  function Document() {} 
+  function Event() {} 
+  function HTMLCollection() {} 
+  function HTMLElement() {} 
+  function Node() {} 
+  Document.prototype = window["[[DOMDocument]]"]; 
+  Event.prototype = window["[[DOMEvent]]"]; 
+  HTMLCollection.prototype = window["[[HTMLCollection.prototype]]"]; 
+  HTMLElement.prototype = window["[[DOMElement.prototype]]"]; 
+  Node.prototype = window["[[DOMNode.prototype]]"]; 
+}
+
 /* custom extensions to the DOM api */
 HTMLElement.prototype.addInterface = function(objectInterface) {
   Object.extend(this, objectInterface);
index b5e48e2fc2f3c409406c2045f21d28c756d0662e..a3a1528a416dca95df7ec8d7e77d1309767bcd66 100644 (file)
@@ -1,7 +1,7 @@
 HTMLInputElement.prototype._replicate = function() {
   if (this.replica) {
     this.replica.value = this.value;
-    var onReplicaChangeEvent = document.createEvent("Event");
+    var onReplicaChangeEvent = document.createEvent("UIEvents");
     onReplicaChangeEvent.initEvent("change", true, true);
     this.replica.dispatchEvent(onReplicaChangeEvent);
   }
@@ -56,7 +56,7 @@ HTMLInputElement.prototype.valueAsShortDateString = function() {
 HTMLSelectElement.prototype._replicate = function() {
   if (this.replica) {
     this.replica.value = this.value;
-    var onReplicaChangeEvent = document.createEvent("Event");
+    var onReplicaChangeEvent = document.createEvent("UIEvents");
     onReplicaChangeEvent.initEvent("change", true, true);
     this.replica.dispatchEvent(onReplicaChangeEvent);
   }
index aee95098f83f59bee9a753fcbd955eb2e3789599..f1501bca46ff0d530d40ac7e5ad5f1cddd9146bc 100644 (file)
@@ -13,6 +13,7 @@ var SOGoDragHandlesInterface = {
   lowerBlock: null,
   bind: function () {
     this.addEventListener("mousedown", this.startHandleDragging, false);
+    this.onmousedown = function() { return false }
   },
   _determineType: function () {
     if (this.leftBlock && this.rightBlock)
@@ -23,7 +24,14 @@ var SOGoDragHandlesInterface = {
   startHandleDragging: function (event) {
     if (!this.dhType)
       this._determineType();
-    if (event.button == 0) {
+    var targ;
+    if (!event)
+      var event = window.event;
+    if (event.target)
+      targ = event.target
+    else if (event.srcElement)
+      targ = event.srcElement
+    if (targ.nodeType == 1) {
       if (this.dhType == 'horizontal') {
         this.origX = this.offsetLeft;
         this.origLeft = this.leftBlock.offsetWidth;
@@ -38,8 +46,13 @@ var SOGoDragHandlesInterface = {
         document.body.style.cursor = "n-resize";
       }
       document._currentDragHandle = this;
-      document.addEventListener("mouseup", this.documentStopHandleDragging, true);
-      document.addEventListener("mousemove", this.documentMove, true);
+      if (document.addEventListener) {
+       document.addEventListener("mouseup", this.documentStopHandleDragging, true);
+       document.addEventListener("mousemove", this.documentMove, true);
+      } else if (window.addEventListener) {
+       window.addEventListener("mouseup", this.documentStopHandleDragging, true);
+       window.addEventListener("mousemove", this.documentMove, true);
+      }
       this.move(event);
       event.cancelBubble = true;
     }
@@ -52,6 +65,7 @@ var SOGoDragHandlesInterface = {
   },
   documentMove: function (event) {
     var handle = document._currentDragHandle;
+    if (!handle) return false;
     return handle.move(event);
   },
   stopHandleDragging: function (event) {
@@ -60,17 +74,22 @@ var SOGoDragHandlesInterface = {
     if (this.dhType == 'horizontal') {
       var deltaX
         = Math.floor(event.clientX - this.origX - (this.offsetWidth / 2));
-      this.rightBlock.style.left = (this.origRight + deltaX) + 'px;';
-      this.leftBlock.style.width = (this.origLeft + deltaX) + 'px;';
+      this.rightBlock.style.left = (this.origRight + deltaX) + 'px';
+      this.leftBlock.style.width = (this.origLeft + deltaX) + 'px';
     } else if (this.dhType == 'vertical') {
       var deltaY
         = Math.floor(event.clientY - this.origY - (this.offsetHeight / 2));
-      this.lowerBlock.style.top = (this.origLower + deltaY - delta) + 'px;';
-      this.upperBlock.style.height = (this.origUpper + deltaY - delta) + 'px;';
+      this.lowerBlock.style.top = (this.origLower + deltaY - delta) + 'px';
+      this.upperBlock.style.height = (this.origUpper + deltaY - delta) + 'px';
     }
  
-    document.removeEventListener("mouseup", this.documentStopHandleDragging, true);
-    document.removeEventListener("mousemove", this.documentMove, true);
+    if (window.addEventListener) {
+      window.removeEventListener("mouseup", this.documentStopHandleDragging, true);
+      window.removeEventListener("mousemove", this.documentMove, true);      
+    } else if (document.addEventListener) {
+      document.removeEventListener("mouseup", this.documentStopHandleDragging, true);
+      document.removeEventListener("mousemove", this.documentMove, true);
+    }
     document.body.setAttribute('style', '');
 
     this.move(event);
@@ -87,7 +106,7 @@ var SOGoDragHandlesInterface = {
       var hX = event.clientX;
       if (hX > -1) {
         var newLeft = Math.floor(hX - (width / 2));
-        this.style.left = newLeft + 'px;';
+        this.style.left = newLeft + 'px';
         event.cancelBubble = true;
       
         return false;
@@ -97,7 +116,7 @@ var SOGoDragHandlesInterface = {
       var hY = event.clientY;
       if (hY > -1) {
         var newTop = Math.floor(hY - (height / 2))  - delta;
-        this.style.top = newTop + 'px;';
+        this.style.top = newTop + 'px';
         event.cancelBubble = true;
 
         return false;
@@ -113,9 +132,9 @@ var SOGoDragHandlesInterface = {
       if (this.offsetLeft > lLeft) {
         var leftdelta = this.rightBlock.offsetLeft - this.offsetLeft;
 
-        this.style.left = lLeft + 'px;';
+        this.style.left = lLeft + 'px';
         this.leftBlock.style.width = '0px';
-        this.rightBlock.style.left = (lLeft + leftdelta) + 'px;';
+        this.rightBlock.style.left = (lLeft + leftdelta) + 'px';
       }
     } else if (this.dhType == 'vertical') {
       var uTop = this.upperBlock.offsetTop;
@@ -123,9 +142,9 @@ var SOGoDragHandlesInterface = {
       if (this.offsetTop > uTop) {
         var topdelta = this.lowerBlock.offsetTop - this.offsetTop;
       
-        this.style.top = uTop + 'px;';
+        this.style.top = uTop + 'px';
         this.upperBlock.style.width = '0px';
-        this.lowerBlock.style.top = (uTop + topdelta) + 'px;';
+        this.lowerBlock.style.top = (uTop + topdelta) + 'px';
       }
     }
   }
index 1ee7ce91fb628253ac37350a18c7b2b87b5bc619..420c635778cc3a467f9f6a44c2dd20af01915357 100644 (file)
@@ -239,13 +239,11 @@ A.toolbarButton
 
 SPAN.toolbarButton, SPAN.disabledToolbarButton
 { cursor: default;
-  display: block;
+  display: inline;
   float: left;
-  height: 80%;
   text-align: center;
   -moz-box-align: center;
   -moz-box-pack: center;
-  margin: 0px;
   border-left: 1px solid transparent;
   border-top: 1px solid transparent;
   border-right: 1px solid transparent;
@@ -278,8 +276,7 @@ SPAN.toolbarButton:active
   margin: auto; }
 
 .toolbarButton .buttonLabel
-{ width: 100%;
-  margin: auto; }
+{ margin: auto; }
 
 /* popups */
 .menu
index 8efe056e9d0cfefbd17b11885eda6e6d26b5a12e..df12e456f6ee6328a23a2e2225bdc3ef6492a6ed 100644 (file)
@@ -411,7 +411,7 @@ function onRowClick(event) {
     var parentNode = node.parentNode;
     if (parentNode instanceof HTMLTableSectionElement)
       parentNode = parentNode.parentNode;
-    var onSelectionChangeEvent = document.createEvent("Event");
+    var onSelectionChangeEvent = document.createEvent("UIEvents");
     onSelectionChangeEvent.initEvent("selectionchange", true, true);
     parentNode.dispatchEvent(onSelectionChangeEvent);
   }
@@ -509,7 +509,7 @@ function hideMenu(event, menuNode) {
     menuNode.parentMenu = null;
   }
 
-  var onhideEvent = document.createEvent("Event");
+  var onhideEvent = document.createEvent("UIEvents");
   onhideEvent.initEvent("hideMenu", false, true);
   menuNode.dispatchEvent(onhideEvent);
 }
@@ -893,18 +893,18 @@ function initTabs() {
     for (var i = 0; i < nodes.length; i++) {
       if (nodes[i] instanceof HTMLLIElement) {
         if (!firstTab) {
-          firstTab = nodes[i];
+          firstTab = i;
         }
         nodes[i].addEventListener("mousedown", onTabMouseDown, true);
         nodes[i].addEventListener("click", onTabClick, true);
       }
     }
 
-    firstTab.addClassName("first");
-    firstTab.addClassName("active");
-    container.activeTab = firstTab;
+    nodes[firstTab].addClassName("first");
+    nodes[firstTab].addClassName("active");
+    container.activeTab = nodes[firstTab];
 
-    var target = $(firstTab.getAttribute("target"));
+    var target = $(nodes[firstTab].getAttribute("target"));
     target.addClassName("active");
   }
 }
@@ -1065,22 +1065,20 @@ function indexColor(number) {
   return color;
 }
 
-var onLoadHandler = {
-  handleEvent: function (event) {
-    queryParameters = parseQueryParameters('' + window.location);
-    if (!document.body.hasClassName("popup")) {
-      initLogConsole();
-      initializeMenus();
-      initCriteria();
-    }
-    initTabs();
-    configureDragHandles();
-    configureSortableTableHeaders();
-    configureLinkBanner();
-    var progressImage = $("progressIndicator");
-    if (progressImage)
-      progressImage.parentNode.removeChild(progressImage);
+var onLoadHandler = function (event) {
+  queryParameters = parseQueryParameters('' + window.location);
+  if (!document.body.hasClassName("popup")) {
+    initLogConsole();
+    initializeMenus();
+    initCriteria();
   }
+  initTabs();
+  configureDragHandles();
+  configureSortableTableHeaders();
+  configureLinkBanner();
+  var progressImage = $("progressIndicator");
+  if (progressImage)
+    progressImage.parentNode.removeChild(progressImage);
 }
 
 function configureSortableTableHeaders() {
@@ -1114,7 +1112,11 @@ function configureLinkBanner() {
   }
 }
 
-window.addEventListener("load", onLoadHandler, false);
+if (window.addEventListener) {
+  window.addEventListener('load', onLoadHandler, false);
+} else if (document.addEventListener) {
+  document.addEventListener('load', onLoadHandler, false);
+}
 
 /* stubs */
 function configureDragHandles() {