当前位置: 首页>>代码示例>>C#>>正文


C# GroupTypeService.IsAuthorized方法代码示例

本文整理汇总了C#中Rock.Model.GroupTypeService.IsAuthorized方法的典型用法代码示例。如果您正苦于以下问题:C# GroupTypeService.IsAuthorized方法的具体用法?C# GroupTypeService.IsAuthorized怎么用?C# GroupTypeService.IsAuthorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rock.Model.GroupTypeService的用法示例。


在下文中一共展示了GroupTypeService.IsAuthorized方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowDetail

        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail( string itemKey, int itemKeyValue )
        {
            pnlDetails.Visible = false;

            if ( !itemKey.Equals( "groupTypeId" ) )
            {
                return;
            }

            bool editAllowed = true;

            GroupType groupType = null;

            if ( !itemKeyValue.Equals( 0 ) )
            {
                groupType = new GroupTypeService( new RockContext() ).Get( itemKeyValue );
                editAllowed = groupType.IsAuthorized( Authorization.EDIT, CurrentPerson );
            }
            else
            {
                groupType = new GroupType { Id = 0, ShowInGroupList = true, GroupTerm = "Group", GroupMemberTerm = "Member" };
                groupType.ChildGroupTypes = new List<GroupType>();
                groupType.LocationTypes = new List<GroupTypeLocationType>();

                Guid defaultRoleGuid = Guid.NewGuid();
                var memberRole = new GroupTypeRole { Guid = defaultRoleGuid, Name = "Member" };
                groupType.Roles.Add( memberRole );
                groupType.DefaultGroupRole = memberRole;

                groupType.LocationSelectionMode = GroupLocationPickerMode.None;
            }

            if ( groupType == null )
            {
                return;
            }

            DefaultRoleGuid = groupType.DefaultGroupRole != null ? groupType.DefaultGroupRole.Guid : Guid.Empty;

            pnlDetails.Visible = true;
            hfGroupTypeId.Value = groupType.Id.ToString();

            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if ( !editAllowed || !IsUserAuthorized( Authorization.EDIT ) )
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed( GroupType.FriendlyTypeName );
            }

            if ( groupType.IsSystem )
            {
                nbEditModeMessage.Text = EditModeMessage.System( GroupType.FriendlyTypeName );
            }

            if ( readOnly )
            {
                ShowReadonlyDetails( groupType );
            }
            else
            {
                ShowEditDetails( groupType );
            }
        }
开发者ID:jondhinkle,项目名称:Rock,代码行数:70,代码来源:GroupTypeDetail.ascx.cs

示例2: ShowGroupTypeEditDetails

        /// <summary>
        /// Shows the group type edit details.
        /// </summary>
        /// <param name="groupType">Type of the group.</param>
        /// <param name="group">The group.</param>
        /// <param name="setValues">if set to <c>true</c> [set values].</param>
        private void ShowGroupTypeEditDetails( GroupTypeCache groupType, Group group, bool setValues )
        {
            if ( group != null )
            {
                // Save value to viewstate for use later when binding location grid
                AllowMultipleLocations = groupType != null && groupType.AllowMultipleLocations;

                // show/hide group sync panel based on permissions from the group type
                if ( group.GroupTypeId != 0 )
                {
                    using ( var rockContext = new RockContext() )
                    {
                        GroupType selectedGroupType = new GroupTypeService( rockContext ).Get( group.GroupTypeId );
                        if ( selectedGroupType != null )
                        {
                            wpGroupSync.Visible = selectedGroupType.IsAuthorized( Authorization.ADMINISTRATE, CurrentPerson );
                        }
                    }
                }

                if ( groupType != null && groupType.LocationSelectionMode != GroupLocationPickerMode.None )
                {
                    wpMeetingDetails.Visible = true;
                    gLocations.Visible = true;
                    BindLocationsGrid();
                }
                else
                {
                    wpMeetingDetails.Visible = pnlSchedule.Visible;
                    gLocations.Visible = false;
                }

                gLocations.Columns[2].Visible = groupType != null && ( groupType.EnableLocationSchedules ?? false );
                spSchedules.Visible = groupType != null && ( groupType.EnableLocationSchedules ?? false );

                phGroupAttributes.Controls.Clear();
                group.LoadAttributes();

                if ( group.Attributes != null && group.Attributes.Any() )
                {
                    wpGroupAttributes.Visible = true;
                    Rock.Attribute.Helper.AddEditControls( group, phGroupAttributes, setValues, BlockValidationGroup );
                }
                else
                {
                    wpGroupAttributes.Visible = false;
                }
            }
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:55,代码来源:GroupDetail.ascx.cs


注:本文中的Rock.Model.GroupTypeService.IsAuthorized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。