/// <summary>
        /// Checks the settings.
        /// </summary>
        /// <returns></returns>
        private bool CheckSettings()
        {
            _rockContext = _rockContext ?? new RockContext();

            _mode = GetAttributeValue("Mode");

            int groupId = PageParameter("GroupId").AsInteger();

            _group = new GroupService(_rockContext)
                     .Queryable("GroupType.DefaultGroupRole").AsNoTracking()
                     .FirstOrDefault(g => g.Id == groupId);
            if (_group == null)
            {
                nbNotice.Heading = "Unknown Group";
                nbNotice.Text    = "<p>This page requires a valid group id parameter, and there was not one provided.</p>";
                return(false);
            }
            else
            {
                _defaultGroupRole = _group.GroupType.DefaultGroupRole;
            }

            _dvcConnectionStatus = DefinedValueCache.Read(GetAttributeValue("ConnectionStatus").AsGuid());
            if (_dvcConnectionStatus == null)
            {
                nbNotice.Heading = "Invalid Connection Status";
                nbNotice.Text    = "<p>The selected Connection Status setting does not exist.</p>";
                return(false);
            }

            _dvcRecordStatus = DefinedValueCache.Read(GetAttributeValue("RecordStatus").AsGuid());
            if (_dvcRecordStatus == null)
            {
                nbNotice.Heading = "Invalid Record Status";
                nbNotice.Text    = "<p>The selected Record Status setting does not exist.</p>";
                return(false);
            }

            _married         = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.PERSON_MARITAL_STATUS_MARRIED.AsGuid());
            _homeAddressType = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME.AsGuid());
            _familyType      = GroupTypeCache.Read(Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid());
            _adultRole       = _familyType.Roles.FirstOrDefault(r => r.Guid.Equals(Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid()));

            if (_married == null || _homeAddressType == null || _familyType == null || _adultRole == null)
            {
                nbNotice.Heading = "Missing System Value";
                nbNotice.Text    = "<p>There is a missing or invalid system value. Check the settings for Marital Status of 'Married', Location Type of 'Home', Group Type of 'Family', and Family Group Role of 'Adult'.</p>";
                return(false);
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Checks the settings.
        /// </summary>
        /// <returns></returns>
        private bool CheckSettings()
        {
            _rockContext = _rockContext ?? new RockContext();

            if (CurrentGroup == null)
            {
                NavigateToHomePage();
                return(false);
            }

            //Authorization check. Nothing is visible otherwise
            if (!CurrentGroup.IsAuthorized(Authorization.EDIT, CurrentPerson))
            {
                return(false);
            }

            _defaultGroupRole = CurrentGroup.GroupType.DefaultGroupRole;

            _dvcConnectionStatus = DefinedValueCache.Get(GetAttributeValue("ConnectionStatus").AsGuid());
            if (_dvcConnectionStatus == null)
            {
                return(false);
            }

            _dvcRecordStatus = DefinedValueCache.Get(GetAttributeValue("RecordStatus").AsGuid());
            if (_dvcRecordStatus == null)
            {
                return(false);
            }


            _homeAddressType = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME.AsGuid());
            _familyType      = GroupTypeCache.Get(Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid());
            _adultRole       = _familyType.Roles.FirstOrDefault(r => r.Guid.Equals(Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid()));

            if (!GetAttributeValue("LargeButton").AsBoolean())
            {
                btnLaunchModal.Text = "<i class='fa fa-user-plus'></i>";
            }

            if (!string.IsNullOrWhiteSpace(GetAttributeValue("CSSClass")))
            {
                btnLaunchModal.CssClass = GetAttributeValue("CSSClass");
            }

            return(true);
        }
