//private BlockCache _block = null; //private string _zoneName = string.Empty; /// <summary> /// Raises the <see cref="E:Init" /> event. /// </summary> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected override void OnInit(EventArgs e) { Rock.Web.UI.DialogMasterPage masterPage = this.Page.Master as Rock.Web.UI.DialogMasterPage; if (masterPage != null) { masterPage.OnSave += new EventHandler <EventArgs>(masterPage_OnSave); } try { int blockId = Convert.ToInt32(PageParameter("BlockId")); BlockCache _block = BlockCache.Read(blockId); if (_block.IsAuthorized("Administrate", CurrentPerson)) { phAttributes.Controls.Clear(); Rock.Attribute.Helper.AddEditControls(_block, phAttributes, !Page.IsPostBack); } else { DisplayError("You are not authorized to edit this block"); } } catch (SystemException ex) { DisplayError(ex.Message); } base.OnInit(e); }
/// <summary> /// Raises the <see cref="E:Init" /> event. /// </summary> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected override void OnInit(EventArgs e) { Rock.Web.UI.DialogMasterPage masterPage = this.Page.Master as Rock.Web.UI.DialogMasterPage; if (masterPage != null) { masterPage.OnSave += new EventHandler <EventArgs>(masterPage_OnSave); } try { int blockId = Convert.ToInt32(PageParameter("BlockId")); BlockCache _block = BlockCache.Read(blockId); if (_block.IsAuthorized("Administrate", CurrentPerson)) { phAttributes.Controls.Clear(); phAdvancedAttributes.Controls.Clear(); if (_block.Attributes != null) { foreach (var attributeCategory in Rock.Attribute.Helper.GetAttributeCategories(_block)) { if (attributeCategory.Category != null && attributeCategory.Category.Name.Equals("advanced", StringComparison.OrdinalIgnoreCase)) { Rock.Attribute.Helper.AddEditControls( string.Empty, attributeCategory.Attributes.Select(a => a.Key).ToList(), _block, phAdvancedAttributes, string.Empty, !Page.IsPostBack, new List <string>()); } else { Rock.Attribute.Helper.AddEditControls( attributeCategory.Category != null ? attributeCategory.Category.Name : string.Empty, attributeCategory.Attributes.Select(a => a.Key).ToList(), _block, phAttributes, string.Empty, !Page.IsPostBack, new List <string>()); } } } } else { DisplayError("You are not authorized to edit this block"); } } catch (SystemException ex) { DisplayError(ex.Message); } base.OnInit(e); }