3 var contactSelectorAction = 'acls-contacts';
4 var defaultUserID = '';
6 function addUser(userName, userID) {
8 var ul = $("userList");
9 ul.appendChild(nodeForUser(userName, userID));
10 var url = window.location.href;
11 var elements = url.split("/");
12 elements[elements.length-1] = ("addUserInAcls?uid="
14 triggerAjaxRequest(elements.join("/"), addUserCallback);
18 function addUserCallback(http) {
21 function setEventsOnUserNode(node) {
22 Event.observe(node, "mousedown", listRowMouseDownHandler);
23 Event.observe(node, "dblclick", onOpenUserRights);
24 Event.observe(node, "click", onRowClick);
27 function nodeForUser(userName, userId) {
28 var node = document.createElement("li");
29 node.setAttribute("id", userId);
30 node.setAttribute("class", "");
31 setEventsOnUserNode(node);
33 var image = document.createElement("img");
34 image.setAttribute("src", ResourcesURL + "/abcard.gif");
36 node.appendChild(image);
37 node.appendChild(document.createTextNode(" " + userName));
43 var uidList = new Array();
44 var users = $("userList").childNodesWithTag("li");
45 for (var i = 0; i < users.length; i++)
46 uidList.push(users[i].getAttribute("id"));
47 $("userUIDS").value = uidList.join(",");
48 $("aclForm").submit();
53 function onUserAdd(event) {
54 openUserFolderSelector(null, "user");
56 event.preventDefault();
59 function removeUserCallback(http) {
60 var node = http.callbackData;
62 if (http.readyState == 4
63 && http.status == 204)
64 node.parentNode.removeChild(node);
66 log("error deleting user: " + node.getAttribute("id"));
69 function onUserRemove(event) {
70 var userList = $("userList");
71 var nodes = userList.getSelectedRows();
73 var url = window.location.href;
74 var elements = url.split("/");
75 elements[elements.length-1] = "removeUserFromAcls?uid=";
76 var baseURL = elements.join("/");
78 for (var i = 0; i < nodes.length; i++) {
79 var userId = nodes[i].getAttribute("id");
80 triggerAjaxRequest(baseURL + userId, removeUserCallback, nodes[i]);
82 event.preventDefault();
85 function subscribeToFolder(refreshCallback, refreshCallbackData) {
86 addUser(refreshCallbackData["folderName"],
87 refreshCallbackData["folder"]);
90 function openRightsForUserID(userID) {
91 var url = window.location.href;
92 var elements = url.split("/");
93 elements[elements.length-1] = "userRights?uid=" + userID;
95 window.open(elements.join("/"), "",
96 "width=" + this.userRightsWidth
97 + ",height=" + this.userRightsHeight
98 + ",resizable=0,scrollbars=0,toolbar=0,"
99 + "location=0,directories=0,status=0,menubar=0,copyhistory=0");
102 function openRightsForUser(button) {
103 var nodes = $("userList").getSelectedRows();
104 if (nodes.length > 0)
105 openRightsForUserID(nodes[0].getAttribute("id"));
110 function openRightsForDefaultUser(event) {
111 openRightsForUserID(defaultUserID);
112 event.preventDefault();
115 function onOpenUserRights(event) {
117 event.preventDefault();
120 function onAclLoadHandler() {
121 defaultUserID = $("defaultUserID").value;
122 Event.observe($("defaultRolesBtn"), "click", openRightsForDefaultUser);
123 var ul = $("userList");
124 var lis = ul.childNodesWithTag("li");
125 for (var i = 0; i < lis.length; i++)
126 setEventsOnUserNode(lis[i]);
128 var buttons = $("userSelectorButtons").childNodesWithTag("a");
129 Event.observe(buttons[0], "click", onUserAdd);
130 Event.observe(buttons[1], "click", onUserRemove);
132 this.userRightsHeight = window.opener.getUsersRightsWindowHeight();
133 this.userRightsWidth = window.opener.getUsersRightsWindowWidth();
136 Event.observe(window, "load", onAclLoadHandler);