';
var count = 1;
if (currentNode.links != null) {
// Sort the list of users to display
@@ -5065,20 +5065,14 @@
for (var i in currentNode.links) { if (i.startsWith('user/')) { useridlist.push(i); } }
useridlist.sort();
for (var i in useridlist) {
- var trash = '', rights = '', userid = useridlist[i], srights = currentNode.links[userid].rights, rights = "Some Added Rights", username = userid.split('/')[2];
- if ((users != null) && (users[userid] != null)) { username = users[userid].name; }
-
- /*
- var node = nodelist[i], r = currentUser.links[node._id].rights, trash = '', rights = "Partial Device Rights", cr = GetNodeRights(node);
- if ((userinfo.links) && (userinfo.links[i] != null) && (userinfo.links[i].rights != null)) { cr = userinfo.links[i].rights; }
- var nodename = node?EscapeHtml(node.name):('' + "Unknown Device" + '');
- */
- if (srights == 0xFFFFFFFF) rights = "Full Device Rights"; else if (srights == 0) rights = "No Added Rights";
+ var trash = '', rights = '', userid = useridlist[i], srights = currentNode.links[userid].rights, username = EscapeHtml(userid.split('/')[2]), rights = makeUserDeviceRightsString(srights);
+ if ((users != null) && (users[userid] != null)) { username = EscapeHtml(users[userid].name); }
if ((meshrights & 2) != 0) {
- rights = '
' + rights + '
';
+ rights = '
' + rights + '
';
trash = '';
}
- x += '
' + username + '
' + trash + '
' + rights + '
';
+ if (users != null) { username = '' + username + ''; }
+ x += '
' + username + '
' + trash + '
' + rights + '
';
}
}
if (count == 1) { x += '
' + "No users with special device permissions" + '
'; }
@@ -5099,6 +5093,30 @@
go(panel);
}
+ function makeUserDeviceRightsString(rights) {
+ if (rights == 57592) { return "Full Device Rights"; }
+ var str = [];
+ if (rights & 8) {
+ var str1 = [];
+ if (rights & 256) str1.push("No Input");
+ if (rights & 512) str1.push("No Terminal");
+ if (rights & 1024) str1.push("No Files");
+ if (rights & 2048) str1.push("No AMT");
+ if (rights & 4096) str1.push("Limited Input");
+ if (rights & 65536) str1.push("No Desktop");
+ if (str1.length > 0) { str.push('Control (' + str1.join(', ') + ')'); } else { str.push("Control"); }
+ }
+ if (rights & 16) str.push("Console");
+ if (rights & 32) str.push("Server Files");
+ if (rights & 64) str.push("Wake");
+ if (rights & 128) str.push("Notes");
+ if (rights & 8192) str.push("Limit Events");
+ if (rights & 16384) str.push("Chat");
+ if (rights & 32768) str.push("Uninstall");
+ if (str.length == 0) return "No Added Rights";
+ return str.join(', ');
+ }
+
function writeDeviceEvent(nodeid) {
if (xxdialogMode) return;
setDialogMode(2, "Add Device Event", 3, writeDeviceEventEx, '' + "This will add an entry to this device\'s event log." + '', nodeid);
@@ -8447,9 +8465,12 @@
if (xxdialogMode) return false;
var x = '';
if ((userid == null) || (userid == 5)) {
- if (userid == null) { x += "Allow users to manage this device group and devices in this group."; } else { x += "Allow users to manage this device."; }
- if (features & 0x00080000) { x += " Users need to login to this server once before they can be added to a device group." }
- x += '
';
+ if (selected == null) {
+ if (userid == null) { x += "Allow users to manage this device group and devices in this group."; } else { x += "Allow users to manage this device."; }
+ if (features & 0x00080000) { x += " Users need to login to this server once before they can be added to a device group." }
+ x += '
';
+ }
+ x += '
';
x += addHtmlValue("User Names", '');
x += '';
x += '
';
@@ -8522,7 +8543,29 @@
QE('dp2meshid', selected == null);
QE('dp2nodeid', selected == null);
} else if (userid === 5) {
- setDialogMode(2, "Add Users to Device", 3, p20showAddMeshUserDialogEx, x, userid);
+ setDialogMode(2, selected?"Edit User Device Permissions":"Add User Device Permissions", 3, p20showAddMeshUserDialogEx, x, userid);
+ if (selected != null) {
+ selected = decodeURIComponent(selected);
+ if ((users != null) && (users[selected] != null)) { Q('dp20username').value = users[selected].name; } else { Q('dp20username').value = selected.split('/')[2]; }
+ var urights = currentNode.links[selected].rights;
+ QE('dp20username', false);
+ if (urights & 8) {
+ Q('p20remotecontrol').checked = true;
+ if (urights & 65536) { Q('p20nodesktop').checked = true; }
+ if (urights & 256) { Q('p20remoteview').checked = true; }
+ if (urights & 512) { Q('p20noterminal').checked = true; }
+ if (urights & 1024) { Q('p20nofiles').checked = true; }
+ if (urights & 2048) { Q('p20noamt').checked = true; }
+ if (urights & 4096) { Q('p20remotelimitedinput').checked = true; }
+ }
+ if (urights & 16) { Q('p20meshagentconsole').checked = true; }
+ if (urights & 32) { Q('p20meshserverfiles').checked = true; }
+ if (urights & 64) { Q('p20wakedevices').checked = true; }
+ if (urights & 128) { Q('p20editnotes').checked = true; }
+ if (urights & 8192) { Q('p20limitevents').checked = true; }
+ if (urights & 16384) { Q('p20chatnotify').checked = true; }
+ if (urights & 32768) { Q('p20uninstall').checked = true; }
+ }
Q('dp20username').focus();
} else {
if (userid.startsWith('ugrp/')) {
@@ -10278,15 +10321,15 @@
for (var i in currentUser.links) { if (i.startsWith('node/')) { var node = getNodeFromId(i); if (node != null) { nodelist.push(node); } } }
nodelist.sort(nameSort);
for (var i in nodelist) {
- var node = nodelist[i], r = currentUser.links[node._id].rights, trash = '', rights = "Partial Device Rights", cr = GetNodeRights(node);
+ var node = nodelist[i], r = currentUser.links[node._id].rights, trash = '', cr = GetNodeRights(node);
if ((userinfo.links) && (userinfo.links[i] != null) && (userinfo.links[i].rights != null)) { cr = userinfo.links[i].rights; }
var nodename = node?EscapeHtml(node.name):('' + "Unknown Device" + '');
- if (r == 0xFFFFFFFF) rights = "Full Device Rights"; else if (r == 0) rights = "No Rights";
if ((cr & 2) != 0) {
- rights = '
'; }
@@ -11377,17 +11420,23 @@
if (userid == null) { userid = userinfo._id; }
if (typeof node == 'string') { node = getNodeFromId(node); if (node == null) { return 0; } }
var r = GetMeshRights(node.meshid, userid);
- if (r != 0xFFFFFFFF) {
- var user = null;
- if (userid == userinfo._id) { user = userinfo; } else { if (users != null) { user = users[userid]; } }
- if ((user != null) && (user.links != null)) {
- var r2 = user.links[node._id];
- if (r2 != null) {
- if (r2.rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device link, stop here.
- r |= r2; // TODO: Deal with reverse permissions
- }
+ if (r == 0xFFFFFFFF) return r;
+ var user = null;
+
+ // Check direct device rights using device data
+ if ((node.links != null) && (node.links[userid] != null)) { r |= node.links[userid].rights; } // TODO: Deal with reverse permissions
+
+ // Check direct device rights using user data
+ /*
+ if (userid == userinfo._id) { user = userinfo; } else { if (users != null) { user = users[userid]; } }
+ if ((user != null) && (user.links != null)) {
+ var r2 = user.links[node._id];
+ if (r2 != null) {
+ if (r2.rights == 0xFFFFFFFF) { return 0xFFFFFFFF; } // User has full rights thru a device link, stop here.
+ r |= r2.rights; // TODO: Deal with reverse permissions
}
}
+ */
return r;
}