示例#1
0
        public void UpdateParameters(MenuItem menuItem)
        {
            if (Visible(menuItem))
            {
                var query = GetPathQuery(menuItem);

                int tabId, portalId;
                if (query.ContainsKey("path"))
                {
                    portalId = query.ContainsKey("portalId") ? Convert.ToInt32(query["portalId"]) : PortalSettings.Current.PortalId;
                    tabId    = TabController.GetTabByTabPath(portalId, query["path"], string.Empty);
                }
                else
                {
                    portalId = Convert.ToInt32(query["portalId"]);
                    tabId    = Convert.ToInt32(query["tabId"]);
                }

                var tabUrl = Globals.NavigateURL(tabId, portalId == Null.NullInteger);
                var alias  = Globals.AddHTTP(PortalSettings.Current.PortalAlias.HTTPAlias);
                tabUrl = tabUrl.Replace(alias, string.Empty).TrimStart('/');

                menuItem.Link = tabUrl;
            }
        }
示例#2
0
        private void GetAdminTabs()
        {
            var adminTab = TabController.GetTabByTabPath(PortalSettings.PortalId, "//Admin", string.Empty);

            _adminTabs = TabController.GetTabsByParent(adminTab, PortalSettings.PortalId).OrderBy(t => t.LocalizedTabName).ToList();

            _adminBaseTabs     = new List <TabInfo>();
            _adminAdvancedTabs = new List <TabInfo>();

            foreach (var tabInfo in _adminTabs)
            {
                switch (tabInfo.TabName)
                {
                case "Site Settings":
                case "Pages":
                case "Security Roles":
                case "User Accounts":
                case "File Management":
                case "Recycle Bin":
                case "Log Viewer":
                    _adminBaseTabs.Add(tabInfo);
                    break;

                default:
                    _adminAdvancedTabs.Add(tabInfo);
                    break;
                }
            }
        }
示例#3
0
        internal static void AddAdminPage(TabController tabCtl, PortalInfo portal)
        {
            try
            {
                var desktopModule = DesktopModuleController.GetDesktopModuleByFriendlyName("CloudFlareClearCache Module");
                var pageName      = "CloudFlare Cache";
                var tabPath       = string.Format("//{0}//{1}", portal.PortalID == Null.NullInteger ? "Host" : "Admin", pageName);
                var tabId         = TabController.GetTabByTabPath(portal.PortalID, tabPath, Null.NullString);
                var existTab      = TabController.Instance.GetTab(tabId, portal.PortalID);

                if (existTab == null || existTab.TabID == Null.NullInteger)
                {
                    existTab = Upgrade.AddAdminPage(
                        PortalController.Instance.GetPortal(portal.PortalID),
                        pageName,
                        pageName,
                        "~/Icons/Sigma/Configuration_16X16_Standard.png",
                        "~/Icons/Sigma/Configuration_32X32_Standard.png",
                        true);
                }

                AddModuleToPage(desktopModule, existTab);
            }
            catch (Exception e)
            {
                LogError(e);
                throw;
            }
        }
        private void GetHostTabs()
        {
            var hostTab = TabController.GetTabByTabPath(Null.NullInteger, "//Host", string.Empty);
            var hosts   = TabController.GetTabsByParent(hostTab, -1);

            var professionalTab  = TabController.Instance.GetTabByName("Professional Features", -1);
            var professionalTabs = professionalTab != null
                ? TabController.GetTabsByParent(professionalTab.TabID, -1)
                : new List <TabInfo>();

            this._hostTabs = new List <TabInfo>();
            this._hostTabs.AddRange(hosts);
            this._hostTabs.AddRange(professionalTabs);
            this._hostTabs = this._hostTabs.OrderBy(t => t.LocalizedTabName).ToList();

            this._hostBaseTabs     = new List <TabInfo>();
            this._hostAdvancedTabs = new List <TabInfo>();

            foreach (var tabInfo in this._hostTabs)
            {
                if (this.IsCommonTab(tabInfo, true))
                {
                    this._hostBaseTabs.Add(tabInfo);
                }
                else
                {
                    this._hostAdvancedTabs.Add(tabInfo);
                }
            }
        }
示例#5
0
        public string UpgradeModule(string Version)
        {
            try
            {
                switch (Version)
                {
                case "01.00.00":
                    int hostTabId = TabController.GetTabByTabPath(Null.NullInteger, "//Host", Null.NullString);

                    AddHostPage(hostTabId,
                                "//Host//ManageGlimpse",
                                "DotNetNuke Glimpse",
                                "Manage Glimpse",
                                "Manage Glimpse features",
                                "~/desktopmodules/dnnglimpse/icons/glimpse_16px.gif",
                                "~/desktopmodules/dnnglimpse/icons/glimpse_16px.gif");
                    break;
                }
                return("Success");
            }
            catch (Exception)
            {
                return("Failed");
            }
        }
        private bool ValidateTab(TabInfo tab)
        {
            if (tab.IsDeleted || tab.DisableLink || !tab.IsVisible)
            {
                return(false);
            }

            var type     = tab.IsSuperTab ? "host" : "admin";
            var portalId = tab.PortalID;
            var tabName  = tab.TabName;

            var knownPages = GetKnownPages(type);

            if (knownPages.Contains(tabName, StringComparer.InvariantCultureIgnoreCase))
            {
                return(false);
            }

            if (!tab.IsSuperTab)
            {
                var adminPage = TabController.GetTabByTabPath(portalId, "//Admin", string.Empty);
                if (adminPage == Null.NullInteger)
                {
                    return(false);
                }

                return(tab.ParentId == adminPage);
            }

            return(true);
        }
        private static int GetTabByTabPath(int portalID, string tabPath, string cultureCode)
        {
            // Check to see if the tab exists (if localization is enable, check for the specified culture)
            int tabID = TabController.GetTabByTabPath(portalID, tabPath.Replace("/", "//").Replace(".aspx", ""), cultureCode);

            // Check to see if neutral culture tab exists
            if ((tabID == Null.NullInteger && cultureCode.Length > 0))
            {
                tabID = TabController.GetTabByTabPath(portalID, tabPath.Replace("/", "//").Replace(".aspx", ""), "");
            }
            return(tabID);
        }
