/// <summary> /// Subscriber control items changed event. /// </summary> protected void SubscriberSelector_OnItemsSelected(object sender, EventArgs e) { // Check permissions CheckAuthorization(); int subscriberID = 0; string[] newItems = null; Subscriber sb = null; // Get new items from selector string newValues = ValidationHelper.GetString(selectSubscriber.Value, null); newItems = newValues.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Add all new items to site foreach (string item in newItems) { subscriberID = ValidationHelper.GetInteger(item, 0); // Get subscriber sb = SubscriberProvider.GetSubscriber(subscriberID); // If subscriber exists and is not subscribed, subscribe him if ((sb != null) && (!SubscriberProvider.IsSubscribed(sb.SubscriberID, newsletterId))) { try { SubscriberProvider.Subscribe(sb.SubscriberID, newsletterId, DateTime.Now, chkSendConfirmation.Checked, chkRequireOptIn.Checked); } catch { } } } } selectSubscriber.Value = null; UniGridSubscribers.ReloadData(); pnlUpdate.Update(); }
private void usNewsletters_OnSelectionChanged(object sender, EventArgs e) { if (RaiseOnCheckPermissions("ManageSubscribers", this)) { if (this.StopProcessing) { return; } } // Get specified user if used instead of current user UserInfo ui = null; if (this.UserID > 0) { ui = UserInfoProvider.GetUserInfo(this.UserID); } else { ui = CMSContext.CurrentUser; } // Get specified site ID instead of current site ID int siteId = 0; if (this.SiteID > 0) { siteId = this.SiteID; } else { siteId = CMSContext.CurrentSiteID; } if ((sb == null) && (ui != null)) { // Create new subsciber (bind to existing user account) if ((!ui.IsPublic()) && (ValidationHelper.IsEmail(ui.Email) || ValidationHelper.IsEmail(ui.UserName))) { sb = new Subscriber(); if (ui != null) { if (!string.IsNullOrEmpty(ui.FirstName) && !string.IsNullOrEmpty(ui.LastName)) { sb.SubscriberFirstName = ui.FirstName; sb.SubscriberLastName = ui.LastName; } else { sb.SubscriberFirstName = ui.FullName; } // Full name consists of "user " and user full name sb.SubscriberFullName = "User '" + ui.FullName + "'"; } sb.SubscriberSiteID = siteId; sb.SubscriberType = SiteObjectType.USER; sb.SubscriberRelatedID = ui.UserID; // Save subscriber to DB SubscriberProvider.SetSubscriber(sb); } } if (sb == null) { return; } // Remove old items int newsletterId = 0; string newValues = ValidationHelper.GetString(usNewsletters.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { foreach (string item in newItems) { newsletterId = ValidationHelper.GetInteger(item, 0); // If subscriber is subscribed, unsubscribe him if (SubscriberProvider.IsSubscribed(sb.SubscriberID, newsletterId)) { SubscriberProvider.Unsubscribe(sb.SubscriberID, newsletterId, SendConfirmationEmail); // Log activity LogActivity(ui, newsletterId, false, siteId); } } } } // Add new items items = DataHelper.GetNewItemsInList(currentValues, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { foreach (string item in newItems) { newsletterId = ValidationHelper.GetInteger(item, 0); // If subscriber is not subscribed, subscribe him if (!SubscriberProvider.IsSubscribed(sb.SubscriberID, newsletterId)) { try { SubscriberProvider.Subscribe(sb.SubscriberID, newsletterId, DateTime.Now, SendConfirmationEmail); // Log activity LogActivity(ui, newsletterId, true, siteId); } catch { } } } } } // Display information about successful (un)subscription this.lblInfoMsg.Visible = true; }
private void usNewsletters_OnSelectionChanged(object sender, EventArgs e) { // Check 'EcommerceModify' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Ecommerce", "EcommerceModify")) { // Check 'ModifyCustomers' permission if don't have general ecommerce modify permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Ecommerce", "ModifyCustomers")) { CMSPage.RedirectToCMSDeskAccessDenied("CMS.Ecommerce", "EcommerceModify OR ModifyCustomers"); } } // Check if a customer has a valid email if ((email != null) && (email.Trim() != string.Empty) && (ValidationHelper.IsEmail(email))) { // Check whether subcriber already exist Subscriber sb = SubscriberProvider.GetSubscriber(email, siteId); if (sb == null) { // Create new subscriber sb = new Subscriber(); sb.SubscriberEmail = email; sb.SubscriberFirstName = firstName; sb.SubscriberLastName = lastName; sb.SubscriberFullName = (firstName + " " + lastName).Trim(); sb.SubscriberSiteID = siteId; sb.SubscriberGUID = Guid.NewGuid(); SubscriberProvider.SetSubscriber(sb); } // Remove old items string newValues = ValidationHelper.GetString(usNewsletters.Value, null); string items = DataHelper.GetNewItemsInList(newValues, currentValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { foreach (string item in newItems) { int newsletterId = ValidationHelper.GetInteger(item, 0); // If subscriber is subscribed, unsubscribe him if (SubscriberProvider.IsSubscribed(sb.SubscriberID, newsletterId)) { SubscriberProvider.Unsubscribe(sb.SubscriberID, newsletterId); } } } } // Add new items items = DataHelper.GetNewItemsInList(currentValues, newValues); if (!String.IsNullOrEmpty(items)) { string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { foreach (string item in newItems) { int newsletterId = ValidationHelper.GetInteger(item, 0); // If subscriber is not subscribed, subscribe him if (!SubscriberProvider.IsSubscribed(sb.SubscriberID, newsletterId)) { SubscriberProvider.Subscribe(sb.SubscriberID, newsletterId, DateTime.Now); } } } } // Display information about successful (un)subscription lblInfo.Visible = true; lblInfo.Text = GetString("General.ChangesSaved"); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { int siteId = 0; // Get current id if (CMSContext.CurrentSite != null) { siteId = CMSContext.CurrentSiteID; } // Get subscriber and newsletter guid from query string Guid subscriberGuid = QueryHelper.GetGuid("subscriberguid", Guid.Empty); Guid newsletterGuid = QueryHelper.GetGuid("newsletterguid", Guid.Empty); string subscriptionHash = QueryHelper.GetString("subscriptionhash", string.Empty); int issueId = QueryHelper.GetInteger("issueid", 0); Guid issueGuid = QueryHelper.GetGuid("issueguid", Guid.Empty); int contactId = QueryHelper.GetInteger("contactid", 0); string requestTime = QueryHelper.GetString("datetime", string.Empty); DateTime datetime = DateTimeHelper.ZERO_TIME; // Get date and time if (!string.IsNullOrEmpty(requestTime)) { try { datetime = DateTime.ParseExact(requestTime, SecurityHelper.EMAIL_CONFIRMATION_DATETIME_FORMAT, null); } catch { lblError.Visible = true; lblError.Text = GetString("newsletter.unsubscribefailed"); return; } } // Check whether both guid exists if ((subscriberGuid != Guid.Empty) && (newsletterGuid != Guid.Empty)) { Subscriber subscriber = SubscriberProvider.GetSubscriber(subscriberGuid, siteId); if (subscriber == null) { lblError.Visible = true; lblError.Text = GetString("Unsubscribe.SubscriberDoesNotExist"); return; } // Show error message if subscriber type is 'Role' if (!string.IsNullOrEmpty(subscriber.SubscriberType) && subscriber.SubscriberType.Equals(SiteObjectType.ROLE, StringComparison.InvariantCultureIgnoreCase)) { lblError.Visible = true; lblError.Text = GetString("Unsubscriber.CannotUnsubscribeRole"); return; } Newsletter newsletter = NewsletterProvider.GetNewsletter(newsletterGuid, siteId); if (newsletter == null) { lblError.Visible = true; lblError.Text = GetString("Unsubscribe.NewsletterDoesNotExist"); return; } // Check whether subscription is valid if (SubscriberProvider.IsSubscribed(subscriber.SubscriberID, newsletter.NewsletterID)) { bool isSubscribed = true; if (string.IsNullOrEmpty(subscriber.SubscriberType) || !subscriber.SubscriberType.Equals(PredefinedObjectType.CONTACTGROUP, StringComparison.InvariantCultureIgnoreCase)) { // Unsubscribe action SubscriberProvider.Unsubscribe(subscriber.SubscriberID, newsletter.NewsletterID, SendConfirmationEmail); } else { // Check if the contact group member has unsubscription activity for the specified newsletter isSubscribed = (contactId > 0) && !ModuleCommands.OnlineMarketingIsContactUnsubscribed(contactId, newsletter.NewsletterID, siteId); } if (isSubscribed) { // Log newsletter unsubscription activity LogActivity(subscriber, subscriber.SubscriberID, newsletter.NewsletterID, subscriber.SubscriberSiteID, issueId, issueGuid, contactId); // Display confirmation DisplayConfirmation(); } else { // Contact group member is already unsubscribed lblError.Visible = true; lblError.Text = GetString("Unsubscribe.NotSubscribed"); } } else { lblError.Visible = true; lblError.Text = GetString("Unsubscribe.NotSubscribed"); } } // Check if subscriptionGUID is supplied else if (!string.IsNullOrEmpty(subscriptionHash)) { // Check if given subscription exists SubscriberNewsletterInfo sni = SubscriberNewsletterInfoProvider.GetSubscriberNewsletterInfo(subscriptionHash); if (sni != null) { SubscriberProvider.ApprovalResult result = SubscriberProvider.Unsubscribe(subscriptionHash, true, CMSContext.CurrentSiteName, datetime); switch (result) { // Approving subscription was successful case SubscriberProvider.ApprovalResult.Success: bool isSubscribed = true; // Get subscriber Subscriber subscriber = SubscriberProvider.GetSubscriber(sni.SubscriberID); if ((subscriber != null) && !string.IsNullOrEmpty(subscriber.SubscriberType) && subscriber.SubscriberType.Equals(PredefinedObjectType.CONTACTGROUP, StringComparison.InvariantCultureIgnoreCase)) { // Check if the contact group member has unsubscription activity for the specified newsletter isSubscribed = (contactId > 0) && !ModuleCommands.OnlineMarketingIsContactUnsubscribed(contactId, sni.NewsletterID, siteId); } if (isSubscribed) { // Log newsletter unsubscription activity LogActivity(subscriber, subscriber.SubscriberID, sni.NewsletterID, siteId, issueId, issueGuid, contactId); // Display confirmation DisplayConfirmation(); } else { // Contact group member is already unsubscribed lblError.Visible = true; lblError.Text = GetString("Unsubscribe.NotSubscribed"); } break; // Subscription was already approved case SubscriberProvider.ApprovalResult.Failed: lblError.Visible = true; lblError.Text = GetString("newsletter.unsubscribefailed"); break; case SubscriberProvider.ApprovalResult.TimeExceeded: lblError.Visible = true; lblError.Text = GetString("newsletter.approval_timeexceeded"); break; // Subscription not found default: case SubscriberProvider.ApprovalResult.NotFound: lblError.Visible = true; lblError.Text = GetString("Unsubscribe.NotSubscribed"); break; } } else { lblError.Visible = true; lblError.Text = GetString("Unsubscribe.NotSubscribed"); } } else { Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { // Get data from query string Guid subscriberGuid = QueryHelper.GetGuid("subscriberguid", Guid.Empty); Guid newsletterGuid = QueryHelper.GetGuid("newsletterguid", Guid.Empty); string subscriptionHash = QueryHelper.GetString("subscriptionhash", string.Empty); Guid issueGuid = QueryHelper.GetGuid("issueGuid", Guid.Empty); int issueID = QueryHelper.GetInteger("issueid", 0); int contactId = QueryHelper.GetInteger("contactid", 0); bool unsubscribed = false; string requestTime = QueryHelper.GetString("datetime", string.Empty); DateTime datetime = DateTimeHelper.ZERO_TIME; // Get date and time if (!string.IsNullOrEmpty(requestTime)) { try { datetime = DateTime.ParseExact(requestTime, SecurityHelper.EMAIL_CONFIRMATION_DATETIME_FORMAT, null); } catch { ShowError(GetString("newsletter.unsubscribefailed")); return; } } // Get site ID int siteId = 0; if (CMSContext.CurrentSite != null) { siteId = CMSContext.CurrentSiteID; } if ((subscriberGuid != Guid.Empty) && (newsletterGuid != Guid.Empty) && (siteId != 0)) { Subscriber subscriber = SubscriberProvider.GetSubscriber(subscriberGuid, siteId); if (subscriber == null) { ShowError(GetString("Unsubscribe.SubscriberDoesNotExist")); return; } // Show error message if subscriber type is 'Role' if (!string.IsNullOrEmpty(subscriber.SubscriberType) && subscriber.SubscriberType.Equals(SiteObjectType.ROLE, StringComparison.InvariantCultureIgnoreCase)) { ShowError(GetString("Unsubscribe.CannotUnsubscribeRole")); return; } Newsletter newsletter = NewsletterProvider.GetNewsletter(newsletterGuid, siteId); if (newsletter == null) { ShowError(GetString("Unsubscribe.NewsletterDoesNotExist")); return; } // Check if subscriber with given GUID is subscribed to specified newsletter if (SubscriberProvider.IsSubscribed(subscriber.SubscriberID, newsletter.NewsletterID)) { bool isSubscribed = true; if (string.IsNullOrEmpty(subscriber.SubscriberType) || !subscriber.SubscriberType.Equals(PredefinedObjectType.CONTACTGROUP, StringComparison.InvariantCultureIgnoreCase)) { // Unsubscribe action SubscriberProvider.Unsubscribe(subscriber.SubscriberID, newsletter.NewsletterID); } else { // Check if the contact group member has unsubscription activity for the specified newsletter isSubscribed = (contactId > 0) && !ModuleCommands.OnlineMarketingIsContactUnsubscribed(contactId, newsletter.NewsletterID, siteId); } if (isSubscribed) { // Log newsletter unsubscription activity LogActivity(subscriber, 0, newsletter.NewsletterID, issueID, issueGuid, siteId, contactId); // Display confirmation ShowInformation(GetString("Unsubscribe.Unsubscribed")); unsubscribed = true; } else { // Contact group member is already unsubscribed ShowError(GetString("Unsubscribe.NotSubscribed")); } } else { ShowError(GetString("Unsubscribe.NotSubscribed")); } } // Check if subscription approval hash is supplied else if (!string.IsNullOrEmpty(subscriptionHash)) { SubscriberNewsletterInfo sni = SubscriberNewsletterInfoProvider.GetSubscriberNewsletterInfo(subscriptionHash); // Check if hash is valid if (sni != null) { SubscriberProvider.ApprovalResult result = SubscriberProvider.Unsubscribe(subscriptionHash, true, CMSContext.CurrentSiteName, datetime); switch (result) { // Approving subscription was successful case SubscriberProvider.ApprovalResult.Success: bool isSubscribed = true; // Get subscriber Subscriber subscriber = SubscriberProvider.GetSubscriber(sni.SubscriberID); if ((subscriber != null) && !string.IsNullOrEmpty(subscriber.SubscriberType) && subscriber.SubscriberType.Equals(PredefinedObjectType.CONTACTGROUP, StringComparison.InvariantCultureIgnoreCase)) { // Check if the contact group member has unsubscription activity for the specified newsletter isSubscribed = (contactId > 0) && !ModuleCommands.OnlineMarketingIsContactUnsubscribed(contactId, sni.NewsletterID, siteId); } if (isSubscribed) { // Log newsletter unsubscription activity LogActivity(null, sni.SubscriberID, sni.NewsletterID, issueID, issueGuid, siteId, contactId); // Display confirmation ShowInformation(GetString("Unsubscribe.Unsubscribed")); unsubscribed = true; } else { // Contact group member is already unsubscribed ShowError(GetString("Unsubscribe.NotSubscribed")); } break; // Subscription was already approved case SubscriberProvider.ApprovalResult.Failed: ShowError(GetString("newsletter.unsubscribefailed")); break; case SubscriberProvider.ApprovalResult.TimeExceeded: ShowError(GetString("newsletter.approval_timeexceeded")); break; // Subscription not found default: case SubscriberProvider.ApprovalResult.NotFound: ShowError(GetString("Unsubscribe.NotSubscribed")); break; } } else { ShowError(GetString("Unsubscribe.NotSubscribed")); } } else { if (subscriberGuid == Guid.Empty) { ShowError(GetString("Unsubscribe.SubscriberDoesNotExist")); } if (newsletterGuid == Guid.Empty) { ShowError(GetString("Unsubscribe.NewsletterDoesNotExist")); } } // Increase unsubscribed count if (unsubscribed) { // If Issue ID was provided if (issueID > 0) { IssueProvider.Unsubscribe(issueID); return; } // Otherwise try using the Issue GUID if (issueGuid != Guid.Empty) { Issue issue = IssueProvider.GetIssue(issueGuid, siteId); if (issue == null) { return; } IssueProvider.Unsubscribe(issue.IssueID); } } }
/// <summary> /// Contact group items selected event handler. /// </summary> protected void selector_OnItemsSelected(object sender, EventArgs e) { // Check permissions CheckAuthorization(); if (cgSelector == null) { return; } int groupID = 0; string[] newItems = null; Subscriber sb = null; int siteId = CMSContext.CurrentSiteID; string cgType = "om.contactgroup"; // Get new items from selector string newValues = ValidationHelper.GetString(cgSelector.Value, null); // Get added items newItems = newValues.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { foreach (string item in newItems) { groupID = ValidationHelper.GetInteger(item, 0); // Get subscriber sb = SubscriberProvider.GetSubscriber(cgType, groupID, siteId); if (sb == null) { // Get contact group display name string cgName = ModuleCommands.OnlineMarketingGetContactGroupName(groupID); if (string.IsNullOrEmpty(cgName)) { break; } // Check limited number of subscribers if (!SubscriberProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Subscribers, VersionActionEnum.Insert)) { lblError.Text = GetString("licenselimitations.subscribers.errormultiple"); lblError.Visible = true; break; } // Create new subscriber of contact group type sb = new Subscriber(); sb.SubscriberFirstName = cgName; // Full name consists of "contact group " and display name sb.SubscriberFullName = string.Concat("Contact group '", cgName, "'"); sb.SubscriberSiteID = siteId; sb.SubscriberType = cgType; sb.SubscriberRelatedID = groupID; SubscriberProvider.SetSubscriber(sb); } // If subscriber exists and is not subscribed, subscribe him if ((sb != null) && (!SubscriberProvider.IsSubscribed(sb.SubscriberID, newsletterId))) { try { SubscriberProvider.Subscribe(sb.SubscriberID, newsletterId, DateTime.Now, chkSendConfirmation.Checked, false); } catch { } } } } cgSelector.Value = null; UniGridSubscribers.ReloadData(); pnlUpdate.Update(); }
/// <summary> /// User control items changed event. /// </summary> protected void UserSelector_OnItemsSelected(object sender, EventArgs e) { // Check permissions CheckAuthorization(); int userID = 0; string[] newItems = null; Subscriber sb = null; int siteId = CMSContext.CurrentSiteID; // Get new items from selector string newValues = ValidationHelper.GetString(selectUser.Value, null); UserInfo ui = null; newItems = newValues.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { foreach (string item in newItems) { userID = ValidationHelper.GetInteger(item, 0); // Get subscriber sb = SubscriberProvider.GetSubscriber(SiteObjectType.USER, userID, siteId); if (sb == null) { // Get user info ui = UserInfoProvider.GetUserInfo(userID); if (ui == null) { break; } // Check limited number of subscribers if (!SubscriberProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Subscribers, VersionActionEnum.Insert)) { lblError.Text = GetString("licenselimitations.subscribers.errormultiple"); lblError.Visible = true; break; } // Create new subscriber of user type sb = new Subscriber(); sb.SubscriberFirstName = ui.FullName; sb.SubscriberFullName = "User '" + ui.FullName + "'"; sb.SubscriberSiteID = siteId; sb.SubscriberType = SiteObjectType.USER; sb.SubscriberRelatedID = userID; SubscriberProvider.SetSubscriber(sb); } // If subscriber exists and is not subscribed, subscribe him if ((sb != null) && (!SubscriberProvider.IsSubscribed(sb.SubscriberID, newsletterId))) { try { SubscriberProvider.Subscribe(sb.SubscriberID, newsletterId, DateTime.Now, chkSendConfirmation.Checked, chkRequireOptIn.Checked); } catch { } } } } selectUser.Value = null; UniGridSubscribers.ReloadData(); pnlUpdate.Update(); }
/// <summary> /// Roles control items changed event. /// </summary> protected void RolesSelector_OnItemsSelected(object sender, EventArgs e) { // Check permissions CheckAuthorization(); int roleID = 0; string[] newItems = null; Subscriber sb = null; int siteId = CMSContext.CurrentSiteID; // Get new items from selector string newValues = ValidationHelper.GetString(selectRole.Value, null); // Get added items newItems = newValues.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { foreach (string item in newItems) { roleID = ValidationHelper.GetInteger(item, 0); // Get subscriber sb = SubscriberProvider.GetSubscriber(SiteObjectType.ROLE, roleID, siteId); if (sb == null) { // Get role info and copy display name to new subscriber RoleInfo ri = RoleInfoProvider.GetRoleInfo(roleID); if (ri == null) { break; } // Check limited number of subscribers if (!SubscriberProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Subscribers, VersionActionEnum.Insert)) { lblError.Text = GetString("licenselimitations.subscribers.errormultiple"); lblError.Visible = true; break; } // Create new subscriber of role type sb = new Subscriber(); sb.SubscriberFirstName = ri.DisplayName; // Full name consists of "role " and role display name sb.SubscriberFullName = string.Concat("Role '", ri.DisplayName, "'"); sb.SubscriberSiteID = siteId; sb.SubscriberType = SiteObjectType.ROLE; sb.SubscriberRelatedID = roleID; SubscriberProvider.SetSubscriber(sb); } // If subscriber exists and is not subscribed, subscribe him if ((sb != null) && (!SubscriberProvider.IsSubscribed(sb.SubscriberID, newsletterId))) { try { SubscriberProvider.Subscribe(sb.SubscriberID, newsletterId, DateTime.Now, chkSendConfirmation.Checked, false); } catch { } } } } selectRole.Value = null; UniGridSubscribers.ReloadData(); pnlUpdate.Update(); }
/// <summary> /// Saves the data. /// </summary> private bool Save(string newsletterName, Subscriber sb) { bool toReturn = false; int siteId = CMSContext.CurrentSiteID; // Check if sunscriber info object exists if ((sb == null) || string.IsNullOrEmpty(newsletterName)) { return(false); } // Get nesletter info Newsletter news = NewsletterProvider.GetNewsletter(newsletterName, siteId); if (news != null) { try { // Check if subscriber is not allready subscribed if (!SubscriberProvider.IsSubscribed(sb.SubscriberGUID, news.NewsletterGUID, siteId)) { toReturn = true; // Subscribe to the site SubscriberProvider.Subscribe(sb.SubscriberID, news.NewsletterID, DateTime.Now, this.SendConfirmationEmail); // Info message if (!chooseMode) { lblInfo.Visible = true; lblInfo.Text = GetString("NewsletterSubscription.Subscribed"); } // Track successful subscription conversion if (this.TrackConversionName != string.Empty) { string siteName = CMSContext.CurrentSiteName; if (AnalyticsHelper.AnalyticsEnabled(siteName) && AnalyticsHelper.TrackConversionsEnabled(siteName) && !AnalyticsHelper.IsIPExcluded(siteName, HTTPHelper.UserHostAddress)) { // Log conversion HitLogProvider.LogConversions(siteName, CMSContext.PreferredCultureCode, TrackConversionName, 0, ConversionValue); } } // Log newsletter subscription activity if double opt-in is not required if (!news.NewsletterEnableOptIn) { if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && news.NewsletterLogActivity && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteId) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) && ActivitySettingsHelper.NewsletterSubscribeEnabled(siteId)) { int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); ModuleCommands.OnlineMarketingUpdateContactFromExternalData(sb, contactId); ModuleCommands.OnlineMarketingCreateRelation(sb.SubscriberID, MembershipType.NEWSLETTER_SUBSCRIBER, contactId); if (ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser)) { var data = new ActivityData() { ContactID = contactId, SiteID = sb.SubscriberSiteID, Type = PredefinedActivityType.NEWSLETTER_SUBSCRIBING, TitleData = news.NewsletterName, ItemID = news.NewsletterID, URL = URLHelper.CurrentRelativePath, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); } } } } else { // Info message - subscriber is allready in site if (!chooseMode) { lblInfo.Visible = true; lblInfo.Text = GetString("NewsletterSubscription.SubscriberIsAlreadySubscribed"); } else { lblInfo.Visible = true; lblInfo.Text += GetString("NewsletterSubscription.SubscriberIsAlreadySubscribedXY") + " " + HTMLHelper.HTMLEncode(news.NewsletterDisplayName) + ".<br />"; } } } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } } else { lblError.Visible = true; lblError.Text = GetString("NewsletterSubscription.NewsletterDoesNotExist"); } return(toReturn); }