本文整理汇总了C#中Rock.Model.GroupService.IsAuthorized方法的典型用法代码示例。如果您正苦于以下问题:C# GroupService.IsAuthorized方法的具体用法?C# GroupService.IsAuthorized怎么用?C# GroupService.IsAuthorized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.GroupService
的用法示例。
在下文中一共展示了GroupService.IsAuthorized方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMapInfoWindow
public InfoWindowResult GetMapInfoWindow( int groupId, int locationId, [FromBody] InfoWindowRequest infoWindowDetails )
{
// Enable proxy creation since security is being checked and need to navigate parent authorities
SetProxyCreation( true );
// Use new service with new context so properties can be navigated by liquid
var group = new GroupService( new RockContext() ).Queryable( "GroupType,GroupLocations.Location,Campus,Members.Person" )
.Where( g => g.Id == groupId )
.FirstOrDefault();
if ( group != null )
{
var person = GetPerson();
if ( group.IsAuthorized( Rock.Security.Authorization.VIEW, person ) )
{
string infoWindow = group.Name;
if ( infoWindowDetails != null )
{
var groupPageParams = new Dictionary<string, string>();
groupPageParams.Add( "GroupId", group.Id.ToString() );
var groupDetailUrl = new PageReference( infoWindowDetails.GroupPage, groupPageParams ).BuildUrl();
var personPageParams = new Dictionary<string, string>();
personPageParams.Add( "PersonId", string.Empty );
var personProfileUrl = new PageReference( infoWindowDetails.PersonProfilePage, personPageParams ).BuildUrl();
var mapPageParams = new Dictionary<string, string>();
mapPageParams.Add( "GroupId", group.Id.ToString() );
var groupMapUrl = new PageReference( infoWindowDetails.MapPage, mapPageParams ).BuildUrl();
var grouplocation = group.GroupLocations
.Where( g => g.LocationId == locationId )
.FirstOrDefault();
dynamic dynGroup = new ExpandoObject();
dynGroup.GroupId = group.Id;
dynGroup.GroupName = group.Name;
dynGroup.DetailPageUrl = groupDetailUrl;
dynGroup.MapPageUrl = groupMapUrl;
var dictCampus = new Dictionary<string, object>();
dictCampus.Add( "Name", group.Campus != null ? group.Campus.Name : string.Empty );
dynGroup.Campus = dictCampus;
var dictGroupType = new Dictionary<string, object>();
dictGroupType.Add( "Id", group.GroupType.Id );
dictGroupType.Add( "Guid", group.GroupType.Guid.ToString().ToUpper() );
dictGroupType.Add( "GroupTerm", group.GroupType.GroupTerm );
dictGroupType.Add( "GroupMemberTerm", group.GroupType.GroupMemberTerm );
dynGroup.GroupType = dictGroupType;
var dictLocation = new Dictionary<string, object>();
dictLocation.Add( "Type", grouplocation.GroupLocationTypeValue.Value );
dictLocation.Add( "Address", grouplocation.Location.GetFullStreetAddress().ConvertCrLfToHtmlBr() );
dictLocation.Add( "Street1", grouplocation.Location.Street1 );
dictLocation.Add( "Street2", grouplocation.Location.Street2 );
dictLocation.Add( "City", grouplocation.Location.City );
dictLocation.Add( "State", grouplocation.Location.State );
dictLocation.Add( "PostalCode", grouplocation.Location.PostalCode );
dictLocation.Add( "Country", grouplocation.Location.Country );
dynGroup.Location = dictLocation;
var members = new List<Dictionary<string, object>>();
foreach ( var member in group.Members.OrderBy( m => m.GroupRole.Order ).ThenBy( m => m.Person.BirthDate ) )
{
var dictMember = new Dictionary<string, object>();
dictMember.Add( "PersonId", member.Person.Id );
dictMember.Add( "ProfilePageUrl", personProfileUrl + member.Person.Id.ToString() );
dictMember.Add( "Role", member.GroupRole.Name );
dictMember.Add( "NickName", member.Person.NickName );
dictMember.Add( "LastName", member.Person.LastName );
dictMember.Add( "PhotoUrl", member.Person.PhotoId.HasValue ? member.Person.PhotoUrl : string.Empty );
dictMember.Add( "PhotoId", member.Person.PhotoId );
dictMember.Add(
"ConnectionStatus",
member.Person.ConnectionStatusValue != null ? member.Person.ConnectionStatusValue.Value : string.Empty );
dictMember.Add( "Email", member.Person.Email );
var phoneTypes = new List<Dictionary<string, object>>();
foreach ( PhoneNumber p in member.Person.PhoneNumbers )
{
var dictPhoneNumber = new Dictionary<string, object>();
dictPhoneNumber.Add( "Name", p.NumberTypeValue.Value );
dictPhoneNumber.Add( "Number", p.ToString() );
phoneTypes.Add( dictPhoneNumber );
}
dictMember.Add( "PhoneTypes", phoneTypes );
members.Add( dictMember );
}
dynGroup.Members = members;
var groupDict = dynGroup as IDictionary<string, object>;
string result = System.Web.HttpUtility.HtmlDecode( infoWindowDetails.Template ).ResolveMergeFields( groupDict );
return new InfoWindowResult( result );
//.........这里部分代码省略.........
示例2: ShowDetail
/// <summary>
/// Shows the detail.
/// </summary>
/// <param name="itemKey">The item key.</param>
/// <param name="itemKeyValue">The group id.</param>
public void ShowDetail( string itemKey, int itemKeyValue, int? parentGroupId )
{
pnlDetails.Visible = false;
if ( !itemKey.Equals( "groupId" ) )
{
return;
}
bool editAllowed = true;
Group group = null;
if ( !itemKeyValue.Equals( 0 ) )
{
group = new GroupService().Get( itemKeyValue );
if ( group != null )
{
editAllowed = group.IsAuthorized( "Edit", CurrentPerson );
}
}
else
{
group = new Group { Id = 0, IsActive = true, ParentGroupId = parentGroupId };
wpGeneral.Expanded = true;
}
if ( group == null )
{
return;
}
pnlDetails.Visible = true;
hfGroupId.Value = group.Id.ToString();
// render UI based on Authorized and IsSystem
bool readOnly = false;
nbEditModeMessage.Text = string.Empty;
if ( !editAllowed || !IsUserAuthorized( "Edit" ) )
{
readOnly = true;
nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( Group.FriendlyTypeName );
}
if ( group.IsSystem )
{
nbEditModeMessage.Text = EditModeMessage.System( Group.FriendlyTypeName );
}
var roleLimitWarnings = new StringBuilder();
if ( group.GroupType != null && group.GroupType.Roles != null && group.GroupType.Roles.Any() )
{
foreach ( var role in group.GroupType.Roles )
{
int curCount = 0;
if ( group.Members != null )
{
curCount = group.Members
.Where( m => m.GroupRoleId == role.Id && m.GroupMemberStatus == GroupMemberStatus.Active )
.Count();
}
if ( role.MinCount.HasValue && role.MinCount.Value > curCount )
{
roleLimitWarnings.AppendFormat( "The <strong>{1}</strong> role is currently below its minimum requirement of {2:N0} active {3}.<br/>",
role.Name.Pluralize(), role.Name, role.MinCount, role.MinCount == 1 ? group.GroupType.GroupMemberTerm : group.GroupType.GroupMemberTerm.Pluralize() );
}
if ( role.MaxCount.HasValue && role.MaxCount.Value < curCount )
{
roleLimitWarnings.AppendFormat( "The <strong>{1}</strong> role is currently above its maximum limit of {2:N0} active {3}.<br/>",
role.Name.Pluralize(), role.Name, role.MaxCount, role.MaxCount == 1 ? group.GroupType.GroupMemberTerm : group.GroupType.GroupMemberTerm.Pluralize() );
}
}
}
nbRoleLimitWarning.Text = roleLimitWarnings.ToString();
nbRoleLimitWarning.Visible = roleLimitWarnings.Length > 0;
if ( readOnly )
{
btnEdit.Visible = false;
btnDelete.Visible = false;
ShowReadonlyDetails( group );
}
else
{
btnEdit.Visible = true;
btnDelete.Visible = !group.IsSystem;
if ( group.Id > 0 )
{
ShowReadonlyDetails( group );
}
else
//.........这里部分代码省略.........