コード例 #1
0
ファイル: Categories.ascx.cs プロジェクト: jdschrack/RockKit
        /// <summary>
        /// Sets the display.
        /// </summary>
        private void SetDisplay()
        {
            SecurityField securityField = gCategories.Columns[8] as SecurityField;

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Category)).Id;

            _canConfigure = IsUserAuthorized(Authorization.ADMINISTRATE);
            if (_canConfigure)
            {
                Guid entityTypeGuid = Guid.Empty;
                if (Guid.TryParse(GetAttributeValue("EntityType"), out entityTypeGuid))
                {
                    var entityType = Rock.Web.Cache.EntityTypeCache.Read(entityTypeGuid);
                    if (entityType != null)
                    {
                        securityField.Visible = entityType.IsSecured;

                        _entityTypeId = entityType.Id;
                        _entityCol    = GetAttributeValue("EntityQualifierColumn");
                        _entityVal    = GetAttributeValue("EntityQualifierValue");

                        catpParentCategory.EntityTypeId = _entityTypeId;

                        pnlList.Visible   = true;
                        nbMessage.Visible = false;
                    }
                }
            }
            else
            {
                pnlList.Visible   = false;
                nbMessage.Text    = "You are not authorized to configure this page.";
                nbMessage.Visible = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            rFilter.ApplyFilterClick += rFilter_ApplyFilterClick;

            gGroupType.DataKeyNames      = new string[] { "Id" };
            gGroupType.Actions.ShowAdd   = true;
            gGroupType.Actions.AddClick += gGroupType_Add;
            gGroupType.GridReorder      += gGroupType_GridReorder;
            gGroupType.GridRebind       += gGroupType_GridRebind;

            // Block Security and special attributes (RockPage takes care of View)
            bool canEditBlock = IsUserAuthorized(Authorization.EDIT);

            gGroupType.Actions.ShowAdd = canEditBlock;
            gGroupType.IsDeleteEnabled = canEditBlock;

            // Only display reordering column if user can edit the block
            gGroupType.ColumnsOfType <ReorderField>().First().Visible = canEditBlock;

            SecurityField securityField = gGroupType.ColumnsOfType <SecurityField>().First();

            securityField.EntityTypeId = EntityTypeCache.GetId <Rock.Model.GroupType>().Value;

            BindFilter();
        }
コード例 #3
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            rFilter.ApplyFilterClick += rFilter_ApplyFilterClick;

            gGroupType.DataKeyNames      = new string[] { "id" };
            gGroupType.Actions.ShowAdd   = true;
            gGroupType.Actions.AddClick += gGroupType_Add;
            gGroupType.GridReorder      += gGroupType_GridReorder;
            gGroupType.GridRebind       += gGroupType_GridRebind;

            // Block Security and special attributes (RockPage takes care of "View")
            bool canEditBlock = IsUserAuthorized("Edit");

            gGroupType.Actions.ShowAdd = canEditBlock;
            gGroupType.IsDeleteEnabled = canEditBlock;

            // Only display reordering column if user can edit the block
            gGroupType.Columns[0].Visible = canEditBlock;

            SecurityField securityField = gGroupType.Columns[5] as SecurityField;

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.GroupType)).Id;

            BindFilter();
        }
コード例 #4
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _canConfigure = IsUserAuthorized(Authorization.ADMINISTRATE);
            if (_canConfigure)
            {
                Guid entityTypeGuid = Guid.Empty;
                if (Guid.TryParse(GetAttributeValue("EntityType"), out entityTypeGuid))
                {
                    var entityType = Rock.Web.Cache.EntityTypeCache.Read(entityTypeGuid);
                    if (entityType != null)
                    {
                        _entityTypeId = entityType.Id;

                        SecurityField securityField = gCategories.Columns[5] as SecurityField;
                        securityField.Visible      = entityType.IsSecured;
                        securityField.EntityTypeId = EntityTypeCache.Read(typeof(Category)).Id;

                        catpParentCategory.EntityTypeId = _entityTypeId;

                        int parentCategoryId = int.MinValue;
                        if (int.TryParse(PageParameter("CategoryId"), out parentCategoryId))
                        {
                            _parentCategoryId = parentCategoryId;
                        }

                        gCategories.DataKeyNames    = new string[] { "Id" };
                        gCategories.Actions.ShowAdd = true;

                        gCategories.Actions.AddClick += gCategories_Add;
                        gCategories.GridReorder      += gCategories_GridReorder;
                        gCategories.GridRebind       += gCategories_GridRebind;

                        mdDetails.SaveClick     += mdDetails_SaveClick;
                        mdDetails.OnCancelScript = string.Format("$('#{0}').val('');", hfIdValue.ClientID);
                    }
                    else
                    {
                        pnlList.Visible   = false;
                        nbMessage.Text    = "Block has not been configured for a valid Enity Type.";
                        nbMessage.Visible = true;
                    }
                }
                else
                {
                    pnlList.Visible   = false;
                    nbMessage.Text    = "Block has not been configured for a valid Enity Type.";
                    nbMessage.Visible = true;
                }
            }
            else
            {
                pnlList.Visible   = false;
                nbMessage.Text    = "You are not authorized to configure this page.";
                nbMessage.Visible = true;
            }
        }
