Ejemplo n.º 1
0
        private string GetTabsSection(string Template)
        {
            string sOut = string.Empty;
            sOut = TemplateUtils.GetTemplateSection(Template, "[AM:CONTROLS:TABS]", "[/AM:CONTROLS:TABS]");
            string pattern = "(\\[AM:CONTROLS:TAB:(.+?)\\])";
            Regex regExp = new Regex(pattern);
            MatchCollection matches = null;
            matches = regExp.Matches(sOut);
            amTabs = new DotNetNuke.Modules.ActiveForums.Controls.ActiveTabs();
            foreach (Match match in matches)
            {
                bool bAddTab = false;
                string matchValue = match.Groups[2].Value;
                CurrentUserTypes access = CurrentUserTypes.Anon;
                if (matchValue.Contains(":"))
                {
                    string sec = matchValue.Split(':')[1].ToLowerInvariant();
                    if (sec == "private")
                    {
                        if (!(CurrentUserType == CurrentUserTypes.Anon))
                        {
                            if (UserId == UID || (CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser))
                            {
                                bAddTab = true;
                                access = CurrentUserTypes.Admin;
                            }
                        }
                    }
                    else
                    {
                        switch (sec)
                        {
                            case "auth":
                                access = CurrentUserTypes.Auth;
                                break;
                            case "forummod":
                                access = CurrentUserTypes.ForumMod;
                                break;
                            case "admin":
                                access = CurrentUserTypes.Admin;
                                break;
                            case "superuser":
                                access = CurrentUserTypes.SuperUser;
                                break;
                        }
                        switch (access)
                        {
                            case CurrentUserTypes.Anon:
                                bAddTab = true;
                                break;
                            case CurrentUserTypes.Auth:
                                if (!(CurrentUserType == CurrentUserTypes.Anon))
                                {
                                    bAddTab = true;
                                }
                                break;
                            case CurrentUserTypes.ForumMod:
                                if (!(CurrentUserType == CurrentUserTypes.Anon) && !(CurrentUserType == CurrentUserTypes.Auth))
                                {
                                    bAddTab = true;
                                }
                                break;
                            case CurrentUserTypes.Admin:
                                if (CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser)
                                {
                                    bAddTab = true;
                                }
                                break;
                            case CurrentUserTypes.SuperUser:
                                if (CurrentUserType == CurrentUserTypes.SuperUser)
                                {
                                    bAddTab = true;
                                }
                                break;
                        }
                    }
                    matchValue = matchValue.Split(':')[0];
                }
                else
                {
                    bAddTab = true;
                }


                if (bAddTab)
                {
                    DotNetNuke.Modules.ActiveForums.Controls.Tab tb = new DotNetNuke.Modules.ActiveForums.Controls.Tab();
                    tb.ControlKey = matchValue;
                    tb.Text = "[RESX:Label:" + matchValue + "]";
                    if (sOut.Contains(match.Value.Replace("[AM", "[/AM")))
                    {
                        DotNetNuke.Modules.ActiveForums.Controls.TabContent tbc = new DotNetNuke.Modules.ActiveForums.Controls.TabContent();
                        string tmp = TemplateUtils.GetTemplateSection(sOut, match.Value, match.Value.Replace("[AM", "[/AM"));
                        if (tmp.Contains("<dnn:"))
                        {
                            tmp = "<%@ Register TagPrefix=\"dnn\" Assembly=\"DotNetNuke\" Namespace=\"DotNetNuke.UI.WebControls\"%>" + tmp;
                        }
                        if (tmp.Contains("<social:"))
                        {
                            tmp = Globals.SocialRegisterTag + tmp;
                        }
                        Control ctl = this.ParseControl(tmp);
                        tbc.Controls.Add(ctl);
                        tb.Content = tbc;
                    }
                    amTabs.Tabs.Add(tb);
                }

            }
            Template = TemplateUtils.ReplaceSubSection(Template, "<asp:placeholder id=\"plhTabs\" runat=\"server\" />", "[AM:CONTROLS:TABS]", "[/AM:CONTROLS:TABS]");
            return Template;
        }
