aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/PermissionsManager.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-12-27 16:38:13 +0500
committerAbyss777 <abyss@fox5.ru>2017-12-27 16:38:13 +0500
commitd489eac12119ed62f899569db121364b20b1c9dc (patch)
treeaac938b2511bb9d45a7048236b93c6d740c457be /src/org/traccar/database/PermissionsManager.java
parentf128ed17780ad56dfd889d617f518cc0310a96a7 (diff)
downloadtrackermap-server-d489eac12119ed62f899569db121364b20b1c9dc.tar.gz
trackermap-server-d489eac12119ed62f899569db121364b20b1c9dc.tar.bz2
trackermap-server-d489eac12119ed62f899569db121364b20b1c9dc.zip
Implement device disable
Diffstat (limited to 'src/org/traccar/database/PermissionsManager.java')
-rw-r--r--src/org/traccar/database/PermissionsManager.java23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 0e9097d25..60bda99ce 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -74,13 +74,28 @@ public class PermissionsManager {
return devicePermissions.get(userId);
}
- public Set<Long> getDeviceUsers(long deviceId) {
+ private Set<Long> getAllDeviceUsers(long deviceId) {
if (!deviceUsers.containsKey(deviceId)) {
deviceUsers.put(deviceId, new HashSet<Long>());
}
return deviceUsers.get(deviceId);
}
+ public Set<Long> getDeviceUsers(long deviceId) {
+ Device device = Context.getIdentityManager().getById(deviceId);
+ if (device != null && !device.getDisabled()) {
+ return getAllDeviceUsers(deviceId);
+ } else {
+ Set<Long> result = new HashSet<>();
+ for (long userId : getAllDeviceUsers(deviceId)) {
+ if (getUserAdmin(userId)) {
+ result.add(userId);
+ }
+ }
+ return result;
+ }
+ }
+
public Set<Long> getGroupDevices(long groupId) {
if (!groupDevices.containsKey(groupId)) {
groupDevices.put(groupId, new HashSet<Long>());
@@ -133,7 +148,7 @@ public class PermissionsManager {
deviceUsers.clear();
for (Map.Entry<Long, Set<Long>> entry : devicePermissions.entrySet()) {
for (long deviceId : entry.getValue()) {
- getDeviceUsers(deviceId).add(entry.getKey());
+ getAllDeviceUsers(deviceId).add(entry.getKey());
}
}
}
@@ -179,9 +194,9 @@ public class PermissionsManager {
if (deviceLimit != -1) {
int deviceCount = 0;
if (getUserManager(userId)) {
- deviceCount = Context.getDeviceManager().getManagedItems(userId).size();
+ deviceCount = Context.getDeviceManager().getAllManagedItems(userId).size();
} else {
- deviceCount = Context.getDeviceManager().getUserItems(userId).size();
+ deviceCount = Context.getDeviceManager().getAllUserItems(userId).size();
}
if (deviceCount >= deviceLimit) {
throw new SecurityException("User device limit reached");