public static string PluginAdminList(HttpContext context)
 {
     try
     {
         if (NBrightBuyUtils.CheckRights())
         {
             var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context);
             var list     = PluginUtils.GetPluginList();
             return(RenderPluginAdminList(list, ajaxInfo, 0));
         }
     }
     catch (Exception ex)
     {
         Logging.LogException(ex);
         return(ex.ToString());
     }
     return("");
 }
Example #2
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);
        }
Example #3
0
        protected override void OnInit(EventArgs e)
        {
            _pluginData = new PluginData(PortalId);

            base.OnInit(e);
            try
            {
                if (UserId > 0) //do nothing if user not logged on
                {
                    var ctrl = Utils.RequestQueryStringParam(Context, "ctrl");

                    // anyone only in the client role is only allowed in the products control
                    if (UserInfo.IsInRole(StoreSettings.ClientEditorRole) && (!UserInfo.IsInRole(StoreSettings.EditorRole) && !UserInfo.IsInRole(StoreSettings.ManagerRole) && !UserInfo.IsInRole("Administrators")))
                    {
                        //   ctrl = "products";
                    }

                    if (ctrl == "")
                    {
                        ctrl = (String)HttpContext.Current.Session["nbrightbackofficectrl"];
                    }
                    else
                    {
                        HttpContext.Current.Session["nbrightbackofficectrl"] = ctrl;
                    }

                    if (String.IsNullOrEmpty(ctrl))
                    {
                        var plist = PluginUtils.GetPluginList();
                        if (plist.Count() > 0)
                        {
                            // get first plugin in list as default.
                            ctrl = plist.First().GUIDKey;
                        }
                        if (ctrl == "")
                        {
                            ctrl = "dashsummary";
                        }
                        if (StoreSettings.Current.Settings().Count == 0)
                        {
                            ctrl = "settings";
                        }
                        HttpContext.Current.Session["nbrightbackofficectrl"] = ctrl;
                    }

                    var ctlpath = GetControlPath(ctrl);
                    if (ctlpath == "")  // ctrl may not exist in system, so default to products
                    {
                        ctrl    = "products";
                        ctlpath = GetControlPath(ctrl);
                    }

                    // check for group data, this MUST be there otherwise this is the first time into the BO, so redirect to Admin.
                    var l = NBrightBuyUtils.GetCategoryGroups(Utils.GetCurrentCulture(), true, ""); // don't test for grouptype, on upgrade it might not be there!!
                    if (!l.Any())
                    {
                        // redisplay settings
                        ctrl    = "settings";
                        ctlpath = GetControlPath(ctrl);
                        NBrightBuyUtils.SetNotfiyMessage(ModuleId, "settingssetup", NotifyCode.fail);
                    }

                    if (ctlpath != "" && CheckSecurity(ctrl))
                    {
                        // make compatible with running DNN in virtual directory
                        if (HttpContext.Current.Request.ApplicationPath != null && !ctlpath.StartsWith(HttpContext.Current.Request.ApplicationPath))
                        {
                            ctlpath = HttpContext.Current.Request.ApplicationPath + ctlpath;
                        }
                        var c1 = LoadControl(ctlpath);
                        phData.Controls.Add(c1);
                    }
                    else
                    {
                        var c1 = new Literal();
                        c1.Text = "INVALID CONTROL: " + ctrl;
                        phData.Controls.Add(c1);
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                //display the error on the template (don;t want to log it here, prefer to deal with errors directly.)
                var l = new Literal();
                l.Text = exc.ToString();
                phData.Controls.Add(l);
            }
        }