Example #3
0
        /// <summary>
        /// Checks the settings.
        /// </summary>
        /// <returns></returns>
        private bool CheckSettings()
        {
            _rockContext = _rockContext ?? new RockContext();

            _mode = GetAttributeValue( "Mode" );

            _autoFill = GetAttributeValue( "AutoFillForm" ).AsBoolean();

            tbEmail.Required = _autoFill;

            string registerButtonText = GetAttributeValue( "RegisterButtonAltText" );
            if ( string.IsNullOrWhiteSpace( registerButtonText ) )
            {
                registerButtonText = "Register";
            }
            btnRegister.Text = registerButtonText;

            int groupId = PageParameter( "GroupId" ).AsInteger();
            _group = new GroupService( _rockContext )
                .Queryable( "GroupType.DefaultGroupRole" ).AsNoTracking()
                .FirstOrDefault( g => g.Id == groupId );
            if ( _group == null )
            {
                nbNotice.Heading = "Unknown Group";
                nbNotice.Text = "<p>This page requires a valid group id parameter, and there was not one provided.</p>";
                return false;
            }
            else
            {
                _defaultGroupRole = _group.GroupType.DefaultGroupRole;
            }

            _dvcConnectionStatus = DefinedValueCache.Read( GetAttributeValue( "ConnectionStatus" ).AsGuid() );
            if ( _dvcConnectionStatus == null )
            {
                nbNotice.Heading = "Invalid Connection Status";
                nbNotice.Text = "<p>The selected Connection Status setting does not exist.</p>";
                return false;
            }

            _dvcRecordStatus = DefinedValueCache.Read( GetAttributeValue( "RecordStatus" ).AsGuid() );
            if ( _dvcRecordStatus == null )
            {
                nbNotice.Heading = "Invalid Record Status";
                nbNotice.Text = "<p>The selected Record Status setting does not exist.</p>";
                return false;
            }

            _married = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_MARITAL_STATUS_MARRIED.AsGuid() );
            _homeAddressType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME.AsGuid() );
            _familyType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid() );
            _adultRole = _familyType.Roles.FirstOrDefault( r => r.Guid.Equals( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid() ) );

            if ( _married == null || _homeAddressType == null || _familyType == null || _adultRole == null )
            {
                nbNotice.Heading = "Missing System Value";
                nbNotice.Text = "<p>There is a missing or invalid system value. Check the settings for Marital Status of 'Married', Location Type of 'Home', Group Type of 'Family', and Family Group Role of 'Adult'.</p>";
                return false;
            }

            return true;
        }
        /// <summary>
        /// Checks the settings.  If false is returned, it's expected that the caller will make
        /// the nbNotice visible to inform the user of the "settings" error.
        /// </summary>
        /// <returns>true if settings are valid; false otherwise</returns>
        private bool CheckSettings()
        {
            _rockContext = _rockContext ?? new RockContext();


            _autoFill = GetAttributeValue("AutoFillForm").AsBoolean();

            string registerButtonText = GetAttributeValue("RegisterButtonAltText");

            if (string.IsNullOrWhiteSpace(registerButtonText))
            {
                registerButtonText = "Register";
            }
            btnRegister.Text = registerButtonText;

            var publishGroupService = new PublishGroupService(_rockContext);

            if (_publishGroup == null)
            {
                var publishGroupGuid = PageParameter("PublishGroup").AsGuidOrNull();
                if (publishGroupGuid.HasValue)
                {
                    _publishGroup = publishGroupService.Get(publishGroupGuid.Value);
                }
                else
                {
                    var slug = PageParameter("PublishGroup").ToLower();
                    _publishGroup = publishGroupService.Queryable().Where(pg => pg.Slug == slug).FirstOrDefault();
                }
            }

            if (_publishGroup == null || _publishGroup.PublishGroupStatus != PublishGroupStatus.Approved)
            {
                nbNotice.Heading = "Unknown Group";
                nbNotice.Text    = "<p>This page requires a valid group identifying parameter and there was not one provided.</p>";
                nbNotice.Visible = true;
                return(false);
            }

            if (_publishGroup.RegistrationLink.IsNotNullOrWhiteSpace())
            {
                Response.Redirect(_publishGroup.RegistrationLink, false);
                Context.ApplicationInstance.CompleteRequest();
                return(false);
            }

            _showSpouse       = _publishGroup.AllowSpouseRegistration;
            _defaultGroupRole = _publishGroup.Group.GroupType.DefaultGroupRole;


            _dvcConnectionStatus = DefinedValueCache.Get(GetAttributeValue("ConnectionStatus").AsGuid());
            if (_dvcConnectionStatus == null)
            {
                nbNotice.Heading = "Invalid Connection Status";
                nbNotice.Text    = "<p>The selected Connection Status setting does not exist.</p>";
                return(false);
            }

            _dvcRecordStatus = DefinedValueCache.Get(GetAttributeValue("RecordStatus").AsGuid());
            if (_dvcRecordStatus == null)
            {
                nbNotice.Heading = "Invalid Record Status";
                nbNotice.Text    = "<p>The selected Record Status setting does not exist.</p>";
                return(false);
            }

            _married         = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_MARITAL_STATUS_MARRIED.AsGuid());
            _homeAddressType = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME.AsGuid());
            _familyType      = GroupTypeCache.Get(Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid());
            _adultRole       = _familyType.Roles.FirstOrDefault(r => r.Guid.Equals(Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid()));

            if (_married == null || _homeAddressType == null || _familyType == null || _adultRole == null)
            {
                nbNotice.Heading = "Missing System Value";
                nbNotice.Text    = "<p>There is a missing or invalid system value. Check the settings for Marital Status of 'Married', Location Type of 'Home', Group Type of 'Family', and Family Group Role of 'Adult'.</p>";
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Checks the settings.  If false is returned, it's expected that the caller will make
        /// the nbNotice visible to inform the user of the "settings" error.
        /// </summary>
        /// <returns>true if settings are valid; false otherwise</returns>
        private bool CheckSettings()
        {
            _rockContext = _rockContext ?? new RockContext();

            _mode = GetAttributeValue("Mode");

            _autoFill = GetAttributeValue("AutoFillForm").AsBoolean();

            string registerButtonText = GetAttributeValue("RegisterButtonAltText");

            if (string.IsNullOrWhiteSpace(registerButtonText))
            {
                registerButtonText = "Register";
            }
            btnRegister.Text = registerButtonText;

            var  groupService         = new GroupService(_rockContext);
            bool groupIsFromQryString = true;

            Guid?groupGuid = GetAttributeValue("Group").AsGuidOrNull();

            if (groupGuid.HasValue)
            {
                _group = groupService.Get(groupGuid.Value);
                groupIsFromQryString = false;
            }

            if (_group == null)
            {
                groupGuid = PageParameter("GroupGuid").AsGuidOrNull();
                if (groupGuid.HasValue)
                {
                    _group = groupService.Get(groupGuid.Value);
                }
            }

            if (_group == null && GetAttributeValue("EnablePassingGroupId").AsBoolean(false))
            {
                int?groupId = PageParameter("GroupId").AsIntegerOrNull();
                if (groupId.HasValue)
                {
                    _group = groupService.Get(groupId.Value);
                }
            }

            if (_group == null)
            {
                nbNotice.Heading = "Unknown Group";
                nbNotice.Text    = "<p>This page requires a valid group identifying parameter and there was not one provided.</p>";
                return(false);
            }
            else
            {
                var groupTypeGuids = this.GetAttributeValue("AllowedGroupTypes").SplitDelimitedValues().AsGuidList();

                if (groupIsFromQryString && groupTypeGuids.Any() && !groupTypeGuids.Contains(_group.GroupType.Guid))
                {
                    _group           = null;
                    nbNotice.Heading = "Invalid Group";
                    nbNotice.Text    = "<p>The selected group is a restricted group type therefore this block cannot be used to add people to these groups (unless configured to allow).</p>";
                    return(false);
                }
                else
                {
                    _defaultGroupRole = _group.GroupType.DefaultGroupRole;
                }
            }

            _dvcConnectionStatus = DefinedValueCache.Get(GetAttributeValue("ConnectionStatus").AsGuid());
            if (_dvcConnectionStatus == null)
            {
                nbNotice.Heading = "Invalid Connection Status";
                nbNotice.Text    = "<p>The selected Connection Status setting does not exist.</p>";
                return(false);
            }

            _dvcRecordStatus = DefinedValueCache.Get(GetAttributeValue("RecordStatus").AsGuid());
            if (_dvcRecordStatus == null)
            {
                nbNotice.Heading = "Invalid Record Status";
                nbNotice.Text    = "<p>The selected Record Status setting does not exist.</p>";
                return(false);
            }

            _married         = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_MARITAL_STATUS_MARRIED.AsGuid());
            _homeAddressType = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME.AsGuid());
            _familyType      = GroupTypeCache.Get(Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid());
            _adultRole       = _familyType.Roles.FirstOrDefault(r => r.Guid.Equals(Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid()));

            if (_married == null || _homeAddressType == null || _familyType == null || _adultRole == null)
            {
                nbNotice.Heading = "Missing System Value";
                nbNotice.Text    = "<p>There is a missing or invalid system value. Check the settings for Marital Status of 'Married', Location Type of 'Home', Group Type of 'Family', and Family Group Role of 'Adult'.</p>";
                return(false);
            }

            return(true);
        }