Ejemplo n.º 2
0
        private string GetTabsSection(string Template)
        {
            string sOut = string.Empty;

            sOut = TemplateUtils.GetTemplateSection(Template, "[AM:CONTROLS:TABS]", "[/AM:CONTROLS:TABS]");
            string          pattern = "(\\[AM:CONTROLS:TAB:(.+?)\\])";
            Regex           regExp  = new Regex(pattern);
            MatchCollection matches = null;

            matches = regExp.Matches(sOut);
            amTabs  = new DotNetNuke.Modules.ActiveForums.Controls.ActiveTabs();
            foreach (Match match in matches)
            {
                bool             bAddTab    = false;
                string           matchValue = match.Groups[2].Value;
                CurrentUserTypes access     = CurrentUserTypes.Anon;
                if (matchValue.Contains(":"))
                {
                    string sec = matchValue.Split(':')[1].ToLowerInvariant();
                    if (sec == "private")
                    {
                        if (!(CurrentUserType == CurrentUserTypes.Anon))
                        {
                            if (UserId == UID || (CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser))
                            {
                                bAddTab = true;
                                access  = CurrentUserTypes.Admin;
                            }
                        }
                    }
                    else
                    {
                        switch (sec)
                        {
                        case "auth":
                            access = CurrentUserTypes.Auth;
                            break;

                        case "forummod":
                            access = CurrentUserTypes.ForumMod;
                            break;

                        case "admin":
                            access = CurrentUserTypes.Admin;
                            break;

                        case "superuser":
                            access = CurrentUserTypes.SuperUser;
                            break;
                        }
                        switch (access)
                        {
                        case CurrentUserTypes.Anon:
                            bAddTab = true;
                            break;

                        case CurrentUserTypes.Auth:
                            if (!(CurrentUserType == CurrentUserTypes.Anon))
                            {
                                bAddTab = true;
                            }
                            break;

                        case CurrentUserTypes.ForumMod:
                            if (!(CurrentUserType == CurrentUserTypes.Anon) && !(CurrentUserType == CurrentUserTypes.Auth))
                            {
                                bAddTab = true;
                            }
                            break;

                        case CurrentUserTypes.Admin:
                            if (CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser)
                            {
                                bAddTab = true;
                            }
                            break;

                        case CurrentUserTypes.SuperUser:
                            if (CurrentUserType == CurrentUserTypes.SuperUser)
                            {
                                bAddTab = true;
                            }
                            break;
                        }
                    }
                    matchValue = matchValue.Split(':')[0];
                }
                else
                {
                    bAddTab = true;
                }


                if (bAddTab)
                {
                    DotNetNuke.Modules.ActiveForums.Controls.Tab tb = new DotNetNuke.Modules.ActiveForums.Controls.Tab();
                    tb.ControlKey = matchValue;
                    tb.Text       = "[RESX:Label:" + matchValue + "]";
                    if (sOut.Contains(match.Value.Replace("[AM", "[/AM")))
                    {
                        DotNetNuke.Modules.ActiveForums.Controls.TabContent tbc = new DotNetNuke.Modules.ActiveForums.Controls.TabContent();
                        string tmp = TemplateUtils.GetTemplateSection(sOut, match.Value, match.Value.Replace("[AM", "[/AM"));
                        if (tmp.Contains("<dnn:"))
                        {
                            tmp = "<%@ Register TagPrefix=\"dnn\" Assembly=\"DotNetNuke\" Namespace=\"DotNetNuke.UI.WebControls\"%>" + tmp;
                        }
                        if (tmp.Contains("<social:"))
                        {
                            tmp = Globals.SocialRegisterTag + tmp;
                        }
                        Control ctl = this.ParseControl(tmp);
                        tbc.Controls.Add(ctl);
                        tb.Content = tbc;
                    }
                    amTabs.Tabs.Add(tb);
                }
            }
            Template = TemplateUtils.ReplaceSubSection(Template, "<asp:placeholder id=\"plhTabs\" runat=\"server\" />", "[AM:CONTROLS:TABS]", "[/AM:CONTROLS:TABS]");
            return(Template);
        }