コード例 #5
0
ファイル: TemplateList.ascx.cs プロジェクト: philltran/Rock
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (!this.IsPostBack)
            {
                BindFilter();
            }

            rFilter.ApplyFilterClick   += rFilter_ApplyFilterClick;
            rFilter.DisplayFilterValue += rFilter_DisplayFilterValue;

            gCommunicationTemplates.DataKeyNames      = new string[] { "Id" };
            gCommunicationTemplates.Actions.ShowAdd   = true;
            gCommunicationTemplates.Actions.AddClick += Actions_AddClick;
            gCommunicationTemplates.GridRebind       += gCommunicationTemplates_GridRebind;

            // The created by column/filter should only be displayed if user is allowed to approve
            _canEdit            = IsUserAuthorized(Authorization.EDIT);
            ppCreatedBy.Visible = _canEdit;
            RockBoundField createdByField = gCommunicationTemplates.ColumnsOfType <RockBoundField>().FirstOrDefault(a => a.DataField == "CreatedByPersonAlias.Person.FullName");

            createdByField.Visible = _canEdit;

            SecurityField securityField = gCommunicationTemplates.ColumnsOfType <SecurityField>().FirstOrDefault();

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.CommunicationTemplate)).Id;

            // make a custom delete confirmation dialog
            gCommunicationTemplates.ShowConfirmDeleteDialog = false;

            string deleteScript = @"
    $('table.js-grid-communicationtemplate-list a.grid-delete-button').click(function( e ){
        var $btn = $(this);
        e.preventDefault();
        Rock.dialogs.confirm('Are you sure you want to delete this template?', function (result) {
            if (result) {
                if ( $btn.closest('tr').hasClass('js-has-communications') ) {
                    Rock.dialogs.confirm('Deleting this template will unlink it from communications that have used it. If you would like to keep the link consider inactivating the template instead. Are you sure you wish to delete this template?', function (result) {
                        if (result) {
                            window.location = e.target.href ? e.target.href : e.target.parentElement.href;
                        }
                    });
                } else {
                    window.location = e.target.href ? e.target.href : e.target.parentElement.href;
                }
            }
        });
    });
";

            ScriptManager.RegisterStartupScript(gCommunicationTemplates, gCommunicationTemplates.GetType(), "deleteCommunicationTemplateScript", deleteScript, true);
        }
コード例 #6
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            gActions.DataKeyNames    = new string[] { "Id" };
            gActions.GridRebind     += gActions_GridRebind;
            gActions.Actions.ShowAdd = false;
            gActions.IsDeleteEnabled = false;

            SecurityField securityField = gActions.Columns[2] as SecurityField;

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.RestAction)).Id;
        }
コード例 #7
0
ファイル: LayoutList.ascx.cs プロジェクト: shelsonjava/Rock
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            gLayouts.DataKeyNames      = new string[] { "Id" };
            gLayouts.Actions.AddClick += gLayouts_AddClick;
            gLayouts.Actions.ShowAdd   = true;
            gLayouts.IsDeleteEnabled   = true;
            gLayouts.GridRebind       += gLayouts_GridRebind;

            SecurityField securityField = gLayouts.Columns[4] as SecurityField;

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.Layout)).Id;
        }
コード例 #8
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it
            this.BlockUpdated += Block_BlockUpdated;
            this.AddConfigurationUpdateTrigger(upnlSettings);

            int definedTypeId = InitForDefinedType();

            _definedType = new DefinedTypeService(new RockContext()).Get(definedTypeId);

            if (_definedType != null)
            {
                gDefinedValues.DataKeyNames      = new string[] { "Id" };
                gDefinedValues.Actions.ShowAdd   = true;
                gDefinedValues.Actions.AddClick += gDefinedValues_Add;
                gDefinedValues.GridRebind       += gDefinedValues_GridRebind;
                gDefinedValues.GridReorder      += gDefinedValues_GridReorder;

                bool canAddEditDelete = IsUserAuthorized(Authorization.EDIT);
                gDefinedValues.Actions.ShowAdd = canAddEditDelete;
                gDefinedValues.IsDeleteEnabled = canAddEditDelete;

                AddAttributeColumns();

                if (_definedType.EnableSecurityOnValues)
                {
                    var securityField = new SecurityField();
                    securityField.ButtonCssClass = "btn btn-security btn-xs";
                    securityField.ToolTip        = "Secure Defined Value";
                    securityField.EntityTypeId   = EntityTypeCache.GetId(Rock.SystemGuid.EntityType.DEFINED_VALUE).Value;
                    gDefinedValues.Columns.Add(securityField);
                }

                var deleteField = new DeleteField();
                gDefinedValues.Columns.Add(deleteField);
                deleteField.Click += gDefinedValues_Delete;

                modalValue.SaveClick     += btnSaveValue_Click;
                modalValue.OnCancelScript = string.Format("$('#{0}').val('');", hfDefinedValueId.ClientID);

                lTitle.Text = _definedType.Name;
            }
            else
            {
                lTitle.Text = "Values";
            }
        }
コード例 #9
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            ApplyBlockSettings();

            modalDetails.SaveClick += modalDetails_SaveClick;

            this.BlockUpdated += GroupList_BlockUpdated;
            this.AddConfigurationUpdateTrigger(upnlGroupList);

            SecurityField securityField = gGroups.Columns.OfType <SecurityField>().FirstOrDefault();

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.Group)).Id;
        }
コード例 #10
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (CurrentPage.IsAuthorized("Administrate", CurrentPerson))
            {
                gSites.DataKeyNames         = new string[] { "id" };
                gSites.Actions.IsAddEnabled = true;
                gSites.Actions.AddClick    += gSites_Add;
                gSites.GridRebind          += gSites_GridRebind;
            }

            SecurityField securityField = gSites.Columns[3] as SecurityField;

            securityField.EntityType = typeof(Rock.Model.Site);
        }
コード例 #11
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            gSites.DataKeyNames      = new string[] { "Id" };
            gSites.Actions.AddClick += gSites_Add;
            gSites.GridRebind       += gSites_GridRebind;

            // Block Security and special attributes (RockPage takes care of View)
            bool canAddEdit = IsUserAuthorized(Authorization.EDIT);

            gSites.Actions.ShowAdd = canAddEdit;

            SecurityField securityField = gSites.Columns[5] as SecurityField;

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.Site)).Id;
        }
