/// <summary>
        /// Shows the readonly details.
        /// </summary>
        /// <param name="group">The group.</param>
        private void ShowReadonlyDetails( Group group )
        {
            SetEditMode( false );
            var rockContext = new RockContext();

            string groupIconHtml = !string.IsNullOrWhiteSpace( group.GroupType.IconCssClass ) ?
                groupIconHtml = string.Format( "<i class='{0}' ></i>", group.GroupType.IconCssClass ) : string.Empty;

            hfGroupId.SetValue( group.Id );
            lGroupIconHtml.Text = groupIconHtml;
            lReadOnlyTitle.Text = group.Name.FormatAsHtmlTitle();

            hlInactive.Visible = !group.IsActive;
            hlType.Text = group.GroupType.Name;

            lGroupDescription.Text = group.Description;

            DescriptionList descriptionList = new DescriptionList();

            if ( group.ParentGroup != null )
            {
                descriptionList.Add( "Parent Group", group.ParentGroup.Name );
            }

            if ( group.Campus != null )
            {
                hlCampus.Visible = true;
                hlCampus.Text = group.Campus.Name;
            }
            else
            {
                hlCampus.Visible = false;
            }

            lblMainDetails.Text = descriptionList.Html;

            var attributes = new List<Rock.Web.Cache.AttributeCache>();

            // Get the attributes inherited from group type
            GroupType groupType = new GroupTypeService( rockContext ).Get( group.GroupTypeId );
            groupType.LoadAttributes();
            attributes = groupType.Attributes.Select( a => a.Value ).OrderBy( a => a.Order ).ThenBy( a => a.Name ).ToList();

            // Combine with the group attributes
            group.LoadAttributes();
            attributes.AddRange( group.Attributes.Select( a => a.Value ).OrderBy( a => a.Order ).ThenBy( a => a.Name ) );

            // display attribute values
            var attributeCategories = Helper.GetAttributeCategories( attributes );
            Rock.Attribute.Helper.AddDisplayControls( group, attributeCategories, phAttributes );

            // Get Map Style
            phMaps.Controls.Clear();
            var mapStyleValue = DefinedValueCache.Read( GetAttributeValue( "MapStyle" ) );
            if ( mapStyleValue == null )
            {
                mapStyleValue = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.MAP_STYLE_ROCK );
            }

            if ( mapStyleValue != null )
            {
                string mapStyle = mapStyleValue.GetAttributeValue( "StaticMapStyle" );

                if ( !string.IsNullOrWhiteSpace( mapStyle ) )
                {
                    // Get all the group locations and group all those that have a geo-location into either points or polygons
                    var points = new List<GroupLocation>();
                    var polygons = new List<GroupLocation>();
                    foreach ( GroupLocation groupLocation in group.GroupLocations )
                    {
                        if ( groupLocation.Location != null )
                        {
                            if ( groupLocation.Location.GeoPoint != null )
                            {
                                points.Add( groupLocation );
                            }
                            else if ( groupLocation.Location.GeoFence != null )
                            {
                                polygons.Add( groupLocation );
                            }
                        }
                    }

                    if ( points.Any() )
                    {
                        foreach ( var groupLocation in points )
                        {
                            string markerPoints = string.Format( "{0},{1}", groupLocation.Location.GeoPoint.Latitude, groupLocation.Location.GeoPoint.Longitude );
                            string mapLink = System.Text.RegularExpressions.Regex.Replace( mapStyle, @"\{\s*MarkerPoints\s*\}", markerPoints );
                            mapLink = System.Text.RegularExpressions.Regex.Replace( mapLink, @"\{\s*PolygonPoints\s*\}", string.Empty );
                            mapLink += "&sensor=false&size=350x200&zoom=13&format=png";
                            var literalcontrol = new Literal()
                            {
                                Text = string.Format(
                                "<div class='group-location-map'>{0}<img src='{1}'/></div>",
                                groupLocation.GroupLocationTypeValue != null ? ( "<h4>" + groupLocation.GroupLocationTypeValue.Name + "</h4>" ) : string.Empty,
                                mapLink ),
                                Mode = LiteralMode.PassThrough
                            };
                            phMaps.Controls.Add( literalcontrol );
                        }
                    }

                    if ( polygons.Any() )
                    {
                        foreach ( var groupLocation in polygons )
                        {
                            string polygonPoints = "enc:" + groupLocation.Location.EncodeGooglePolygon();
                            string mapLink = System.Text.RegularExpressions.Regex.Replace( mapStyle, @"\{\s*MarkerPoints\s*\}", string.Empty );
                            mapLink = System.Text.RegularExpressions.Regex.Replace( mapLink, @"\{\s*PolygonPoints\s*\}", polygonPoints );
                            mapLink += "&sensor=false&size=350x200&format=png";
                            phMaps.Controls.Add(
                                new LiteralControl( string.Format(
                                    "<div class='group-location-map'>{0}<img src='{1}'/></div>",
                                    groupLocation.GroupLocationTypeValue != null ? ( "<h4>" + groupLocation.GroupLocationTypeValue.Name + "</h4>" ) : string.Empty,
                                    mapLink ) ) );
                        }
                    }
                }
            }

            btnSecurity.Visible = group.IsAuthorized( Authorization.ADMINISTRATE, CurrentPerson );
            btnSecurity.Title = group.Name;
            btnSecurity.EntityId = group.Id;
        }
