+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])
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)
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"];
- (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];
}
- (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];
}
- (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];
}
@implementation SOGoMailFolder
-static BOOL useAltNamespace = NO;
-
-+ (void) initialize
-{
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
-
- useAltNamespace = [ud boolForKey:@"SOGoSpecialFoldersInRoot"];
-}
-
- (void) _adjustOwner
{
SOGoMailAccount *mailAccount;
menus["searchMenu"] = new Array(setSearchCriteria, setSearchCriteria,
setSearchCriteria, setSearchCriteria,
setSearchCriteria);
- $("label-menu").prepareVisibility = onLabelMenuPrepareVisibility;
+ var labelMenu = $("label-menu");
+ if (labelMenu)
+ labelMenu.prepareVisibility = onLabelMenuPrepareVisibility;
return menus;
}
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");
//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");
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; }');
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);
}
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);
}
}
else
i++;
}
- refreshEvents();
- refreshTasks();
- changeCalendarDisplay();
+ removeFolderRequestCount--;
+ if (removeFolderRequestCount == 0) {
+ refreshEvents();
+ refreshTasks();
+ changeCalendarDisplay();
+ }
}
- document.deletePersonalCalendarAjaxRequest = null;
}
else
log ("ajax problem 5: " + http.status);
var queryParameters;
-var activeAjaxRequests = 0;
var menus = new Array();
var search = {};
var sorting = {};
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();
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;
}
}
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!"]);
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);
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)