コード例 #12
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            gActions.DataKeyNames    = new string[] { "Id" };
            gActions.GridRebind     += gActions_GridRebind;
            gActions.Actions.ShowAdd = false;
            gActions.IsDeleteEnabled = false;
            if (GetAttributeValue("DetailPage").AsGuidOrNull() != null)
            {
                gActions.RowSelected += gActions_RowSelected;
            }

            SecurityField securityField = gActions.Columns[2] as SecurityField;

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.RestAction)).Id;
        }
コード例 #13
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            gSignatureDocumentTemplate.DataKeyNames      = new string[] { "Id" };
            gSignatureDocumentTemplate.Actions.ShowAdd   = true;
            gSignatureDocumentTemplate.Actions.AddClick += gSignatureDocumentTemplate_Add;
            gSignatureDocumentTemplate.GridRebind       += gSignatureDocumentTemplate_GridRebind;

            SecurityField securityField = gSignatureDocumentTemplate.ColumnsOfType <SecurityField>().First();

            securityField.EntityTypeId = EntityTypeCache.GetId <Rock.Model.SignatureDocumentTemplate>().Value;

            bool editAllowed = this.UserCanEdit;

            gSignatureDocumentTemplate.Actions.ShowAdd = editAllowed;
            gSignatureDocumentTemplate.IsDeleteEnabled = editAllowed;
        }
コード例 #14
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it
            this.BlockUpdated += Block_BlockUpdated;
            this.AddConfigurationUpdateTrigger(upnlContent);

            gAttributes.DataKeyNames      = new string[] { "Guid" };
            gAttributes.Actions.ShowAdd   = true;
            gAttributes.Actions.AddClick += gAttributes_Add;
            gAttributes.GridRebind       += gAttributes_GridRebind;
            gAttributes.GridReorder      += gAttributes_GridReorder;

            SecurityField securityField = gAttributes.Columns.OfType <SecurityField>().FirstOrDefault();

            securityField.EntityTypeId = EntityTypeCache.GetId <Attribute>() ?? 0;
        }
コード例 #15
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            gSites.DataKeyNames      = new string[] { "id" };
            gSites.Actions.ShowAdd   = true;
            gSites.Actions.AddClick += gSites_Add;
            gSites.GridRebind       += gSites_GridRebind;

            // Block Security and special attributes (RockPage takes care of "View")
            bool canAddEditDelete = IsUserAuthorized("Edit");

            gSites.Actions.ShowAdd = canAddEditDelete;
            gSites.IsDeleteEnabled = canAddEditDelete;

            SecurityField securityField = gSites.Columns[3] as SecurityField;

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.Site)).Id;
        }
コード例 #16
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            gBinaryFileType.DataKeyNames      = new string[] { "Id" };
            gBinaryFileType.Actions.ShowAdd   = true;
            gBinaryFileType.Actions.AddClick += gBinaryFileType_Add;
            gBinaryFileType.GridRebind       += gBinaryFileType_GridRebind;

            // Block Security and special attributes (RockPage takes care of View)
            bool canAddEditDelete = IsUserAuthorized(Authorization.EDIT);

            gBinaryFileType.Actions.ShowAdd = canAddEditDelete;
            gBinaryFileType.IsDeleteEnabled = canAddEditDelete;

            SecurityField securityField = gBinaryFileType.Columns.OfType <SecurityField>().FirstOrDefault();

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.BinaryFileType)).Id;
        }
コード例 #17
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            gPersonBadge.DataKeyNames      = new string[] { "id" };
            gPersonBadge.Actions.ShowAdd   = true;
            gPersonBadge.Actions.AddClick += gPersonBadge_Add;
            gPersonBadge.GridReorder      += gPersonBadge_GridReorder;
            gPersonBadge.GridRebind       += gPersonBadge_GridRebind;
            gPersonBadge.RowItemText       = "Person Badge";

            // Block Security and special attributes (RockPage takes care of View)
            bool canAddEditDelete = IsUserAuthorized(Authorization.EDIT);

            gPersonBadge.Actions.ShowAdd = canAddEditDelete;
            gPersonBadge.IsDeleteEnabled = canAddEditDelete;

            SecurityField securityField = gPersonBadge.Columns[3] as SecurityField;

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.PersonBadge)).Id;
        }
コード例 #18
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            BindFilter();
            rFilter.ApplyFilterClick   += rFilter_ApplyFilterClick;
            rFilter.DisplayFilterValue += rFilter_DisplayFilterValue;

            gCommunication.DataKeyNames      = new string[] { "Id" };
            gCommunication.Actions.ShowAdd   = true;
            gCommunication.Actions.AddClick += Actions_AddClick;
            gCommunication.GridRebind       += gCommunication_GridRebind;

            // The created by column/filter should only be displayed if user is allowed to approve
            _canEdit            = IsUserAuthorized(Authorization.EDIT);
            ppCreatedBy.Visible = _canEdit;
            gCommunication.Columns[4].Visible = _canEdit;

            SecurityField securityField = gCommunication.Columns[4] as SecurityField;

            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.CommunicationTemplate)).Id;
        }