Пример #2
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            if ( !Page.IsPostBack )
            {
                string groupTypeId = PageParameter( "CheckinTypeId" );

                if ( !string.IsNullOrWhiteSpace( groupTypeId ) )
                {
                    wpGeneral.Expanded = true;
                    LoadDropdowns();
                    ShowDetail( groupTypeId.AsInteger() );
                }
                else
                {
                    pnlDetails.Visible = false;
                }
            }
            else
            {
                // Rebuild the attribute controls on postback based on group type
                if ( pnlEditDetails.Visible )
                {
                    int? groupTypeId = PageParameter( "CheckinTypeId" ).AsIntegerOrNull();
                    if ( groupTypeId.HasValue && groupTypeId.Value > 0 )
                    {
                        var groupType = new GroupTypeService( new RockContext() ).Get( groupTypeId.Value );
                        if ( groupType != null )
                        {
                            groupType.LoadAttributes();
                            BuildAttributeEdits( groupType, true );
                        }
                    }

                }
            }
        }
Пример #3
0
        /// <summary>
        /// Shows the readonly details.
        /// </summary>
        /// <param name="group">The group.</param>
        private void ShowReadonlyDetails( Group group )
        {
            SetEditMode( false );

            string groupIconHtml = !string.IsNullOrWhiteSpace( group.GroupType.IconCssClass ) ?
                groupIconHtml = string.Format( "<i class='{0}' ></i>", group.GroupType.IconCssClass ) : "";

            hfGroupId.SetValue( group.Id );
            lGroupIconHtml.Text = groupIconHtml;
            lReadOnlyTitle.Text = group.Name.FormatAsHtmlTitle();

            hlInactive.Visible = !group.IsActive;
            hlType.Text = group.GroupType.Name;

            lGroupDescription.Text = group.Description;

            DescriptionList descriptionList = new DescriptionList();

            if ( group.ParentGroup != null )
            {
                descriptionList.Add( "Parent Group", group.ParentGroup.Name );
            }

            if ( group.Campus != null )
            {
                hlCampus.Visible = true;
                hlCampus.Text = group.Campus.Name;
            }
            else
            {
                hlCampus.Visible = false;
            }


            lblMainDetails.Text = descriptionList.Html;

            var attributes = new List<Rock.Web.Cache.AttributeCache>();

            // Get the attributes inherited from group type
            GroupType groupType = new GroupTypeService().Get( group.GroupTypeId );
            groupType.LoadAttributes();
            attributes = groupType.Attributes.Select( a => a.Value ).OrderBy( a => a.Order ).ThenBy( a => a.Name ).ToList();

            // Combine with the group attributes
            group.LoadAttributes();
            attributes.AddRange( group.Attributes.Select( a => a.Value ).OrderBy( a => a.Order ).ThenBy( a => a.Name ) );

            // display attribute values
            var attributeCategories = Helper.GetAttributeCategories( attributes );
            Rock.Attribute.Helper.AddDisplayControls( group, attributeCategories, phAttributes );

            // Get all the group locations and group all those that have a geo-location into either points or polygons
            var points = new List<GroupLocation>();
            var polygons = new List<GroupLocation>();
            foreach ( GroupLocation groupLocation in group.GroupLocations )
            {
                if ( groupLocation.Location != null )
                {
                    if ( groupLocation.Location.GeoPoint != null )
                    {
                        points.Add( groupLocation );
                    }
                    else if ( groupLocation.Location.GeoFence != null )
                    {
                        polygons.Add( groupLocation );
                    }
                }
            }

            var dict = new Dictionary<string, object>();
            if ( points.Any() )
            {
                var pointsList = new List<Dictionary<string, object>>();
                foreach ( var groupLocation in points)
                {
                    var pointsDict = new Dictionary<string, object>();
                    if ( groupLocation.GroupLocationTypeValue != null )
                    {
                        pointsDict.Add( "type", groupLocation.GroupLocationTypeValue.Name );
                    }
                    pointsDict.Add( "latitude", groupLocation.Location.GeoPoint.Latitude );
                    pointsDict.Add( "longitude", groupLocation.Location.GeoPoint.Longitude );
                    pointsList.Add( pointsDict );
                }
                dict.Add( "points", pointsList );
            }

            if ( polygons.Any() )
            {
                var polygonsList = new List<Dictionary<string, object>>();
                foreach ( var groupLocation in polygons )
                {
                    var polygonDict = new Dictionary<string, object>();
                    if ( groupLocation.GroupLocationTypeValue != null )
                    {
                        polygonDict.Add( "type", groupLocation.GroupLocationTypeValue.Name );
                    }
                    polygonDict.Add( "polygon_wkt", groupLocation.Location.GeoFence.AsText());
                    polygonDict.Add( "google_encoded_polygon", groupLocation.Location.EncodeGooglePolygon() );
                    polygonsList.Add( polygonDict );
                }
                dict.Add( "polygons", polygonsList );
            }

            phMaps.Controls.Clear();
            phMaps.Controls.Add( new LiteralControl( GetAttributeValue( "MapHTML" ).ResolveMergeFields( dict ) ) );

            btnSecurity.Visible = group.IsAuthorized( "Administrate", CurrentPerson );
            btnSecurity.Title = group.Name;
            btnSecurity.EntityId = group.Id;

        }