示例#8
0
        private static void GenerateAdminTab(string friendlyModuleName, int portalId)
        {
            var tabId = TabController.GetTabByTabPath(portalId, $"//Admin//{friendlyModuleName}", Null.NullString);

            if (tabId == Null.NullInteger)
            {
                var adminTabId = TabController.GetTabByTabPath(portalId, @"//Admin", Null.NullString);

                // create new page
                int parentTabId = adminTabId;
                var tabName     = friendlyModuleName;
                var tabPath     = Globals.GenerateTabPath(parentTabId, tabName);
                tabId = TabController.GetTabByTabPath(portalId, tabPath, Null.NullString);
                if (tabId == Null.NullInteger)
                {
                    //Create a new page
                    var newTab = new TabInfo
                    {
                        TabName       = tabName,
                        ParentId      = parentTabId,
                        PortalID      = portalId,
                        IsVisible     = true,
                        IconFile      = "~/Images/icon_search_16px.gif",
                        IconFileLarge = "~/Images/icon_search_32px.gif"
                    };
                    newTab.TabID = new TabController().AddTab(newTab, false);
                    tabId        = newTab.TabID;
                }
            }

            // create new module
            var moduleCtl = new ModuleController();

            if (moduleCtl.GetTabModules(tabId).Count == 0)
            {
                var dm = DesktopModuleController.GetDesktopModuleByModuleName(friendlyModuleName, portalId);
                var md = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(friendlyModuleName, dm.DesktopModuleID);

                var objModule = new ModuleInfo
                {
                    PortalID               = portalId,
                    TabID                  = tabId,
                    ModuleOrder            = Null.NullInteger,
                    ModuleTitle            = friendlyModuleName,
                    PaneName               = Globals.glbDefaultPane,
                    ModuleDefID            = md.ModuleDefID,
                    InheritViewPermissions = true,
                    AllTabs                = false,
                    IconFile               = "~/Images/icon_search_32px.gif"
                };
                moduleCtl.AddModule(objModule);
            }
        }
示例#9
0
文件: PageUtils.cs 项目: wncoder/core
        private static int FindOrCreateFirstLevelTab(string tabName)
        {
            var portal  = DnnGlobal.Instance.GetCurrentPortal();
            var tabPath = Globals.GenerateTabPath(Null.NullInteger, tabName);

            var tabId         = TabController.GetTabByTabPath(portal.PortalID, tabPath, portal.CultureCode);
            var tabController = new TabController();

            if (tabId > Null.NullInteger)
            {
                return(tabId);
            }

            return(CreateTabFromTemplate(tabName, -1));
        }
示例#10
0
        private void GetHostTabs()
        {
            var tabController = new TabController();
            var hostTab       = TabController.GetTabByTabPath(Null.NullInteger, "//Host", string.Empty);
            var hosts         = TabController.GetTabsByParent(hostTab, -1);

            var            professionalTab = tabController.GetTabByName("Professional Features", -1);
            List <TabInfo> professionalTabs;

            if (professionalTab != null)
            {
                professionalTabs = TabController.GetTabsByParent(professionalTab.TabID, -1);
            }
            else
            {
                professionalTabs = new List <TabInfo>();
            }

            _hostTabs = new List <TabInfo>();
            _hostTabs.AddRange(hosts);
            _hostTabs.AddRange(professionalTabs);
            _hostTabs = _hostTabs.OrderBy(t => t.LocalizedTabName).ToList();

            _hostBaseTabs     = new List <TabInfo>();
            _hostAdvancedTabs = new List <TabInfo>();

            foreach (var tabInfo in _hostTabs)
            {
                switch (tabInfo.TabName)
                {
                case "Host Settings":
                case "Site Management":
                case "File Management":
                case "Extensions":
                case "Dashboard":
                case "Health Monitoring":
                case "Technical Support":
                case "Knowledge Base":
                case "Software and Documentation":
                    _hostBaseTabs.Add(tabInfo);
                    break;

                default:
                    _hostAdvancedTabs.Add(tabInfo);
                    break;
                }
            }
        }
示例#11
0
        private void CreatePageLinks(int portalId, string parentPath)
        {
            var parentTab = TabController.GetTabByTabPath(portalId, "//" + parentPath, string.Empty);

            if (parentTab == Null.NullInteger)
            {
                return;
            }

            var adminTabs = TabController.GetTabsByParent(parentTab, portalId);

            foreach (var tab in adminTabs)
            {
                AdminMenuController.Instance.CreateLinkMenu(tab);
            }
        }
示例#12
0
        public ActionResult Index()
        {
            var records = ModuleContext.Settings["FlexEventsUpcoming_Setting1"];

            var items = ItemManager.Instance.GetItems(ModuleContext.ModuleId, PortalSettings.PortalId, Convert.ToInt32(records));

            foreach (var item in items)
            {
                var urlFormat = "{0}/ctl/ViewEvent/mid/{1}/OccuranceId/{2}";
                item.Url =
                    string.Format(urlFormat, Globals.NavigateURL(TabController.GetTabByTabPath(PortalSettings.PortalId, "//FestivalCalendar",
                                                                                               string.Empty)), item.ModuleId, item.ItemId);
            }

            return(View(items));
        }
示例#13
0
        public void MustNotHaveTestPages()
        {
            var tabController = new TabController();
            var tabId         = Null.NullInteger;

            tabId = TabController.GetTabByTabPath(PortalId, "//TestA", Null.NullString);
            if (tabId != Null.NullInteger)
            {
                tabController.DeleteTab(tabId, PortalId);
            }

            tabId = TabController.GetTabByTabPath(PortalId, "//TestB", Null.NullString);
            if (tabId != Null.NullInteger)
            {
                tabController.DeleteTab(tabId, PortalId);
            }
        }
示例#14
0
        public bool Visible(MenuItem menuItem)
        {
            var query = GetPathQuery(menuItem);

            if (PortalSettings.Current == null || query == null)
            {
                return(false);
            }

            if (query.ContainsKey("sku") && !string.IsNullOrEmpty(query["sku"]))
            {
                if (DotNetNukeContext.Current.Application.SKU != query["sku"])
                {
                    return(false);
                }
            }

            int tabId, portalId;

            if (query.ContainsKey("path") && !string.IsNullOrEmpty(query["path"]))
            {
                portalId = query.ContainsKey("portalId") ? Convert.ToInt32(query["portalId"]) : PortalSettings.Current.PortalId;
                tabId    = TabController.GetTabByTabPath(portalId, query["path"], string.Empty);

                if (tabId == Null.NullInteger)
                {
                    return(false);
                }
            }
            else
            {
                if (!query.ContainsKey("portalId") || !query.ContainsKey("tabId"))
                {
                    return(false);
                }

                portalId = Convert.ToInt32(query["portalId"]);
                tabId    = Convert.ToInt32(query["tabId"]);
            }

            var tab = TabController.Instance.GetTab(tabId, portalId);

            return((portalId == Null.NullInteger || portalId == PortalSettings.Current.PortalId) &&
                   tab != null && !tab.IsDeleted && !tab.DisableLink && tab.IsVisible);
        }
