コード例 #1
0
        private Tab InternalGetTab(ArrayList tabList, string reference)
        {
            reference = reference.ToLower(CultureInfo.InvariantCulture);
            if (tabList == null)
            {
                return(null);
            }

            foreach (Tab t in tabList)
            {
                if (string.Compare(t.reference, reference, true, CultureInfo.InvariantCulture) == 0)
                {
                    if (UserManagement.HasViewRights(HttpContext.Current.User, t.roles))
                    {
                        return(t);
                    }
                    else
                    {
                        return(null);
                    }
                }
                Tab tb = InternalGetTab(t.tabs, reference);
                if (tb != null)
                {
                    return(tb);
                }
            }

            return(null);
        }
コード例 #2
0
        private DisplayTabItem BuildDisplayTabItem(PortalDefinition.Tab t)
        {
            if (UserManagement.HasViewRights(Page.User, t.roles))
            {
                // User may view the tab, create a Display Item
                DisplayTabItem dt = new DisplayTabItem(t, false);

                return(dt);
            }

            return(null);
        }
コード例 #3
0
        override protected void OnInit(EventArgs e)
        {
            PortalDefinition.Tab tab = PortalDefinition.GetCurrentTab();

            if (UserManagement.HasViewRights(Page.User, tab.roles))
            {
                // Render
                RenderModules(left, tab, tab.left);
                RenderModules(middle, tab, tab.middle);
                RenderModules(right, tab, tab.right);
            }

            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            InitializeComponent();
            base.OnInit(e);
        }
コード例 #4
0
 private bool CheckAccessModules(ArrayList modules, string modType, string modRef)
 {
     foreach (PortalDefinition.Module md in modules)
     {
         md.LoadModuleSettings();
         if ((md.type == modType) && (md.reference == modRef))
         {
             // Check if the user has View Rights. It verifys only the module itself, not the parent tabs. This enables
             // to download a file from a list, without having access to the list itself. (For instance, the user can
             // download files linked in a page. The files are managed in a list, but has no possibility to see the
             // list itself, because he has no access to the tab.
             if (UserManagement.HasViewRights(Page.User, md.roles))
             {
                 return(true); // A module with View Access found.
             }
         }
     }
     return(false); // No Module with View Access found.
 }
コード例 #5
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Load Protal Definition and the current Tab
            PortalDefinition pd = PortalDefinition.Load();

            PortalDefinition.Tab currentTab = pd.GetTab(Request["TabRef"]);

            // Foreach Tab...
            ArrayList tabList = new ArrayList();

            foreach (PortalDefinition.Tab t in pd.tabs)
            {
                if (UserManagement.HasViewRights(Page.User, t.roles))
                {
                    // User may view the tab, create a Display Item
                    DisplayTabItem dt = new DisplayTabItem();
                    tabList.Add(dt);

                    dt.m_Text = t.title;

                    // Set current Tab Property
                    if (currentTab == null)
                    {
                        if (tabList.Count == 1)
                        {
                            // First tab -> default
                            dt.m_CurrentTab = true;
                        }
                    }
                    else
                    {
                        dt.m_CurrentTab = currentTab.GetRootTab() == t;
                    }

                    dt.m_URL = Helper.GetTabLink(t.reference);
                }         // if(User may view)
            }             // foreach(tab)

            // Bind Repeater
            Tabs.DataSource = tabList;
            Tabs.DataBind();
        }
コード例 #6
0
        override protected void CreateChildControls()
        {
            PortalDefinition.Tab tab = PortalDefinition.CurrentTab;
            if (tab == null)
            {
                return;
            }

            if (UserManagement.HasViewRights(Page.User, tab.roles))
            {
                // Render
                RenderModules(TabLeft, tab, tab.left);
                RenderModules(TabMiddle, tab, tab.middle);
                RenderModules(TabRight, tab, tab.right);

                // Special case, if the middle part is not visible.
                if (!TabMiddle.Visible && TabLeft.Visible && TabRight.Visible)
                {
                    TabLeft.Attributes["class"]  = "TabLeftTwoCol";
                    TabRight.Attributes["class"] = "TabRightTwoCol";
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Returns a Tab by a reference.
        /// If not reference is provided it returns the default (first) Tab.
        /// </summary>
        /// <param name="reference">Tabs reference</param>
        /// <returns>null if Tab not found or the default Tab if no reference is provided</returns>
        public Tab GetTab(string reference)
        {
            Tab currTab = null;

            if (!string.IsNullOrEmpty(reference))
            {
                currTab = InternalGetTab(tabs, reference);
            }

            if (currTab == null)
            {
                for (int i = 0; i < tabs.Count; i++)
                {
                    currTab = (Tab)tabs[i];
                    if (UserManagement.HasViewRights(HttpContext.Current.User, currTab.roles))
                    {
                        return(currTab);
                    }
                }
            }

            return(currTab);
        }
コード例 #8
0
        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);
                    }
                }
            }
        }
コード例 #9
0
        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
                }
            }
        }