コード例 #19
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (!bool.TryParse(GetAttributeValue("ConfigureType"), out _configuredType))
            {
                _configuredType = true;
            }

            string entityTypeName = GetAttributeValue("Entity");

            _entityTypeId          = Rock.Web.Cache.EntityTypeCache.GetId(entityTypeName);
            _entityQualifierColumn = GetAttributeValue("EntityQualifierColumn");
            _entityQualifierValue  = GetAttributeValue("EntityQualifierValue");
            _displayValueEdit      = Convert.ToBoolean(GetAttributeValue("AllowSettingofValues"));

            string entityIdString = GetAttributeValue("EntityId");

            if (!string.IsNullOrWhiteSpace(entityIdString))
            {
                int entityIdint = 0;
                if (int.TryParse(entityIdString, out entityIdint) && entityIdint > 0)
                {
                    _entityId = entityIdint;
                }
            }

            _canConfigure = CurrentPage.IsAuthorized("Administrate", CurrentPerson);

            rFilter.ApplyFilterClick += rFilter_ApplyFilterClick;

            if (_canConfigure)
            {
                rGrid.DataKeyNames    = new string[] { "id" };
                rGrid.Actions.ShowAdd = true;

                rGrid.Actions.AddClick += rGrid_Add;
                rGrid.GridRebind       += rGrid_GridRebind;
                rGrid.RowDataBound     += rGrid_RowDataBound;

                rGrid.Columns[1].Visible  = !_configuredType;
                rGrid.Columns[8].Visible  = !_displayValueEdit;
                rGrid.Columns[9].Visible  = _displayValueEdit;
                rGrid.Columns[10].Visible = _displayValueEdit;

                SecurityField securityField = rGrid.Columns[11] as SecurityField;
                securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.Attribute)).Id;

                modalDetails.SaveClick     += modalDetails_SaveClick;
                modalDetails.OnCancelScript = string.Format("$('#{0}').val('');", hfIdValues.ClientID);

                string editAttributeId = Request.Form[hfIdValues.UniqueID];
                if (Page.IsPostBack && editAttributeId != null && editAttributeId.Trim() != string.Empty)
                {
                    ShowEditValue(int.Parse(editAttributeId), false);
                }

                if (!_configuredType)
                {
                    ddlEntityType.Items.Clear();
                    ddlEntityType.Items.Add(new ListItem("None (Global Attributes)", None.IdValue));

                    ddlAttrEntityType.Items.Clear();
                    ddlAttrEntityType.Items.Add(new ListItem("None (Global Attribute)", None.IdValue));

                    new EntityTypeService().GetEntityListItems().ForEach(l =>
                    {
                        ddlEntityType.Items.Add(l);
                        ddlAttrEntityType.Items.Add(l);
                    });
                }

                BindFilter();
            }
            else
            {
                nbMessage.Text    = "You are not authorized to configure this page";
                nbMessage.Visible = true;
            }
        }
コード例 #20
0
        /// <summary>
        /// Set the properties of the main grid.
        /// </summary>
        private void InitializeGrid()
        {
            ListGridControl.DataKeyNames = new string[] { "Id" };
            ListGridControl.RowItemText  = _entityType.FriendlyName;
            ListGridControl.ExportSource = ExcelExportSource.DataSource;

            ListGridControl.HideDeleteButtonForIsSystem = this.PreventSystemItemDelete;

            ListGridControl.Actions.AddClick += gList_Add;
            ListGridControl.GridRebind       += gList_GridRebind;

            ListGridControl.AllowSorting = !this.ShowItemReorder;

            // Show Reorder handle
            if (this.ShowItemReorder)
            {
                _reorderColumn = new ReorderField();

                ListGridControl.Columns.Insert(0, _reorderColumn);

                ListGridControl.GridReorder += gList_GridReorder;
            }

            // Verify block authorization
            bool canAddEditDelete = IsUserAuthorized(Authorization.EDIT);
            bool canAdministrate  = IsUserAuthorized(Authorization.ADMINISTRATE);

            ListGridControl.Actions.ShowAdd = this.ShowItemAdd && canAddEditDelete;

            if (canAddEditDelete)
            {
                ListGridControl.RowSelected += gList_Edit;
            }

            // Show Security button
            if (this.ShowItemSecurity &&
                canAdministrate)
            {
                _securityColumn = ListGridControl.ColumnsOfType <SecurityField>().FirstOrDefault();

                if (_securityColumn == null)
                {
                    _securityColumn = new SecurityField();

                    ListGridControl.Columns.Add(_securityColumn);
                }

                _securityColumn.EntityTypeId = _entityType.Id;
            }

            // Show Delete button
            ListGridControl.IsDeleteEnabled = this.ShowItemDelete && canAddEditDelete;

            if (this.ShowItemDelete &&
                canAddEditDelete)
            {
                _deleteColumn = ListGridControl.ColumnsOfType <DeleteField>().FirstOrDefault();

                if (_deleteColumn == null)
                {
                    _deleteColumn = new DeleteField();

                    _deleteColumn.Click += gList_Delete;

                    ListGridControl.Columns.Add(_deleteColumn);
                }
            }

            // Perform additional customization of the list grid if required.
            OnConfigureListGrid(this.ListGridControl);
        }
