private bool IsChildPortal(PortalSettings ps, HttpContext context) { var isChild = false; var arr = PortalAliasController.Instance.GetPortalAliasesByPortalId(ps.PortalId).ToList(); var serverPath = Globals.GetAbsoluteServerPath(context.Request); if (arr.Count > 0) { var portalAlias = (PortalAliasInfo)arr[0]; var portalName = Globals.GetPortalDomainName(ps.PortalAlias.HTTPAlias, Request, true); if (portalAlias.HTTPAlias.IndexOf("/") > -1) { portalName = PortalController.GetPortalFolder(portalAlias.HTTPAlias); } if (!string.IsNullOrEmpty(portalName) && Directory.Exists(serverPath + portalName)) { isChild = true; } } return(isChild); }
protected void DeleteAiasesGrid(object source, CommandEventArgs e) { //Get the index of the row to delete int index = Convert.ToInt32(e.CommandArgument); //Remove the alias from the aliases collection var portalAlias = Aliases[index]; PortalAliasController.Instance.DeletePortalAlias(portalAlias); //should remove the portal's folder if exist var portalFolder = PortalController.GetPortalFolder(portalAlias.HTTPAlias); var serverPath = Globals.GetAbsoluteServerPath(Request); if (!string.IsNullOrEmpty(portalFolder) && Directory.Exists(serverPath + portalFolder)) { PortalController.DeletePortalFolder(serverPath, portalFolder); } //Rebind the collection _Aliases = null; BindAliases(); }
private bool IsChildPortal(PortalSettings ps, HttpContext context) { bool isChild = false; string portalName = null; var aliasController = new PortalAliasController(); ArrayList arr = aliasController.GetPortalAliasArrayByPortalID(ps.PortalId); string serverPath = Globals.GetAbsoluteServerPath(context.Request); if (arr.Count > 0) { var portalAlias = (PortalAliasInfo)arr[0]; portalName = Globals.GetPortalDomainName(ps.PortalAlias.HTTPAlias, null, true); if (portalAlias.HTTPAlias.IndexOf("/") > -1) { portalName = PortalController.GetPortalFolder(portalAlias.HTTPAlias); } if (!string.IsNullOrEmpty(portalName) && Directory.Exists(serverPath + portalName)) { isChild = true; } } return(isChild); }
/// ----------------------------------------------------------------------------- /// <summary> /// DeleteAlias runs when a delete button is clicked /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 12/12/2008 Created /// </history> /// ----------------------------------------------------------------------------- private void DeleteAlias(object source, DataGridCommandEventArgs e) { var controller = new PortalAliasController(); //Get the index of the row to delete int index = e.Item.ItemIndex; //Remove the alias from the aliases collection var portalAlias = (PortalAliasInfo)Aliases[index]; controller.DeletePortalAlias(portalAlias.PortalAliasID); //should remove the portal's folder if exist var portalFolder = PortalController.GetPortalFolder(portalAlias.HTTPAlias); var serverPath = Globals.GetAbsoluteServerPath(Request); if (!string.IsNullOrEmpty(portalFolder) && Directory.Exists(serverPath + portalFolder)) { PortalController.DeletePortalFolder(serverPath, portalFolder); } //Rebind the collection _Aliases = null; BindAliases(); }
/// ----------------------------------------------------------------------------- /// <summary> /// cmdUpdate_Click runs when the Update button is clicked /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 5/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> /// ----------------------------------------------------------------------------- private void cmdUpdate_Click(Object sender, EventArgs e) { if (Page.IsValid) { PortalController.PortalTemplateInfo template = LoadPortalTemplateInfoForSelectedItem(); try { bool blnChild; string strPortalAlias; string strChildPath = string.Empty; var closePopUpStr = string.Empty; var objPortalController = new PortalController(); //check template validity var messages = new ArrayList(); string schemaFilename = Server.MapPath(string.Concat(AppRelativeTemplateSourceDirectory, "portal.template.xsd")); string xmlFilename = template.TemplateFilePath; var xval = new PortalTemplateValidator(); if (!xval.Validate(xmlFilename, schemaFilename)) { UI.Skins.Skin.AddModuleMessage(this, "", String.Format(Localization.GetString("InvalidTemplate", LocalResourceFile), Path.GetFileName(template.TemplateFilePath)), ModuleMessage.ModuleMessageType.RedError); messages.AddRange(xval.Errors); lstResults.Visible = true; lstResults.DataSource = messages; lstResults.DataBind(); validationPanel.Visible = true; return; } //Set Portal Name txtPortalAlias.Text = txtPortalAlias.Text.ToLowerInvariant(); txtPortalAlias.Text = txtPortalAlias.Text.Replace("http://", ""); //Validate Portal Name if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID)) { blnChild = true; strPortalAlias = txtPortalAlias.Text; } else { blnChild = (optType.SelectedValue == "C"); strPortalAlias = blnChild ? PortalController.GetPortalFolder(txtPortalAlias.Text) : txtPortalAlias.Text; } string message = String.Empty; ModuleMessage.ModuleMessageType messageType = ModuleMessage.ModuleMessageType.RedError; if (!PortalAliasController.ValidateAlias(strPortalAlias, blnChild)) { message = Localization.GetString("InvalidName", LocalResourceFile); } //check whether have conflict between tab path and portal alias. var checkTabPath = string.Format("//{0}", strPortalAlias); if (TabController.GetTabByTabPath(PortalSettings.PortalId, checkTabPath, string.Empty) != Null.NullInteger || TabController.GetTabByTabPath(Null.NullInteger, checkTabPath, string.Empty) != Null.NullInteger) { message = Localization.GetString("DuplicateWithTab", LocalResourceFile); } //Validate Password if (txtPassword.Text != txtConfirm.Text) { if (!String.IsNullOrEmpty(message)) { message += "<br/>"; } message += Localization.GetString("InvalidPassword", LocalResourceFile); } string strServerPath = Globals.GetAbsoluteServerPath(Request); //Set Portal Alias for Child Portals if (String.IsNullOrEmpty(message)) { if (blnChild) { strChildPath = strServerPath + strPortalAlias; if (Directory.Exists(strChildPath)) { message = Localization.GetString("ChildExists", LocalResourceFile); } else { if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID)) { strPortalAlias = Globals.GetDomainName(Request, true) + "/" + strPortalAlias; } else { strPortalAlias = txtPortalAlias.Text; } } } } //Get Home Directory string homeDir = txtHomeDirectory.Text != @"Portals/[PortalID]" ? txtHomeDirectory.Text : ""; //Validate Home Folder if (!string.IsNullOrEmpty(homeDir)) { if (string.IsNullOrEmpty(String.Format("{0}\\{1}\\", Globals.ApplicationMapPath, homeDir).Replace("/", "\\"))) { message = Localization.GetString("InvalidHomeFolder", LocalResourceFile); } if (homeDir.Contains("admin") || homeDir.Contains("DesktopModules") || homeDir.ToLowerInvariant() == "portals/") { message = Localization.GetString("InvalidHomeFolder", LocalResourceFile); } } //Validate Portal Alias if (!string.IsNullOrEmpty(strPortalAlias)) { PortalAliasInfo portalAlias = PortalAliasController.GetPortalAliasLookup(strPortalAlias.ToLower()); if (portalAlias != null) { message = Localization.GetString("DuplicatePortalAlias", LocalResourceFile); } } //Create Portal if (String.IsNullOrEmpty(message)) { //Attempt to create the portal UserInfo adminUser = new UserInfo(); int intPortalId; try { if (useCurrent.Checked) { adminUser = UserInfo; intPortalId = objPortalController.CreatePortal(txtPortalName.Text, adminUser.UserID, txtDescription.Text, txtKeyWords.Text, template, homeDir, strPortalAlias, strServerPath, strChildPath, blnChild); } else { adminUser = new UserInfo { FirstName = txtFirstName.Text, LastName = txtLastName.Text, Username = txtUsername.Text, DisplayName = txtFirstName.Text + " " + txtLastName.Text, Email = txtEmail.Text, IsSuperUser = false, Membership = { Approved = true, Password = txtPassword.Text, PasswordQuestion = txtQuestion.Text, PasswordAnswer = txtAnswer.Text }, Profile = { FirstName = txtFirstName.Text, LastName = txtLastName.Text } }; intPortalId = objPortalController.CreatePortal(txtPortalName.Text, adminUser, txtDescription.Text, txtKeyWords.Text, template, homeDir, strPortalAlias, strServerPath, strChildPath, blnChild); } } catch (Exception ex) { intPortalId = Null.NullInteger; message = ex.Message; } if (intPortalId != -1) { //Create a Portal Settings object for the new Portal PortalInfo objPortal = objPortalController.GetPortal(intPortalId); var newSettings = new PortalSettings { PortalAlias = new PortalAliasInfo { HTTPAlias = strPortalAlias }, PortalId = intPortalId, DefaultLanguage = objPortal.DefaultLanguage }; string webUrl = Globals.AddHTTP(strPortalAlias); try { if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID)) { message = Mail.SendMail(PortalSettings.Email, txtEmail.Text, PortalSettings.Email + ";" + Host.HostEmail, Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", adminUser), Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", adminUser), "", "", "", "", "", ""); } else { message = Mail.SendMail(Host.HostEmail, txtEmail.Text, Host.HostEmail, Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", adminUser), Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", adminUser), "", "", "", "", "", ""); } } catch (Exception exc) { Logger.Error(exc); closePopUpStr = (PortalSettings.EnablePopUps) ? "onclick=\"return " + UrlUtils.ClosePopUp(true, webUrl, true) + "\"" : ""; message = string.Format(Localization.GetString("UnknownSendMail.Error", LocalResourceFile), webUrl, closePopUpStr); } var objEventLog = new EventLogController(); objEventLog.AddLog(objPortalController.GetPortal(intPortalId), PortalSettings, UserId, "", EventLogController.EventLogType.PORTAL_CREATED); // mark default language as published if content localization is enabled bool ContentLocalizationEnabled = PortalController.GetPortalSettingAsBoolean("ContentLocalizationEnabled", PortalId, false); if (ContentLocalizationEnabled) { LocaleController lc = new LocaleController(); lc.PublishLanguage(intPortalId, objPortal.DefaultLanguage, true); } //Redirect to this new site if (message == Null.NullString) { webUrl = (PortalSettings.EnablePopUps) ? UrlUtils.ClosePopUp(true, webUrl, false) : webUrl; Response.Redirect(webUrl, true); } else { closePopUpStr = (PortalSettings.EnablePopUps) ? "onclick=\"return " + UrlUtils.ClosePopUp(true, webUrl, true) + "\"" : ""; message = string.Format(Localization.GetString("SendMail.Error", LocalResourceFile), message, webUrl, closePopUpStr); messageType = ModuleMessage.ModuleMessageType.YellowWarning; } } } UI.Skins.Skin.AddModuleMessage(this, "", message, messageType); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } } }
protected void SaveAlias(object source, CommandEventArgs e) { var controller = new PortalAliasController(); bool isChild = false; string childPath = string.Empty; string message = string.Empty; //Get the index of the row to save int index = dgPortalAlias.EditItemIndex; var portalAlias = (PortalAliasInfo)Aliases[index]; var ctlAlias = (TextBox)dgPortalAlias.Items[index].Cells[1].FindControl("txtHTTPAlias"); string strAlias = ctlAlias.Text.Trim(); if (string.IsNullOrEmpty(strAlias)) { message = Localization.GetString("InvalidAlias", LocalResourceFile); } else { if (strAlias.IndexOf("://") != -1) { strAlias = strAlias.Remove(0, strAlias.IndexOf("://") + 3); } if (strAlias.IndexOf("\\\\") != -1) { strAlias = strAlias.Remove(0, strAlias.IndexOf("\\\\") + 2); } isChild = !string.IsNullOrEmpty(PortalController.GetPortalFolder(strAlias)); //Validate Alias if (!PortalAliasController.ValidateAlias(strAlias, false)) { message = Localization.GetString("InvalidAlias", LocalResourceFile); } //Validate Child Folder Name if (isChild) { childPath = PortalController.GetPortalFolder(strAlias); if (!PortalAliasController.ValidateAlias(childPath, true)) { message = Localization.GetString("InvalidAlias", LocalResourceFile); } } } if (string.IsNullOrEmpty(message) && isChild) { //Attempt to create child folder string childPhysicalPath = Server.MapPath(childPath); if (Directory.Exists(childPhysicalPath)) { message = Localization.GetString("ChildExists", LocalResourceFile); } else { message = PortalController.CreateChildPortalFolder(childPhysicalPath); } } if (string.IsNullOrEmpty(message)) { string defaultAlias = PortalController.GetPortalSetting("DefaultPortalAlias", intPortalId, ""); var editDefaultAias = defaultAlias == portalAlias.HTTPAlias; portalAlias.HTTPAlias = strAlias; if (AddMode) { controller.AddPortalAlias(portalAlias); } else { controller.UpdatePortalAliasInfo(portalAlias); if (editDefaultAias) { PortalController.UpdatePortalSetting(intPortalId, "DefaultPortalAlias", portalAlias.HTTPAlias); } } //Reset Edit Index lblError.Visible = false; dgPortalAlias.EditItemIndex = -1; _Aliases = null; OnAliasChanged(); } else { lblError.Text = message; lblError.Visible = true; } BindAliases(); }