public override void TestFixtureSetUp() { base.TestFixtureSetUp(); var tc = new TabController(); var tab = tc.GetTabByName(_aboutUsPageName, PortalId); _tabId = tab.TabID; //Add Portal Aliases var aliasController = new PortalAliasController(); TestUtil.ReadStream(String.Format("{0}", "Aliases"), (line, header) => { string[] fields = line.Split(','); var alias = aliasController.GetPortalAlias(fields[0], PortalId); if (alias == null) { alias = new PortalAliasInfo { HTTPAlias = fields[0], PortalID = PortalId }; TestablePortalAliasController.Instance.AddPortalAlias(alias); } }); TestUtil.ReadStream(String.Format("{0}", "Users"), (line, header) => { string[] fields = line.Split(','); TestUtil.AddUser(PortalId, fields[0].Trim(), fields[1].Trim(), fields[2].Trim()); }); }
/// <summary> /// cmdUpdate_Click runs when the Update button is clicked /// </summary> /// <history> /// [cnurse] 01/17/2005 documented /// </history> protected void cmdUpdate_Click(Object sender, EventArgs e) { try { string strAlias = txtAlias.Text; if (!String.IsNullOrEmpty(strAlias)) { if (strAlias.IndexOf("://") != -1) { strAlias = strAlias.Remove(0, strAlias.IndexOf("://") + 3); } if (strAlias.IndexOf("\\\\") != -1) { strAlias = strAlias.Remove(0, strAlias.IndexOf("\\\\") + 2); } PortalAliasController p = new PortalAliasController(); if (ViewState["PortalAliasID"] != null) { PortalAliasInfo objPortalAliasInfo = new PortalAliasInfo(); objPortalAliasInfo.PortalAliasID = Convert.ToInt32(ViewState["PortalAliasID"]); objPortalAliasInfo.PortalID = Convert.ToInt32(ViewState["PortalID"]); objPortalAliasInfo.HTTPAlias = strAlias; try { p.UpdatePortalAliasInfo(objPortalAliasInfo); } catch { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("DuplicateAlias", this.LocalResourceFile), ModuleMessageType.RedError); return; } } else { PortalAliasInfo objPortalAliasInfo; objPortalAliasInfo = p.GetPortalAlias(strAlias, Convert.ToInt32(ViewState["PortalAliasID"])); if (objPortalAliasInfo == null) { objPortalAliasInfo = new PortalAliasInfo(); objPortalAliasInfo.PortalID = Convert.ToInt32(ViewState["PortalID"]); objPortalAliasInfo.HTTPAlias = strAlias; p.AddPortalAlias(objPortalAliasInfo); } else { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("DuplicateAlias", this.LocalResourceFile), ModuleMessageType.RedError); return; } } UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("Success", this.LocalResourceFile), ModuleMessageType.GreenSuccess); Response.Redirect(Convert.ToString(ViewState["UrlReferrer"]), true); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
public override void TestFixtureTearDown() { base.TestFixtureTearDown(); var aliasController = new PortalAliasController(); TestUtil.ReadStream(String.Format("{0}", "Aliases"), (line, header) => { string[] fields = line.Split(','); var alias = aliasController.GetPortalAlias(fields[0], PortalId); TestablePortalAliasController.Instance.DeletePortalAlias(alias); }); TestUtil.ReadStream(String.Format("{0}", "Users"), (line, header) => { string[] fields = line.Split(','); TestUtil.DeleteUser(PortalId, fields[0]); }); }
protected string AddPortalAlias(string portalAlias, int portalID) { if (!String.IsNullOrEmpty(portalAlias)) { if (portalAlias.IndexOf("://") != -1) { portalAlias = portalAlias.Remove(0, portalAlias.IndexOf("://") + 3); } var objPortalAliasController = new PortalAliasController(); var objPortalAlias = objPortalAliasController.GetPortalAlias(portalAlias, portalID); if (objPortalAlias == null) { objPortalAlias = new PortalAliasInfo { PortalID = portalID, HTTPAlias = portalAlias }; objPortalAliasController.AddPortalAlias(objPortalAlias); } } return(portalAlias); }
/// <summary> /// Given a rule, returns a redirect location /// </summary> /// <param name="redirectInfo"></param> /// <param name="redirectUrl"></param> /// <returns></returns> internal static string RedirectLocation(UrlRedirectProvider provider, RedirectInfo redirectInfo, string redirectUrl, string scheme, NameValueCollection queryString, ref List <string> messages) { string destinationUrl = ""; switch (redirectInfo.DestType.ToLower()) { case "tab": string path = redirectInfo.DestUrl; if (redirectInfo.DestTabId > -1) { //construct the portal settings required for the destination PortalAliasController pac = new PortalAliasController(); PortalAliasInfo pa = null; if (string.IsNullOrEmpty(redirectInfo.HttpAlias)) { var aliases = pac.GetPortalAliasArrayByPortalID(redirectInfo.PortalId); foreach (PortalAliasInfo alias in aliases) { if (alias.IsPrimary) { pa = alias; break; } } //safety check for failed alias if (pa == null) { throw new NullReferenceException( "Either Redirect HttpAlias must be specified for DestType of 'Tab', or this portal must have a primary alias. Redirect Id : " + redirectInfo.RedirectId.ToString()); } } else { //get this specific alias pa = pac.GetPortalAlias(redirectInfo.HttpAlias, redirectInfo.PortalId); } //create a new portal settings object with this alias PortalSettings ps = new PortalSettings(redirectInfo.DestTabId, pa); //build the redirect path if (string.IsNullOrEmpty(path) == false) { //add a url path onto the url created for the tab string qs; SplitPathAndQuerystring(path, out path, out qs); path = provider.EnsureNotLeadingChar("/", path); //now call down to the navigate url destinationUrl = DotNetNuke.Common.Globals.NavigateURL(redirectInfo.DestTabId, ps, "", path); if (queryString != null && queryString.Count > 0) { destinationUrl = AddQueryString(destinationUrl, queryString); } //check for querystring preservation if (redirectInfo.KeepQueryString && qs != null) { //put the querystring back on, if it existed destinationUrl = AddQueryString(destinationUrl, qs); messages.Add("URP: Redirecting " + redirectUrl + " to " + destinationUrl + " by tab + path + qs. RuleId: " + redirectInfo.RedirectId.ToString()); } else { messages.Add("URP: Redirecting " + redirectUrl + " to " + destinationUrl + " by tab + path. RuleId: " + redirectInfo.RedirectId.ToString()); } } else { //no path -just the tab destinationUrl = DotNetNuke.Common.Globals.NavigateURL(redirectInfo.DestTabId, ps, ""); if (redirectInfo.KeepQueryString && queryString != null && queryString.Count > 0) { destinationUrl = AddQueryString(destinationUrl, queryString); messages.Add("URP: Redirecting " + redirectUrl + " to " + destinationUrl + " by tab + qs. RuleId: " + redirectInfo.RedirectId.ToString()); } else { messages.Add("URP: Redirecting " + redirectUrl + " to " + destinationUrl + " by tab. RuleId: " + redirectInfo.RedirectId.ToString()); } } } break; case "url": destinationUrl = redirectInfo.DestUrl; if (Regex.IsMatch(destinationUrl, @"^https?://", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) == false) { //no scheme, add on supplied scheme destinationUrl = scheme + Uri.SchemeDelimiter + destinationUrl; } //keep query string from redirect destination if (redirectInfo.KeepQueryString) { destinationUrl = AddQueryString(destinationUrl, queryString); messages.Add("URP: Redirecting " + redirectUrl + " to " + destinationUrl + " by url + qs. RuleId: " + redirectInfo.RedirectId.ToString()); } else { messages.Add("URP: Redirecting " + redirectUrl + " to " + destinationUrl + " by url. RuleId: " + redirectInfo.RedirectId.ToString()); } try { Uri redirectUri = new Uri(destinationUrl); } catch (Exception invalidEx) { messages.Add("Invalid redirect URL '" + redirectUrl + "'. Message: " + invalidEx.Message); throw; } break; } return(destinationUrl); }