/// <inheritdoc /> public virtual string GetLogoutPageUrl() { string logoutRedirectUrl = this.ExternalLogoutUrl; if (string.IsNullOrEmpty(logoutRedirectUrl)) { if (this.LogoutPageId.HasValue) { logoutRedirectUrl = HyperLinkHelpers.GetFullPageUrl(this.LogoutPageId.Value); } else { logoutRedirectUrl = UrlPath.ResolveAbsoluteUrl(this.currentPageUrl, true); } } if (HttpContext.Current.Request.Url == null) { return(string.Empty); } string fullLogoutUrl = RouteHelper.ResolveUrl(ClaimsManager.GetLogoutUrl(logoutRedirectUrl), UrlResolveOptions.Rooted); // Workaround an issue when the application is hosted under an application path. if (SystemManager.CurrentHttpContext != null && SystemManager.CurrentHttpContext.Request.ApplicationPath != "/") { fullLogoutUrl = fullLogoutUrl.Replace("sts_signout=true&", ""); } return(fullLogoutUrl); }
/// <inheritDoc/> public virtual string GetLoginPageUrl() { var loginRedirectUrl = this.ExternalLoginUrl; if (string.IsNullOrEmpty(loginRedirectUrl)) { var claimsModule = SitefinityClaimsAuthenticationModule.Current; string pageUrl; if (this.AllowWindowsStsLogin) { pageUrl = claimsModule.GetIssuer(); } else if (this.LoginPageId.HasValue) { pageUrl = HyperLinkHelpers.GetFullPageUrl(this.LoginPageId.Value); } else { pageUrl = SitefinityContext.FrontendLoginUrl; } if (!pageUrl.IsNullOrEmpty()) { var currentUrl = HttpContext.Current.Request.RawUrl; var returnUrl = this.AppendUrlParameter(currentUrl, LoginStatusModel.HandleRejectedUser, "true"); loginRedirectUrl = "{0}?realm={1}&redirect_uri={2}&deflate=true".Arrange( pageUrl, claimsModule.GetRealm(), HttpUtility.UrlEncode(returnUrl)); } } return(loginRedirectUrl); }
/// <summary> /// Gets the detail page URL for blog item. /// </summary> /// <param name="item">The item.</param> /// <param name="detailsPageId">The details page identifier.</param> /// <param name="blogDetailLocationMode">The blog detail location mode.</param> /// <returns></returns> public static string GetDetailPageUrl(ItemViewModel item, Guid detailsPageId, BlogDetailLocationMode blogDetailLocationMode) { string url = null; if (blogDetailLocationMode == BlogDetailLocationMode.SelectedExistingPage) { url = HyperLinkHelpers.GetDetailPageUrl(item.DataItem, detailsPageId); } else if (blogDetailLocationMode == BlogDetailLocationMode.PerItem) { var blog = item.DataItem as Blog; if (blog != null) { var blogPageId = blog.DefaultPageId; if (blogPageId.HasValue && blogPageId.Value != Guid.Empty) { url = HyperLinkHelpers.GetDetailPageUrl(item.DataItem, blogPageId.Value); } } } else if (blogDetailLocationMode == BlogDetailLocationMode.SamePage) { url = DetailLocationHyperLinkHelper.ConstructSamePageUrl(item); } return(url); }
/// <inheritdoc /> public virtual string GetProfilePageUrl() { var profileRedirectUrl = this.ExternalProfileUrl; if (string.IsNullOrEmpty(profileRedirectUrl) && this.ProfilePageId.HasValue) { profileRedirectUrl = HyperLinkHelpers.GetFullPageUrl(this.ProfilePageId.Value); } return(profileRedirectUrl); }
/// <inheritdoc /> public virtual string GetRegistrationPageUrl() { var registrationRedirectUrl = this.ExternalRegistrationUrl; if (string.IsNullOrEmpty(registrationRedirectUrl) && this.RegistrationPageId.HasValue) { registrationRedirectUrl = HyperLinkHelpers.GetFullPageUrl(this.RegistrationPageId.Value); } return(registrationRedirectUrl); }
/// <inheritdoc /> public virtual bool AddSubscriber(SubscribeFormViewModel viewModel, out string error) { error = string.Empty; if (NewsletterValidator.IsValidEmail(viewModel.Email)) { var newslettersManager = NewslettersManager.GetManager(this.Provider); // check if subscriber exists var email = viewModel.Email.ToLower(); IQueryable <Subscriber> matchingSubscribers = newslettersManager.GetSubscribers().Where(s => s.Email == email); bool subscriberAlreadyInList = false; foreach (Subscriber s in matchingSubscribers) { if (s.Lists.Any(ml => ml.Id == this.SelectedMailingListId)) { subscriberAlreadyInList = true; break; } } if (subscriberAlreadyInList) { // If the email has already been subscribed, consider it as success. return(true); } else { Subscriber subscriber = matchingSubscribers.FirstOrDefault(); if (subscriber == null) { subscriber = newslettersManager.CreateSubscriber(true); subscriber.Email = viewModel.Email; subscriber.FirstName = viewModel.FirstName != null ? viewModel.FirstName : string.Empty; subscriber.LastName = viewModel.LastName != null ? viewModel.LastName : string.Empty; } // check if the mailing list exists if (newslettersManager.Subscribe(subscriber, this.SelectedMailingListId)) { if (this.SuccessfullySubmittedForm == SuccessfullySubmittedForm.OpenSpecificPage) { viewModel.RedirectPageUrl = HyperLinkHelpers.GetFullPageUrl(this.PageId); } newslettersManager.SaveChanges(); return(true); } } } error = Res.Get <SubscribeFormResources>().EmailAddressErrorMessageResourceName; return(false); }
/// <inheritDoc/> public virtual string GetPageUrl(Guid?pageId) { if (pageId.HasValue) { return(HyperLinkHelpers.GetFullPageUrl(pageId.Value)); } else { var currentNode = SiteMapBase.GetActualCurrentNode(); return(currentNode != null?HyperLinkHelpers.GetFullPageUrl(currentNode.Id) : null); } }
/// <inheritdoc /> public virtual string GetJobAlertPageUrl() { var jobAlertRedirectUrl = this.ExternalJobAlertUrl; if (string.IsNullOrEmpty(jobAlertRedirectUrl) && this.JobAlertPageId.HasValue) { if (string.IsNullOrEmpty(jobAlertRedirectUrl) && this.JobAlertPageId.HasValue) { jobAlertRedirectUrl = HyperLinkHelpers.GetFullPageUrl(this.JobAlertPageId.Value); } } return(jobAlertRedirectUrl); }
/// <summary> /// Gets the login redirect URL. /// </summary> /// <returns></returns> public virtual string GetLoginPageUrl() { string result; if (this.LoginPageId.HasValue) { result = HyperLinkHelpers.GetFullPageUrl(this.LoginPageId.Value); } else { result = SitefinityContext.FrontendLoginUrl; } return(result); }
/// <summary> /// Distinguish the currently opened content item and other content items on the same page that are in details mode. /// The current navigated URL is a canonical URL for an item. We take its meta properties. /// </summary> /// <param name="item">The item.</param> /// <returns></returns> internal virtual bool IsURLMatch(IDataItem item) { var locationsService = SystemManager.GetContentLocationService(); var locations = locationsService.GetItemLocations(item); var currentNode = (PageSiteNode)SystemManager.CurrentHttpContext.Items[SiteMapBase.CurrentNodeKey]; var itemUrl = HyperLinkHelpers.GetDetailPageUrl(item, currentNode.Id); // TODO: compare urls better var urlMatch = locations.Where(location => location.ItemAbsoluteUrl == itemUrl).ToList(); if (urlMatch.Count <= 0) { return(false); } return(true); }
/// <summary> /// Distinguish the currently opened content item and other content items on the same page that are in details mode. /// The current navigated URL is a canonical URL for an item. We take its meta properties. /// </summary> /// <param name="item">The item.</param> /// <returns></returns> internal virtual bool IsURLMatch(IDataItem item) { IManager manager = null; if (!ManagerBase.TryGetMappedManager(item.GetType(), string.Empty, out manager)) { return(true); } var locationsService = SystemManager.GetContentLocationService(); var locations = locationsService.GetItemLocations(item); var currentNode = (PageSiteNode)SystemManager.CurrentHttpContext.Items[SiteMapBase.CurrentNodeKey]; var itemUrl = HyperLinkHelpers.GetDetailPageUrl(item, currentNode.Id); // TODO: compare urls better return(locations.Any(location => location.ItemAbsoluteUrl == itemUrl)); }
/// <inheritDoc/> public virtual bool Unsubscribe(UnsubscribeFormViewModel viewModel, out string error) { error = string.Empty; var newslettersManager = NewslettersManager.GetManager(this.ProviderName); string email = viewModel.Email.ToLower(); IQueryable <Subscriber> subscribers = newslettersManager.GetSubscribers().Where(s => s.Email == email); if (subscribers.Count() == 0) { error = string.Format(Res.Get <UnsubscribeFormResources>().YouDontBelongToTheMailingList, email); return(false); } var hasUnsubscribedUser = false; foreach (Subscriber subscriber in subscribers) { if (subscriber != null) { var isUnsubscribed = newslettersManager.Unsubscribe(subscriber, this.ListId); hasUnsubscribedUser = hasUnsubscribedUser || isUnsubscribed; } } if (hasUnsubscribedUser) { newslettersManager.SaveChanges(); if (this.SuccessfullySubmittedForm == SuccessfullySubmittedForm.OpenSpecificPage) { viewModel.RedirectPageUrl = HyperLinkHelpers.GetFullPageUrl(this.PageId); } this.Message = string.Format(Res.Get <UnsubscribeFormResources>().UnsubscribedFromMailingListSuccessMessage, email); return(true); } else { error = string.Format(Res.Get <UnsubscribeFormResources>().YouDontBelongToTheMailingList, email); return(false); } }
/// <inheritDoc/> public virtual string GetLoginPageUrl() { var loginRedirectUrl = this.ExternalLoginUrl; if (string.IsNullOrEmpty(loginRedirectUrl)) { string pageUrl; if (this.LoginPageId.HasValue) { pageUrl = HyperLinkHelpers.GetFullPageUrl(this.LoginPageId.Value); } else { pageUrl = SitefinityContext.FrontendLoginUrl; } loginRedirectUrl = pageUrl; } return(loginRedirectUrl); }
/// <inheritdoc /> public virtual string GetLogoutPageUrl() { string logoutRedirectUrl = this.ExternalLogoutUrl; if (string.IsNullOrEmpty(logoutRedirectUrl)) { if (this.LogoutPageId.HasValue) { logoutRedirectUrl = HyperLinkHelpers.GetFullPageUrl(this.LogoutPageId.Value); } else { logoutRedirectUrl = HttpContext.Current.Request.UrlReferrer?.AbsoluteUri ?? UrlPath.ResolveAbsoluteUrl(this.currentPageUrl, true); } } if (HttpContext.Current.Request.Url == null) { return(string.Empty); } return(logoutRedirectUrl); }