Example #6
0
        /// <summary>
        /// Checks the settings.
        /// </summary>
        /// <returns></returns>
        private bool CheckSettings()
        {
            _rockContext = _rockContext ?? new RockContext();

            _mode = GetAttributeValue( "Mode" );

            _autoFill = GetAttributeValue( "AutoFillForm" ).AsBoolean();

            tbEmail.Required = _autoFill;

            string registerButtonText = GetAttributeValue( "RegisterButtonAltText" );
            if ( string.IsNullOrWhiteSpace( registerButtonText ) )
            {
                registerButtonText = "Register";
            }
            btnRegister.Text = registerButtonText;

            var groupService = new GroupService( _rockContext );
            bool groupIsFromQryString = true;

            Guid? groupGuid = GetAttributeValue( "Group" ).AsGuidOrNull();
            if ( groupGuid.HasValue )
            {
                _group = groupService.Get( groupGuid.Value );
                groupIsFromQryString = false;
            }

            if ( _group == null )
            {
                groupGuid = PageParameter( "GroupGuid" ).AsGuidOrNull();
                if ( groupGuid.HasValue )
                {
                    _group = groupService.Get( groupGuid.Value );
                }
            }

            if ( _group == null )
            {
                int? groupId = PageParameter( "GroupId" ).AsIntegerOrNull();
                if ( groupId.HasValue )
                {
                    _group = groupService.Get( groupId.Value );
                }
            }

            if ( _group == null )
            {
                nbNotice.Heading = "Unknown Group";
                nbNotice.Text = "<p>This page requires a valid group id parameter, and there was not one provided.</p>";
                return false;
            }
            else
            {
                if ( groupIsFromQryString && ( _group.IsSecurityRole || _group.GroupType.Guid == Rock.SystemGuid.GroupType.GROUPTYPE_SECURITY_ROLE.AsGuid() ) )
                {
                    nbNotice.Heading = "Invalid Group";
                    nbNotice.Text = "<p>The selected group is a security group and this block cannot be used to add people to a security group (unless configured for that specific group).</p>";
                    return false;
                }
                else
                {
                    _defaultGroupRole = _group.GroupType.DefaultGroupRole;
                }
            }

            _dvcConnectionStatus = DefinedValueCache.Read( GetAttributeValue( "ConnectionStatus" ).AsGuid() );
            if ( _dvcConnectionStatus == null )
            {
                nbNotice.Heading = "Invalid Connection Status";
                nbNotice.Text = "<p>The selected Connection Status setting does not exist.</p>";
                return false;
            }

            _dvcRecordStatus = DefinedValueCache.Read( GetAttributeValue( "RecordStatus" ).AsGuid() );
            if ( _dvcRecordStatus == null )
            {
                nbNotice.Heading = "Invalid Record Status";
                nbNotice.Text = "<p>The selected Record Status setting does not exist.</p>";
                return false;
            }

            _married = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_MARITAL_STATUS_MARRIED.AsGuid() );
            _homeAddressType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME.AsGuid() );
            _familyType = GroupTypeCache.Read( Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid() );
            _adultRole = _familyType.Roles.FirstOrDefault( r => r.Guid.Equals( Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid() ) );

            if ( _married == null || _homeAddressType == null || _familyType == null || _adultRole == null )
            {
                nbNotice.Heading = "Missing System Value";
                nbNotice.Text = "<p>There is a missing or invalid system value. Check the settings for Marital Status of 'Married', Location Type of 'Home', Group Type of 'Family', and Family Group Role of 'Adult'.</p>";
                return false;
            }

            return true;
        }
        /// <summary>
        /// Checks the settings.
        /// </summary>
        /// <returns></returns>
        private bool CheckSettings()
        {
            _rockContext = _rockContext ?? new RockContext();

            var connectionOpportunityService = new ConnectionOpportunityService(_rockContext);

            Guid?connectionOpportunityGuid = GetAttributeValue("ConnectionOpportunity").AsGuidOrNull();

            if (connectionOpportunityGuid.HasValue)
            {
                _connectionOpportunity = connectionOpportunityService.Get(connectionOpportunityGuid.Value);
            }

            if (_connectionOpportunity == null)
            {
                connectionOpportunityGuid = PageParameter("ConnectionOpportunityGuid").AsGuidOrNull();
                if (connectionOpportunityGuid.HasValue)
                {
                    _connectionOpportunity = connectionOpportunityService.Get(connectionOpportunityGuid.Value);
                }
            }

            if (_connectionOpportunity == null)
            {
                int?connectionOpportunityId = PageParameter("ConnectionOpportunityId").AsIntegerOrNull();
                if (connectionOpportunityId.HasValue)
                {
                    _connectionOpportunity = connectionOpportunityService.Get(connectionOpportunityId.Value);
                }
            }

            if (_connectionOpportunity == null)
            {
                nbNotice.Heading = "Missing Connection Opportunity Setting";
                nbNotice.Text    = "<p>Please edit the block settings. This block requires a valid Connection Opportunity setting.</p>";
                return(false);
            }

            _dvcConnectionStatus = DefinedValueCache.Get(GetAttributeValue("ConnectionStatus").AsGuid());
            if (_dvcConnectionStatus == null)
            {
                nbNotice.Heading = "Invalid Connection Status";
                nbNotice.Text    = "<p>The selected Connection Status setting does not exist.</p>";
                return(false);
            }

            _dvcChildConnectionStatus = DefinedValueCache.Get(GetAttributeValue("ChildConnectionStatus").AsGuid());
            if (_dvcChildConnectionStatus == null)
            {
                nbNotice.Heading = "Invalid Child Connection Status";
                nbNotice.Text    = "<p>The selected Child Connection Status setting does not exist.</p>";
                return(false);
            }

            _dvcRecordStatus = DefinedValueCache.Get(GetAttributeValue("RecordStatus").AsGuid());
            if (_dvcRecordStatus == null)
            {
                nbNotice.Heading = "Invalid Record Status";
                nbNotice.Text    = "<p>The selected Record Status setting does not exist.</p>";
                return(false);
            }

            _single          = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_MARITAL_STATUS_SINGLE.AsGuid());
            _married         = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.PERSON_MARITAL_STATUS_MARRIED.AsGuid());
            _homeAddressType = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.GROUP_LOCATION_TYPE_HOME.AsGuid());
            _familyType      = GroupTypeCache.Get(Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuid());
            _adultRole       = _familyType.Roles.FirstOrDefault(r => r.Guid.Equals(Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid()));
            _childRole       = _familyType.Roles.FirstOrDefault(r => r.Guid.Equals(Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD.AsGuid()));

            if (_single == null || _married == null || _homeAddressType == null || _familyType == null || _adultRole == null || _childRole == null)
            {
                nbNotice.Heading = "Missing System Value";
                nbNotice.Text    = "<p>There is a missing or invalid system value. Check the settings for Marital Status of 'Single'/'Married', Location Type of 'Home', Group Type of 'Family', and Family Group Role of 'Adult'.</p>";
                return(false);
            }

            _isPrayerRequestEnabled = GetAttributeValue("IsPrayerRequestEnabled").AsBoolean();

            return(true);
        }