示例#15
0
        public static int AddModuleToPage(string tabPath, int portalId, int moduleDefId, string moduleTitle,
                                          string moduleIconFile, bool inheritPermissions)
        {
            var tabController = new TabController();
            var moduleId      = Null.NullInteger;

            var tabID = TabController.GetTabByTabPath(portalId, tabPath, Null.NullString);

            if ((tabID != Null.NullInteger))
            {
                var tab = tabController.GetTab(tabID, portalId, true);
                if ((tab != null))
                {
                    moduleId = AddModuleToPage(tab, moduleDefId, moduleTitle, moduleIconFile, inheritPermissions);
                }
            }
            return(moduleId);
        }
        private bool IsValidTabPath(TabInfo tab, string newTabPath, out string errorMessage)
        {
            var valid = true;

            errorMessage = null;

            //get default culture if the tab's culture is null
            var cultureCode = tab.CultureCode;

            if (string.IsNullOrEmpty(cultureCode))
            {
                var portalSettings = PortalController.Instance.GetCurrentPortalSettings();
                cultureCode = portalSettings.DefaultLanguage;
            }

            //Validate Tab Path
            var tabId = TabController.GetTabByTabPath(tab.PortalID, newTabPath, cultureCode);

            if (tabId != Null.NullInteger && tabId != tab.TabID)
            {
                var existingTab = TabController.Instance.GetTab(tabId, tab.PortalID, false);
                if (existingTab != null && existingTab.IsDeleted)
                {
                    errorMessage = Localization.GetString("TabRecycled");
                }
                else
                {
                    errorMessage = Localization.GetString("TabExists");
                }

                valid = false;
            }

            //check whether have conflict between tab path and portal alias.
            if (TabController.IsDuplicateWithPortalAlias(tab.PortalID, newTabPath))
            {
                errorMessage = string.Format(Localization.GetString("PathDuplicateWithAlias"), tab.TabName, newTabPath);
                valid        = false;
            }

            return(valid);
        }
示例#17
0
        public bool IsValidTabPath(TabInfo tab, string newTabPath, out string errorMessage)
        {
            var portalSettings = PortalController.Instance.GetCurrentPortalSettings();
            var valid          = true;

            errorMessage = string.Empty;

            //get default culture if the tab's culture is null
            var cultureCode = tab != null ? tab.CultureCode : string.Empty;

            if (string.IsNullOrEmpty(cultureCode))
            {
                cultureCode = portalSettings.DefaultLanguage;
            }

            //Validate Tab Path
            var tabId = TabController.GetTabByTabPath(portalSettings.PortalId, newTabPath, cultureCode);

            if (tabId != Null.NullInteger && (tab == null || tabId != tab.TabID))
            {
                var existingTab = _tabController.GetTab(tabId, portalSettings.PortalId, false);
                if (existingTab != null && existingTab.IsDeleted)
                {
                    errorMessage = "TabRecycled";
                }
                else
                {
                    errorMessage = "TabExists";
                }

                valid = false;
            }

            //check whether have conflict between tab path and portal alias.
            if (TabController.IsDuplicateWithPortalAlias(portalSettings.PortalId, newTabPath))
            {
                errorMessage = "PathDuplicateWithAlias";
                valid        = false;
            }

            return(valid);
        }
