예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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);
        }