/// <summary> /// Loads aan existing Section from the database or creates a new one if the SectionId = -1 /// </summary> private void LoadSection() { // NOTE: Called from OnInit! if (Context.Request.QueryString["SectionId"] != null) { if (Int32.Parse(Context.Request.QueryString["SectionId"]) == -1) { // Create a new section instance _activeSection = new Section(); _activeSection.Node = ActiveNode; if (!IsPostBack) { _activeSection.CopyRolesFromNode(); } } else { // Get section data _activeSection = (Section)CoreRepository.GetObjectById(typeof(Section), Int32.Parse( Context.Request.QueryString[ "SectionId"])); } } // Preload available ModuleTypes because we might need them to display the CustomSettings // of the first ModuleType if none is selected (when adding a brand new Section). _availableModuleTypes = CoreRepository.GetAll(typeof(ModuleType), "Name"); // Create the controls for the ModuleType-specific settings. CreateCustomSettings(); }
private void BindRoles() { IList roles = CoreRepository.GetAll(typeof(Role), "PermissionLevel"); rptRoles.ItemDataBound += rptRoles_ItemDataBound; rptRoles.DataSource = roles; rptRoles.DataBind(); }
private void BindCompatibleSections() { string selectedAction = String.Empty; if (ddlAction.SelectedIndex == -1 && ddlAction.Items.Count > 0) { selectedAction = ddlAction.Items[0].Value; } else { selectedAction = ddlAction.SelectedValue; } ArrayList compatibleModuleTypes = new ArrayList(); // Get all ModuleTypes. IList moduleTypes = CoreRepository.GetAll(typeof(ModuleType)); foreach (ModuleType mt in moduleTypes) { string assemblyQualifiedName = mt.ClassName + ", " + mt.AssemblyName; Type moduleTypeType = Type.GetType(assemblyQualifiedName); if (moduleTypeType != null) // throw exception when moduleTypeType == null? { ModuleBase moduleInstance = base.ModuleLoader.GetModuleFromType(mt); if (moduleInstance is IActionConsumer) { IActionConsumer actionConsumer = moduleInstance as IActionConsumer; CMS.Core.Communication.Action currentAction = _activeActionProvider.GetOutboundActions().FindByName(selectedAction); if (actionConsumer.GetInboundActions().Contains(currentAction)) { compatibleModuleTypes.Add(mt); } } } } if (compatibleModuleTypes.Count > 0) { // Retrieve all sections that have the compatible ModuleTypes IList compatibleSections = CoreRepository.GetSectionsByModuleTypes(compatibleModuleTypes); if (compatibleSections.Count > 0) { pnlTo.Visible = true; btnSave.Enabled = true; ddlSectionTo.DataSource = compatibleSections; ddlSectionTo.DataValueField = "Id"; ddlSectionTo.DataTextField = "FullName"; ddlSectionTo.DataBind(); } else { pnlTo.Visible = false; btnSave.Enabled = false; } } }
private void BindTemplates() { IList templates = CoreRepository.GetAll(typeof(Template), "Name"); // Bind ddlTemplates.DataSource = templates; ddlTemplates.DataValueField = "Id"; ddlTemplates.DataTextField = "Name"; ddlTemplates.DataBind(); if (ActiveNode != null && ActiveNode.Template != null) { ListItem li = ddlTemplates.Items.FindByValue(ActiveNode.Template.Id.ToString()); if (li != null) { li.Selected = true; } } }