public GetChildren ( int id, int rootGroupId, bool limitToSecurityRoleGroups, List |
||
id | int | The ID of the Group to get the children of (or 0 to use rootGroupId) |
rootGroupId | int | The root group ID |
limitToSecurityRoleGroups | bool | if set to |
groupTypeIncludedIds | List |
The group type included ids. |
groupTypeExcludedIds | List |
The group type excluded ids. |
includeInactiveGroups | bool | if set to |
limitToShowInNavigation | bool | if set to |
return | IQueryable |
/// <summary> /// Finds the first group. /// </summary> /// <returns></returns> private Group FindFirstGroup() { var groupService = new GroupService( new RockContext() ); var includedGroupTypeIds = hfGroupTypesInclude.Value.SplitDelimitedValues().AsIntegerList().Except( new List<int> { 0 } ).ToList(); var excludedGroupTypeIds = hfGroupTypesExclude.Value.SplitDelimitedValues().AsIntegerList().Except( new List<int> { 0 } ).ToList(); // if specific group types are specified, show the groups regardless of ShowInNavigation bool limitToShowInNavigation = !includedGroupTypeIds.Any(); var qry = groupService.GetChildren( 0, hfRootGroupId.ValueAsInt(), hfLimitToSecurityRoleGroups.Value.AsBoolean(), includedGroupTypeIds, excludedGroupTypeIds, !tglHideInactiveGroups.Checked, limitToShowInNavigation ); foreach ( var group in qry.OrderBy( g => g.Name ) ) { // return first group they are authorized to view if ( group.IsAuthorized( Authorization.VIEW, CurrentPerson ) ) { return group; } } return null; }