Example #1
0
        private static int RemoveModule(string DesktopModuleName, string TabName, int ParentId, bool TabRemove)
        {
            TabController objTabs = new TabController();
            ModuleController objModules = new ModuleController();
            TabInfo objTab = objTabs.GetTabByName(TabName, Null.NullInteger, ParentId);
            int intModuleDefId = 0;
            int intCount = 0;

            //Get the Modules on the Tab
            if (objTab != null)
            {
                foreach (KeyValuePair<int, ModuleInfo> kvp in objModules.GetTabModules(objTab.TabID))
                {
                    ModuleInfo objModule = kvp.Value;
                    if (objModule.DesktopModule.FriendlyName == DesktopModuleName)
                    {
                        //Delete the Module from the Modules list
                        objModules.DeleteTabModule(objModule.TabID, objModule.ModuleID, false);
                        intModuleDefId = objModule.ModuleDefID;
                    }
                    else
                    {
                        intCount += 1;
                    }
                }

                //If Tab has no modules optionally remove tab
                if (intCount == 0 & TabRemove)
                {
                    objTabs.DeleteTab(objTab.TabID, objTab.PortalID);
                }
            }

            return intModuleDefId;
        }
Example #2
0
        private static void UpgradeToVersion_500()
        {
            PortalController objPortals = new PortalController();
            ArrayList arrPortals = objPortals.GetPortals();
            TabController controller = new TabController();

            //Add Edit Permissions for Admin Tabs to legacy portals
            PermissionController permissionControler = new PermissionController();
            TabPermissionController tabPermissionControler = new TabPermissionController();
            ArrayList permissions = permissionControler.GetPermissionByCodeAndKey("SYSTEM_TAB", "EDIT");
            int permissionID = Null.NullInteger;
            if (permissions.Count == 1)
            {
                PermissionInfo permission = permissions[0] as PermissionInfo;
                permissionID = permission.PermissionID;

                foreach (PortalInfo portal in arrPortals)
                {
                    TabInfo adminTab = controller.GetTab(portal.AdminTabId, portal.PortalID, true);
                    if (adminTab != null)
                    {
                        TabPermissionInfo tabPermission = new TabPermissionInfo();
                        tabPermission.TabID = adminTab.TabID;
                        tabPermission.PermissionID = permissionID;
                        tabPermission.AllowAccess = true;
                        tabPermission.RoleID = portal.AdministratorRoleId;
                        if (!TabPermissionExists(tabPermission, portal.PortalID))
                        {
                            adminTab.TabPermissions.Add(tabPermission);
                        }

                        //Save Tab Permissions to Data Base
                        TabPermissionController.SaveTabPermissions(adminTab);

                        foreach (TabInfo childTab in TabController.GetTabsByParent(portal.AdminTabId, portal.PortalID))
                        {
                            tabPermission = new TabPermissionInfo();
                            tabPermission.TabID = childTab.TabID;
                            tabPermission.PermissionID = permissionID;
                            tabPermission.AllowAccess = true;
                            tabPermission.RoleID = portal.AdministratorRoleId;
                            if (!TabPermissionExists(tabPermission, portal.PortalID))
                            {
                                childTab.TabPermissions.Add(tabPermission);
                            }
                            //Save Tab Permissions to Data Base
                            TabPermissionController.SaveTabPermissions(childTab);
                        }
                    }
                }
            }

            //Update Host/Admin modules Visibility setting
            bool superTabProcessed = Null.NullBoolean;
            ModuleController moduleController = new ModuleController();
            foreach (PortalInfo portal in arrPortals)
            {
                if (!superTabProcessed)
                {
                    //Process Host Tabs
                    foreach (TabInfo childTab in TabController.GetTabsByParent(portal.SuperTabId, Null.NullInteger))
                    {
                        foreach (ModuleInfo tabModule in moduleController.GetTabModules(childTab.TabID).Values)
                        {
                            tabModule.Visibility = VisibilityState.None;
                            moduleController.UpdateModule(tabModule);
                        }
                    }
                }

                //Process Portal Tabs
                foreach (TabInfo childTab in TabController.GetTabsByParent(portal.AdminTabId, portal.PortalID))
                {
                    foreach (ModuleInfo tabModule in moduleController.GetTabModules(childTab.TabID).Values)
                    {
                        tabModule.Visibility = VisibilityState.None;
                        moduleController.UpdateModule(tabModule);
                    }
                }
            }

            //Upgrade PortalDesktopModules to support new "model"
            permissions = permissionControler.GetPermissionByCodeAndKey("SYSTEM_DESKTOPMODULE", "DEPLOY");
            if (permissions.Count == 1)
            {
                PermissionInfo permission = permissions[0] as PermissionInfo;
                permissionID = permission.PermissionID;
                foreach (PortalInfo portal in arrPortals)
                {
                    foreach (DesktopModuleInfo desktopModule in DesktopModuleController.GetDesktopModules(Null.NullInteger).Values)
                    {
                        if (!desktopModule.IsPremium)
                        {
                            //Parse the permissions
                            DesktopModulePermissionCollection deployPermissions = new DesktopModulePermissionCollection();
                            DesktopModulePermissionInfo deployPermission = default(DesktopModulePermissionInfo);

                            // if Not IsAdmin add Registered Users
                            if (!desktopModule.IsAdmin)
                            {
                                deployPermission = new DesktopModulePermissionInfo();
                                deployPermission.PermissionID = permissionID;
                                deployPermission.AllowAccess = true;
                                deployPermission.RoleID = portal.RegisteredRoleId;
                                deployPermissions.Add(deployPermission);
                            }

                            // if Not a Host Module add Administrators
                            string hostModules = "Portals, SQL, HostSettings, Scheduler, SearchAdmin, Lists, SkinDesigner, Extensions";
                            if (!hostModules.Contains(desktopModule.ModuleName))
                            {
                                deployPermission = new DesktopModulePermissionInfo();
                                deployPermission.PermissionID = permissionID;
                                deployPermission.AllowAccess = true;
                                deployPermission.RoleID = portal.AdministratorRoleId;
                                deployPermissions.Add(deployPermission);
                            }

                            //Add Portal/Module to PortalDesktopModules
                            DesktopModuleController.AddDesktopModuleToPortal(portal.PortalID, desktopModule, deployPermissions, false);
                        }
                    }

                    DataCache.ClearPortalCache(portal.PortalID, true);
                }
            }

            LegacyUtil.ProcessLegacyModules();
            LegacyUtil.ProcessLegacyLanguages();
            LegacyUtil.ProcessLegacySkins();
            LegacyUtil.ProcessLegacySkinControls();
        }
 private static bool FindModule(XmlNode nodeModule, int TabId, PortalTemplateModuleAction mergeTabs)
 {
     ModuleController objModules = new ModuleController();
     Dictionary<int, ModuleInfo> dicModules = objModules.GetTabModules(TabId);
     ModuleInfo objModule;
     bool moduleFound = false;
     string modTitle = XmlUtils.GetNodeValue(nodeModule.CreateNavigator(), "title");
     if (mergeTabs == PortalTemplateModuleAction.Merge)
     {
         foreach (KeyValuePair<int, ModuleInfo> kvp in dicModules)
         {
             objModule = kvp.Value;
             if (modTitle == objModule.ModuleTitle)
             {
                 moduleFound = true;
                 break;
             }
         }
     }
     return moduleFound;
 }
