]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1194 d1b88da0-ebda-0310...
authorwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 23 Oct 2007 17:47:56 +0000 (17:47 +0000)
committerwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 23 Oct 2007 17:47:56 +0000 (17:47 +0000)
ChangeLog
SoObjects/Contacts/SOGoContactLDAPFolder.m
SoObjects/Mailer/SOGoMailAccount.m
SoObjects/Mailer/SOGoMailFolder.m
UI/WebServerResources/MailerUI.js
UI/WebServerResources/SchedulerUI.js
UI/WebServerResources/generic.js

index d23d7bad3dd7af14479db9686a2d76b95090c2dc..e0077923389acba69f11c9e61a0b51015e256804 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-10-23  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
+
+       * SoObjects/Contacts/SOGoContactLDAPFolder.m: if "displayName" is
+       empty, use "c_cn" instead.
+
+       * SoObjects/Mailer/SOGoMailAccount.m ([SOGoMailAccount -inboxFolderInContext:_ctx])
+       ([SOGoMailAccount -draftsFolderInContext:_ctx])
+       ([SOGoMailAccount -sentFolderInContext:_ctx]): no longer make use
+       of the "SOGoSpecialFoldersInRoot" user defaults. The folders will
+       no always be specified from the root instead of sometimes from the
+       INBOX.
+
 2007-10-22  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
 
        * UI/Common/UIxPageFrame.m ([UIxPageFrame -commonLocalizableStrings])
index 5f1ad9ecbace020ad1343e09b656ab61e088efd2..4a266c4b3c75961f67bca839858eb41bb171bdcc 100644 (file)
                 forKey: @"c_name"];
 
       data = [oldRecord objectForKey: @"displayName"];
+      if (!data)
+       data = [oldRecord objectForKey: @"c_cn"];
       if (!data)
        data = @"";
-      [newRecord setObject: data
-                forKey: @"displayName"];
+      [newRecord setObject: data forKey: @"displayName"];
 
       data = [oldRecord objectForKey: @"mail"];
       if (!data)
index f39aa7f6b1e98a52b3671a9d9e0ef42ea7efb128..aa2f1d05cb7ddcb53c8a5c3a1936a68f6e23ed8b 100644 (file)
@@ -50,15 +50,12 @@ static NSString *sentFolderName = nil;
 static NSString *trashFolderName = nil;
 static NSString *sharedFolderName = @""; // TODO: add English default
 static NSString *otherUsersFolderName = @""; // TODO: add English default