示例#18
0
        public PackageInfoDto(int portalId, PackageInfo package)
        {
            PackageType      = package.PackageType;
            FriendlyName     = package.FriendlyName;
            Name             = package.Name;
            PackageId        = package.PackageID;
            Description      = package.Description;
            IsInUse          = ExtensionsController.IsPackageInUse(package, portalId);
            Version          = package.Version.ToString(3);
            UpgradeUrl       = ExtensionsController.UpgradeRedirect(package.Version, package.PackageType, package.Name);
            UpgradeIndicator = ExtensionsController.UpgradeIndicator(package.Version, package.PackageType, package.Name);
            PackageIcon      = ExtensionsController.GetPackageIcon(package);
            License          = package.License;
            ReleaseNotes     = package.ReleaseNotes;
            Owner            = package.Owner;
            Organization     = package.Organization;
            Url       = package.Url;
            Email     = package.Email;
            CanDelete = !package.IsSystemPackage &&
                        package.PackageID > 0 &&
                        PackageController.CanDeletePackage(package, PortalSettings.Current);

            var authService = AuthenticationController.GetAuthenticationServiceByPackageID(PackageId);

            ReadOnly = authService != null && authService.AuthenticationType == Constants.DnnAuthTypeName;

            var locale  = LocaleController.Instance.GetLocale(PortalController.Instance.GetCurrentPortalSettings().DefaultLanguage);
            var tabId   = TabController.GetTabByTabPath(portalId, "//Admin//Extensions", locale.Culture.Name);
            var tabInfo = TabController.Instance.GetTab(tabId, portalId);
            var module  = tabInfo.Modules.OfType <ModuleInfo>().First();

            SiteSettingsLink = (module == null)
                ? ""
                : Globals.NavigateURL(tabId, "Edit",
                                      new[]
            {
                $"mid={module.ModuleID}",
                $"packageid={PackageId}",
                "Display=editor",
                "popUp=true",
            });
        }
        public string UpgradeModule(string version)
        {
            try
            {
                var hostTabId = TabController.GetTabByTabPath(Null.NullInteger, "//Host", Null.NullString);
                AddHostPage(hostTabId,
                            "//Host//AppInsights",
                            "AppInsights",
                            "Application Insights",
                            "Application Insights Monitoring",
                            "~/Providers/MonitoringProviders/AppInsights/images/AppInsights.png",
                            "~/Providers/MonitoringProviders/AppInsights/images/AppInsights.png");

                return("Success");
            }
            catch (Exception ex)
            {
                return("Failed: " + ex.Message);
            }
        }
        public PackageInfoDto GetPackageDetail(int portalId, PackageInfo package)
        {
            var languagePack = LanguagePackController.GetLanguagePackByPackage(package.PackageID);
            var languagesTab = TabController.GetTabByTabPath(portalId, "//Admin//Languages", Null.NullString);

            var detail = new CoreLanguagePackageDetailDto(portalId, package)
            {
                Locales       = Utility.GetAllLanguagesList(),
                LanguageId    = languagePack.LanguageID,
                EditUrlFormat = this.NavigationManager.NavigateURL(languagesTab, "", "Locale={0}")
            };

            if (languagePack.PackageType == LanguagePackType.Extension)
            {
                //Get all the packages but only bind to combo if not a language package
                detail.Packages = Utility.GetAllPackagesListExceptLangPacks();
            }

            return(detail);
        }
        internal static void AddDesktopModulePageToPortal(DesktopModuleInfo desktopModule, string pageName, int portalId, ref bool createdNewPage, ref bool addedNewModule)
        {
            var     tabPath  = string.Format("//{0}//{1}", portalId == Null.NullInteger ? "Host" : "Admin", pageName);
            var     tabId    = TabController.GetTabByTabPath(portalId, tabPath, Null.NullString);
            TabInfo existTab = TabController.Instance.GetTab(tabId, portalId);

            if (existTab == null)
            {
                if (portalId == Null.NullInteger)
                {
                    existTab = Upgrade.AddHostPage(
                        pageName,
                        desktopModule.Page.Description,
                        desktopModule.Page.Icon,
                        desktopModule.Page.LargeIcon,
                        true);
                }
                else
                {
                    existTab = Upgrade.AddAdminPage(
                        PortalController.Instance.GetPortal(portalId),
                        pageName,
                        desktopModule.Page.Description,
                        desktopModule.Page.Icon,
                        desktopModule.Page.LargeIcon,
                        true);
                }

                createdNewPage = true;
            }

            if (existTab != null)
            {
                if (desktopModule.Page.IsCommon)
                {
                    TabController.Instance.UpdateTabSetting(existTab.TabID, "ControlBar_CommonTab", "Y");
                }

                AddDesktopModuleToPage(desktopModule, existTab, ref addedNewModule);
            }
        }
        private void GetAdminTabs()
        {
            var adminTab = TabController.GetTabByTabPath(this.PortalSettings.PortalId, "//Admin", string.Empty);

            this._adminTabs = TabController.GetTabsByParent(adminTab, this.PortalSettings.PortalId).OrderBy(t => t.LocalizedTabName).ToList();

            this._adminBaseTabs     = new List <TabInfo>();
            this._adminAdvancedTabs = new List <TabInfo>();

            foreach (var tabInfo in this._adminTabs)
            {
                if (this.IsCommonTab(tabInfo))
                {
                    this._adminBaseTabs.Add(tabInfo);
                }
                else
                {
                    this._adminAdvancedTabs.Add(tabInfo);
                }
            }
        }
        private static void AddHostPage(int parentId, string tabPath, string moduleFriendlyName, string tabName, string tabDescription, string smallIcon, string largeIcon, bool isVisible = true)
        {
            var     tabController    = new TabController();
            var     moduleController = new ModuleController();
            TabInfo hostTab;

            // Get the module definition
            var moduleDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(moduleFriendlyName);

            // Add pages
            var tabId = TabController.GetTabByTabPath(Null.NullInteger, tabPath, Null.NullString);

            if (tabId == Null.NullInteger)
            {
                //Add host page
                hostTab          = Upgrade.AddHostPage(tabName, tabDescription, smallIcon, largeIcon, isVisible);
                hostTab.ParentId = parentId;
                tabController.UpdateTab(hostTab);

                //Add module to page
                Upgrade.AddModuleToPage(hostTab, moduleDef.ModuleDefID, tabName, largeIcon, true);
            }
            else
            {
                hostTab = tabController.GetTab(tabId, Null.NullInteger, false);
                foreach (
                    var kvp in
                    moduleController.GetTabModules(tabId)
                    .Where(kvp => kvp.Value.DesktopModule.ModuleName == moduleFriendlyName))
                {
                    // Remove previous module instance
                    moduleController.DeleteTabModule(tabId, kvp.Value.ModuleID, false);
                    break;
                }

                //Add module to page
                Upgrade.AddModuleToPage(hostTab, moduleDef.ModuleDefID, tabName, largeIcon, true);
            }
        }
        private string CreateNewPage(ModuleDefinitionInfo moduleDefinition)
        {
            if (PortalSettings.Current == null)
            {
                return(string.Empty);
            }

            var portalId = PortalSettings.Current.PortalId;
            var tabName  = "Test " + moduleDefinition.FriendlyName + " Page";
            var tabPath  = Globals.GenerateTabPath(Null.NullInteger, tabName);
            var tabId    = TabController.GetTabByTabPath(portalId, tabPath, Null.NullString);

            if (tabId == Null.NullInteger)
            {
                //Create a new page
                var newTab = new TabInfo();
                newTab.TabName   = tabName;
                newTab.ParentId  = Null.NullInteger;
                newTab.PortalID  = portalId;
                newTab.IsVisible = true;
                newTab.TabID     = TabController.Instance.AddTabBefore(newTab, PortalSettings.Current.AdminTabId);
                var objModule = new ModuleInfo();
                objModule.Initialize(portalId);
                objModule.PortalID               = portalId;
                objModule.TabID                  = newTab.TabID;
                objModule.ModuleOrder            = Null.NullInteger;
                objModule.ModuleTitle            = moduleDefinition.FriendlyName;
                objModule.PaneName               = Globals.glbDefaultPane;
                objModule.ModuleDefID            = moduleDefinition.ModuleDefID;
                objModule.InheritViewPermissions = true;
                objModule.AllTabs                = false;
                ModuleController.Instance.AddModule(objModule);

                return(NavigationManager.NavigateURL(newTab.TabID));
            }

            return(string.Empty);
        }