コード例 #21
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (!bool.TryParse(GetAttributeValue("ConfigureType"), out _configuredType))
            {
                _configuredType = true;
            }


            bool displayShowInGrid = true;

            if (bool.TryParse(GetAttributeValue("DisplayShowInGrid"), out displayShowInGrid) && displayShowInGrid)
            {
                edtAttribute.ShowInGridVisible = true;
            }
            else
            {
                edtAttribute.ShowInGridVisible = false;
            }

            Guid entityTypeGuid = Guid.Empty;

            if (Guid.TryParse(GetAttributeValue("Entity"), out entityTypeGuid))
            {
                _entityTypeId = EntityTypeCache.Read(entityTypeGuid).Id;
            }
            _entityQualifierColumn = GetAttributeValue("EntityQualifierColumn");
            _entityQualifierValue  = GetAttributeValue("EntityQualifierValue");
            _displayValueEdit      = Convert.ToBoolean(GetAttributeValue("AllowSettingofValues"));

            string entityIdString = GetAttributeValue("EntityId");

            if (!string.IsNullOrWhiteSpace(entityIdString))
            {
                int entityIdint = 0;
                if (int.TryParse(entityIdString, out entityIdint) && entityIdint > 0)
                {
                    _entityId = entityIdint;
                }
            }

            _canConfigure = IsUserAuthorized(Authorization.ADMINISTRATE);

            rFilter.ApplyFilterClick += rFilter_ApplyFilterClick;

            if (_canConfigure)
            {
                rGrid.DataKeyNames    = new string[] { "id" };
                rGrid.Actions.ShowAdd = true;

                rGrid.Actions.AddClick += rGrid_Add;
                rGrid.GridRebind       += rGrid_GridRebind;
                rGrid.RowDataBound     += rGrid_RowDataBound;

                rGrid.Columns[1].Visible = !_configuredType;   // qualifier

                rGrid.Columns[4].Visible = !_displayValueEdit; // default value / value
                rGrid.Columns[5].Visible = _displayValueEdit;  // default value / value
                rGrid.Columns[6].Visible = _displayValueEdit;  // edit

                SecurityField securityField = rGrid.Columns[7] as SecurityField;
                securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.Attribute)).Id;

                mdAttribute.SaveClick      += mdAttribute_SaveClick;
                mdAttributeValue.SaveClick += mdAttributeValue_SaveClick;

                if (!_configuredType)
                {
                    var entityTypeList = new EntityTypeService(new RockContext()).GetEntities().ToList();
                    ddlEntityType.EntityTypes     = entityTypeList;
                    ddlAttrEntityType.EntityTypes = entityTypeList;
                }

                BindFilter();
            }
            else
            {
                nbMessage.Text    = "You are not authorized to configure this page";
                nbMessage.Visible = true;
            }
        }
コード例 #22
0
        /// <summary>
        /// Adds the attribute columns.
        /// </summary>
        private void AddDynamicControls()
        {
            // Clear the filter controls
            phAttributeFilters.Controls.Clear();

            var deleteCol = gConnectionOpportunities.Columns.OfType <DeleteField>().FirstOrDefault();

            if (deleteCol != null)
            {
                gConnectionOpportunities.Columns.Remove(deleteCol);
            }

            var securityCol = gConnectionOpportunities.Columns.OfType <SecurityField>().FirstOrDefault();

            if (securityCol != null)
            {
                gConnectionOpportunities.Columns.Remove(securityCol);
            }

            // Remove attribute columns
            foreach (var column in gConnectionOpportunities.Columns.OfType <AttributeField>().ToList())
            {
                gConnectionOpportunities.Columns.Remove(column);
            }

            if (AvailableAttributes != null)
            {
                foreach (var attribute in AvailableAttributes)
                {
                    var control = attribute.FieldType.Field.FilterControl(attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter);
                    if (control != null)
                    {
                        if (control is IRockControl)
                        {
                            var rockControl = (IRockControl)control;
                            rockControl.Label = attribute.Name;
                            rockControl.Help  = attribute.Description;
                            phAttributeFilters.Controls.Add(control);
                        }
                        else
                        {
                            var wrapper = new RockControlWrapper();
                            wrapper.ID    = control.ID + "_wrapper";
                            wrapper.Label = attribute.Name;
                            wrapper.Controls.Add(control);
                            phAttributeFilters.Controls.Add(wrapper);
                        }

                        string savedValue = rFilter.GetUserPreference(MakeKeyUniqueToConnectionType(attribute.Key));
                        if (!string.IsNullOrWhiteSpace(savedValue))
                        {
                            try
                            {
                                var values = JsonConvert.DeserializeObject <List <string> >(savedValue);
                                attribute.FieldType.Field.SetFilterValues(control, attribute.QualifierValues, values);
                            }
                            catch { }
                        }
                    }

                    string dataFieldExpression = attribute.Key;
                    bool   columnExists        = gConnectionOpportunities.Columns.OfType <AttributeField>().FirstOrDefault(a => a.DataField.Equals(dataFieldExpression)) != null;
                    if (!columnExists)
                    {
                        AttributeField boundField = new AttributeField();
                        boundField.DataField   = dataFieldExpression;
                        boundField.AttributeId = attribute.Id;
                        boundField.HeaderText  = attribute.Name;

                        var attributeCache = Rock.Web.Cache.AttributeCache.Get(attribute.Id);
                        if (attributeCache != null)
                        {
                            boundField.ItemStyle.HorizontalAlign = attributeCache.FieldType.Field.AlignValue;
                        }

                        gConnectionOpportunities.Columns.Add(boundField);
                    }
                }
            }

            securityCol              = new SecurityField();
            securityCol.TitleField   = "Name";
            securityCol.EntityTypeId = EntityTypeCache.Get(typeof(Rock.Model.ConnectionOpportunity)).Id;
            gConnectionOpportunities.Columns.Add(securityCol);

            deleteCol = new DeleteField();
            gConnectionOpportunities.Columns.Add(deleteCol);
            deleteCol.Click += DeleteConnectionOpportunity_Click;
        }
