Example #1
0
        private String GetMenu()
        {
            var strCacheKey = "bomenuhtml*" + Utils.GetCurrentCulture() + "*" + PortalId.ToString("") + "*" + UserId.ToString("");

            var strOut = "";
            var obj    = Utils.GetCache(strCacheKey);

            if (obj != null)
            {
                strOut = (String)obj;
            }

            if (StoreSettings.Current.DebugMode || strOut == "")
            {
                lock (lockobjectGetMenu)
                {
                    var pluginData = new PluginData(PortalId);

                    var bomenuattributes    = DnnUtils.GetLocalizedString("bomenuattributes", _resxpath, Utils.GetCurrentCulture());
                    var bosubmenuattributes = DnnUtils.GetLocalizedString("bosubmenuattributes", _resxpath, Utils.GetCurrentCulture());

                    //get group list (these are the sections/first level of the menu)
                    var rootList = new Dictionary <String, String>();

                    var pluginList = PluginUtils.GetPluginList();
                    foreach (var p in pluginList)
                    {
                        if (PluginUtils.CheckSecurity(p))
                        {
                            var grpname = p.GetXmlProperty("genxml/textbox/group");
                            if (p.GetXmlPropertyBool("genxml/checkbox/hidden") == false)
                            {
                                var rootname = grpname;
                                if (rootname == "")
                                {
                                    rootname = p.GetXmlProperty("genxml/textbox/ctrl");
                                }
                                if (!rootList.ContainsKey(rootname))
                                {
                                    var resxname = DnnUtils.GetLocalizedString(rootname.ToLower(), _resxpath, Utils.GetCurrentCulture());
                                    if (resxname == "")
                                    {
                                        resxname = rootname;
                                    }
                                    rootList.Add(rootname, resxname);
                                }
                            }
                        }
                    }

                    strOut = "<ul " + bomenuattributes + ">";

                    // clientEditor roles can only access products, so only add the exit button to the menu.
                    // the security restriuction on product ctrl is applied in the container.ascx.cs
                    //if (!NBrightBuyUtils.IsClientOnly())
                    //{
                    foreach (var rootname in rootList)
                    {
                        var rtnlist = pluginData.GetSubList(rootname.Key);
                        var sublist = new List <NBrightInfo>();
                        // check security
                        foreach (var p in rtnlist)
                        {
                            if (PluginUtils.CheckSecurity(p))
                            {
                                sublist.Add(p);
                            }
                        }


                        var href              = "#";
                        var ctrl              = "";
                        var name              = "unknown";
                        var icon              = "";
                        var hrefclass         = "";
                        var securityrootcheck = true;
                        if (sublist.Count > 0)
                        {
                            // has sub menus
                            ctrl      = rootname.Key;
                            name      = rootname.Value;
                            hrefclass = "class='dropdown-toggle'";
                            icon      = DnnUtils.GetLocalizedString(ctrl.ToLower() + "_icon", _resxpath, Utils.GetCurrentCulture());
                            strOut   += "<li class='dropdown'>";
                        }
                        else
                        {
                            // clickable root menu
                            var rootp = pluginData.GetPluginByCtrl(rootname.Key);
                            if (rootp != null)
                            {
                                ctrl = rootp.GetXmlProperty("genxml/textbox/ctrl");
                                name = rootp.GetXmlProperty("genxml/textbox/name");
                                icon = rootp.GetXmlProperty("genxml/textbox/icon");

                                securityrootcheck = PluginUtils.CheckSecurity(rootp);
                                if (securityrootcheck)
                                {
                                    strOut += "<li>";
                                    var param = new string[1];
                                    param[0] = "ctrl=" + ctrl;
                                    href     = Globals.NavigateURL(TabId, "", param);
                                }
                            }
                            else
                            {
                                securityrootcheck = false;
                            }
                        }
                        if (securityrootcheck)
                        {
                            strOut += GetRootLinkNode(name, ctrl, icon, href, hrefclass);
                        }

                        if (sublist.Count > 0)
                        {
                            strOut += "<ul " + bosubmenuattributes + ">";
                            foreach (var p in sublist)
                            {
                                if (p.GetXmlPropertyBool("genxml/checkbox/hidden") == false)
                                {
                                    ctrl = p.GetXmlProperty("genxml/textbox/ctrl");
                                    name = p.GetXmlProperty("genxml/textbox/name");
                                    icon = p.GetXmlProperty("genxml/textbox/icon");
                                    var param = new string[1];
                                    param[0] = "ctrl=" + ctrl;
                                    href     = Globals.NavigateURL(TabId, "", param);
                                    strOut  += "<li>" + GetSubLinkNode(name, ctrl, icon, href) + "</li>";
                                }
                            }
                            strOut += "</ul>";
                        }
                        if (securityrootcheck)
                        {
                            strOut += "</li>";
                        }
                    }

                    // }

                    // add exit button
                    strOut += "<li>";
                    var tabid    = StoreSettings.Current.Get("exittab");
                    var exithref = "/";
                    if (Utils.IsNumeric(tabid))
                    {
                        exithref = Globals.NavigateURL(Convert.ToInt32(tabid));
                    }
                    strOut += GetRootLinkNode("Exit", "exit", DnnUtils.GetLocalizedString("exit_icon", _resxpath, Utils.GetCurrentCulture()), exithref, "");
                    strOut += "</li>";

                    strOut += "</ul>";

                    NBrightBuyUtils.SetModCache(0, strCacheKey, strOut);

                    if (StoreSettings.Current.DebugModeFileOut)
                    {
                        Utils.SaveFile(PortalSettings.HomeDirectoryMapPath + "\\debug_menu.html", strOut);
                    }
                }
            }
            return(strOut);
        }