/// ----------------------------------------------------------------------------- /// <summary> /// AddPortal manages the Installation of a new DotNetNuke Portal /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 11/06/2004 created /// </history> /// ----------------------------------------------------------------------------- public static int AddPortal(XmlNode node, bool status, int indent) { try { int intPortalId = 0; string strHostPath = Common.Globals.HostMapPath; string strChildPath = ""; string strDomain = ""; if ((HttpContext.Current != null)) { strDomain = Globals.GetDomainName(HttpContext.Current.Request, true).ToLowerInvariant().Replace("/install", ""); } string strPortalName = XmlUtils.GetNodeValue(node.CreateNavigator(), "portalname"); if (status) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Portal: " + strPortalName + "<br>"); } PortalController objPortalController = new PortalController(); XmlNode adminNode = node.SelectSingleNode("administrator"); string strFirstName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "firstname"); string strLastName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "lastname"); string strUserName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "username"); string strPassword = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "password"); string strEmail = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "email"); string strDescription = XmlUtils.GetNodeValue(node.CreateNavigator(), "description"); string strKeyWords = XmlUtils.GetNodeValue(node.CreateNavigator(), "keywords"); string strTemplate = XmlUtils.GetNodeValue(node.CreateNavigator(), "templatefile"); string strServerPath = Globals.ApplicationMapPath + "\\"; bool isChild = bool.Parse(XmlUtils.GetNodeValue(node.CreateNavigator(), "ischild")); string strHomeDirectory = XmlUtils.GetNodeValue(node.CreateNavigator(), "homedirectory"); //Get the Portal Alias XmlNodeList portalAliases = node.SelectNodes("portalaliases/portalalias"); string strPortalAlias = strDomain; if (portalAliases.Count > 0) { if (!string.IsNullOrEmpty(portalAliases[0].InnerText)) { strPortalAlias = portalAliases[0].InnerText; } } //Create default email if (string.IsNullOrEmpty(strEmail)) { strEmail = "admin@" + strDomain.Replace("www.", ""); //Remove any domain subfolder information ( if it exists ) if (strEmail.IndexOf("/") != -1) { strEmail = strEmail.Substring(0, strEmail.IndexOf("/")); } } if (isChild) { strChildPath = strPortalAlias.Substring(strPortalAlias.LastIndexOf("/") + 1); } //Create Portal intPortalId = objPortalController.CreatePortal(strPortalName, strFirstName, strLastName, strUserName, strPassword, strEmail, strDescription, strKeyWords, strHostPath, strTemplate, strHomeDirectory, strPortalAlias, strServerPath, strServerPath + strChildPath, isChild); if (intPortalId > -1) { //Add Extra Aliases foreach (XmlNode portalAlias in portalAliases) { if (!string.IsNullOrEmpty(portalAlias.InnerText)) { if (status) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Portal Alias: " + portalAlias.InnerText + "<br>"); } objPortalController.AddPortalAlias(intPortalId, portalAlias.InnerText); } } //Force Administrator to Update Password on first log in PortalInfo objPortal = objPortalController.GetPortal(intPortalId); UserInfo objAdminUser = UserController.GetUserById(intPortalId, objPortal.AdministratorId); objAdminUser.Membership.UpdatePassword = true; UserController.UpdateUser(intPortalId, objAdminUser); } return intPortalId; } catch (Exception ex) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "<font color='red'>Error: " + ex.Message + "</font><br>"); // failure return -1; } }