コード例 #23
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _channelId = PageParameter("contentChannelId").AsIntegerOrNull();
            string cssIcon        = "fa fa-bullhorn";
            var    contentChannel = new ContentChannelService(new RockContext()).Get(_channelId.Value);

            if (contentChannel != null)
            {
                string startHeading = contentChannel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Active";
                bool   isRange      = contentChannel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange;

                gItems.Columns[1].HeaderText = startHeading;
                gItems.Columns[3].HeaderText = startHeading;

                if (contentChannel.ContentChannelType.IncludeTime)
                {
                    gItems.Columns[1].Visible = true;
                    gItems.Columns[2].Visible = isRange;
                    gItems.Columns[3].Visible = false;
                    gItems.Columns[4].Visible = false;
                }
                else
                {
                    gItems.Columns[1].Visible = false;
                    gItems.Columns[2].Visible = false;
                    gItems.Columns[3].Visible = true;
                    gItems.Columns[4].Visible = isRange;
                }

                gItems.Columns[5].Visible = !contentChannel.ContentChannelType.DisablePriority;
                lContentChannel.Text      = contentChannel.Name;
                _typeId = contentChannel.ContentChannelTypeId;

                if (!string.IsNullOrWhiteSpace(contentChannel.IconCssClass))
                {
                    cssIcon = contentChannel.IconCssClass;
                }
            }

            lIcon.Text = string.Format("<i class='{0}'></i>", cssIcon);

            // Block Security and special attributes (RockPage takes care of View)
            bool canAddEditDelete = IsUserAuthorized(Authorization.EDIT);

            gfFilter.ApplyFilterClick   += gfFilter_ApplyFilterClick;
            gfFilter.DisplayFilterValue += gfFilter_DisplayFilterValue;

            gItems.DataKeyNames      = new string[] { "Id" };
            gItems.Actions.ShowAdd   = canAddEditDelete;
            gItems.IsDeleteEnabled   = canAddEditDelete;
            gItems.Actions.AddClick += gItems_Add;
            gItems.GridRebind       += gItems_GridRebind;

            AddAttributeColumns();

            if (contentChannel != null && contentChannel.RequiresApproval)
            {
                var statusField = new BoundField();
                gItems.Columns.Add(statusField);
                statusField.DataField      = "Status";
                statusField.HeaderText     = "Status";
                statusField.SortExpression = "Status";
                statusField.HtmlEncode     = false;
            }

            var securityField = new SecurityField();

            gItems.Columns.Add(securityField);
            securityField.TitleField   = "Title";
            securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.ContentChannelItem)).Id;

            var deleteField = new DeleteField();

            gItems.Columns.Add(deleteField);
            deleteField.Click += gItems_Delete;

            // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it
            this.BlockUpdated += Block_BlockUpdated;
            this.AddConfigurationUpdateTrigger(upnlContent);
        }
コード例 #24
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _configuredType = GetAttributeValue("ConfigureType").AsBooleanOrNull() ?? true;
            edtAttribute.ShowInGridVisible = GetAttributeValue("EnableShowInGrid").AsBooleanOrNull() ?? false;

            Guid?entityTypeGuid = GetAttributeValue("Entity").AsGuidOrNull();

            if (entityTypeGuid.HasValue)
            {
                _entityTypeId = EntityTypeCache.Read(entityTypeGuid.Value).Id;
            }

            _entityQualifierColumn = GetAttributeValue("EntityQualifierColumn");
            _entityQualifierValue  = GetAttributeValue("EntityQualifierValue");
            _displayValueEdit      = GetAttributeValue("AllowSettingofValues").AsBooleanOrNull() ?? false;

            _entityId = GetAttributeValue("EntityId").AsIntegerOrNull();
            if (_entityId == 0)
            {
                _entityId = null;
            }

            _canConfigure = IsUserAuthorized(Rock.Security.Authorization.ADMINISTRATE);

            _enableOrdering = GetAttributeValue("EnableOrdering").AsBoolean();

            rFilter.ApplyFilterClick += rFilter_ApplyFilterClick;

            if (_canConfigure)
            {
                rGrid.DataKeyNames      = new string[] { "Id" };
                rGrid.Actions.ShowAdd   = true;
                rGrid.AllowSorting      = !_enableOrdering;
                rGrid.GridReorder      += RGrid_GridReorder;
                rGrid.Actions.AddClick += rGrid_Add;
                rGrid.GridRebind       += rGrid_GridRebind;
                rGrid.RowDataBound     += rGrid_RowDataBound;

                rGrid.Columns[0].Visible = _enableOrdering;
                rGrid.Columns[2].Visible = !_configuredType;   // qualifier

                rGrid.Columns[5].Visible = !_displayValueEdit; // default value / value
                rGrid.Columns[6].Visible = _displayValueEdit;  // default value / value
                rGrid.Columns[7].Visible = _displayValueEdit;  // edit

                SecurityField securityField = rGrid.Columns[8] as SecurityField;
                securityField.EntityTypeId = EntityTypeCache.Read(typeof(Rock.Model.Attribute)).Id;

                mdAttribute.SaveClick      += mdAttribute_SaveClick;
                mdAttributeValue.SaveClick += mdAttributeValue_SaveClick;

                if (!_configuredType)
                {
                    var entityTypeList = new EntityTypeService(new RockContext()).GetEntities().ToList();
                    ddlEntityType.EntityTypes     = entityTypeList;
                    ddlAttrEntityType.EntityTypes = entityTypeList;
                }

                BindFilter();
            }
            else
            {
                nbMessage.Text    = "You are not authorized to configure this page";
                nbMessage.Visible = true;
            }
        }
