From d940a84da87bcf4c164344fa7018cbf96ca1a920 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 10 Mar 2016 17:03:37 +1300 Subject: Expand group permissions in manager --- src/org/traccar/database/PermissionsManager.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/org') 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 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); } -- cgit v1.2.3