/// <summary> /// people can subscribe to the newsletters without registering on the site. This method is used to attach those existing subscriptions to the user upon registration /// </summary> /// <param name="siteUser"></param> public static void ClaimExistingSubscriptions(SiteUser siteUser) { SubscriberRepository subscriptions = new SubscriberRepository(); List <LetterSubscriber> userSubscriptions = subscriptions.GetListByEmail(siteUser.SiteGuid, siteUser.Email); foreach (LetterSubscriber s in userSubscriptions) { if (s.UserGuid != siteUser.UserGuid) { s.UserGuid = siteUser.UserGuid; subscriptions.Save(s); } if (!s.IsVerified) { subscriptions.Verify(s.SubscribeGuid, true, Guid.Empty); LetterInfo.UpdateSubscriberCount(s.LetterInfoGuid); } } List <LetterSubscriber> memberSubscriptions = subscriptions.GetListByUser(siteUser.SiteGuid, siteUser.UserGuid); RemoveDuplicates(memberSubscriptions); // commented out 2012-11-16 since we now give the user a chance to opt in the registration // then we should not force him in if he chose not to opt in //if (memberSubscriptions.Count == 0) //{ // string ipAddress = SiteUtils.GetIP4Address(); // //user has no previous subscriptions and just registered // // lets give him the site subscriptions that are configured for opting in new users by default // List<LetterInfo> allNewsletters = LetterInfo.GetAll(siteUser.SiteGuid); // foreach (LetterInfo l in allNewsletters) // { // if ((l.ProfileOptIn) && (l.AvailableToRoles.Contains("All Users;"))) // { // LetterSubscriber s = new LetterSubscriber(); // s.SiteGuid = siteUser.SiteGuid; // s.LetterInfoGuid = l.LetterInfoGuid; // s.UserGuid = siteUser.UserGuid; // s.EmailAddress = siteUser.Email; // s.IsVerified = true; // s.UseHtml = true; // s.IpAddress = ipAddress; // subscriptions.Save(s); // } // } //} }
/// <summary> /// people can subscribe to the newsletters without registering on the site. This method is used to attach those existing subscriptions to the user upon registration /// </summary> /// <param name="siteUser"></param> public static void ClaimExistingSubscriptions(SiteUser siteUser) { SubscriberRepository subscriptions = new SubscriberRepository(); List <LetterSubscriber> userSubscriptions = subscriptions.GetListByEmail(siteUser.SiteGuid, siteUser.Email); foreach (LetterSubscriber s in userSubscriptions) { if (s.UserGuid != siteUser.UserGuid) { s.UserGuid = siteUser.UserGuid; subscriptions.Save(s); } if (!s.IsVerified) { subscriptions.Verify(s.SubscribeGuid, true, Guid.Empty); LetterInfo.UpdateSubscriberCount(s.LetterInfoGuid); } } RemoveDuplicates(userSubscriptions); if (userSubscriptions.Count == 0) { string ipAddress = SiteUtils.GetIP4Address(); //user has no previous subscriptions and just registered // lets give him the site subscriptions that are configured for opting in new users by default List <LetterInfo> allNewsletters = LetterInfo.GetAll(siteUser.SiteGuid); foreach (LetterInfo l in allNewsletters) { if ((l.ProfileOptIn) && (l.AvailableToRoles.Contains("All Users;"))) { LetterSubscriber s = new LetterSubscriber(); s.SiteGuid = siteUser.SiteGuid; s.LetterInfoGuid = l.LetterInfoGuid; s.UserGuid = siteUser.UserGuid; s.EmailAddress = siteUser.Email; s.IsVerified = true; s.UseHtml = true; s.IpAddress = ipAddress; subscriptions.Save(s); } } } }