コード例 #25
0
        protected void AddDynamicControls(ContentChannel channel)
        {
            // Remove all columns
            gContentChannelItems.Columns.Clear();
            phAttributeFilters.Controls.Clear();

            if (channel != null)
            {
                // Add Reorder column
                var reorderField = new ReorderField();
                gContentChannelItems.Columns.Add(reorderField);

                // Add Title column
                var titleField = new BoundField();
                titleField.DataField      = "Title";
                titleField.HeaderText     = "Title";
                titleField.SortExpression = "Title";
                gContentChannelItems.Columns.Add(titleField);

                // Add Attribute columns
                int    entityTypeId  = EntityTypeCache.Get(typeof(Rock.Model.ContentChannelItem)).Id;
                string channelId     = channel.Id.ToString();
                string channelTypeId = channel.ContentChannelTypeId.ToString();
                foreach (var attribute in AvailableAttributes)
                {
                    var control = attribute.FieldType.Field.FilterControl(attribute.QualifierValues, "filter_" + attribute.Id.ToString(), false, Rock.Reporting.FilterMode.SimpleFilter);
                    if (control != null)
                    {
                        if (control is IRockControl)
                        {
                            var rockControl = ( IRockControl )control;
                            rockControl.Label = attribute.Name;
                            rockControl.Help  = attribute.Description;
                            phAttributeFilters.Controls.Add(control);
                        }
                        else
                        {
                            var wrapper = new RockControlWrapper();
                            wrapper.ID    = control.ID + "_wrapper";
                            wrapper.Label = attribute.Name;
                            wrapper.Controls.Add(control);
                            phAttributeFilters.Controls.Add(wrapper);
                        }

                        string savedValue = gfFilter.GetUserPreference(MakeKeyUniqueToChannel(channel.Id, attribute.Key));
                        if (!string.IsNullOrWhiteSpace(savedValue))
                        {
                            try
                            {
                                var values = JsonConvert.DeserializeObject <List <string> >(savedValue);
                                attribute.FieldType.Field.SetFilterValues(control, attribute.QualifierValues, values);
                            }
                            catch
                            {
                                // intentionally ignore
                            }
                        }
                    }

                    string dataFieldExpression = attribute.Key;
                    bool   columnExists        = gContentChannelItems.Columns.OfType <AttributeField>().FirstOrDefault(a => a.DataField.Equals(dataFieldExpression)) != null;
                    if (!columnExists)
                    {
                        AttributeField boundField = new AttributeField();
                        boundField.DataField   = dataFieldExpression;
                        boundField.AttributeId = attribute.Id;
                        boundField.HeaderText  = attribute.Name;
                        boundField.ItemStyle.HorizontalAlign = attribute.FieldType.Field.AlignValue;
                        gContentChannelItems.Columns.Add(boundField);
                    }
                }

                if (channel.ContentChannelType.DateRangeType != ContentChannelDateType.NoDates)
                {
                    RockBoundField startDateTimeField;
                    RockBoundField expireDateTimeField;
                    if (channel.ContentChannelType.IncludeTime)
                    {
                        startDateTimeField  = new DateTimeField();
                        expireDateTimeField = new DateTimeField();
                    }
                    else
                    {
                        startDateTimeField  = new DateField();
                        expireDateTimeField = new DateField();
                    }

                    startDateTimeField.DataField      = "StartDateTime";
                    startDateTimeField.HeaderText     = channel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Date";
                    startDateTimeField.SortExpression = "StartDateTime";
                    gContentChannelItems.Columns.Add(startDateTimeField);

                    var dateStatusField = new BoundField();
                    gContentChannelItems.Columns.Add(dateStatusField);
                    dateStatusField.DataField  = "DateStatus";
                    dateStatusField.HeaderText = "";
                    dateStatusField.HtmlEncode = false;

                    expireDateTimeField.DataField      = "ExpireDateTime";
                    expireDateTimeField.HeaderText     = "Expire";
                    expireDateTimeField.SortExpression = "ExpireDateTime";
                    if (channel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange)
                    {
                        gContentChannelItems.Columns.Add(expireDateTimeField);
                    }
                }

                if (!channel.ContentChannelType.DisablePriority)
                {
                    // Priority column
                    var priorityField = new BoundField();
                    priorityField.DataField                 = "Priority";
                    priorityField.HeaderText                = "Priority";
                    priorityField.SortExpression            = "Priority";
                    priorityField.DataFormatString          = "{0:N0}";
                    priorityField.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                    gContentChannelItems.Columns.Add(priorityField);
                }

                // Status column
                if (channel.RequiresApproval)
                {
                    var statusField = new BoundField();
                    gContentChannelItems.Columns.Add(statusField);
                    statusField.DataField      = "Status";
                    statusField.HeaderText     = "Status";
                    statusField.SortExpression = "Status";
                    statusField.HtmlEncode     = false;
                }

                // Add occurrences Count column
                var occurrencesField = new BoolField();
                occurrencesField.DataField  = "Occurrences";
                occurrencesField.HeaderText = "Event Occurrences";
                gContentChannelItems.Columns.Add(occurrencesField);

                // Add Created By column
                var createdByPersonNameField = new BoundField();
                createdByPersonNameField.DataField  = "CreatedByPersonName";
                createdByPersonNameField.HeaderText = "Created By";
                createdByPersonNameField.HtmlEncode = false;
                gContentChannelItems.Columns.Add(createdByPersonNameField);

                // Add Tag Field
                if (channel.IsTaggingEnabled)
                {
                    var tagField = new BoundField();
                    gContentChannelItems.Columns.Add(tagField);
                    tagField.DataField          = "Tags";
                    tagField.HeaderText         = "Tags";
                    tagField.ItemStyle.CssClass = "taglist";
                    tagField.HtmlEncode         = false;
                }

                bool canEditChannel = channel.IsAuthorized(Rock.Security.Authorization.EDIT, CurrentPerson);
                gContentChannelItems.Actions.ShowAdd = canEditChannel;
                gContentChannelItems.IsDeleteEnabled = canEditChannel;
                if (canEditChannel)
                {
                    var securityField = new SecurityField();
                    gContentChannelItems.Columns.Add(securityField);
                    securityField.TitleField   = "Title";
                    securityField.EntityTypeId = EntityTypeCache.Get(typeof(Rock.Model.ContentChannelItem)).Id;

                    var deleteField = new DeleteField();
                    gContentChannelItems.Columns.Add(deleteField);
                    deleteField.Click += gContentChannelItems_Delete;
                }
            }
        }
