2006-12-14 21:20:40 +01:00
|
|
|
/* test */
|
|
|
|
|
|
|
|
var contactSelectorAction = 'acls-contacts';
|
2007-05-18 01:07:31 +02:00
|
|
|
var defaultUserID = '';
|
2006-12-14 21:20:40 +01:00
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function addUser(userName, userID) {
|
|
|
|
if (!$(userID)) {
|
|
|
|
var ul = $("userList");
|
|
|
|
ul.appendChild(nodeForUser(userName, userID));
|
2007-04-17 15:56:19 +02:00
|
|
|
var url = window.location.href;
|
|
|
|
var elements = url.split("/");
|
|
|
|
elements[elements.length-1] = ("addUserInAcls?uid="
|
|
|
|
+ userID);
|
|
|
|
triggerAjaxRequest(elements.join("/"), addUserCallback);
|
2006-12-14 21:20:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-17 15:56:19 +02:00
|
|
|
function addUserCallback(http) {
|
|
|
|
}
|
|
|
|
|
2007-05-18 01:07:31 +02:00
|
|
|
function setEventsOnUserNode(node) {
|
|
|
|
Event.observe(node, "mousedown", listRowMouseDownHandler);
|
|
|
|
Event.observe(node, "dblclick", onOpenUserRights);
|
|
|
|
Event.observe(node, "click", onRowClick);
|
|
|
|
}
|
|
|
|
|
2007-01-03 22:11:08 +01:00
|
|
|
function nodeForUser(userName, userId) {
|
2006-12-14 21:20:40 +01:00
|
|
|
var node = document.createElement("li");
|
2007-03-29 20:05:23 +02:00
|
|
|
node.setAttribute("id", userId);
|
2006-12-14 21:20:40 +01:00
|
|
|
node.setAttribute("class", "");
|
2007-05-18 01:07:31 +02:00
|
|
|
setEventsOnUserNode(node);
|
2006-12-14 21:20:40 +01:00
|
|
|
|
2007-01-03 22:11:08 +01:00
|
|
|
var image = document.createElement("img");
|
|
|
|
image.setAttribute("src", ResourcesURL + "/abcard.gif");
|
2006-12-14 21:20:40 +01:00
|
|
|
|
2007-01-03 22:11:08 +01:00
|
|
|
node.appendChild(image);
|
|
|
|
node.appendChild(document.createTextNode(" " + userName));
|
2006-12-14 21:20:40 +01:00
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2007-01-03 22:11:08 +01:00
|
|
|
function saveAcls() {
|
2007-04-17 15:56:19 +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) {
|
|
|
|
openUserFolderSelector(null, "user");
|
|
|
|
|
2007-06-28 20:29:59 +02:00
|
|
|
preventDefault(event);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
2007-05-11 23:45:33 +02:00
|
|
|
function removeUserCallback(http) {
|
|
|
|
var node = http.callbackData;
|
|
|
|
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& http.status == 204)
|
|
|
|
node.parentNode.removeChild(node);
|
|
|
|
else
|
|
|
|
log("error deleting user: " + node.getAttribute("id"));
|
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function onUserRemove(event) {
|
2007-04-17 15:56:19 +02:00
|
|
|
var userList = $("userList");
|
|
|
|
var nodes = userList.getSelectedRows();
|
2007-05-11 23:45:33 +02:00
|
|
|
|
|
|
|
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]);
|
|
|
|
}
|
2007-06-28 20:29:59 +02:00
|
|
|
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) {
|
2007-07-31 23:14:14 +02:00
|
|
|
if (UserLogin != refreshCallbackData["folder"]) {
|
|
|
|
addUser(refreshCallbackData["folderName"],
|
|
|
|
refreshCallbackData["folder"]);
|
|
|
|
}
|
|
|
|
else
|
2007-09-14 23:54:19 +02:00
|
|
|
refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]);
|
2007-03-29 20:05:23 +02:00
|
|
|
}
|
|
|
|
|
2007-05-18 01:07:31 +02:00
|
|
|
function openRightsForUserID(userID) {
|
|
|
|
var url = window.location.href;
|
|
|
|
var elements = url.split("/");
|
|
|
|
elements[elements.length-1] = "userRights?uid=" + userID;
|
|
|
|
|
|
|
|
window.open(elements.join("/"), "",
|
|
|
|
"width=" + this.userRightsWidth
|
|
|
|
+ ",height=" + this.userRightsHeight
|
|
|
|
+ ",resizable=0,scrollbars=0,toolbar=0,"
|
|
|
|
+ "location=0,directories=0,status=0,menubar=0,copyhistory=0");
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
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) {
|
|
|
|
openRightsForUserID(defaultUserID);
|
2007-06-28 20:29:59 +02:00
|
|
|
preventDefault(event);
|
2007-05-18 01:07:31 +02:00
|
|
|
}
|
|
|
|
|
2007-04-17 15:56:19 +02:00
|
|
|
function onOpenUserRights(event) {
|
2007-04-25 00:34:04 +02:00
|
|
|
openRightsForUser();
|
2007-06-28 20:29:59 +02:00
|
|
|
preventDefault(event);
|
2007-04-17 15:56:19 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:05:23 +02:00
|
|
|
function onAclLoadHandler() {
|
2007-05-18 01:07:31 +02:00
|
|
|
defaultUserID = $("defaultUserID").value;
|
2007-05-19 02:43:40 +02:00
|
|
|
var defaultRolesBtn = $("defaultRolesBtn");
|
|
|
|
if (defaultRolesBtn)
|
|
|
|
Event.observe(defaultRolesBtn, "click", openRightsForDefaultUser);
|
2007-05-18 01:07:31 +02:00
|
|
|
var ul = $("userList");
|
|
|
|
var lis = ul.childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < lis.length; i++)
|
|
|
|
setEventsOnUserNode(lis[i]);
|
|
|
|
|
2007-05-22 16:38:54 +02:00
|
|
|
var buttonArea = $("userSelectorButtons");
|
|
|
|
if (buttonArea) {
|
|
|
|
var buttons = buttonArea.childNodesWithTag("a");
|
|
|
|
Event.observe(buttons[0], "click", onUserAdd);
|
|
|
|
Event.observe(buttons[1], "click", onUserRemove);
|
|
|
|
}
|
2007-05-18 01:07:31 +02:00
|
|
|
|
|
|
|
this.userRightsHeight = window.opener.getUsersRightsWindowHeight();
|
|
|
|
this.userRightsWidth = window.opener.getUsersRightsWindowWidth();
|
2007-01-03 22:11:08 +01:00
|
|
|
}
|
|
|
|
|
2007-11-15 20:02:23 +01:00
|
|
|
FastInit.addOnLoad(onAclLoadHandler);
|