Esempio n. 1
0
        public static string GetPortalAliasByPortal(int PortalId, string PortalAlias)
        {
            string retValue = "";
            PortalAliasCollection objPortalAliasCollection = PortalAliasController.GetPortalAliasLookup();
            string          strHTTPAlias;
            bool            bFound             = false;
            PortalAliasInfo objPortalAliasInfo = objPortalAliasCollection[PortalAlias.ToLower()];

            if (objPortalAliasInfo != null)
            {
                if (objPortalAliasInfo.PortalID == PortalId)
                {
                    retValue = objPortalAliasInfo.HTTPAlias;
                    bFound   = true;
                }
            }
            if (!bFound)
            {
                foreach (string key in objPortalAliasCollection.Keys)
                {
                    objPortalAliasInfo = objPortalAliasCollection[key];
                    strHTTPAlias       = objPortalAliasInfo.HTTPAlias.ToLower();
                    if (strHTTPAlias.StartsWith(PortalAlias.ToLower()) == true && objPortalAliasInfo.PortalID == PortalId)
                    {
                        retValue = objPortalAliasInfo.HTTPAlias;
                        break;
                    }
                    if (strHTTPAlias.StartsWith("www."))
                    {
                        strHTTPAlias = strHTTPAlias.Replace("www.", "");
                    }
                    else
                    {
                        strHTTPAlias = string.Concat("www.", strHTTPAlias);
                    }
                    if (strHTTPAlias.StartsWith(PortalAlias.ToLower()) == true && objPortalAliasInfo.PortalID == PortalId)
                    {
                        retValue = objPortalAliasInfo.HTTPAlias;
                        break;
                    }
                }
            }
            return(retValue);
        }
Esempio n. 2
0
        /// -----------------------------------------------------------------------------
        /// <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 bool IsChildPortal(PortalInfo portal, string serverPath)
 {
     bool isChild = Null.NullBoolean;
     string portalName;
     PortalAliasController aliasController = new PortalAliasController();
     ArrayList arr = aliasController.GetPortalAliasArrayByPortalID(portal.PortalID);
     if (arr.Count > 0)
     {
         PortalAliasInfo portalAlias = (PortalAliasInfo)arr[0];
         portalName = Globals.GetPortalDomainName(portalAlias.HTTPAlias, null, true);
         if (portalAlias.HTTPAlias.IndexOf("/") > -1)
         {
             portalName = portalAlias.HTTPAlias.Substring(portalAlias.HTTPAlias.LastIndexOf("/") + 1);
         }
         if (!String.IsNullOrEmpty(portalName) && System.IO.Directory.Exists(serverPath + portalName))
         {
             isChild = true;
         }
     }
     return isChild;
 }
 public static string DeletePortal(PortalInfo portal, string serverPath)
 {
     string strPortalName;
     string strMessage = string.Empty;
     int portalCount = DataProvider.Instance().GetPortalCount();
     if (portalCount > 1)
     {
         if (portal != null)
         {
             Globals.DeleteFilesRecursive(serverPath, ".Portal-" + portal.PortalID.ToString() + ".resx");
             PortalAliasController objPortalAliasController = new PortalAliasController();
             ArrayList arr = objPortalAliasController.GetPortalAliasArrayByPortalID(portal.PortalID);
             if (arr.Count > 0)
             {
                 PortalAliasInfo objPortalAliasInfo = (PortalAliasInfo)arr[0];
                 strPortalName = Globals.GetPortalDomainName(objPortalAliasInfo.HTTPAlias, null, true);
                 if (objPortalAliasInfo.HTTPAlias.IndexOf("/") > -1)
                 {
                     strPortalName = objPortalAliasInfo.HTTPAlias.Substring(objPortalAliasInfo.HTTPAlias.LastIndexOf("/") + 1);
                 }
                 if (!String.IsNullOrEmpty(strPortalName) && System.IO.Directory.Exists(serverPath + strPortalName))
                 {
                     Globals.DeleteFolderRecursive(serverPath + strPortalName);
                 }
             }
             Globals.DeleteFolderRecursive(serverPath + "Portals\\" + portal.PortalID.ToString());
             if (!string.IsNullOrEmpty(portal.HomeDirectory))
             {
                 string HomeDirectory = portal.HomeDirectoryMapPath;
                 if (System.IO.Directory.Exists(HomeDirectory))
                 {
                     Globals.DeleteFolderRecursive(HomeDirectory);
                 }
             }
             PortalController objPortalController = new PortalController();
             objPortalController.DeletePortalInfo(portal.PortalID);
         }
     }
     else
     {
         strMessage = Localization.GetString("LastPortal");
     }
     return strMessage;
 }
 public void AddPortalAlias(int PortalId, string PortalAlias)
 {
     PortalAliasController objPortalAliasController = new PortalAliasController();
     PortalAliasInfo objPortalAliasInfo = objPortalAliasController.GetPortalAlias(PortalAlias, PortalId);
     if (objPortalAliasInfo == null)
     {
         objPortalAliasInfo = new PortalAliasInfo();
         objPortalAliasInfo.PortalID = PortalId;
         objPortalAliasInfo.HTTPAlias = PortalAlias;
         objPortalAliasController.AddPortalAlias(objPortalAliasInfo);
     }
 }