コード例 #26
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // set person context
            var contextEntity = this.ContextEntity();

            if (contextEntity != null)
            {
                if (contextEntity is Person)
                {
                    _person = contextEntity as Person;
                }
            }

            // set person if grid should be filtered by the current person
            if (GetAttributeValue(AttributeKey.FilterItemsForCurrentUser).AsBoolean())
            {
                _person = CurrentPerson;
            }

            gfFilter.Visible = GetAttributeValue(AttributeKey.ShowFilters).AsBoolean();

            if (string.IsNullOrWhiteSpace(GetAttributeValue(AttributeKey.ContentChannel)))
            {
                _channelId = PageParameter(PageParameterKey.ContentChannelId).AsIntegerOrNull();
            }
            else
            {
                _channelId = new ContentChannelService(new RockContext()).Get(GetAttributeValue(AttributeKey.ContentChannel).AsGuid()).Id;
            }

            if (_channelId != null)
            {
                upnlContent.Visible = true;

                string cssIcon        = "fa fa-bullhorn";
                var    contentChannel = new ContentChannelService(new RockContext()).Get(_channelId.Value);
                if (contentChannel != null)
                {
                    string startHeading = contentChannel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Active";

                    _manuallyOrdered = contentChannel.ItemsManuallyOrdered;

                    var startDateTimeColumn  = gItems.ColumnsWithDataField("StartDateTime").OfType <DateTimeField>().FirstOrDefault();
                    var expireDateTimeColumn = gItems.ColumnsWithDataField("ExpireDateTime").OfType <DateTimeField>().FirstOrDefault();
                    var startDateColumn      = gItems.ColumnsWithDataField("StartDateTime").OfType <DateField>().FirstOrDefault();
                    var expireDateColumn     = gItems.ColumnsWithDataField("ExpireDateTime").OfType <DateField>().FirstOrDefault();
                    var priorityColumn       = gItems.ColumnsWithDataField("Priority").FirstOrDefault();

                    //// NOTE: The EventOccurrences Column's visibility is set in GridBind()

                    startDateTimeColumn.HeaderText = startHeading;
                    startDateColumn.HeaderText     = startHeading;

                    ddlStatus.Visible = contentChannel.RequiresApproval && !contentChannel.ContentChannelType.DisableStatus;

                    if (contentChannel.ContentChannelType.IncludeTime)
                    {
                        startDateTimeColumn.Visible  = contentChannel.ContentChannelType.DateRangeType != ContentChannelDateType.NoDates;
                        expireDateTimeColumn.Visible = contentChannel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange && GetAttributeValue(AttributeKey.ShowExpireColumn).AsBoolean();
                        startDateColumn.Visible      = false;
                        expireDateColumn.Visible     = false;
                    }
                    else
                    {
                        startDateTimeColumn.Visible  = false;
                        expireDateTimeColumn.Visible = false;
                        startDateColumn.Visible      = contentChannel.ContentChannelType.DateRangeType != ContentChannelDateType.NoDates;
                        expireDateColumn.Visible     = contentChannel.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange && GetAttributeValue(AttributeKey.ShowExpireColumn).AsBoolean();
                    }

                    priorityColumn.Visible = !contentChannel.ContentChannelType.DisablePriority && GetAttributeValue(AttributeKey.ShowPriorityColumn).AsBoolean();

                    lContentChannel.Text = contentChannel.Name;
                    _typeId = contentChannel.ContentChannelTypeId;

                    if (!string.IsNullOrWhiteSpace(contentChannel.IconCssClass))
                    {
                        cssIcon = contentChannel.IconCssClass;
                    }
                }

                lIcon.Text = string.Format("<i class='{0}'></i>", cssIcon);

                // Block Security and special attributes (RockPage takes care of View)
                bool canAddEditDelete = IsUserAuthorized(Authorization.EDIT);

                gfFilter.ApplyFilterClick   += gfFilter_ApplyFilterClick;
                gfFilter.DisplayFilterValue += gfFilter_DisplayFilterValue;

                gItems.DataKeyNames      = new string[] { "Id" };
                gItems.AllowSorting      = !_manuallyOrdered;
                gItems.Actions.ShowAdd   = canAddEditDelete;
                gItems.IsDeleteEnabled   = canAddEditDelete;
                gItems.Actions.AddClick += gItems_Add;
                gItems.GridRebind       += gItems_GridRebind;
                gItems.GridReorder      += GItems_GridReorder;
                gItems.EntityTypeId      = EntityTypeCache.Get <ContentChannelItem>().Id;

                AddAttributeColumns();

                if (contentChannel != null && contentChannel.RequiresApproval && !contentChannel.ContentChannelType.DisableStatus)
                {
                    var statusField = new BoundField();
                    gItems.Columns.Add(statusField);
                    statusField.DataField      = "Status";
                    statusField.HeaderText     = "Status";
                    statusField.SortExpression = "Status";
                    statusField.HtmlEncode     = false;
                }

                var securityField = new SecurityField();
                gItems.Columns.Add(securityField);
                securityField.TitleField   = "Title";
                securityField.EntityTypeId = EntityTypeCache.Get(typeof(Rock.Model.ContentChannelItem)).Id;

                var securityColumn = gItems.Columns.OfType <SecurityField>().FirstOrDefault();
                if (securityColumn != null)
                {
                    securityColumn.Visible = GetAttributeValue(AttributeKey.ShowSecurityColumn).AsBoolean();
                }

                var deleteField = new DeleteField();
                gItems.Columns.Add(deleteField);
                deleteField.Click += gItems_Delete;

                // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it
                this.BlockUpdated += Block_BlockUpdated;
                this.AddConfigurationUpdateTrigger(upnlContent);
            }
            else
            {
                upnlContent.Visible = false;
            }
        }