-static BOOL useAltNamespace = NO;
 
 + (void) initialize
 {
   NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
   NSString *cfgDraftsFolderName;
 
-  useAltNamespace = [ud boolForKey:@"SOGoSpecialFoldersInRoot"];
-  
   sharedFolderName = [ud stringForKey:@"SOGoSharedFolderName"];
   otherUsersFolderName = [ud stringForKey:@"SOGoOtherUsersFolderName"];
   cfgDraftsFolderName = [ud stringForKey:@"SOGoDraftsFolderName"];
@@ -406,21 +403,16 @@ static BOOL useAltNamespace = NO;
 
 - (SOGoDraftsFolder *) draftsFolderInContext: (id) _ctx
 {
-  SOGoMailFolder *lookupFolder;
   // TODO: use some profile to determine real location, use a -traverse lookup
 
   if (!draftsFolder)
     {
-      lookupFolder = (useAltNamespace
-                     ? (id) self
-                     : [self inboxFolderInContext:_ctx]);
-      if (![lookupFolder isKindOfClass: [NSException class]])
-       draftsFolder
-         = [lookupFolder lookupName: [self draftsFolderNameInContext:_ctx]
-                         inContext: _ctx acquire: NO];
-      if (![draftsFolder isNotNull])
-       draftsFolder = [NSException exceptionWithHTTPStatus: 404 /* not found */
-                                   reason: @"did not find Drafts folder!"];
+      draftsFolder
+       = [self lookupName: [self draftsFolderNameInContext:_ctx]
+               inContext: _ctx acquire: NO];
+//       if (![draftsFolder isNotNull])
+//     draftsFolder = [NSException exceptionWithHTTPStatus: 404 /* not found */
+//                                 reason: @"did not find Drafts folder!"];
       [draftsFolder retain];
     }
 
@@ -429,20 +421,15 @@ static BOOL useAltNamespace = NO;
 
 - (SOGoMailFolder *) sentFolderInContext: (id) _ctx
 {
-  SOGoMailFolder *lookupFolder;
   // TODO: use some profile to determine real location, use a -traverse lookup
 
   if (!sentFolder)
     {
-      lookupFolder = (useAltNamespace
-                     ? (id) self
-                     : [self inboxFolderInContext:_ctx]);
-      if (![lookupFolder isKindOfClass: [NSException class]])
-       sentFolder = [lookupFolder lookupName: [self sentFolderNameInContext:_ctx]
-                                  inContext: _ctx acquire: NO];
-      if (![sentFolder isNotNull])
-       sentFolder = [NSException exceptionWithHTTPStatus: 404 /* not found */
-                                 reason: @"did not find Sent folder!"];
+      sentFolder = [self lookupName: [self sentFolderNameInContext:_ctx]
+                        inContext: _ctx acquire: NO];
+//       if (![sentFolder isNotNull])
+//     sentFolder = [NSException exceptionWithHTTPStatus: 404 /* not found */
+//                               reason: @"did not find Sent folder!"];
       [sentFolder retain];
     }
 
@@ -451,20 +438,13 @@ static BOOL useAltNamespace = NO;
 
 - (SOGoMailFolder *) trashFolderInContext: (id) _ctx
 {
-  SOGoMailFolder *lookupFolder;
-  // TODO: use some profile to determine real location, use a -traverse lookup
-
   if (!trashFolder)
     {
-      lookupFolder = (useAltNamespace
-                     ? (id) self
-                     : [self inboxFolderInContext:_ctx]);
-      if (![lookupFolder isKindOfClass: [NSException class]])
-       trashFolder = [lookupFolder lookupName: [self trashFolderNameInContext: _ctx]
-                                   inContext: _ctx acquire: NO];
-      if (![trashFolder isNotNull])
-       trashFolder = [NSException exceptionWithHTTPStatus: 404 /* not found */
-                                 reason: @"did not find Trash folder!"];
+      trashFolder = [self lookupName: [self trashFolderNameInContext: _ctx]
+                         inContext: _ctx acquire: NO];
+//       if (![trashFolder isNotNull])
+//     trashFolder = [NSException exceptionWithHTTPStatus: 404 /* not found */
+//                               reason: @"did not find Trash folder!"];
       [trashFolder retain];
     }
 
index bf277fbbc13cf459838fcc1ae072e66dc2365b67..50f2484b04a5d9b19e54f5b9d8a57aeed221088c 100644 (file)
@@ -43,15 +43,6 @@ static NSString *defaultUserID =  @"anyone";
 
 @implementation SOGoMailFolder
 
-static BOOL useAltNamespace = NO;
-
-+ (void) initialize
-{
-  NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
-
-  useAltNamespace = [ud boolForKey:@"SOGoSpecialFoldersInRoot"];
-}
-
 - (void) _adjustOwner
 {
   SOGoMailAccount *mailAccount;
index 2e086b91f0dd2692e6ffa78273cd3de0211cc59c..c51a3ecc1bd2b70f8c9577c24b8805574a96a4a1 100644 (file)
@@ -1551,7 +1551,9 @@ function getMenus() {
   menus["searchMenu"] = new Array(setSearchCriteria, setSearchCriteria,
                                  setSearchCriteria, setSearchCriteria,
                                  setSearchCriteria);
-  $("label-menu").prepareVisibility = onLabelMenuPrepareVisibility;
+  var labelMenu = $("label-menu");
+  if (labelMenu)
+    labelMenu.prepareVisibility = onLabelMenuPrepareVisibility;
 
   return menus;
 }
index e1b86a0ab4e77a906bd7fbe00377f069355f1cfe..99930c3bcfb3483bf9dce16aeb37e68fcddd5fd0 100644 (file)
@@ -1410,15 +1410,22 @@ function onCalendarAdd(event) {
   preventDefault(event);
 }
 
-function appendCalendar(folderName, folder) {
-  if (folder)
-    folder = accessToSubscribedFolder(folder);
+function appendCalendar(folderName, folderPath) {
+  var owner;
+
+  if (folderPath) {
+    owner = getSubscribedFolderOwner(folderPath);
+    folderPath = accessToSubscribedFolder(folderPath);
+  }
   else
-    folder = "/" + folderName;
+    folderPath = "/" + folderName;
+
+  if (!owner)
+    owner = UserLogin;
 
-//   log ("append: " + folderName + "; folder: " + folder);
+  //log ("append name: " + folderName + "; path: " + folderPath + "; owner: " + owner);
 
-  if ($(folder))
+  if ($(folderPath))
     window.alert(clabels["You have already subscribed to that folder!"]);
   else {
     var calendarList = $("calendarList");
@@ -1427,8 +1434,34 @@ function appendCalendar(folderName, folder) {
     //log ("color: " + color);
 
     var li = document.createElement("li");
-    calendarList.appendChild(li);
-    li.setAttribute("id", folder);
+    
+    // Add the calendar to the proper place
+    for (var i = 0; i < lis.length; i++) {
+      var currentFolderName = lis[i].lastChild.nodeValue.strip();
+      if (lis[i].readAttribute('owner') != owner)
+       continue;
+      if (currentFolderName > folderName)
+       break;
+    }
+    if (i != lis.length) { // User is subscribed to other calendars of the same owner
+      calendarList.insertBefore(li, lis[i]);
+    }
+    else {
+      for (var i = 0; i < lis.length; i++) {
+       if (lis[i].readAttribute('owner') == UserLogin)
+         continue;
+       if (lis[i].readAttribute('owner') > owner) {
+         calendarList.insertBefore(li, lis[i]);
+         break;
+       }
+      }
+      if (i == lis.length) {
+       calendarList.appendChild(li);
+      }
+    }
+
+    li.setAttribute("id", folderPath);
+    li.setAttribute("owner", owner);
 
     var checkBox = document.createElement("input");
     checkBox.setAttribute("type", "checkbox");
@@ -1453,20 +1486,21 @@ function appendCalendar(folderName, folder) {
     Event.observe(checkBox, "click",
                  updateCalendarStatus.bindAsEventListener(checkBox));
 
-    var url = URLForFolderID(folder) + "/canAccessContent";
-    triggerAjaxRequest(url, calendarEntryCallback, folder);
+    var url = URLForFolderID(folderPath) + "/canAccessContent";
+    triggerAjaxRequest(url, calendarEntryCallback, folderPath);
     
+    // Update CSS for events color
     if (!document.styleSheets) return;
     var theRules = new Array();
     var lastSheet = document.styleSheets[document.styleSheets.length - 1];
     if (lastSheet.insertRule) { // Mozilla
-      lastSheet.insertRule('.calendarFolder' + folder.substr(1) + ' {'
+      lastSheet.insertRule('.calendarFolder' + folderPath.substr(1) + ' {'
                           + ' background-color: '
                           + color
                           + ' !important; }', 0);
     }
     else { // IE
-      lastSheet.addRule('.calendarFolder' + folder.substr(1),
+      lastSheet.addRule('.calendarFolder' + folderPath.substr(1),
                        ' background-color: '
                        + color
                        + ' !important; }');
@@ -1483,26 +1517,30 @@ function onFolderSubscribeCB(folderData) {
 function onFolderUnsubscribeCB(folderId) {
   var node = $(folderId);
   node.parentNode.removeChild(node);
-  refreshEvents();
-  refreshTasks();
-  changeCalendarDisplay();
+  if (removeFolderRequestCount == 0) {
+    refreshEvents();
+    refreshTasks();
+    changeCalendarDisplay();
+  }
 }
 
 function onCalendarRemove(event) {
-  var nodes = $("calendarList").getSelectedNodes();
-  if (nodes.length > 0) { 
-     nodes[0].deselect();
-     var folderId = nodes[0].getAttribute("id");
-     var folderIdElements = folderId.split("_");
-     if (folderIdElements.length > 1) {
-       unsubscribeFromFolder(folderId, onFolderUnsubscribeCB, folderId);
-     }
-     else {
-       var calId = folderIdElements[0].substr(1);
-       deletePersonalCalendar(calId);
-     }
+  if (removeFolderRequestCount == 0) {
+    var nodes = $("calendarList").getSelectedNodes();
+    for (var i = 0; i < nodes.length; i++) {
+      nodes[i].deselect();
+      var folderId = nodes[i].getAttribute("id");
+      var folderIdElements = folderId.split("_");
+      if (folderIdElements.length > 1) {
+       unsubscribeFromFolder(folderId, onFolderUnsubscribeCB, folderId);
+      }
+      else {
+       var calId = folderIdElements[0].substr(1);
+       deletePersonalCalendar(calId);
+      }
+    }
   }
-
+  
   preventDefault(event);
 }
 
@@ -1510,13 +1548,9 @@ function deletePersonalCalendar(folderId) {
   var label
     = labels["Are you sure you want to delete the selected calendar?"];
   if (window.confirm(label)) {
-    if (document.deletePersonalCalendarAjaxRequest) {
-      document.deletePersonalCalendarAjaxRequest.aborted = true;
-      document.deletePersonalCalendarAjaxRequest.abort();
-    }
+    removeFolderRequestCount++;
     var url = ApplicationBaseURL + "/" + folderId + "/deleteFolder";
-    document.deletePersonalCalendarAjaxRequest
-      = triggerAjaxRequest(url, deletePersonalCalendarCallback, folderId);
+    triggerAjaxRequest(url, deletePersonalCalendarCallback, folderId);
   }
 }
 
@@ -1536,11 +1570,13 @@ function deletePersonalCalendarCallback(http) {
        else
          i++;
       }
-      refreshEvents();
-      refreshTasks();
-      changeCalendarDisplay();
+      removeFolderRequestCount--;
+      if (removeFolderRequestCount == 0) {
+       refreshEvents();
+       refreshTasks();
+       changeCalendarDisplay();
+      }
     }
-    document.deletePersonalCalendarAjaxRequest = null;
   }
   else
     log ("ajax problem 5: " + http.status);
index 68a5d49148bd2ba0a3af1be48b526c32f61443cb..b3c9d070b86bac71f3ef239ffbac6b5a84405dcf 100644 (file)
@@ -27,7 +27,6 @@ var logWindow = null;
 
 var queryParameters;
 
-var activeAjaxRequests = 0;
 var menus = new Array();
 var search = {};
 var sorting = {};
@@ -42,6 +41,10 @@ var allDocumentElements = null;
 var userDefaults = null;
 var userSettings = null;
 
+// Ajax requests counts
+var activeAjaxRequests = 0;
+var removeFolderRequestCount = 0;
+
 /* a W3C compliant document.all */
 function getAllScopeElements(scope) {
   var elements = new Array();
@@ -1029,19 +1032,18 @@ function subscribeToFolder(refreshCallback, refreshCallbackData) {
                                                          rfCbData);
   }
   else
-    refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]
-                                       );
+    refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]);
 }
 
 function folderUnsubscriptionCallback(http) {
   if (http.readyState == 4) {
+    removeFolderRequestCount--;
     if (isHttpStatus204(http.status)) {
       if (http.callbackData)
        http.callbackData["method"](http.callbackData["data"]);
     }
     else
       window.alert(clabels["Unable to unsubscribe from that folder!"]);
-    document.unsubscriptionAjaxRequest = null;
   }
 }
 
@@ -1051,19 +1053,16 @@ function unsubscribeFromFolder(folder, refreshCallback, refreshCallbackData) {
                                        refreshCallbackData);
   }
   else {
-    var folderData = folder.split("+");
+    var folderData = folder.split("_");
     var username = folderData[0];
     var folderPath = folderData[1];
+    if (username.startsWith('/'))
+      username = username.substring(1);
     if (username != UserLogin) {
       var url = (ApplicationBaseURL + folder + "/unsubscribe");
-      if (document.unsubscriptionAjaxRequest) {
-       document.unsubscriptionAjaxRequest.aborted = true;
-       document.unsubscriptionAjaxRequest.abort();
-      }
+      removeFolderRequestCount++;
       var rfCbData = { method: refreshCallback, data: refreshCallbackData };
-      document.unsubscriptionAjaxRequest
-       = triggerAjaxRequest(url, folderUnsubscriptionCallback,
-                            rfCbData);
+      triggerAjaxRequest(url, folderUnsubscriptionCallback, rfCbData);
     }
     else
       window.alert(clabels["You cannot unsubscribe from a folder that you own!"]);
@@ -1084,6 +1083,17 @@ function accessToSubscribedFolder(serverFolder) {
   return folder;
 }
 
+function getSubscribedFolderOwner(serverFolder) {
+  var owner;
+  
+  var parts = serverFolder.split(":");
+  if (parts.length > 1) {
+    owner = parts[0];
+  }
+  
+  return owner;
+}
+
 function listRowMouseDownHandler(event) {
   preventDefault(event);
   //Event.stop(event); 
@@ -1414,7 +1424,7 @@ function createFolderCallback(http) {
     var data = http.callbackData;
     if (http.status == 201) {
       if (data.okCB)
-       data.okCB(data.name, "/" + http.responseText);
+       data.okCB(data.name, "/" + http.responseText, UserLogin);
     }
     else {
       if (data.notOkCB)