示例#25
0
        public void AddHostPage(int parentId, string tabPath, string moduleFriendlyName, string tabName, string tabDescription, string smallIcon, string largeIcon)
        {
            var     tabController    = new TabController();
            var     moduleController = new ModuleController();
            TabInfo hostTab;

            //Get web servers module
            ModuleDefinitionInfo moduleDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(moduleFriendlyName);

            //Add Pages under Advanced Features Tab
            int tabId = TabController.GetTabByTabPath(Null.NullInteger, tabPath, Null.NullString);

            if (tabId == Null.NullInteger)
            {
                //Add host page
                hostTab          = Upgrade.AddHostPage(tabName, tabDescription, smallIcon, largeIcon, true);
                hostTab.ParentId = parentId;
                tabController.UpdateTab(hostTab);

                //Add module to page
                Upgrade.AddModuleToPage(hostTab, moduleDef.ModuleDefID, tabName, largeIcon, true);
            }
            else
            {
                hostTab = tabController.GetTab(tabId, Null.NullInteger, false);
                foreach (var kvp in moduleController.GetTabModules(tabId))
                {
                    if (kvp.Value.DesktopModule.ModuleName == "ProfessionalPreview")
                    {
                        //Preview module so hard delete
                        moduleController.DeleteTabModule(tabId, kvp.Value.ModuleID, false);
                        break;
                    }
                }
                //Add module to page
                Upgrade.AddModuleToPage(hostTab, moduleDef.ModuleDefID, tabName, largeIcon, true);
            }
        }
