From: wolfgang Date: Tue, 23 Oct 2007 17:47:56 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1194 d1b88da0-ebda-0310... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d941bf3055d073bf4a5cf5826fe253c48271be5;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1194 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/ChangeLog b/ChangeLog index d23d7bad..e0077923 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-10-23 Wolfgang Sourdeau + + * 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 * UI/Common/UIxPageFrame.m ([UIxPageFrame -commonLocalizableStrings]) diff --git a/SoObjects/Contacts/SOGoContactLDAPFolder.m b/SoObjects/Contacts/SOGoContactLDAPFolder.m index 5f1ad9ec..4a266c4b 100644 --- a/SoObjects/Contacts/SOGoContactLDAPFolder.m +++ b/SoObjects/Contacts/SOGoContactLDAPFolder.m @@ -161,10 +161,11 @@ 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) diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index f39aa7f6..aa2f1d05 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -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]; } diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index bf277fbb..50f2484b 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -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; diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index 2e086b91..c51a3ecc 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -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; } diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index e1b86a0a..99930c3b 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -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); diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 68a5d491..b3c9d070 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -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)