/// <summary> /// Returns the proper edit ascx Control. Uses the current Page to load the Control. /// If the user has no right a error control is returned /// </summary> /// <param name="p">The current Page</param> /// <returns>Edit ascx Control</returns> public static Control GetEditControl(Page p) { PortalDefinition.Tab tab = PortalDefinition.CurrentTab; PortalDefinition.Module m = tab.GetModule(p.Request["ModuleRef"]); if (!UserManagement.HasEditRights(HttpContext.Current.User, m.roles)) { return(GetNoAccessControl()); } m.LoadModuleSettings(); Module em = null; if (m.moduleSettings != null) { // Module Settings are present, use custom ascx Control em = (Module)p.LoadControl(Config.GetModuleVirtualPath(m.type) + m.moduleSettings.editCtrl); } else { // Use default ascx control (Edit[type].ascx) em = (Module)p.LoadControl(Config.GetModuleVirtualPath(m.type) + "Edit" + m.type + ".ascx"); } // Initialize the control em.InitModule( tab.reference, m.reference, m.type, Config.GetModuleDataVirtualPath(m.type), true); return(em); }
private void Page_Load(object sender, System.EventArgs e) { // Set the link per default invisible tdEdit.Visible = false; if (UserManagement.HasEditRights(Page.User, ModuleDef.roles)) { // User has right, continue if (ModuleDef.moduleSettings == null) { // no Module Settings, set visible tdEdit.Visible = true; } else { // Module has module settings if (ModuleDef.moduleSettings.HasEditCtrl) { // Module has a edit control, set visible tdEdit.Visible = true; } } } if (Page.User.IsInRole(Portal.API.Config.AdminRole)) { ovm.Visible = true; lnkEditLink.Visible = false; } else { ovm.Visible = false; lnkEditLink.Visible = true; } }
/// <summary> /// Returns the proper edit ascx Control. Uses the current Page to load the Control. /// If the user has no right a error control is returned /// </summary> /// <param name="p">The current Page</param> /// <returns>Edit ascx Control</returns> internal static Control GetEditControl(Page p) { PortalDefinition.Tab tab = PortalDefinition.GetCurrentTab(); PortalDefinition.Module m = tab.GetModule(p.Request["ModuleRef"]); if (!UserManagement.HasEditRights(HttpContext.Current.User, m.roles)) { // No rights, return a error Control Label l = new Label(); l.CssClass = "Error"; l.Text = "Access denied!"; return(l); } m.LoadModuleSettings(); Module em = null; if (m.moduleSettings != null) { // Module Settings are present, use custom ascx Control em = (Module)p.LoadControl(Config.GetModuleVirtualPath(m.type) + m.moduleSettings.editCtrl); } else { // Use default ascx control (Edit[type].ascx) em = (Module)p.LoadControl(Config.GetModuleVirtualPath(m.type) + "Edit" + m.type + ".ascx"); } // Initialize the control em.InitModule( tab.reference, m.reference, Config.GetModuleVirtualPath(m.type), true); return(em); }
private void RenderModules(HtmlTableCell td, PortalDefinition.Tab tab, ArrayList modules) { if (modules.Count == 0) { td.Visible = false; return; } foreach (PortalDefinition.Module md in modules) { if (UserManagement.HasViewRights(Page.User, md.roles)) { md.LoadModuleSettings(); // Initialize the Module Control m = null; bool visible = false; try { // Is the Edit Mode Requested? if (Helper.IsEditModuleRequested(md)) { // Load the Edit Mode of the module. m = Helper.GetEditControl(Page); } if (m == null) { // Load the View of the module. if (md.moduleSettings == null) { m = LoadControl(Config.GetModuleVirtualPath(md.type) + md.type + ".ascx"); } else { m = LoadControl(Config.GetModuleVirtualPath(md.type) + md.moduleSettings.ctrl); } ((Module)m).InitModule(tab.reference, md.reference, md.type, Config.GetModuleDataVirtualPath(md.type), UserManagement.HasEditRights(Page.User, md.roles)); visible = ((Module)m).IsVisible(); } else { visible = true; } if (visible) { // Add ModuleContainer HtmlGenericControl cont = new HtmlGenericControl("div"); cont.Attributes.Add("class", "ModuleContainer"); td.Controls.Add(cont); // Add Module Header ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx"); mh.SetModuleConfig(md); cont.Controls.Add(mh); // Add Module Body Container HtmlGenericControl bodyCont = new HtmlGenericControl("div"); bodyCont.Attributes.Add("class", "Module"); cont.Controls.Add(bodyCont); // Add Module HtmlGenericControl div = new HtmlGenericControl("div"); div.Controls.Add(m); bodyCont.Controls.Add(div); } } catch (Exception e) { if (Config.ShowModuleExceptions) { throw new Exception(e.Message, e); } // Add ModuleContainer HtmlGenericControl cont = new HtmlGenericControl("div"); cont.Attributes.Add("class", "ModuleContainer"); cont.Controls.Add(m); td.Controls.Add(cont); // Add Module Header ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx"); mh.SetModuleConfig(md); cont.Controls.Add(mh); // Add Error Module ModuleFailed mf = (ModuleFailed)LoadControl("ModuleFailed.ascx"); while (e != null) { mf.Message += e.GetType().Name + ": "; mf.Message += e.Message + "<br>"; e = e.InnerException; } mf.Message = mf.Message.Remove(mf.Message.Length - 4, 4); HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes.Add("class", "Module"); div.Controls.Add(mf); cont.Controls.Add(div); } } } }
protected void Page_Load(object sender, System.EventArgs e) { // Initially are all Edit Controls and the title invisible. HeaderContainer.Visible = false; ModuleMenuDiv.Visible = false; lnkEditLink.Visible = false; ovm.Visible = false; ModuleTitle.Visible = false; // No Menu if in edit mode. if (!Helper.IsEditModuleRequested(ModuleDef)) { // Set the link per default invisible bool showedit = false; if (UserManagement.HasEditRights(Page.User, ModuleDef.roles)) { // User has right, continue if (ModuleDef.moduleSettings == null) { // no Module Settings, set visible showedit = true; } else { // Module has module settings if (ModuleDef.moduleSettings.HasEditCtrl) { // Module has a edit control, set visible showedit = true; } } } // Show Edit-Link. if (showedit) { HeaderContainer.Visible = true; ModuleMenuDiv.Visible = true; lnkEditLink.Visible = true; } // Ist ovm Menu visible? if (Page.User.IsInRole(Portal.API.Config.AdminRole)) { HeaderContainer.Visible = true; ModuleMenuDiv.Visible = true; ovm.Visible = true; if (!showedit) // No Edit Link. { // Remove Edit Link ((OverlayMenuItem)ovm.Items[0]).Visible = false; } else { lnkEditLink.Visible = false; // Allready exist in ovm. } } } // Show Title. if (ModuleDef.title.Length > 0) { HeaderContainer.Visible = true; ModuleTitle.InnerHtml = ModuleDef.title; ModuleTitle.Visible = true; } }
private void RenderModules(HtmlTableCell td, PortalDefinition.Tab tab, ArrayList modules) { if (modules.Count == 0) { td.Visible = false; return; } foreach (PortalDefinition.Module md in modules) { if (UserManagement.HasViewRights(Page.User, md.roles)) { md.LoadModuleSettings(); // Initialize the Module Module m = null; #if !DEBUG try { #endif if (md.moduleSettings == null) { m = (Module)LoadControl(Config.GetModuleVirtualPath(md.type) + md.type + ".ascx"); } else { m = (Module)LoadControl(Config.GetModuleVirtualPath(md.type) + md.moduleSettings.ctrl); } m.InitModule(tab.reference, md.reference, Config.GetModuleVirtualPath(md.type), UserManagement.HasEditRights(Page.User, md.roles)); if (m.IsVisible()) { // Add Module Header ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx"); mh.SetModuleConfig(md); td.Controls.Add(mh); // Add Module HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes.Add("class", "Module"); div.Controls.Add(m); td.Controls.Add(div); } #if !DEBUG } catch (Exception e) { // Add Module Header ModuleHeader mh = (ModuleHeader)LoadControl("ModuleHeader.ascx"); mh.SetModuleConfig(md); td.Controls.Add(mh); // Add Error Module ModuleFailed mf = (ModuleFailed)LoadControl("ModuleFailed.ascx"); while (e != null) { mf.Message += e.GetType().Name + ": "; mf.Message += e.Message + "<br>"; e = e.InnerException; } mf.Message = mf.Message.Remove(mf.Message.Length - 4, 4); HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes.Add("class", "Module"); div.Controls.Add(mf); td.Controls.Add(div); } #endif } } }