示例#26
0
        private void RewriteUrl(HttpApplication app, out string portalAlias)
        {
            HttpRequest  request       = app.Request;
            HttpResponse response      = app.Response;
            string       requestedPath = app.Request.Url.AbsoluteUri;

            portalAlias = string.Empty;

            // determine portal alias looking for longest possible match
            string          myAlias = Globals.GetDomainName(app.Request, true);
            PortalAliasInfo objPortalAlias;

            do
            {
                objPortalAlias = PortalAliasController.Instance.GetPortalAlias(myAlias);

                if (objPortalAlias != null)
                {
                    portalAlias = myAlias;
                    break;
                }

                int slashIndex = myAlias.LastIndexOf('/');
                myAlias = slashIndex > 1 ? myAlias.Substring(0, slashIndex) : string.Empty;
            }while (myAlias.Length > 0);

            app.Context.Items.Add("UrlRewrite:OriginalUrl", app.Request.Url.AbsoluteUri);

            // Friendly URLs are exposed externally using the following format
            // http://www.domain.com/tabid/###/mid/###/ctl/xxx/default.aspx
            // and processed internally using the following format
            // http://www.domain.com/default.aspx?tabid=###&mid=###&ctl=xxx
            // The system for accomplishing this is based on an extensible Regex rules definition stored in /SiteUrls.config
            string sendTo = string.Empty;

            // save and remove the querystring as it gets added back on later
            // path parameter specifications will take precedence over querystring parameters
            string strQueryString = string.Empty;

            if (!string.IsNullOrEmpty(app.Request.Url.Query))
            {
                strQueryString = request.QueryString.ToString();
                requestedPath  = requestedPath.Replace(app.Request.Url.Query, string.Empty);
            }

            // get url rewriting rules
            RewriterRuleCollection rules = RewriterConfiguration.GetConfig().Rules;

            // iterate through list of rules
            int matchIndex = -1;

            for (int ruleIndex = 0; ruleIndex <= rules.Count - 1; ruleIndex++)
            {
                // check for the existence of the LookFor value
                string pattern = "^" +
                                 RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[ruleIndex].LookFor) +
                                 "$";
                Match objMatch = Regex.Match(requestedPath, pattern, RegexOptions.IgnoreCase);

                // if there is a match
                if (objMatch.Success)
                {
                    // create a new URL using the SendTo regex value
                    sendTo = RewriterUtils.ResolveUrl(
                        app.Context.Request.ApplicationPath,
                        Regex.Replace(requestedPath, pattern, rules[ruleIndex].SendTo,
                                      RegexOptions.IgnoreCase));

                    string parameters = objMatch.Groups[2].Value;

                    // process the parameters
                    if (parameters.Trim().Length > 0)
                    {
                        // split the value into an array based on "/" ( ie. /tabid/##/ )
                        parameters = parameters.Replace("\\", "/");
                        string[] splitParameters = parameters.Split('/');

                        // icreate a well formed querystring based on the array of parameters
                        for (int parameterIndex = 0; parameterIndex < splitParameters.Length; parameterIndex++)
                        {
                            // ignore the page name
                            if (
                                splitParameters[parameterIndex].IndexOf(
                                    ".aspx",
                                    StringComparison.InvariantCultureIgnoreCase) ==
                                -1)
                            {
                                // get parameter name
                                string parameterName = splitParameters[parameterIndex].Trim();
                                if (parameterName.Length > 0)
                                {
                                    // add parameter to SendTo if it does not exist already
                                    if (
                                        sendTo.IndexOf(
                                            "?" + parameterName + "=",
                                            StringComparison.InvariantCultureIgnoreCase) == -1 &&
                                        sendTo.IndexOf(
                                            "&" + parameterName + "=",
                                            StringComparison.InvariantCultureIgnoreCase) == -1)
                                    {
                                        // get parameter delimiter
                                        string parameterDelimiter = sendTo.IndexOf("?", StringComparison.Ordinal) != -1 ? "&" : "?";
                                        sendTo = sendTo + parameterDelimiter + parameterName;

                                        // get parameter value
                                        string parameterValue = string.Empty;
                                        if (parameterIndex < splitParameters.Length - 1)
                                        {
                                            parameterIndex += 1;
                                            if (!string.IsNullOrEmpty(splitParameters[parameterIndex].Trim()))
                                            {
                                                parameterValue = splitParameters[parameterIndex].Trim();
                                            }
                                        }

                                        // add the parameter value
                                        if (parameterValue.Length > 0)
                                        {
                                            sendTo = sendTo + "=" + parameterValue;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    matchIndex = ruleIndex;
                    break; // exit as soon as it processes the first match
                }
            }

            if (!string.IsNullOrEmpty(strQueryString))
            {
                // add querystring parameters back to SendTo
                string[] parameters = strQueryString.Split('&');

                // iterate through the array of parameters
                for (int parameterIndex = 0; parameterIndex <= parameters.Length - 1; parameterIndex++)
                {
                    // get parameter name
                    string parameterName = parameters[parameterIndex];
                    if (parameterName.IndexOf("=", StringComparison.Ordinal) != -1)
                    {
                        parameterName = parameterName.Substring(0, parameterName.IndexOf("=", StringComparison.Ordinal));
                    }

                    // check if parameter already exists
                    if (sendTo.IndexOf("?" + parameterName + "=", StringComparison.InvariantCultureIgnoreCase) == -1 &&
                        sendTo.IndexOf("&" + parameterName + "=", StringComparison.InvariantCultureIgnoreCase) == -1)
                    {
                        // add parameter to SendTo value
                        sendTo = sendTo.IndexOf("?", StringComparison.Ordinal) != -1
                                     ? sendTo + "&" + parameters[parameterIndex]
                                     : sendTo + "?" + parameters[parameterIndex];
                    }
                }
            }

            // if a match was found to the urlrewrite rules
            if (matchIndex != -1)
            {
                if (rules[matchIndex].SendTo.StartsWith("~"))
                {
                    // rewrite the URL for internal processing
                    RewriterUtils.RewriteUrl(app.Context, sendTo);
                }
                else
                {
                    // it is not possible to rewrite the domain portion of the URL so redirect to the new URL
                    response.Redirect(sendTo, true);
                }
            }
            else
            {
                // Try to rewrite by TabPath
                string url;
                if (Globals.UsePortNumber() &&
                    ((app.Request.Url.Port != 80 && !app.Request.IsSecureConnection) ||
                     (app.Request.Url.Port != 443 && app.Request.IsSecureConnection)))
                {
                    url = app.Request.Url.Host + ":" + app.Request.Url.Port + app.Request.Url.LocalPath;
                }
                else
                {
                    url = app.Request.Url.Host + app.Request.Url.LocalPath;
                }

                if (!string.IsNullOrEmpty(myAlias))
                {
                    if (objPortalAlias != null)
                    {
                        int portalID = objPortalAlias.PortalID;

                        // Identify Tab Name
                        string tabPath = url;
                        if (tabPath.StartsWith(myAlias))
                        {
                            tabPath = url.Remove(0, myAlias.Length);
                        }

                        // Default Page has been Requested
                        if (tabPath == "/" + Globals.glbDefaultPage.ToLowerInvariant())
                        {
                            return;
                        }

                        // Start of patch
                        string cultureCode = string.Empty;

                        Dictionary <string, Locale> dicLocales = LocaleController.Instance.GetLocales(portalID);
                        if (dicLocales.Count > 1)
                        {
                            string[] splitUrl = app.Request.Url.ToString().Split('/');

                            foreach (string culturePart in splitUrl)
                            {
                                if (culturePart.IndexOf("-", StringComparison.Ordinal) > -1)
                                {
                                    foreach (KeyValuePair <string, Locale> key in dicLocales)
                                    {
                                        if (key.Key.ToLower().Equals(culturePart.ToLower()))
                                        {
                                            cultureCode = key.Value.Code;
                                            tabPath     = tabPath.Replace("/" + culturePart, string.Empty);
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                        // Check to see if the tab exists (if localization is enable, check for the specified culture)
                        int tabID = TabController.GetTabByTabPath(
                            portalID,
                            tabPath.Replace("/", "//").Replace(".aspx", string.Empty),
                            cultureCode);

                        // Check to see if neutral culture tab exists
                        if (tabID == Null.NullInteger && cultureCode.Length > 0)
                        {
                            tabID = TabController.GetTabByTabPath(
                                portalID,
                                tabPath.Replace("/", "//").Replace(".aspx", string.Empty), string.Empty);
                        }

                        // End of patch
                        if (tabID != Null.NullInteger)
                        {
                            string sendToUrl = "~/" + Globals.glbDefaultPage + "?TabID=" + tabID;
                            if (!cultureCode.Equals(string.Empty))
                            {
                                sendToUrl = sendToUrl + "&language=" + cultureCode;
                            }

                            if (!string.IsNullOrEmpty(app.Request.Url.Query))
                            {
                                sendToUrl = sendToUrl + "&" + app.Request.Url.Query.TrimStart('?');
                            }

                            RewriterUtils.RewriteUrl(app.Context, sendToUrl);
                            return;
                        }

                        tabPath = tabPath.ToLowerInvariant();
                        if (tabPath.IndexOf('?') != -1)
                        {
                            tabPath = tabPath.Substring(0, tabPath.IndexOf('?'));
                        }

                        // Get the Portal
                        PortalInfo portal       = PortalController.Instance.GetPortal(portalID);
                        string     requestQuery = app.Request.Url.Query;
                        if (!string.IsNullOrEmpty(requestQuery))
                        {
                            requestQuery = TabIdRegex.Replace(requestQuery, string.Empty);
                            requestQuery = PortalIdRegex.Replace(requestQuery, string.Empty);
                            requestQuery = requestQuery.TrimStart('?', '&');
                        }

                        if (tabPath == "/login.aspx")
                        {
                            if (portal.LoginTabId > Null.NullInteger && Globals.ValidateLoginTabID(portal.LoginTabId))
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.LoginTabId + "&" + requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.LoginTabId);
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.HomeTabId + "&portalid=" + portalID + "&ctl=login&" +
                                        requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.HomeTabId + "&portalid=" + portalID + "&ctl=login");
                                }
                            }

                            return;
                        }

                        if (tabPath == "/register.aspx")
                        {
                            if (portal.RegisterTabId > Null.NullInteger)
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.RegisterTabId + "&portalid=" + portalID + "&" +
                                        requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.RegisterTabId + "&portalid=" + portalID);
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.HomeTabId + "&portalid=" + portalID +
                                        "&ctl=Register&" + requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" +
                                        portal.HomeTabId + "&portalid=" + portalID +
                                        "&ctl=Register");
                                }
                            }

                            return;
                        }

                        if (tabPath == "/terms.aspx")
                        {
                            if (!string.IsNullOrEmpty(requestQuery))
                            {
                                RewriterUtils.RewriteUrl(
                                    app.Context,
                                    "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                    "&portalid=" + portalID + "&ctl=Terms&" + requestQuery);
                            }
                            else
                            {
                                RewriterUtils.RewriteUrl(
                                    app.Context,
                                    "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                    "&portalid=" + portalID + "&ctl=Terms");
                            }

                            return;
                        }

                        if (tabPath == "/privacy.aspx")
                        {
                            if (!string.IsNullOrEmpty(requestQuery))
                            {
                                RewriterUtils.RewriteUrl(
                                    app.Context,
                                    "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                    "&portalid=" + portalID + "&ctl=Privacy&" + requestQuery);
                            }
                            else
                            {
                                RewriterUtils.RewriteUrl(
                                    app.Context,
                                    "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                    "&portalid=" + portalID + "&ctl=Privacy");
                            }

                            return;
                        }

                        tabPath = tabPath.Replace("/", "//");
                        tabPath = tabPath.Replace(".aspx", string.Empty);
                        TabCollection objTabs = TabController.Instance.GetTabsByPortal(tabPath.StartsWith("//host") ? Null.NullInteger : portalID);
                        foreach (KeyValuePair <int, TabInfo> kvp in objTabs)
                        {
                            if (kvp.Value.IsDeleted == false && kvp.Value.TabPath.ToLowerInvariant() == tabPath)
                            {
                                if (!string.IsNullOrEmpty(app.Request.Url.Query))
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" + kvp.Value.TabID +
                                        "&" + app.Request.Url.Query.TrimStart('?'));
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(
                                        app.Context,
                                        "~/" + Globals.glbDefaultPage + "?TabID=" + kvp.Value.TabID);
                                }

                                return;
                            }
                        }
                    }
                }
            }
        }
        private void RemoveProVersion()
        {
            //update the tab module to use CE version
            var     tabController    = new TabController();
            var     moduleController = new ModuleController();
            TabInfo newTab;

            var portalController = new PortalController();

            foreach (PortalInfo portal in portalController.GetPortals())
            {
                //Update Site Redirection management page
                var tabId = TabController.GetTabByTabPath(portal.PortalID, "//Admin//SiteRedirectionManagement", Null.NullString);
                if (tabId == Null.NullInteger)
                {
                    newTab = Upgrade.AddAdminPage(portal,
                                                  "Site Redirection Management",
                                                  "Site Redirection Management.",
                                                  "~/desktopmodules/MobileManagement/images/MobileManagement_Standard_16x16.png",
                                                  "~/desktopmodules/MobileManagement/images/MobileManagement_Standard_32x32.png",
                                                  true);
                }
                else
                {
                    newTab               = tabController.GetTab(tabId, portal.PortalID, true);
                    newTab.IconFile      = "~/desktopmodules/MobileManagement/images/MobileManagement_Standard_16x16.png";
                    newTab.IconFileLarge = "~/desktopmodules/MobileManagement/images/MobileManagement_Standard_32x32.png";
                    tabController.UpdateTab(newTab);
                }

                //Remove Pro edition module
                int moduleID = Null.NullInteger;
                IDictionary <int, ModuleInfo> modules = moduleController.GetTabModules(newTab.TabID);

                if (modules != null)
                {
                    foreach (ModuleInfo m in modules.Values)
                    {
                        if (m.DesktopModule.FriendlyName == "Site Redirection Management")
                        {
                            moduleID = m.ModuleID;
                            break;
                        }
                    }
                }

                if (moduleID != Null.NullInteger)
                {
                    moduleController.DeleteTabModule(newTab.TabID, moduleID, false);
                }

                //Add community edition module
                ModuleDefinitionInfo mDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("DNN Site Redirection Management");
                if (mDef != null)
                {
                    Upgrade.AddModuleToPage(newTab, mDef.ModuleDefID, "Site Redirection Management", "~/desktopmodules/MobileManagement/images/MobileManagement_Standard_32x32.png", true);
                }
            }

            var package = PackageController.GetPackageByName("DotNetNuke.Professional.MobileManagement");

            if (package != null)
            {
                var installer = new Installer(package, Globals.ApplicationMapPath);
                installer.UnInstall(true);
            }
        }
示例#28
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The DeleteModule method deletes the Module from the data Store.
        /// </summary>
        /// -----------------------------------------------------------------------------
        private void DeleteModule()
        {
            try
            {
                //Attempt to get the Desktop Module
                DesktopModuleInfo tempDesktopModule = DesktopModuleController.GetDesktopModuleByPackageID(Package.PackageID);
                if (tempDesktopModule != null)
                {
                    var modules = ModuleController.Instance.GetModulesByDesktopModuleId(tempDesktopModule.DesktopModuleID);
                    //Remove CodeSubDirectory
                    if ((_desktopModule != null) && (!string.IsNullOrEmpty(_desktopModule.CodeSubDirectory)))
                    {
                        Config.RemoveCodeSubDirectory(_desktopModule.CodeSubDirectory);
                    }
                    var controller = new DesktopModuleController();


                    Log.AddInfo(string.Format(Util.MODULE_UnRegistered, tempDesktopModule.ModuleName));
                    //remove admin/host pages
                    if (!String.IsNullOrEmpty(tempDesktopModule.AdminPage))
                    {
                        string tabPath = "//Admin//" + tempDesktopModule.AdminPage;

                        var portals = PortalController.Instance.GetPortals();
                        foreach (PortalInfo portal in portals)
                        {
                            var tabID = TabController.GetTabByTabPath(portal.PortalID, tabPath, Null.NullString);

                            TabInfo temp = TabController.Instance.GetTab(tabID, portal.PortalID);
                            if ((temp != null))
                            {
                                var  mods             = TabModulesController.Instance.GetTabModules((temp));
                                bool noOtherTabModule = true;
                                foreach (ModuleInfo mod in mods)
                                {
                                    if (mod.DesktopModuleID != tempDesktopModule.DesktopModuleID)
                                    {
                                        noOtherTabModule = false;
                                    }
                                }
                                if (noOtherTabModule)
                                {
                                    Log.AddInfo(string.Format(Util.MODULE_AdminPageRemoved, tempDesktopModule.AdminPage, portal.PortalID));
                                    TabController.Instance.DeleteTab(tabID, portal.PortalID);
                                }
                                Log.AddInfo(string.Format(Util.MODULE_AdminPagemoduleRemoved, tempDesktopModule.AdminPage, portal.PortalID));
                            }
                        }
                    }
                    if (!String.IsNullOrEmpty(tempDesktopModule.HostPage))
                    {
                        Upgrade.Upgrade.RemoveHostPage(tempDesktopModule.HostPage);
                        Log.AddInfo(string.Format(Util.MODULE_HostPageRemoved, tempDesktopModule.HostPage));
                        Log.AddInfo(string.Format(Util.MODULE_HostPagemoduleRemoved, tempDesktopModule.HostPage));
                    }

                    controller.DeleteDesktopModule(tempDesktopModule);
                    //Remove all the tab versions related with the module.
                    foreach (var module in modules)
                    {
                        var moduleInfo = module as ModuleInfo;
                        if (moduleInfo != null)
                        {
                            TabVersionController.Instance.DeleteTabVersionDetailByModule(moduleInfo.ModuleID);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.AddFailure(ex);
            }
        }
        private void RemoveProVersion()
        {
            //update the tab module to use CE version
            var     tabController    = new TabController();
            var     moduleController = new ModuleController();
            TabInfo newTab;

            var portalController = new PortalController();

            foreach (PortalInfo portal in portalController.GetPortals())
            {
                //Update Site Redirection management page
                var tabId = TabController.GetTabByTabPath(portal.PortalID, "//Admin//DevicePreviewManagement", Null.NullString);
                if (tabId == Null.NullInteger)
                {
                    newTab = Upgrade.AddAdminPage(portal,
                                                  "Device Preview Management",
                                                  "Device Preview Management.",
                                                  "~/desktopmodules/DevicePreviewManagement/images/DevicePreview_Standard_16X16.png",
                                                  "~/desktopmodules/DevicePreviewManagement/images/DevicePreview_Standard_32X32.png",
                                                  true);
                }
                else
                {
                    newTab               = tabController.GetTab(tabId, portal.PortalID, true);
                    newTab.IconFile      = "~/desktopmodules/DevicePreviewManagement/images/DevicePreview_Standard_16X16.png";
                    newTab.IconFileLarge = "~/desktopmodules/DevicePreviewManagement/images/DevicePreview_Standard_32X32.png";
                    tabController.UpdateTab(newTab);
                }

                //Remove Pro edition module
                int moduleID = Null.NullInteger;
                IDictionary <int, ModuleInfo> modules = moduleController.GetTabModules(newTab.TabID);

                if (modules != null)
                {
                    foreach (ModuleInfo m in modules.Values)
                    {
                        if (m.DesktopModule.FriendlyName == "Device Preview Management")
                        {
                            moduleID = m.ModuleID;
                            break;
                        }
                    }
                }

                if (moduleID != Null.NullInteger)
                {
                    moduleController.DeleteTabModule(newTab.TabID, moduleID, false);
                }

                //Add community edition module
                ModuleDefinitionInfo mDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("DNN Device Preview Management");
                if (mDef != null)
                {
                    Upgrade.AddModuleToPage(newTab, mDef.ModuleDefID, "Device Preview Management", "~/desktopmodules/DevicePreviewManagement/images/DevicePreview_Standard_32X32.png", true);
                }

                //reset default devices created flag
                string defaultPreviewProfiles;
                var    settings = PortalController.GetPortalSettingsDictionary(portal.PortalID);
                if (settings.TryGetValue("DefPreviewProfiles_Created", out defaultPreviewProfiles) && defaultPreviewProfiles == "DNNCORP.CE")
                {
                    PortalController.DeletePortalSetting(portal.PortalID, "DefPreviewProfiles_Created");
                }
            }

            var package = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name == "DotNetNuke.Professional.PreviewProfileManagement");

            if (package != null)
            {
                var installer = new Installer(package, Globals.ApplicationMapPath);
                installer.UnInstall(true);
            }
        }
        protected void OnImportClick(object sender, EventArgs e)
        {
            try
            {
                if (cboTemplate.SelectedItem == null || cboTemplate.SelectedValue == "None_Specified")
                {
                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("SpecifyFile", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                    return;
                }
                if (optMode.SelectedIndex == -1)
                {
                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("SpecifyMode", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                    return;
                }
                var xmlDoc = new XmlDocument();
                xmlDoc.Load(PortalSettings.HomeDirectoryMapPath + cboFolders.SelectedValue + cboTemplate.SelectedValue);
                XmlNode nodeTab = xmlDoc.SelectSingleNode("//portal/tabs/tab");
                TabInfo objTab;
                if (optMode.SelectedValue == "ADD")
                {
                    if (string.IsNullOrEmpty(txtTabName.Text))
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("SpecifyName", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                        return;
                    }

                    //New Tab
                    objTab = new TabInfo {
                        PortalID = PortalId, TabName = txtTabName.Text, IsVisible = true
                    };
                    if (cboParentTab.SelectedItem != null)
                    {
                        objTab.ParentId = Int32.Parse(cboParentTab.SelectedItem.Value);
                    }
                    objTab.TabPath = Globals.GenerateTabPath(objTab.ParentId, objTab.TabName);
                    int tabID   = TabController.GetTabByTabPath(objTab.PortalID, objTab.TabPath, Null.NullString);
                    var objTabs = new TabController();

                    //Check if tab exists
                    if (tabID != Null.NullInteger)
                    {
                        TabInfo existingTab = objTabs.GetTab(tabID, PortalId, false);
                        if (existingTab != null && existingTab.IsDeleted)
                        {
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabRecycled", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
                        }
                        else
                        {
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                        }
                        return;
                    }

                    int positionTabID = Int32.Parse(cboPositionTab.SelectedItem.Value);

                    var objEventLog = new EventLogController();
                    if (rbInsertPosition.SelectedValue == "After" && positionTabID > Null.NullInteger)
                    {
                        objTab.TabID = objTabs.AddTabAfter(objTab, positionTabID);
                    }
                    else if (rbInsertPosition.SelectedValue == "Before" && positionTabID > Null.NullInteger)
                    {
                        objTab.TabID = objTabs.AddTabBefore(objTab, positionTabID);
                    }
                    else
                    {
                        objTab.TabID = objTabs.AddTab(objTab);
                    }
                    objEventLog.AddLog(objTab, PortalSettings, UserId, "", EventLogController.EventLogType.TAB_CREATED);

                    //Update Tab properties from template
                    objTab = TabController.DeserializeTab(nodeTab, objTab, PortalId, PortalTemplateModuleAction.Replace);
                }
                else
                {
                    //Replace Existing Tab
                    objTab = TabController.DeserializeTab(nodeTab, Tab, PortalId, PortalTemplateModuleAction.Replace);
                }
                switch (optRedirect.SelectedValue)
                {
                case "VIEW":
                    Response.Redirect(Globals.NavigateURL(objTab.TabID), true);
                    break;

                default:
                    Response.Redirect(Globals.NavigateURL(objTab.TabID, "Tab", "action=edit"), true);
                    break;
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }