2009-07-19 18:41:42 +02:00
|
|
|
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2008-08-28 16:48:45 +02:00
|
|
|
|
2006-12-14 21:20:40 +01:00
|
|
|
/* test */
|
|
|
|
|
|
|
|
var contactSelectorAction = 'acls-contacts';
|
2007-05-18 01:07:31 +02:00
|
|
|
var defaultUserID = '';
|
2007-11-20 18:11:26 +01:00
|
|
|
var AclEditor = {
|
|
|
|
userRightsHeight: null,
|
|
|
|
userRightsWidth: null
|
|
|
|
};
|
2006-12-14 21:20:40 +01:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function addUser(userName, userID) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var result = false;
|
|
|
|
if (!$(userID)) {
|
|
|
|
var ul = $("userList");
|
|
|
|
ul.appendChild(nodeForUser(userName, userID));
|
|
|
|
var url = window.location.href;
|
|
|
|
var elements = url.split("/");
|
|
|
|
elements[elements.length-1] = ("addUserInAcls?uid="
|
|
|
|
+ userID);
|
|
|
|
triggerAjaxRequest(elements.join("/"), addUserCallback);
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
return result;
|
2006-12-14 21:20:40 +01:00
|
|
|
}
|
|
|
|
|
2007-04-17 15:56:19 +02:00
|
|
|
function addUserCallback(http) {
|
2009-06-02 21:45:07 +02:00
|
|
|
// Ignore response
|
2007-04-17 15:56:19 +02:00
|
|
|
}
|
|
|
|
|
2007-05-18 01:07:31 +02:00
|
|
|
function setEventsOnUserNode(node) {
|
2008-08-09 03:53:09 +02:00
|
|
|
var n = $(node);
|
|
|
|
n.observe("mousedown", listRowMouseDownHandler);
|
|
|
|
n.observe("selectstart", listRowMouseDownHandler);
|
|
|
|
n.observe("dblclick", onOpenUserRights);
|
|
|
|
n.observe("click", onRowClick);
|
2007-05-18 01:07:31 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:11:08 +01:00
|
|
|
function nodeForUser(userName, userId) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var node = document.createElement("li");
|
|
|
|
node.setAttribute("id", userId);
|
|
|
|
node.setAttribute("class", "");
|
|
|
|
setEventsOnUserNode(node);
|
2006-12-14 21:20:40 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
var image = document.createElement("img");
|
|
|
|
image.setAttribute("src", ResourcesURL + "/abcard.gif");
|
2006-12-14 21:20:40 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
node.appendChild(image);
|
|
|
|
node.appendChild(document.createTextNode(" " + userName));
|
2006-12-14 21:20:40 +01:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
return node;
|
2006-12-14 21:20:40 +01:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:11:08 +01:00
|
|
|
function saveAcls() {
|
2008-08-28 16:48:45 +02:00
|
|
|
var uidList = new Array();
|
|
|
|
var users = $("userList").childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < users.length; i++)
|
|
|
|
uidList.push(users[i].getAttribute("id"));
|
|
|
|
$("userUIDS").value = uidList.join(",");
|
|
|
|
$("aclForm").submit();
|
|
|
|
|
|
|
|
return false;
|
2007-01-03 22:11:08 +01:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function onUserAdd(event) {
|
2008-08-28 16:48:45 +02:00
|
|
|
openUserFolderSelector(null, "user");
|
2007-03-29 20:05:23 +02:00
|
|
|
|
2008-08-28 16:48:45 +02:00
|
|
|
preventDefault(event);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
2007-05-11 23:45:33 +02:00
|
|
|
function removeUserCallback(http) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var node = http.callbackData;
|
2007-05-11 23:45:33 +02:00
|
|
|
|
|
|
|
if (http.readyState == 4
|
2008-09-11 20:15:01 +02:00
|
|
|
&& isHttpStatus204(http.status))
|
2008-08-28 16:48:45 +02:00
|
|
|
node.parentNode.removeChild(node);
|
2007-05-11 23:45:33 +02:00
|
|
|
else
|
2008-08-28 16:48:45 +02:00
|
|
|
log("error deleting user: " + node.getAttribute("id"));
|
2007-05-11 23:45:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function onUserRemove(event) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var userList = $("userList");
|
|
|
|
var nodes = userList.getSelectedRows();
|
|
|
|
|
|
|
|
var url = window.location.href;
|
|
|
|
var elements = url.split("/");
|
|
|
|
elements[elements.length-1] = "removeUserFromAcls?uid=";
|
|
|
|
var baseURL = elements.join("/");
|
|
|
|
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
|
|
var userId = nodes[i].getAttribute("id");
|
|
|
|
triggerAjaxRequest(baseURL + userId, removeUserCallback, nodes[i]);
|
|
|
|
}
|
|
|
|
preventDefault(event);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
2007-01-03 22:11:08 +01:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function subscribeToFolder(refreshCallback, refreshCallbackData) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var result = true;
|
|
|
|
if (UserLogin != refreshCallbackData["folder"]) {
|
|
|
|
result = addUser(refreshCallbackData["folderName"],
|
|
|
|
refreshCallbackData["folder"]);
|
|
|
|
}
|
|
|
|
else
|
2009-09-11 22:25:06 +02:00
|
|
|
refreshCallbackData["window"].alert(label ("You cannot subscribe to a folder that you own!"));
|
2008-08-28 16:48:45 +02:00
|
|
|
return result;
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
2007-05-18 01:07:31 +02:00
|
|
|
function openRightsForUserID(userID) {
|
2008-08-28 16:48:45 +02:00
|
|
|
var url = window.location.href;
|
|
|
|
var elements = url.split("/");
|
|
|
|
elements[elements.length-1] = "userRights?uid=" + userID;
|
|
|
|
|
|
|
|
window.open(elements.join("/"), "",
|
|
|
|
"width=" + AclEditor.userRightsWidth
|
|
|
|
+ ",height=" + AclEditor.userRightsHeight
|
|
|
|
+ ",resizable=0,scrollbars=0,toolbar=0,"
|
|
|
|
+ "location=0,directories=0,status=0,menubar=0,copyhistory=0");
|
2007-05-18 01:07:31 +02:00
|
|
|
}
|
|
|
|
|
2007-04-17 15:56:19 +02:00
|
|
|
function openRightsForUser(button) {
|
|
|
|
var nodes = $("userList").getSelectedRows();
|
2007-05-18 01:07:31 +02:00
|
|
|
if (nodes.length > 0)
|
2008-08-28 16:48:45 +02:00
|
|
|
openRightsForUserID(nodes[0].getAttribute("id"));
|
2007-04-17 15:56:19 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-05-18 01:07:31 +02:00
|
|
|
function openRightsForDefaultUser(event) {
|
2008-08-28 16:48:45 +02:00
|
|
|
openRightsForUserID(defaultUserID);
|
|
|
|
preventDefault(event);
|
2007-05-18 01:07:31 +02:00
|
|
|
}
|
|
|
|
|
2007-04-17 15:56:19 +02:00
|
|
|
function onOpenUserRights(event) {
|
2008-08-28 16:48:45 +02:00
|
|
|
openRightsForUser();
|
|
|
|
preventDefault(event);
|
2007-04-17 15:56:19 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function onAclLoadHandler() {
|
2008-08-28 16:48:45 +02:00
|
|
|
defaultUserID = $("defaultUserID").value;
|
|
|
|
var defaultRolesBtn = $("defaultRolesBtn");
|
|
|
|
if (defaultRolesBtn)
|
|
|
|
defaultRolesBtn.observe("click", openRightsForDefaultUser);
|
|
|
|
var ul = $("userList");
|
|
|
|
var lis = ul.childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < lis.length; i++)
|
|
|
|
setEventsOnUserNode(lis[i]);
|
|
|
|
|
|
|
|
var buttonArea = $("userSelectorButtons");
|
|
|
|
if (buttonArea) {
|
|
|
|
var buttons = buttonArea.childNodesWithTag("a");
|
|
|
|
buttons[0].observe("click", onUserAdd);
|
|
|
|
buttons[1].observe("click", onUserRemove);
|
|
|
|
}
|
|
|
|
|
|
|
|
AclEditor['userRightsHeight'] = window.opener.getUsersRightsWindowHeight();
|
|
|
|
AclEditor['userRightsWidth'] = window.opener.getUsersRightsWindowWidth();
|
2007-01-03 22:11:08 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 22:09:14 +01:00
|
|
|
document.observe("dom:loaded", onAclLoadHandler);
|