Monotone-Parent: c6248a9c3f974ff7df67b342040fdd9b3380477f

Monotone-Revision: b68be9f250b22568280f0f3fe29f6b42ed225aa1

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2007-12-06T20:50:20
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle 2007-12-06 20:50:20 +00:00
parent 126e270a5c
commit 5ccbed256a
3 changed files with 56 additions and 22 deletions

View file

@ -532,16 +532,34 @@ function onAddressBookNew(event) {
}
function appendAddressBook(name, folder) {
if (folder)
var owner;
if (folder) {
owner = getSubscribedFolderOwner(folder);
folder = accessToSubscribedFolder(folder);
}
else
folder = "/" + name;
if (!owner)
owner = UserLogin;
if ($(folder))
window.alert(clabels["You have already subscribed to that folder!"]);
else {
var contactFolders = $("contactFolders");
var items = contactFolders.childNodesWithTag("li");
var li = document.createElement("li");
$("contactFolders").appendChild(li);
// Add the calendar to the proper place
var i = getListIndexForFolder(items, owner, name);
if (i != items.length) // User is subscribed to other calendars of the same owner
contactFolders.insertBefore(li, items[i]);
else
contactFolders.appendChild(li);
li.setAttribute("id", folder);
li.setAttribute("owner", owner);
li.appendChild(document.createTextNode(name));
setEventsOnContactFolder(li);
}
@ -758,12 +776,18 @@ function onContactFoldersMenuPrepareVisibility() {
if (selected.length > 0) {
var folderOwner = selected[0].getAttribute("owner");
var modifyOption = $(this).down("ul").childElements().first();
var sharingOption = $(this).down("ul").childElements().last();
// Disable the "Sharing" option when address book is not owned by user
if (folderOwner == UserLogin || IsSuperUser)
// Disable the "Sharing" and "Modify" options when address book
// is not owned by user
if (folderOwner == UserLogin || IsSuperUser) {
modifyOption.removeClassName("disabled");
sharingOption.removeClassName("disabled");
else
}
else {
modifyOption.addClassName("disabled");
sharingOption.addClassName("disabled");
}
}
}

View file

@ -1548,25 +1548,13 @@ function appendCalendar(folderName, folderPath) {
window.alert(clabels["You have already subscribed to that folder!"]);
else {
var calendarList = $("calendarList");
var lis = calendarList.childNodesWithTag("li");
var items = calendarList.childNodesWithTag("li");
var li = document.createElement("li");
// Add the calendar to the proper place
var previousOwner = null;
for (var i = 0; i < lis.length; i++) {
var currentFolderName = lis[i].lastChild.nodeValue.strip();
var currentOwner = lis[i].readAttribute('owner');
if (currentOwner == owner) {
previousOwner = currentOwner;
if (currentFolderName > folderName)
break;
}
else if (previousOwner ||
(currentOwner != UserLogin && currentOwner > owner))
break;
}
if (i != lis.length) // User is subscribed to other calendars of the same owner
calendarList.insertBefore(li, lis[i]);
var i = getListIndexForFolder(items, owner, folderName);
if (i != items.length) // User is subscribed to other calendars of the same owner
calendarList.insertBefore(li, items[i]);
else
calendarList.appendChild(li);
@ -1575,7 +1563,7 @@ function appendCalendar(folderName, folderPath) {
// Generate new color
if (calendarColorIndex == null)
calendarColorIndex = lis.length;
calendarColorIndex = items.length;
calendarColorIndex++;
var colorTable = [1, 1, 1];
var color;

View file

@ -1070,6 +1070,28 @@ function getSubscribedFolderOwner(serverFolder) {
return owner;
}
function getListIndexForFolder(items, owner, folderName) {
var i;
var previousOwner = null;
for (var i = 0; i < items.length; i++) {
var currentFolderName = items[i].lastChild.nodeValue.strip();
var currentOwner = items[i].readAttribute('owner');
if (currentOwner == owner) {
previousOwner = currentOwner;
if (currentFolderName > folderName)
break;
}
else if (previousOwner ||
(currentOwner != UserLogin && currentOwner > owner))
break;
else if (currentOwner == "nobody")
break;
}
return i;
}
function listRowMouseDownHandler(event) {
preventDefault(event);
//Event.stop(event);