Ejemplo n.º 1
0
        /// <summary>
        /// Creates the control(s) neccessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl(Dictionary<string,ConfigurationValue> configurationValues, string id)
        {
            var editControl = new RockDropDownList { ID = id };

            var systemEmails = new SystemEmailService( new RockContext() ).Queryable().OrderBy( e => e.Title );
            if ( systemEmails.Any() )
            {
                foreach ( var systemEmail in systemEmails )
                {
                    editControl.Items.Add( new ListItem( systemEmail.Title, systemEmail.Guid.ToString() ) );
                }

                return editControl;
            }

            return null;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the control(s) necessary for prompting user for a new value
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id"></param>
        /// <returns>
        /// The control
        /// </returns>
        public override Control EditControl(Dictionary <string, ConfigurationValue> configurationValues, string id)
        {
            var editControl = new RockDropDownList {
                ID = id
            };

            var systemEmails = new SystemEmailService(new RockContext()).Queryable().OrderBy(e => e.Title);

            // add a blank for the first option
            editControl.Items.Add(new ListItem());

            if (systemEmails.Any())
            {
                foreach (var systemEmail in systemEmails)
                {
                    editControl.Items.Add(new ListItem(systemEmail.Title, systemEmail.Guid.ToString()));
                }

                return(editControl);
            }

            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="group">The group.</param>
        private void ShowEditDetails( Group group )
        {
            if ( group.Id == 0 )
            {
                lReadOnlyTitle.Text = ActionTitle.Add( Group.FriendlyTypeName ).FormatAsHtmlTitle();

                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }
            else
            {
                lReadOnlyTitle.Text = group.Name.FormatAsHtmlTitle();
            }

            SetHighlightLabelVisibility( group, false );

            ddlGroupType.Visible = group.Id == 0;
            lGroupType.Visible = group.Id != 0;

            SetEditMode( true );

            tbName.Text = group.Name;
            tbDescription.Text = group.Description;
            nbGroupCapacity.Text = group.GroupCapacity.ToString();
            cbIsSecurityRole.Checked = group.IsSecurityRole;
            cbIsActive.Checked = group.IsActive;
            cbIsPublic.Checked = group.IsPublic;

            var rockContext = new RockContext();

            var groupService = new GroupService( rockContext );
            var attributeService = new AttributeService( rockContext );

            LoadDropDowns( rockContext );

            ddlSignatureDocumentTemplate.SetValue( group.RequiredSignatureDocumentTemplateId );
            gpParentGroup.SetValue( group.ParentGroup ?? groupService.Get( group.ParentGroupId ?? 0 ) );

            // hide sync and requirements panel if no admin access
            bool canAdministrate = group.IsAuthorized( Authorization.ADMINISTRATE, CurrentPerson );
            wpGroupSync.Visible = canAdministrate;
            wpGroupRequirements.Visible = canAdministrate;
            wpGroupMemberAttributes.Visible = canAdministrate;

            var systemEmails = new SystemEmailService( rockContext ).Queryable().OrderBy( e => e.Title )
                .Select( a => new
                {
                    a.Id,
                    a.Title
                } );

            // add a blank for the first option
            ddlWelcomeEmail.Items.Add( new ListItem() );
            ddlExitEmail.Items.Add( new ListItem() );

            if ( systemEmails.Any() )
            {
                foreach ( var systemEmail in systemEmails )
                {
                    ddlWelcomeEmail.Items.Add( new ListItem( systemEmail.Title, systemEmail.Id.ToString() ) );
                    ddlExitEmail.Items.Add( new ListItem( systemEmail.Title, systemEmail.Id.ToString() ) );
                }
            }

            // set dataview
            dvpSyncDataview.EntityTypeId = EntityTypeCache.Read( "Rock.Model.Person" ).Id;
            dvpSyncDataview.SetValue( group.SyncDataViewId );

            if ( group.AddUserAccountsDuringSync.HasValue )
            {
                rbCreateLoginDuringSync.Checked = group.AddUserAccountsDuringSync.Value;
            }

            if ( group.WelcomeSystemEmailId.HasValue )
            {
                ddlWelcomeEmail.SetValue( group.WelcomeSystemEmailId );
            }

            if ( group.ExitSystemEmailId.HasValue )
            {
                ddlExitEmail.SetValue( group.ExitSystemEmailId );
            }

            // GroupType depends on Selected ParentGroup
            ddlParentGroup_SelectedIndexChanged( null, null );
            gpParentGroup.Label = "Parent Group";

            if ( group.Id == 0 && group.GroupType == null && ddlGroupType.Items.Count > 1 )
            {
                if ( GetAttributeValue( "LimittoSecurityRoleGroups" ).AsBoolean() )
                {
                    // default GroupType for new Group to "Security Roles"  if LimittoSecurityRoleGroups
                    var securityRoleGroupType = GroupTypeCache.GetSecurityRoleGroupType();
                    if ( securityRoleGroupType != null )
                    {
                        CurrentGroupTypeId = securityRoleGroupType.Id;
                        ddlGroupType.SetValue( securityRoleGroupType.Id );
                    }
                    else
                    {
                        ddlGroupType.SelectedIndex = 0;
                    }
                }
                else
                {
                    // if this is a new group (and not "LimitToSecurityRoleGroups", and there is more than one choice for GroupType, default to no selection so they are forced to choose (vs unintentionallly choosing the default one)
                    ddlGroupType.SelectedIndex = 0;
                }
            }
            else
            {
                CurrentGroupTypeId = group.GroupTypeId;
                if ( CurrentGroupTypeId == 0 )
                {
                    CurrentGroupTypeId = ddlGroupType.SelectedValueAsInt() ?? 0;
                }

                var groupType = GroupTypeCache.Read( CurrentGroupTypeId, rockContext );
                lGroupType.Text = groupType != null ? groupType.Name : string.Empty;
                ddlGroupType.SetValue( CurrentGroupTypeId );
            }

            ddlCampus.SetValue( group.CampusId );

            GroupRequirementsState = group.GroupRequirements.ToList();
            GroupLocationsState = group.GroupLocations.ToList();

            var groupTypeCache = CurrentGroupTypeCache;
            nbGroupCapacity.Visible = groupTypeCache != null && groupTypeCache.GroupCapacityRule != GroupCapacityRule.None;
            SetScheduleControls( groupTypeCache, group );
            ShowGroupTypeEditDetails( groupTypeCache, group, true );

            // if this block's attribute limit group to SecurityRoleGroups, don't let them edit the SecurityRole checkbox value
            if ( GetAttributeValue( "LimittoSecurityRoleGroups" ).AsBoolean() )
            {
                cbIsSecurityRole.Enabled = false;
                cbIsSecurityRole.Checked = true;
            }

            string qualifierValue = group.Id.ToString();
            GroupMemberAttributesState = attributeService.GetByEntityTypeId( new GroupMember().TypeId ).AsQueryable()
                    .Where( a =>
                        a.EntityTypeQualifierColumn.Equals( "GroupId", StringComparison.OrdinalIgnoreCase ) &&
                        a.EntityTypeQualifierValue.Equals( qualifierValue ) )
                    .OrderBy( a => a.Order )
                    .ThenBy( a => a.Name )
                    .ToList();
            BindGroupMemberAttributesGrid();

            BindInheritedAttributes( group.GroupTypeId, attributeService );

            cbMembersMustMeetRequirementsOnAdd.Checked = group.MustMeetRequirementsToAddMember ?? false;

            BindGroupRequirementsGrid();

            MemberWorkflowTriggersState = new List<GroupMemberWorkflowTrigger>();
            foreach ( var trigger in group.GroupMemberWorkflowTriggers )
            {
                MemberWorkflowTriggersState.Add( trigger );
            }

            BindMemberWorkflowTriggersGrid();
        }