/// -----------------------------------------------------------------------------
        /// <summary>
        /// RemoveCoreModule removes a Core Module from the system
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="DesktopModuleName">The Friendly Name of the Module to Remove</param>
        ///	<param name="ParentTabName">The Name of the parent Tab/Page for this module</param>
        ///	<param name="TabName">The Name to tab that contains the Module</param>
        ///	<param name="TabRemove">A flag to determine whether to remove the Tab if it has no
        ///	other modules</param>
        /// <history>
        /// [cnurse]	10/14/2004	documented
        /// </history>
        /// -----------------------------------------------------------------------------
        private static void RemoveCoreModule(string DesktopModuleName, string ParentTabName, string TabName, bool TabRemove)
        {
            int ParentId = 0;
            int intModuleDefId = Null.NullInteger;
            int intDesktopModuleId = 0;

            //Find and remove the Module from the Tab
            switch (ParentTabName)
            {
                case "Host":
                    TabController objTabs = new TabController();
                    TabInfo objTab = objTabs.GetTabByName("Host", Null.NullInteger, Null.NullInteger);

                    if (objTab != null)
                    {
                        intModuleDefId = RemoveModule(DesktopModuleName, TabName, objTab.TabID, TabRemove);
                    }
                    break;
                case "Admin":
                    PortalController objPortals = new PortalController();
                    PortalInfo objPortal = default(PortalInfo);

                    ArrayList arrPortals = objPortals.GetPortals();
                    int intPortal = 0;

                    //Iterate through the Portals to remove the Module from the Tab
                    for (intPortal = 0; intPortal <= arrPortals.Count - 1; intPortal++)
                    {
                        objPortal = (PortalInfo)arrPortals[intPortal];
                        ParentId = objPortal.AdminTabId;
                        intModuleDefId = RemoveModule(DesktopModuleName, TabName, ParentId, TabRemove);
                    }
                    break;
            }

            DesktopModuleInfo objDesktopModule = null;
            if (intModuleDefId == Null.NullInteger)
            {
                objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName(DesktopModuleName, Null.NullInteger);
                intDesktopModuleId = objDesktopModule.DesktopModuleID;
            }
            else
            {
                //Get the Module Definition
                ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController();
                ModuleDefinitionInfo objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(intModuleDefId);
                if (objModuleDefinition != null)
                {
                    intDesktopModuleId = objModuleDefinition.DesktopModuleID;
                    objDesktopModule = DesktopModuleController.GetDesktopModule(intDesktopModuleId, Null.NullInteger);
                }
            }

            if (objDesktopModule != null)
            {
                //Delete the Desktop Module
                DesktopModuleController objDesktopModules = new DesktopModuleController();
                objDesktopModules.DeleteDesktopModule(intDesktopModuleId);

                //Delete the Package
                PackageController.DeletePackage(objDesktopModule.PackageID);

            }
        }
        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;
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddPage adds a Tab Page
        /// </summary>
        ///	<param name="PortalId">The Id of the Portal</param>
        ///	<param name="ParentId">The Id of the Parent Tab</param>
        ///	<param name="TabName">The Name to give this new Tab</param>
        ///	<param name="TabIconFile">The Icon for this new Tab</param>
        ///	<param name="IsVisible">A flag indicating whether the tab is visible</param>
        ///	<param name="permissions">Page Permissions Collection for this page</param>
        /// <param name="IsAdmin">Is and admin page</param>
        /// <history>
        /// [cnurse]	11/11/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        private static TabInfo AddPage(int PortalId, int ParentId, string TabName, string Description, string TabIconFile, string TabIconFileLarge, bool IsVisible, Security.Permissions.TabPermissionCollection permissions, bool IsAdmin)
        {
            TabController objTabs = new TabController();
            TabInfo objTab = default(TabInfo);

            objTab = objTabs.GetTabByName(TabName, PortalId, ParentId);

            if (objTab == null || objTab.ParentId != ParentId)
            {
                objTab = new TabInfo();
                objTab.TabID = Null.NullInteger;
                objTab.PortalID = PortalId;
                objTab.TabName = TabName;
                objTab.Title = "";
                objTab.Description = Description;
                objTab.KeyWords = "";
                objTab.IsVisible = IsVisible;
                objTab.DisableLink = false;
                objTab.ParentId = ParentId;
                objTab.IconFile = TabIconFile;
                objTab.IconFileLarge = TabIconFileLarge;
                objTab.IsDeleted = false;
                objTab.TabID = objTabs.AddTab(objTab, !IsAdmin);

                if (((permissions != null)))
                {
                    Security.Permissions.TabPermissionController tabPermissionCtrl = new Security.Permissions.TabPermissionController();
                    foreach (TabPermissionInfo tabPermission in permissions)
                    {
                        objTab.TabPermissions.Add(tabPermission, true);
                    }
                    TabPermissionController.SaveTabPermissions(objTab);
                }
            }

            return objTab;
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// HostTabExists determines whether a tab of a given name exists under the Host tab
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="TabName">The Name of the Tab</param>
        ///	<returns>True if the Tab exists, otherwise False</returns>
        /// <history>
        /// [cnurse]	11/08/2004	documented
        /// </history>
        /// -----------------------------------------------------------------------------
        private static bool HostTabExists(string TabName)
        {

            bool blnExists = false;

            TabController objTabController = new TabController();

            TabInfo objTabInfo = objTabController.GetTabByName(TabName, Null.NullInteger);
            if ((objTabInfo != null))
            {
                blnExists = true;
            }
            else
            {
                blnExists = false;
            }


            return blnExists;
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// UpgradeApplication - This overload is used for general application upgrade operations.
        /// </summary>
        /// <remarks>
        ///	Since it is not version specific and is invoked whenever the application is
        ///	restarted, the operations must be re-executable.
        /// </remarks>
        /// <history>
        /// [cnurse]	11/6/2004	documented
        /// [cnurse] 02/27/2007 made public so it can be called from Wizard
        /// </history>
        /// -----------------------------------------------------------------------------
        public static void UpgradeApplication()
        {

            TabController objTabController = new TabController();
            TabInfo HostPage = objTabController.GetTabByName("Host", Null.NullInteger);
            TabInfo newPage = default(TabInfo);

            int ModuleDefID = 0;

            try
            {
                // remove the system message module from the admin tab
                // System Messages are now managed through Localization
                if (CoreModuleExists("System Messages"))
                {
                    RemoveCoreModule("System Messages", "Admin", "Site Settings", false);
                }

                // remove portal alias module
                if (CoreModuleExists("PortalAliases"))
                {
                    RemoveCoreModule("PortalAliases", "Admin", "Site Settings", false);
                }

                // add the log viewer module to the admin tab
                if (CoreModuleExists("LogViewer") == false)
                {
                    ModuleDefID = AddModuleDefinition("LogViewer", "Allows you to view log entries for portal events.", "Log Viewer");
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/LogViewer/LogViewer.ascx", "", SecurityAccessLevel.Admin, 0);
                    AddModuleControl(ModuleDefID, "Edit", "Edit Log Settings", "DesktopModules/Admin/LogViewer/EditLogTypes.ascx", "", SecurityAccessLevel.Host, 0);

                    //Add the Module/Page to all configured portals
                    AddAdminPages("Log Viewer", "View a historical log of database events such as event schedules, exceptions, account logins, module and page changes, user account activities, security role activities, etc.", "icon_viewstats_16px.gif", "icon_viewstats_32px.gif", true, ModuleDefID, "Log Viewer", "icon_viewstats_16px.gif");
                }

                // add the schedule module to the host tab
                if (CoreModuleExists("Scheduler") == false)
                {
                    ModuleDefID = AddModuleDefinition("Scheduler", "Allows you to schedule tasks to be run at specified intervals.", "Scheduler");
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/Scheduler/ViewSchedule.ascx", "", SecurityAccessLevel.Admin, 0);
                    AddModuleControl(ModuleDefID, "Edit", "Edit Schedule", "DesktopModules/Admin/Scheduler/EditSchedule.ascx", "", SecurityAccessLevel.Host, 0);
                    AddModuleControl(ModuleDefID, "History", "Schedule History", "DesktopModules/Admin/Scheduler/ViewScheduleHistory.ascx", "", SecurityAccessLevel.Host, 0);
                    AddModuleControl(ModuleDefID, "Status", "Schedule Status", "DesktopModules/Admin/Scheduler/ViewScheduleStatus.ascx", "", SecurityAccessLevel.Host, 0);

                    //Create New Host Page (or get existing one)
                    newPage = AddHostPage("Schedule", "Add, modify and delete scheduled tasks to be run at specified intervals.", "icon_scheduler_16px.gif", "icon_scheduler_32px.gif", true);

                    //Add Module To Page
                    AddModuleToPage(newPage, ModuleDefID, "Schedule", "icon_scheduler_16px.gif");
                }

                // add the Search Admin module to the host tab
                if (CoreModuleExists("SearchAdmin") == false)
                {
                    ModuleDefID = AddModuleDefinition("SearchAdmin", "The Search Admininstrator provides the ability to manage search settings.", "Search Admin");
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/SearchAdmin/SearchAdmin.ascx", "", SecurityAccessLevel.Host, 0);

                    //Create New Host Page (or get existing one)
                    newPage = AddHostPage("Search Admin", "Manage search settings associated with DotNetNuke's search capability.", "icon_search_16px.gif", "icon_search_32px.gif", true);

                    //Add Module To Page
                    AddModuleToPage(newPage, ModuleDefID, "Search Admin", "icon_search_16px.gif");
                }

                // add the Search Input module
                if (CoreModuleExists("SearchInput") == false)
                {
                    ModuleDefID = AddModuleDefinition("SearchInput", "The Search Input module provides the ability to submit a search to a given search results module.", "Search Input", false, false);
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/SearchInput/SearchInput.ascx", "", SecurityAccessLevel.Anonymous, 0);
                    AddModuleControl(ModuleDefID, "Settings", "Search Input Settings", "DesktopModules/Admin/SearchInput/Settings.ascx", "", SecurityAccessLevel.Edit, 0);
                }

                // add the Search Results module
                if (CoreModuleExists("SearchResults") == false)
                {
                    ModuleDefID = AddModuleDefinition("SearchResults", "The Search Reasults module provides the ability to display search results.", "Search Results", false, false);
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/SearchResults/SearchResults.ascx", "", SecurityAccessLevel.Anonymous, 0);
                    AddModuleControl(ModuleDefID, "Settings", "Search Results Settings", "DesktopModules/Admin/SearchResults/Settings.ascx", "", SecurityAccessLevel.Edit, 0);

                    //Add the Search Module/Page to all configured portals
                    AddSearchResults(ModuleDefID);
                }

                // add the site wizard module to the admin tab
                if (CoreModuleExists("SiteWizard") == false)
                {
                    ModuleDefID = AddModuleDefinition("SiteWizard", "The Administrator can use this user-friendly wizard to set up the common Extensions of the Portal/Site.", "Site Wizard");
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/SiteWizard/Sitewizard.ascx", "", SecurityAccessLevel.Admin, 0);
                    AddAdminPages("Site Wizard", "Configure portal settings, page design and apply a site template using a step-by-step wizard.", "icon_wizard_16px.gif", "icon_wizard_32px.gif", true, ModuleDefID, "Site Wizard", "icon_wizard_16px.gif");
                }

                //add Lists module and tab
                if (HostTabExists("Lists") == false)
                {
                    ModuleDefID = AddModuleDefinition("Lists", "Allows you to edit common lists.", "Lists");
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/Lists/ListEditor.ascx", "", SecurityAccessLevel.Host, 0);

                    //Create New Host Page (or get existing one)
                    newPage = AddHostPage("Lists", "Manage common lists.", "icon_lists_16px.gif", "icon_lists_32px.gif", true);

                    //Add Module To Page
                    AddModuleToPage(newPage, ModuleDefID, "Lists", "icon_lists_16px.gif");
                }

                if (HostTabExists("Superuser Accounts") == false)
                {
                    //add SuperUser Accounts module and tab
                    DesktopModuleInfo objDesktopModuleInfo = DesktopModuleController.GetDesktopModuleByModuleName("DNN_Security", Null.NullInteger);
                    ModuleDefID = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("User Accounts", objDesktopModuleInfo.DesktopModuleID).ModuleDefID;

                    //Create New Host Page (or get existing one)
                    newPage = AddHostPage("Superuser Accounts", "Manage host user accounts.", "icon_users_16px.gif", "icon_users_32px.gif", true);

                    //Add Module To Page
                    AddModuleToPage(newPage, ModuleDefID, "Superuser Accounts", "icon_users_32px.gif");
                }

                //Add Edit Role Groups
                ModuleDefID = GetModuleDefinition("Security", "Security Roles");
                AddModuleControl(ModuleDefID, "EditGroup", "Edit Role Groups", "DesktopModules/Admin/Security/EditGroups.ascx", "icon_securityroles_32px.gif", SecurityAccessLevel.Edit, Null.NullInteger);
                AddModuleControl(ModuleDefID, "UserSettings", "Manage User Settings", "DesktopModules/Admin/Security/UserSettings.ascx", "~/images/settings.gif", SecurityAccessLevel.Edit, Null.NullInteger);

                //Add User Accounts Controls
                ModuleDefID = GetModuleDefinition("Security", "User Accounts");
                AddModuleControl(ModuleDefID, "ManageProfile", "Manage Profile Definition", "DesktopModules/Admin/Security/ProfileDefinitions.ascx", "icon_users_32px.gif", SecurityAccessLevel.Edit, Null.NullInteger);
                AddModuleControl(ModuleDefID, "EditProfileProperty", "Edit Profile Property Definition", "DesktopModules/Admin/Security/EditProfileDefinition.ascx", "icon_users_32px.gif", SecurityAccessLevel.Edit, Null.NullInteger);
                AddModuleControl(ModuleDefID, "UserSettings", "Manage User Settings", "DesktopModules/Admin/Security/UserSettings.ascx", "~/images/settings.gif", SecurityAccessLevel.Edit, Null.NullInteger);
                AddModuleControl(Null.NullInteger, "Profile", "Profile", "DesktopModules/Admin/Security/ManageUsers.ascx", "icon_users_32px.gif", SecurityAccessLevel.Anonymous, Null.NullInteger);
                AddModuleControl(Null.NullInteger, "SendPassword", "Send Password", "DesktopModules/Admin/Security/SendPassword.ascx", "", SecurityAccessLevel.Anonymous, Null.NullInteger);
                AddModuleControl(Null.NullInteger, "ViewProfile", "View Profile", "DesktopModules/Admin/Security/ViewProfile.ascx", "icon_users_32px.gif", SecurityAccessLevel.Anonymous, Null.NullInteger);

                //Update Child Portal subHost.aspx
                PortalAliasController objAliasController = new PortalAliasController();
                ArrayList arrAliases = objAliasController.GetPortalAliasArrayByPortalID(Null.NullInteger);
                string childPath = null;

                foreach (PortalAliasInfo objAlias in arrAliases)
                {
                    //For the alias to be for a child it must be of the form ...../child
                    int intChild = objAlias.HTTPAlias.IndexOf("/");
                    if (intChild != -1 & intChild != (objAlias.HTTPAlias.Length - 1))
                    {
                        childPath = Globals.ApplicationMapPath + "\\" + objAlias.HTTPAlias.Substring(intChild + 1);
                        // check if Folder exists
                        if (Directory.Exists(childPath))
                        {
                            System.IO.FileInfo objDefault = new System.IO.FileInfo(childPath + "\\" + Globals.glbDefaultPage);
                            System.IO.FileInfo objSubHost = new System.IO.FileInfo(Common.Globals.HostMapPath + "subhost.aspx");
                            // check if upgrade is necessary
                            if (objDefault.Length != objSubHost.Length)
                            {
                                //Rename existing file
                                System.IO.File.Copy(childPath + "\\" + Globals.glbDefaultPage, childPath + "\\old_" + Globals.glbDefaultPage, true);
                                // create the subhost default.aspx file
                                System.IO.File.Copy(Common.Globals.HostMapPath + "subhost.aspx", childPath + "\\" + Globals.glbDefaultPage, true);
                            }
                        }
                    }
                }

                // add the solutions explorer module to the admin tab
                if (CoreModuleExists("Solutions") == false)
                {
                    ModuleDefID = AddModuleDefinition("Solutions", "Browse additional solutions for your application.", "Solutions", false, false);
                    AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/Solutions/Solutions.ascx", "", SecurityAccessLevel.Admin, 0);
                    AddAdminPages("Solutions", "DotNetNuke Solutions Explorer page provides easy access to locate free and commercial DotNetNuke modules, skin and more.", "icon_solutions_16px.gif", "icon_solutions_32px.gif", true, ModuleDefID, "Solutions Explorer", "icon_solutions_32px.gif");
                }


                //Add Search Skin Object
                AddSkinControl("SEARCH", "DotNetNuke.SearchSkinObject", "Admin/Skins/Search.ascx");

                //Add TreeView Skin Object
                AddSkinControl("TREEVIEW", "DotNetNuke.TreeViewSkinObject", "Admin/Skins/TreeViewMenu.ascx");

                //Add Text Skin Object
                AddSkinControl("TEXT", "DotNetNuke.TextSkinObject", "Admin/Skins/Text.ascx");

                //Add Styles Skin Object

                AddSkinControl("STYLES", "DotNetNuke.StylesSkinObject", "Admin/Skins/Styles.ascx");
            }
            catch (Exception ex)
            {
                Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
                Services.Log.EventLog.LogInfo objEventLogInfo = new Services.Log.EventLog.LogInfo();
                objEventLogInfo.AddProperty("Upgraded DotNetNuke", "General");
                objEventLogInfo.AddProperty("Warnings", "Error: " + ex.Message + Environment.NewLine);
                objEventLogInfo.LogTypeKey = Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString();
                objEventLogInfo.BypassBuffering = true;
                objEventLog.AddLog(objEventLogInfo);
                try
                {
                    Exceptions.Exceptions.LogException(ex);
                }
                catch
                {
                }

                // ignore
            }

            //Remove any .txt and .config files that may exist in the Install folder
            foreach (string strFile in Directory.GetFiles(Globals.InstallMapPath + "Cleanup\\", "??.??.??.txt"))
            {
                FileSystemUtils.DeleteFile(strFile);
            }
            foreach (string strFile in Directory.GetFiles(Globals.InstallMapPath + "Config\\", "??.??.??.config"))
            {
                FileSystemUtils.DeleteFile(strFile);

            }
        }
 public static void RemoveHostPage(string pageName)
 {
     TabController controller = new TabController();
     TabInfo skinsTab = controller.GetTabByName(pageName, Null.NullInteger);
     if (skinsTab != null)
     {
         controller.DeleteTab(skinsTab.TabID, Null.NullInteger);
     }
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddHostPage adds a Host Tab Page
        /// </summary>
        ///	<param name="TabName">The Name to give this new Tab</param>
        ///	<param name="TabIconFile">The Icon for this new Tab</param>
        ///	<param name="IsVisible">A flag indicating whether the tab is visible</param>
        /// <history>
        /// [cnurse]	11/11/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static TabInfo AddHostPage(string TabName, string Description, string TabIconFile, string TabIconFileLarge, bool IsVisible)
        {
            TabController objTabController = new TabController();
            TabInfo HostPage = objTabController.GetTabByName("Host", Null.NullInteger);

            if ((HostPage != null))
            {
                Security.Permissions.TabPermissionCollection objTabPermissions = new Security.Permissions.TabPermissionCollection();
                AddPagePermission(objTabPermissions, "View", Convert.ToInt32(Common.Globals.glbRoleSuperUser));
                AddPagePermission(objTabPermissions, "Edit", Convert.ToInt32(Common.Globals.glbRoleSuperUser));
                return AddPage(HostPage, TabName, Description, TabIconFile, TabIconFileLarge, IsVisible, objTabPermissions, true);
            }
            else
            {
                return null;
            }
        }
        private static void UpgradeToVersion_510()
        {
            //Upgrade to .NET 3.5
            TryUpgradeNETFramework();

            PortalController objPortalController = new PortalController();
            TabController objTabController = new TabController();
            ModuleController objModuleController = new ModuleController();
            int ModuleDefID = 0;
            int ModuleID = 0;

            //add Dashboard module and tab
            if (HostTabExists("Dashboard") == false)
            {
                ModuleDefID = AddModuleDefinition("Dashboard", "Provides a snapshot of your DotNetNuke Application.", "Dashboard", true, true);
                AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/Dashboard/Dashboard.ascx", "icon_dashboard_32px.gif", SecurityAccessLevel.Host, 0);
                AddModuleControl(ModuleDefID, "Export", "", "DesktopModules/Admin/Dashboard/Export.ascx", "", SecurityAccessLevel.Host, 0);
                AddModuleControl(ModuleDefID, "DashboardControls", "", "DesktopModules/Admin/Dashboard/DashboardControls.ascx", "", SecurityAccessLevel.Host, 0);

                //Create New Host Page (or get existing one)
                TabInfo dashboardPage = AddHostPage("Dashboard", "Summary view of application and site settings.", "~/images/icon_dashboard_16px.gif", "~/images/icon_dashboard_32px.gif", true);

                //Add Module To Page
                AddModuleToPage(dashboardPage, ModuleDefID, "Dashboard", "~/images/icon_dashboard_32px.gif");
            }
            else
            {
                //Module was incorrectly assigned as "IsPremium=False"
                RemoveModuleFromPortals("Dashboard");
                //fix path for dashboarcontrols
                ModuleDefID = GetModuleDefinition("Dashboard", "Dashboard");
                RemoveModuleControl(ModuleDefID, "DashboardControls");
                AddModuleControl(ModuleDefID, "DashboardControls", "", "DesktopModules/Admin/Dashboard/DashboardControls.ascx", "", SecurityAccessLevel.Host, 0);
            }

            //Add the Extensions Module
            if (CoreModuleExists("Extensions") == false)
            {
                ModuleDefID = AddModuleDefinition("Extensions", "", "Extensions");
                AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/Extensions/Extensions.ascx", "~/images/icon_extensions_32px.gif", SecurityAccessLevel.View, 0);
                AddModuleControl(ModuleDefID, "Edit", "Edit Feature", "DesktopModules/Admin/Extensions/EditExtension.ascx", "~/images/icon_extensions_32px.gif", SecurityAccessLevel.Edit, 0);
                AddModuleControl(ModuleDefID, "PackageWriter", "Package Writer", "DesktopModules/Admin/Extensions/PackageWriter.ascx", "~/images/icon_extensions_32px.gif", SecurityAccessLevel.Host, 0);
                AddModuleControl(ModuleDefID, "EditControl", "Edit Control", "DesktopModules/Admin/Extensions/Editors/EditModuleControl.ascx", "~/images/icon_extensions_32px.gif", SecurityAccessLevel.Host, 0);
                AddModuleControl(ModuleDefID, "ImportModuleDefinition", "Import Module Definition", "DesktopModules/Admin/Extensions/Editors/ImportModuleDefinition.ascx", "~/images/icon_extensions_32px.gif", SecurityAccessLevel.Host, 0);
                AddModuleControl(ModuleDefID, "BatchInstall", "Batch Install", "DesktopModules/Admin/Extensions/BatchInstall.ascx", "~/images/icon_extensions_32px.gif", SecurityAccessLevel.Host, 0);
                AddModuleControl(ModuleDefID, "NewExtension", "New Extension Wizard", "DesktopModules/Admin/Extensions/ExtensionWizard.ascx", "~/images/icon_extensions_32px.gif", SecurityAccessLevel.Host, 0);
                AddModuleControl(ModuleDefID, "UsageDetails", "Usage Information", "DesktopModules/Admin/Extensions/UsageDetails.ascx", "~/images/icon_extensions_32px.gif", SecurityAccessLevel.Host, 0, "", true);
            }
            else
            {
                ModuleDefID = GetModuleDefinition("Extensions", "Extensions");
                RemoveModuleControl(ModuleDefID, "EditLanguage");
                RemoveModuleControl(ModuleDefID, "TimeZone");
                RemoveModuleControl(ModuleDefID, "Verify");
                RemoveModuleControl(ModuleDefID, "LanguageSettings");
                RemoveModuleControl(ModuleDefID, "EditResourceKey");
                RemoveModuleControl(ModuleDefID, "EditSkins");
                AddModuleControl(ModuleDefID, "UsageDetails", "Usage Information", "DesktopModules/Admin/Extensions/UsageDetails.ascx", "~/images/icon_extensions_32px.gif", SecurityAccessLevel.Host, 0, "", true);

                //Module was incorrectly assigned as "IsPremium=False"
                RemoveModuleFromPortals("Extensions");
            }

            //Remove Module Definitions Module from Host Page (if present)
            RemoveCoreModule("Module Definitions", "Host", "Module Definitions", false);

            //Remove old Module Definition Validator module
            DesktopModuleController.DeleteDesktopModule("Module Definition Validator");

            //Get Module Definitions
            TabInfo definitionsPage = objTabController.GetTabByName("Module Definitions", Null.NullInteger);

            //Add Module To Page if not present
            ModuleID = AddModuleToPage(definitionsPage, ModuleDefID, "Module Definitions", "~/images/icon_moduledefinitions_32px.gif");
            objModuleController.UpdateModuleSetting(ModuleID, "Extensions_Mode", "Module");

            //Add Extensions Host Page
            TabInfo extensionsPage = AddHostPage("Extensions", "Install, add, modify and delete extensions, such as modules, skins and language packs.", "~/images/icon_extensions_16px.gif", "~/images/icon_extensions_32px.gif", true);

            ModuleID = AddModuleToPage(extensionsPage, ModuleDefID, "Extensions", "~/images/icon_extensions_32px.gif");
            objModuleController.UpdateModuleSetting(ModuleID, "Extensions_Mode", "All");

            //Add Extensions Module to Admin Page for all Portals
            AddAdminPages("Extensions", "Install, add, modify and delete extensions, such as modules, skins and language packs.", "~/images/icon_extensions_16px.gif", "~/images/icon_extensions_32px.gif", true, ModuleDefID, "Extensions", "~/images/icon_extensions_32px.gif");

            //Remove Host Languages Page
            RemoveHostPage("Languages");

            //Remove Admin > Authentication Pages
            RemoveAdminPages("//Admin//Authentication");

            //Remove old Languages module
            DesktopModuleController.DeleteDesktopModule("Languages");

            //Add new Languages module
            ModuleDefID = AddModuleDefinition("Languages", "", "Languages", false, false);
            AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/Languages/languageeditor.ascx", "~/images/icon_language_32px.gif", SecurityAccessLevel.View, 0);
            AddModuleControl(ModuleDefID, "Edit", "Edit Language", "DesktopModules/Admin/Languages/EditLanguage.ascx", "~/images/icon_language_32px.gif", SecurityAccessLevel.Edit, 0);
            AddModuleControl(ModuleDefID, "EditResourceKey", "Full Language Editor", "DesktopModules/Admin/Languages/languageeditorext.ascx", "~/images/icon_language_32px.gif", SecurityAccessLevel.Edit, 0);
            AddModuleControl(ModuleDefID, "LanguageSettings", "Language Settings", "DesktopModules/Admin/Languages/LanguageSettings.ascx", "", SecurityAccessLevel.Edit, 0);
            AddModuleControl(ModuleDefID, "TimeZone", "TimeZone Editor", "DesktopModules/Admin/Languages/timezoneeditor.ascx", "~/images/icon_language_32px.gif", SecurityAccessLevel.Host, 0);
            AddModuleControl(ModuleDefID, "Verify", "Resource File Verifier", "DesktopModules/Admin/Languages/resourceverifier.ascx", "", SecurityAccessLevel.Host, 0);
            AddModuleControl(ModuleDefID, "PackageWriter", "Language Pack Writer", "DesktopModules/Admin/Languages/LanguagePackWriter.ascx", "", SecurityAccessLevel.Host, 0);

            //Add Module to Admin Page for all Portals
            AddAdminPages("Languages", "Manage Language Resources.", "~/images/icon_language_16px.gif", "~/images/icon_language_32px.gif", true, ModuleDefID, "Language Editor", "~/images/icon_language_32px.gif");

            //Remove Host Skins Page
            RemoveHostPage("Skins");

            //Remove old Skins module
            DesktopModuleController.DeleteDesktopModule("Skins");

            //Add new Skins module
            ModuleDefID = AddModuleDefinition("Skins", "", "Skins", false, false);
            AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/Skins/editskins.ascx", "~/images/icon_skins_32px.gif", SecurityAccessLevel.View, 0);

            //Add Module to Admin Page for all Portals
            AddAdminPages("Skins", "Manage Skin Resources.", "~/images/icon_skins_16px.gif", "~/images/icon_skins_32px.gif", true, ModuleDefID, "Skin Editor", "~/images/icon_skins_32px.gif");

            //Remove old Skin Designer module
            DesktopModuleController.DeleteDesktopModule("Skin Designer");
            DesktopModuleController.DeleteDesktopModule("SkinDesigner");

            //Add new Skin Designer module
            ModuleDefID = AddModuleDefinition("Skin Designer", "Allows you to modify skin attributes.", "Skin Designer", true, true);
            AddModuleControl(ModuleDefID, "", "", "DesktopModules/Admin/SkinDesigner/Attributes.ascx", "~/images/icon_skins_32px.gif", SecurityAccessLevel.Host, 0);

            //Add new Skin Designer to every Admin Skins Tab
            AddModuleToPages("//Admin//Skins", ModuleDefID, "Skin Designer", "~/images/icon_skins_32px.gif", true);

            //Remove Admin Whats New Page
            RemoveAdminPages("//Admin//WhatsNew");

            //WhatsNew needs to be set to IsPremium and removed from all portals
            RemoveModuleFromPortals("WhatsNew");

            //Create New WhatsNew Host Page (or get existing one)
            TabInfo newPage = AddHostPage("What's New", "Provides a summary of the major features for each release.", "~/images/icon_whatsnew_16px.gif", "~/images/icon_whatsnew_32px.gif", true);

            //Add WhatsNew Module To Page
            ModuleDefID = GetModuleDefinition("WhatsNew", "WhatsNew");
            AddModuleToPage(newPage, ModuleDefID, "What's New", "~/images/icon_whatsnew_32px.gif");

            //add console module
            ModuleDefID = AddModuleDefinition("Console", "Display children pages as icon links for navigation.", "Console", "DotNetNuke.Modules.Console.Components.ConsoleController", true, false, false);
            AddModuleControl(ModuleDefID, "", "Console", "DesktopModules/Admin/Console/ViewConsole.ascx", "", SecurityAccessLevel.Anonymous, 0);
            AddModuleControl(ModuleDefID, "Settings", "Console Settings", "DesktopModules/Admin/Console/Settings.ascx", "", SecurityAccessLevel.Admin, 0);

            //add console module to host page
            ModuleID = AddModuleToPage("//Host", Null.NullInteger, ModuleDefID, "Basic Features", "", true);
            int tabID = TabController.GetTabByTabPath(Null.NullInteger, "//Host");
            TabInfo tab = null;

            //add console settings for host page
            if ((tabID != Null.NullInteger))
            {
                tab = objTabController.GetTab(tabID, Null.NullInteger, true);
                if (((tab != null)))
                {
                    AddConsoleModuleSettings(tabID, ModuleID);
                }
            }

            //add module to all admin pages
            foreach (PortalInfo portal in objPortalController.GetPortals())
            {
                tabID = TabController.GetTabByTabPath(portal.PortalID, "//Admin");
                if ((tabID != Null.NullInteger))
                {
                    tab = objTabController.GetTab(tabID, portal.PortalID, true);
                    if (((tab != null)))
                    {
                        ModuleID = AddModuleToPage(tab, ModuleDefID, "Basic Features", "", true);
                        AddConsoleModuleSettings(tabID, ModuleID);
                    }
                }
            }

            //Add Google Analytics module
            ModuleDefID = AddModuleDefinition("Google Analytics", "Configure portal Google Analytics settings.", "GoogleAnalytics", false, false);
            AddModuleControl(ModuleDefID, "", "Google Analytics", "DesktopModules/Admin/Analytics/GoogleAnalyticsSettings.ascx", "", SecurityAccessLevel.Admin, 0);
            AddAdminPages("Google Analytics", "Configure portal Google Analytics settings.", "~/images/icon_analytics_16px.gif", "~/images/icon_analytics_32px.gif", true, ModuleDefID, "Google Analytics", "~/images/icon_analytics_32px.gif");
        }
 public static TabInfo DeserializeTab(XmlNode nodeTab, TabInfo objTab, Hashtable hTabs, int PortalId, bool IsAdminTemplate, PortalTemplateModuleAction mergeTabs, Hashtable hModules)
 {
     TabController objTabs = new TabController();
     string tabName = XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "name");
     if (!String.IsNullOrEmpty(tabName))
     {
         if (objTab == null)
         {
             objTab = new TabInfo();
             objTab.TabID = Null.NullInteger;
             objTab.ParentId = Null.NullInteger;
             objTab.TabName = tabName;
         }
         objTab.PortalID = PortalId;
         objTab.Title = XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "title");
         objTab.Description = XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "description");
         objTab.KeyWords = XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "keywords");
         objTab.IsVisible = XmlUtils.GetNodeValueBoolean(nodeTab, "visible", true);
         objTab.DisableLink = XmlUtils.GetNodeValueBoolean(nodeTab, "disabled");
         objTab.IconFile = Globals.ImportFile(PortalId, XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "iconfile"));
         objTab.IconFileLarge = Globals.ImportFile(PortalId, XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "iconfilelarge"));
         objTab.Url = XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "url");
         objTab.StartDate = XmlUtils.GetNodeValueDate(nodeTab, "startdate", Null.NullDate);
         objTab.EndDate = XmlUtils.GetNodeValueDate(nodeTab, "enddate", Null.NullDate);
         objTab.RefreshInterval = XmlUtils.GetNodeValueInt(nodeTab, "refreshinterval", Null.NullInteger);
         objTab.PageHeadText = XmlUtils.GetNodeValue(nodeTab, "pageheadtext", Null.NullString);
         objTab.IsSecure = XmlUtils.GetNodeValueBoolean(nodeTab, "issecure", false);
         objTab.SiteMapPriority = XmlUtils.GetNodeValueSingle(nodeTab, "sitemappriority", (float)0.5);
         objTab.TabPermissions.Clear();
         DeserializeTabPermissions(nodeTab.SelectNodes("tabpermissions/permission"), objTab, IsAdminTemplate);
         DeserializeTabSettings(nodeTab.SelectNodes("tabsettings/tabsetting"), objTab);
         if (!String.IsNullOrEmpty(XmlUtils.GetNodeValue(nodeTab, "skinsrc", "")))
         {
             objTab.SkinSrc = XmlUtils.GetNodeValue(nodeTab, "skinsrc", "");
         }
         if (!String.IsNullOrEmpty(XmlUtils.GetNodeValue(nodeTab, "containersrc", "")))
         {
             objTab.ContainerSrc = XmlUtils.GetNodeValue(nodeTab, "containersrc", "");
         }
         tabName = objTab.TabName;
         if (!String.IsNullOrEmpty(XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "parent")))
         {
             if (hTabs[XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "parent")] != null)
             {
                 objTab.ParentId = Convert.ToInt32(hTabs[XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "parent")]);
                 tabName = XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "parent") + "/" + objTab.TabName;
             }
             else
             {
                 TabInfo objParent = objTabs.GetTabByName(XmlUtils.GetNodeValue(nodeTab.CreateNavigator(), "parent"), PortalId);
                 if (objParent != null)
                 {
                     objTab.ParentId = objParent.TabID;
                     tabName = objParent.TabName + "/" + objTab.TabName;
                 }
                 else
                 {
                     objTab.ParentId = Null.NullInteger;
                     tabName = objTab.TabName;
                 }
             }
         }
         if (objTab.TabID == Null.NullInteger)
         {
             objTab.TabID = objTabs.AddTab(objTab);
         }
         else
         {
             objTabs.UpdateTab(objTab);
         }
         if (hTabs[tabName] == null)
         {
             hTabs.Add(tabName, objTab.TabID);
         }
     }
     if (nodeTab.SelectSingleNode("panes") != null)
     {
         DeserializePanes(nodeTab.SelectSingleNode("panes"), PortalId, objTab.TabID, mergeTabs, hModules);
     }
     nodeTab.AppendChild(XmlUtils.CreateElement(nodeTab.OwnerDocument, "tabid", objTab.TabID.ToString()));
     return objTab;
 }