|
55 | 55 | import org.labkey.api.data.PropertyManager.WritablePropertyMap; |
56 | 56 | import org.labkey.api.data.RuntimeSQLException; |
57 | 57 | import org.labkey.api.data.SQLFragment; |
58 | | -import org.labkey.api.data.Selector; |
59 | 58 | import org.labkey.api.data.SimpleFilter; |
60 | 59 | import org.labkey.api.data.SqlExecutor; |
61 | 60 | import org.labkey.api.data.SqlSelector; |
@@ -1883,126 +1882,6 @@ public static String getMembershipPathwayHTMLDisplay(Set<List<UserPrincipal>> pa |
1883 | 1882 | sb.append("<BR/>"); |
1884 | 1883 | } |
1885 | 1884 | return sb.toString(); |
1886 | | - } |
1887 | | - |
1888 | | - // TODO: Redundant with getProjectUsers() -- this approach should be more efficient for simple cases |
1889 | | - // TODO: Also redundant with getFolderUserids() |
1890 | | - // TODO: Cache this set |
1891 | | - public static Set<Integer> getProjectUsersIds(Container c) |
1892 | | - { |
1893 | | - SQLFragment sql = getProjectUsersSQL(c.getProject()); |
1894 | | - sql.insert(0, "SELECT DISTINCT members.UserId "); |
1895 | | - |
1896 | | - Selector selector = new SqlSelector(core.getSchema(), sql); |
1897 | | - return new HashSet<>(selector.getCollection(Integer.class)); |
1898 | | - } |
1899 | | - |
1900 | | - // True fragment -- need to prepend SELECT DISTINCT() or IN () for this to be valid SQL |
1901 | | - public static SQLFragment getProjectUsersSQL(Container c) |
1902 | | - { |
1903 | | - return new SQLFragment("FROM " + core.getTableInfoMembers() + " members INNER JOIN " + core.getTableInfoUsers() + " users ON members.UserId = users.UserId\n" + |
1904 | | - "INNER JOIN " + core.getTableInfoPrincipals() + " groups ON members.GroupId = groups.UserId\n" + |
1905 | | - "WHERE (groups.Container = ?)", c); |
1906 | | - } |
1907 | | - |
1908 | | - public static @NotNull List<User> getProjectUsers(Container c) |
1909 | | - { |
1910 | | - return getProjectUsers(c, false, true); |
1911 | | - } |
1912 | | - |
1913 | | - public static @NotNull List<User> getProjectUsers(Container c, boolean includeGlobal, boolean includeInactive) |
1914 | | - { |
1915 | | - if (c != null && !c.isProject()) |
1916 | | - c = c.getProject(); |
1917 | | - |
1918 | | - List<Group> groups = getGroups(c, includeGlobal); |
1919 | | - Set<String> emails = new HashSet<>(); |
1920 | | - |
1921 | | - //get members for each group |
1922 | | - ArrayList<User> projectUsers = new ArrayList<>(); |
1923 | | - Set<User> members; |
1924 | | - |
1925 | | - for (Group g : groups) |
1926 | | - { |
1927 | | - if (g.isGuests() || g.isUsers()) |
1928 | | - continue; |
1929 | | - |
1930 | | - // TODO: currently only getting members that are users (no groups). should this be changed to get users of member groups? |
1931 | | - members = getGroupMembers(g, includeInactive ? MemberType.ACTIVE_AND_INACTIVE_USERS : MemberType.ACTIVE_USERS); |
1932 | | - |
1933 | | - //add this group's members to hashset |
1934 | | - if (!members.isEmpty()) |
1935 | | - { |
1936 | | - //get list of users from email |
1937 | | - for (UserPrincipal member : members) |
1938 | | - { |
1939 | | - User user = UserManager.getUser(member.getUserId()); |
1940 | | - if (null != user && emails.add(user.getEmail())) |
1941 | | - projectUsers.add(user); |
1942 | | - } |
1943 | | - } |
1944 | | - } |
1945 | | - |
1946 | | - return projectUsers; |
1947 | | - } |
1948 | | - |
1949 | | - public static Collection<Integer> getFolderUserids(Container c) |
1950 | | - { |
1951 | | - Container project = (c.isProject() || c.isRoot()) ? c : c.getProject(); |
1952 | | - SecurityPolicy policy = c.getPolicy(); |
1953 | | - |
1954 | | - //don't filter if all site users is playing a role |
1955 | | - Group allSiteUsers = getGroup(Group.groupUsers); |
1956 | | - if (policy.getAssignedRoles(allSiteUsers).findAny().isPresent()) |
1957 | | - { |
1958 | | - // Just select all users |
1959 | | - SQLFragment sql = new SQLFragment("SELECT u.UserId FROM "); |
1960 | | - sql.append(core.getTableInfoPrincipals(), "u"); |
1961 | | - sql.append(" WHERE u.type='u'"); |
1962 | | - |
1963 | | - return new SqlSelector(core.getSchema(), sql).getCollection(Integer.class); |
1964 | | - } |
1965 | | - |
1966 | | - //users "in the project" consists of: |
1967 | | - // - users who are members of a project group |
1968 | | - // - users who belong to a site group that has a role assignment in the policy for the specified folder |
1969 | | - // - users who have a direct role assignment in the policy for the specified folder |
1970 | | - |
1971 | | - Set<Integer> userIds = new HashSet<>(); |
1972 | | - |
1973 | | - // Add all project groups |
1974 | | - Set<Group> groupsToExpand = new HashSet<>(getGroups(project, false)); |
1975 | | - |
1976 | | - // Look for users and site groups that have direct assignment to the container |
1977 | | - for (RoleAssignment roleAssignment : c.getPolicy().getAssignments()) |
1978 | | - { |
1979 | | - User user = UserManager.getUser(roleAssignment.getUserId()); |
1980 | | - if (user != null) |
1981 | | - { |
1982 | | - userIds.add(user.getUserId()); |
1983 | | - } |
1984 | | - else |
1985 | | - { |
1986 | | - Group assignedGroup = getGroup(roleAssignment.getUserId()); |
1987 | | - if (assignedGroup != null && !assignedGroup.isProjectGroup()) |
1988 | | - { |
1989 | | - // Add all site groups |
1990 | | - groupsToExpand.add(assignedGroup); |
1991 | | - } |
1992 | | - } |
1993 | | - } |
1994 | | - |
1995 | | - // Find the users who are members of all the relevant site groups |
1996 | | - for (Group group : groupsToExpand) |
1997 | | - { |
1998 | | - Set<User> groupMembers = getAllGroupMembers(group, MemberType.ACTIVE_AND_INACTIVE_USERS); |
1999 | | - for (User groupMember : groupMembers) |
2000 | | - { |
2001 | | - userIds.add(groupMember.getUserId()); |
2002 | | - } |
2003 | | - } |
2004 | | - |
2005 | | - return userIds; |
2006 | 1885 | } |
2007 | 1886 |
|
2008 | 1887 | /** |
|
0 commit comments