Example #4
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddModuleToPage adds a module to a Page
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="page">The Page to add the Module to</param>
        ///	<param name="ModuleDefId">The Module Deinition Id for the module to be aded to this tab</param>
        ///	<param name="ModuleTitle">The Module's title</param>
        ///	<param name="ModuleIconFile">The Module's icon</param>
        ///	<param name="InheritPermissions">Inherit the Pages View Permisions</param>
        /// <history>
        /// [cnurse]	11/16/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static int AddModuleToPage(TabInfo page, int ModuleDefId, string ModuleTitle, string ModuleIconFile, bool InheritPermissions)
        {
            ModuleController objModules = new ModuleController();
            ModuleInfo objModule = new ModuleInfo();
            bool blnDuplicate = false;
            int moduleId = Null.NullInteger;

            if ((page != null))
            {
                blnDuplicate = false;
                foreach (KeyValuePair<int, ModuleInfo> kvp in objModules.GetTabModules(page.TabID))
                {
                    objModule = kvp.Value;
                    if (objModule.ModuleDefID == ModuleDefId)
                    {
                        blnDuplicate = true;
                        moduleId = objModule.ModuleID;
                    }
                }

                if (!blnDuplicate)
                {
                    objModule = new ModuleInfo();
                    objModule.ModuleID = Null.NullInteger;
                    objModule.PortalID = page.PortalID;
                    objModule.TabID = page.TabID;
                    objModule.ModuleOrder = -1;
                    objModule.ModuleTitle = ModuleTitle;
                    objModule.PaneName = Globals.glbDefaultPane;
                    objModule.ModuleDefID = ModuleDefId;
                    objModule.CacheTime = 0;
                    objModule.IconFile = ModuleIconFile;
                    objModule.AllTabs = false;
                    objModule.Visibility = VisibilityState.None;
                    objModule.InheritViewPermissions = InheritPermissions;

                    try
                    {
                        moduleId = objModules.AddModule(objModule);
                    }
                    catch
                    {
                    }
                    // error adding module
                }
            }

            return moduleId;
        }
 public void CopyTab(int PortalId, int FromTabId, int ToTabId, bool asReference)
 {
     ModuleController objModules = new ModuleController();
     ModuleInfo objModule;
     foreach (KeyValuePair<int, ModuleInfo> kvp in objModules.GetTabModules(FromTabId))
     {
         objModule = kvp.Value;
         if (!objModule.AllTabs)
         {
             if (asReference == false)
             {
                 objModule.ModuleID = Null.NullInteger;
             }
             objModule.TabID = ToTabId;
             objModules.AddModule(objModule);
         }
     }
 }
 public static XmlNode SerializeTab(XmlDocument xmlTab, Hashtable hTabs, TabInfo objTab, PortalInfo objPortal, bool includeContent)
 {
     XmlNode nodeTab;
     XmlNode urlNode;
     XmlNode newnode;
     CBO.SerializeObject(objTab, xmlTab);
     nodeTab = xmlTab.SelectSingleNode("tab");
     nodeTab.Attributes.Remove(nodeTab.Attributes["xmlns:xsd"]);
     nodeTab.Attributes.Remove(nodeTab.Attributes["xmlns:xsi"]);
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("tabid"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("moduleID"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("taborder"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("portalid"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("parentid"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("isdeleted"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("tabpath"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("haschildren"));
     nodeTab.RemoveChild(nodeTab.SelectSingleNode("skindoctype"));
     foreach (XmlNode nodePermission in nodeTab.SelectNodes("tabpermissions/permission"))
     {
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("tabpermissionid"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("permissionid"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("tabid"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("roleid"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("userid"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("username"));
         nodePermission.RemoveChild(nodePermission.SelectSingleNode("displayname"));
     }
     urlNode = xmlTab.SelectSingleNode("tab/url");
     switch (objTab.TabType)
     {
         case TabType.Normal:
             urlNode.Attributes.Append(XmlUtils.CreateAttribute(xmlTab, "type", "Normal"));
             break;
         case TabType.Tab:
             urlNode.Attributes.Append(XmlUtils.CreateAttribute(xmlTab, "type", "Tab"));
             TabInfo tab = new TabController().GetTab(Int32.Parse(objTab.Url), objTab.PortalID, false);
             urlNode.InnerXml = tab.TabPath;
             break;
         case TabType.File:
             urlNode.Attributes.Append(XmlUtils.CreateAttribute(xmlTab, "type", "File"));
             Services.FileSystem.FileInfo file = new Services.FileSystem.FileController().GetFileById(Int32.Parse(objTab.Url.Substring(7)), objTab.PortalID);
             urlNode.InnerXml = file.RelativePath;
             break;
         case TabType.Url:
             urlNode.Attributes.Append(XmlUtils.CreateAttribute(xmlTab, "type", "Url"));
             break;
     }
     XmlUtils.SerializeHashtable(objTab.TabSettings, xmlTab, nodeTab, "tabsetting", "settingname", "settingvalue");
     if (objPortal != null)
     {
         if (objTab.TabID == objPortal.SplashTabId)
         {
             newnode = xmlTab.CreateElement("tabtype");
             newnode.InnerXml = "splashtab";
             nodeTab.AppendChild(newnode);
         }
         else if (objTab.TabID == objPortal.HomeTabId)
         {
             newnode = xmlTab.CreateElement("tabtype");
             newnode.InnerXml = "hometab";
             nodeTab.AppendChild(newnode);
         }
         else if (objTab.TabID == objPortal.UserTabId)
         {
             newnode = xmlTab.CreateElement("tabtype");
             newnode.InnerXml = "usertab";
             nodeTab.AppendChild(newnode);
         }
         else if (objTab.TabID == objPortal.LoginTabId)
         {
             newnode = xmlTab.CreateElement("tabtype");
             newnode.InnerXml = "logintab";
             nodeTab.AppendChild(newnode);
         }
     }
     if (hTabs != null)
     {
         if (!Null.IsNull(objTab.ParentId))
         {
             newnode = xmlTab.CreateElement("parent");
             newnode.InnerXml = HttpContext.Current.Server.HtmlEncode(hTabs[objTab.ParentId].ToString());
             nodeTab.AppendChild(newnode);
             hTabs.Add(objTab.TabID, hTabs[objTab.ParentId].ToString() + "/" + objTab.TabName);
         }
         else
         {
             hTabs.Add(objTab.TabID, objTab.TabName);
         }
     }
     XmlNode nodePanes;
     XmlNode nodePane;
     XmlNode nodeName;
     XmlNode nodeModules;
     XmlNode nodeModule;
     XmlDocument xmlModule;
     ModuleInfo objmodule;
     ModuleController objmodules = new ModuleController();
     nodePanes = nodeTab.AppendChild(xmlTab.CreateElement("panes"));
     foreach (KeyValuePair<int, ModuleInfo> kvp in objmodules.GetTabModules(objTab.TabID))
     {
         objmodule = kvp.Value;
         if (!objmodule.IsDeleted)
         {
             xmlModule = new XmlDocument();
             nodeModule = ModuleController.SerializeModule(xmlModule, objmodule, includeContent);
             if (nodePanes.SelectSingleNode("descendant::pane[name='" + objmodule.PaneName + "']") == null)
             {
                 nodePane = xmlModule.CreateElement("pane");
                 nodeName = nodePane.AppendChild(xmlModule.CreateElement("name"));
                 nodeName.InnerText = objmodule.PaneName;
                 nodePane.AppendChild(xmlModule.CreateElement("modules"));
                 nodePanes.AppendChild(xmlTab.ImportNode(nodePane, true));
             }
             nodeModules = nodePanes.SelectSingleNode("descendant::pane[name='" + objmodule.PaneName + "']/modules");
             nodeModules.AppendChild(xmlTab.ImportNode(nodeModule, true));
         }
     }
     return nodeTab;
 }
 public static void DeserializePanes(XmlNode nodePanes, int PortalId, int TabId, PortalTemplateModuleAction mergeTabs, Hashtable hModules)
 {
     ModuleController objModules = new ModuleController();
     ModuleInfo objModule;
     Dictionary<int, ModuleInfo> dicModules = objModules.GetTabModules(TabId);
     if (mergeTabs == PortalTemplateModuleAction.Replace)
     {
         foreach (KeyValuePair<int, ModuleInfo> kvp in dicModules)
         {
             objModule = kvp.Value;
             objModules.DeleteTabModule(TabId, objModule.ModuleID, false);
         }
     }
     foreach (XmlNode nodePane in nodePanes.ChildNodes)
     {
         if (nodePane.SelectSingleNode("modules") != null)
         {
             foreach (XmlNode nodeModule in nodePane.SelectSingleNode("modules"))
             {
                 ModuleController.DeserializeModule(nodeModule, nodePane, PortalId, TabId, mergeTabs, hModules);
             }
         }
     }
 }
 private void GetPortalSettings(int tabID, PortalInfo portal)
 {
     ModuleController objModules = new ModuleController();
     ModuleInfo objModule;
     this.PortalId = portal.PortalID;
     this.PortalName = portal.PortalName;
     this.LogoFile = portal.LogoFile;
     this.FooterText = portal.FooterText;
     this.ExpiryDate = portal.ExpiryDate;
     this.UserRegistration = portal.UserRegistration;
     this.BannerAdvertising = portal.BannerAdvertising;
     this.Currency = portal.Currency;
     this.AdministratorId = portal.AdministratorId;
     this.Email = portal.Email;
     this.HostFee = portal.HostFee;
     this.HostSpace = portal.HostSpace;
     this.PageQuota = portal.PageQuota;
     this.UserQuota = portal.UserQuota;
     this.AdministratorRoleId = portal.AdministratorRoleId;
     this.AdministratorRoleName = portal.AdministratorRoleName;
     this.RegisteredRoleId = portal.RegisteredRoleId;
     this.RegisteredRoleName = portal.RegisteredRoleName;
     this.Description = portal.Description;
     this.KeyWords = portal.KeyWords;
     this.BackgroundFile = portal.BackgroundFile;
     this.GUID = portal.GUID;
     this.SiteLogHistory = portal.SiteLogHistory;
     this.AdminTabId = portal.AdminTabId;
     this.SuperTabId = portal.SuperTabId;
     this.SplashTabId = portal.SplashTabId;
     this.HomeTabId = portal.HomeTabId;
     this.LoginTabId = portal.LoginTabId;
     this.RegisterTabId = portal.RegisterTabId;
     this.UserTabId = portal.UserTabId;
     this.DefaultLanguage = portal.DefaultLanguage;
     this.TimeZoneOffset = portal.TimeZoneOffset;
     this.HomeDirectory = portal.HomeDirectory;
     this.Pages = portal.Pages;
     this.Users = portal.Users;
     if (Null.IsNull(this.HostSpace))
     {
         this.HostSpace = 0;
     }
     if (Null.IsNull(this.DefaultLanguage))
     {
         this.DefaultLanguage = Localization.SystemLocale;
     }
     if (Null.IsNull(this.TimeZoneOffset))
     {
         this.TimeZoneOffset = Localization.SystemTimeZoneOffset;
     }
     this.HomeDirectory = Common.Globals.ApplicationPath + "/" + portal.HomeDirectory + "/";
     if (VerifyPortalTab(PortalId, tabID))
     {
         if (this.ActiveTab != null)
         {
             if (Globals.IsAdminSkin())
             {
                 this.ActiveTab.SkinSrc = this.DefaultAdminSkin;
             }
             else
             {
                 if (String.IsNullOrEmpty(this.ActiveTab.SkinSrc))
                 {
                     this.ActiveTab.SkinSrc = this.DefaultPortalSkin;
                 }
             }
             this.ActiveTab.SkinSrc = SkinController.FormatSkinSrc(this.ActiveTab.SkinSrc, this);
             this.ActiveTab.SkinPath = SkinController.FormatSkinPath(this.ActiveTab.SkinSrc);
             if (Globals.IsAdminSkin())
             {
                 this.ActiveTab.ContainerSrc = this.DefaultAdminContainer;
             }
             else
             {
                 if (String.IsNullOrEmpty(this.ActiveTab.ContainerSrc))
                 {
                     this.ActiveTab.ContainerSrc = this.DefaultPortalContainer;
                 }
             }
             this.ActiveTab.ContainerSrc = SkinController.FormatSkinSrc(this.ActiveTab.ContainerSrc, this);
             this.ActiveTab.ContainerPath = SkinController.FormatSkinPath(this.ActiveTab.ContainerSrc);
             this.ActiveTab.Panes = new ArrayList();
             this.ActiveTab.Modules = new ArrayList();
             ArrayList crumbs = new ArrayList();
             GetBreadCrumbsRecursively(ref crumbs, this.ActiveTab.TabID);
             this.ActiveTab.BreadCrumbs = crumbs;
         }
     }
     if (this.ActiveTab != null)
     {
         Dictionary<string, int> objPaneModules = new Dictionary<string, int>();
         foreach (KeyValuePair<int, ModuleInfo> kvp in objModules.GetTabModules(this.ActiveTab.TabID))
         {
             ModuleInfo cloneModule = kvp.Value.Clone();
             if (Null.IsNull(cloneModule.StartDate))
             {
                 cloneModule.StartDate = System.DateTime.MinValue;
             }
             if (Null.IsNull(cloneModule.EndDate))
             {
                 cloneModule.EndDate = System.DateTime.MaxValue;
             }
             if (String.IsNullOrEmpty(cloneModule.ContainerSrc))
             {
                 cloneModule.ContainerSrc = this.ActiveTab.ContainerSrc;
             }
             cloneModule.ContainerSrc = SkinController.FormatSkinSrc(cloneModule.ContainerSrc, this);
             cloneModule.ContainerPath = SkinController.FormatSkinPath(cloneModule.ContainerSrc);
             if (objPaneModules.ContainsKey(cloneModule.PaneName) == false)
             {
                 objPaneModules.Add(cloneModule.PaneName, 0);
             }
             cloneModule.PaneModuleCount = 0;
             if (!cloneModule.IsDeleted)
             {
                 objPaneModules[cloneModule.PaneName] = objPaneModules[cloneModule.PaneName] + 1;
                 cloneModule.PaneModuleIndex = objPaneModules[cloneModule.PaneName] - 1;
             }
             this.ActiveTab.Modules.Add(cloneModule);
         }
         foreach (ModuleInfo module in this.ActiveTab.Modules)
         {
             module.PaneModuleCount = objPaneModules[module.PaneName];
         }
     }
 }
 public void ParseTemplate(int PortalId, string TemplatePath, string TemplateFile, int AdministratorId, PortalTemplateModuleAction mergeTabs, bool IsNewPortal)
 {
     XmlDocument xmlPortal = new XmlDocument();
     XmlNode node;
     try
     {
         xmlPortal.Load(TemplatePath + TemplateFile);
     }
     catch
     {
     }
     node = xmlPortal.SelectSingleNode("//portal/settings");
     if (node != null && IsNewPortal)
     {
         ParsePortalSettings(node, PortalId);
     }
     node = xmlPortal.SelectSingleNode("//portal/rolegroups");
     if (node != null)
     {
         ParseRoleGroups(node.CreateNavigator(), PortalId, AdministratorId);
     }
     node = xmlPortal.SelectSingleNode("//portal/roles");
     if (node != null)
     {
         ParseRoles(node.CreateNavigator(), PortalId, AdministratorId);
     }
     node = xmlPortal.SelectSingleNode("//portal/portalDesktopModules");
     if (node != null)
     {
         ParsePortalDesktopModules(node.CreateNavigator(), PortalId);
     }
     node = xmlPortal.SelectSingleNode("//portal/folders");
     if (node != null)
     {
         ParseFolders(node, PortalId);
     }
     var objController = new FolderController();
     if (objController.GetFolder(PortalId, "", false) == null)
     {
         int folderid = objController.AddFolder(PortalId, "", (int)Services.FileSystem.FolderController.StorageLocationTypes.InsecureFileSystem, true, false);
         AddFolderPermissions(PortalId, folderid);
     }
     if (objController.GetFolder(PortalId, "Templates/", false) == null)
     {
         int folderid = objController.AddFolder(PortalId, "Templates/", (int)Services.FileSystem.FolderController.StorageLocationTypes.InsecureFileSystem, true, false);
         AddFolderPermissions(PortalId, folderid);
     }
     // force creation of templates folder if not present on template
     if (objController.GetFolder(PortalId, "Users/", false) == null)
     {
         int folderid = objController.AddFolder(PortalId, "Users/", (int)Services.FileSystem.FolderController.StorageLocationTypes.InsecureFileSystem, true, false);
         AddFolderPermissions(PortalId, folderid);
     }
     if (mergeTabs == PortalTemplateModuleAction.Replace)
     {
         var objTabs = new TabController();
         TabInfo objTab;
         foreach (KeyValuePair<int, TabInfo> tabPair in objTabs.GetTabsByPortal(PortalId))
         {
             objTab = tabPair.Value;
             objTab.TabName = objTab.TabName + "_old";
             objTab.TabPath = Common.Globals.GenerateTabPath(objTab.ParentId, objTab.TabName);
             objTab.IsDeleted = true;
             objTabs.UpdateTab(objTab);
             var objModules = new ModuleController();
             ModuleInfo objModule;
             foreach (KeyValuePair<int, ModuleInfo> modulePair in objModules.GetTabModules(objTab.TabID))
             {
                 objModule = modulePair.Value;
                 objModules.DeleteTabModule(objModule.TabID, objModule.ModuleID, false);
             }
         }
     }
     node = xmlPortal.SelectSingleNode("//portal/tabs");
     if (node != null)
     {
         string version = xmlPortal.DocumentElement.GetAttribute("version");
         if (version != "5.0")
         {
             var xmlAdmin = new XmlDocument();
             try
             {
                 xmlAdmin.Load(TemplatePath + "admin.template");
             }
             catch
             {
             }
             XmlNode adminNode = xmlAdmin.SelectSingleNode("//portal/tabs");
             foreach (XmlNode adminTabNode in adminNode.ChildNodes)
             {
                 node.AppendChild(xmlPortal.ImportNode(adminTabNode, true));
             }
         }
         ParseTabs(node, PortalId, false, mergeTabs, IsNewPortal);
     }
 }