aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/PermissionsManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/database/PermissionsManager.java')
-rw-r--r--src/org/traccar/database/PermissionsManager.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 022691b1b..0aefb9605 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -22,7 +22,9 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.traccar.helper.Log;
+import org.traccar.model.Device;
import org.traccar.model.DevicePermission;
+import org.traccar.model.Group;
import org.traccar.model.GroupPermission;
import org.traccar.model.Server;
import org.traccar.model.User;
@@ -66,12 +68,24 @@ public class PermissionsManager {
for (User user : dataManager.getUsers()) {
users.put(user.getId(), user);
}
+
+ GroupTree groupTree = new GroupTree(dataManager.getAllGroups());
+ for (GroupPermission permission : dataManager.getGroupPermissions()) {
+ Set<Long> userGroupPermissions = getGroupPermissions(permission.getUserId());
+ userGroupPermissions.add(permission.getGroupId());
+ for (Group group : groupTree.getDescendants(permission.getGroupId())) {
+ userGroupPermissions.add(group.getId());
+ }
+ }
+
for (DevicePermission permission : dataManager.getDevicePermissions()) {
getDevicePermissions(permission.getUserId()).add(permission.getDeviceId());
}
- for (GroupPermission permission : dataManager.getGroupPermissions()) {
- getGroupPermissions(permission.getUserId()).add(permission.getGroupId());
+
+ for (Device device : dataManager.getAllDevices()) {
+ // TODO
}
+
} catch (SQLException error) {
Log.warning(error);
}