/// <summary> /// Logs activity /// </summary> /// <param name="pollId">Poll</param> /// <param name="answers">Answers</param> private void LogActivity(PollInfo pi, string answers) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || !IsLiveSite || (pi == null) || !pi.PollLogActivity || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.PollVotingEnabled(siteName)) { return; } TreeNode currentDoc = CMSContext.CurrentDocument; var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.POLL_VOTING, TitleData = pi.PollQuestion, ItemID = pi.PollID, URL = URLHelper.CurrentRelativePath, NodeID = (currentDoc != null ? currentDoc.NodeID : 0), Culture = (currentDoc != null ? currentDoc.DocumentCulture : null), Value = answers, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Log activity /// </summary> /// <param name="gmi">Member info</param> /// <param name="logActivity">Determines whether activity logging is enabled for current group</param> /// <param name="groupDisplayName">Display name of the group</param> private void LogLeaveActivity(GroupMemberInfo gmi, bool logActivity, string groupDisplayName) { string siteName = CMSContext.CurrentSiteName; if (!logActivity || (CMSContext.ViewMode != ViewModeEnum.LiveSite) || (gmi == null) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.JoiningAGroupEnabled(siteName)) { return; } TreeNode currentDoc = CMSContext.CurrentDocument; var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.LEAVE_GROUP, TitleData = groupDisplayName, ItemID = gmi.MemberGroupID, URL = URLHelper.CurrentRelativePath, NodeID = (currentDoc != null ? currentDoc.NodeID : 0), Culture = (currentDoc != null ? currentDoc.DocumentCulture : null), Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Logs activity /// </summary> /// <param name="skuId">Product ID</param> /// <param name="skuName">Product name</param> /// <param name="Quantity">Quantity</param> private void LogProductAddedToSCActivity(int skuId, string skuName, int Quantity) { if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser)) { return; } string siteName = CMSContext.CurrentSiteName; if (!ActivitySettingsHelper.AddingProductToSCEnabled(siteName) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName)) { return; } var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.PRODUCT_ADDED_TO_SHOPPINGCART, TitleData = skuName, Value = Quantity.ToString(), ItemID = skuId, URL = URLHelper.CurrentRelativePath, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Logs "subscription" activity. /// </summary> /// <param name="bci">Forum subscription</param> private void LogSubscriptionActivity(ForumSubscriptionInfo fsi, ForumInfo fi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (fsi == null) || (fi == null) || !fi.ForumLogActivity || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ForumPostSubscriptionEnabled(siteName)) { return; } var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.SUBSCRIPTION_FORUM_POST, TitleData = fi.ForumName, ItemID = fi.ForumID, ItemDetailID = fsi.SubscriptionID, URL = URLHelper.CurrentRelativePath, NodeID = CMSContext.CurrentDocument.NodeID, Culture = CMSContext.CurrentDocument.DocumentCulture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Log activity (subscribing) /// </summary> /// <param name="bsi"></param> private void LogActivity(BoardSubscriptionInfo bsi, BoardInfo bi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bsi == null) || (bi == null) || !bi.BoardLogActivity || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.MessageBoardSubscriptionEnabled(siteName)) { return; } TreeNode currentDoc = CMSContext.CurrentDocument; int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); Dictionary <string, object> contactData = new Dictionary <string, object>(); contactData.Add("ContactEmail", bsi.SubscriptionEmail); ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactId); var data = new ActivityData() { ContactID = contactId, SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.SUBSCRIPTION_MESSAGE_BOARD, TitleData = bi.BoardName, URL = URLHelper.CurrentRelativePath, NodeID = (currentDoc != null ? currentDoc.NodeID : 0), Culture = (currentDoc != null ? currentDoc.DocumentCulture : null), Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Logs "post" activity. /// </summary> /// <param name="bci">Forum subscription</param> /// <param name="fi">Forum info</param> private void LogPostActivity(ForumPostInfo fp, ForumInfo fi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (fp == null) || (fi == null) || !fi.ForumLogActivity || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.ForumPostsEnabled(siteName)) { return; } int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); Dictionary <string, object> contactData = new Dictionary <string, object>(); contactData.Add("ContactEmail", fp.PostUserMail); contactData.Add("ContactLastName", fp.PostUserName); ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactId); var data = new ActivityData() { ContactID = contactId, SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.FORUM_POST, TitleData = fi.ForumName, ItemID = fi.ForumID, ItemDetailID = fp.PostId, URL = URLHelper.CurrentRelativePath, NodeID = CMSContext.CurrentDocument.NodeID, Culture = CMSContext.CurrentDocument.DocumentCulture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Log activity (subscribing). /// </summary> /// <param name="bsi">Board subscription info object</param> /// <param name="bi">Message board info</param> private void LogSubscribingActivity(BoardSubscriptionInfo bsi, BoardInfo bi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bsi == null) || (bi == null) || !bi.BoardLogActivity || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.MessageBoardSubscriptionEnabled(siteName)) { return; } TreeNode currentDoc = CMSContext.CurrentDocument; var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.SUBSCRIPTION_MESSAGE_BOARD, TitleData = bi.BoardDisplayName, URL = URLHelper.CurrentRelativePath, NodeID = (currentDoc != null ? currentDoc.NodeID : 0), Culture = (currentDoc != null ? currentDoc.DocumentCulture : null), Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Log activity posting /// </summary> /// <param name="bsi">Board subscription info object</param> /// <param name="bi">Message board info</param> private void LogCommentActivity(BoardMessageInfo bmi, BoardInfo bi) { string siteName = CMSContext.CurrentSiteName; if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bmi == null) || (bi == null) || !bi.BoardLogActivity || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.MessageBoardPostsEnabled(siteName)) { return; } int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); Dictionary <string, object> contactData = new Dictionary <string, object>(); contactData.Add("ContactEmail", bmi.MessageEmail); contactData.Add("ContactWebSite", bmi.MessageURL); contactData.Add("ContactLastName", bmi.MessageUserName); ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactId); TreeNode currentDoc = CMSContext.CurrentDocument; var data = new ActivityData() { ContactID = contactId, SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.MESSAGE_BOARD_COMMENT, TitleData = bi.BoardDisplayName, ItemID = bmi.MessageBoardID, URL = URLHelper.CurrentRelativePath, ItemDetailID = bmi.MessageID, NodeID = (currentDoc != null ? currentDoc.NodeID : 0), Culture = (currentDoc != null ? currentDoc.DocumentCulture : null), Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Logs "delete" activity /// </summary> /// <param name="documentName">Document name</param> /// <param name="nodeId">Document node ID</param> /// <param name="culture">Document culture</param> private void LogDeleteActivity(string documentName, int nodeId, string culture) { if (!this.LogActivity || (CMSContext.ViewMode != ViewModeEnum.LiveSite) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser)) { return; } string siteName = CMSContext.CurrentSiteName; if (ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) && ActivitySettingsHelper.WikiContributionDeleteEnabled(siteName)) { var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.USER_CONTRIB_DELETE, TitleData = documentName, NodeID = nodeId, URL = URLHelper.CurrentRelativePath, Culture = culture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); } }
/// <summary> /// Logs activity for subscribing/unsubscribing /// </summary> /// <param name="ui">User</param> /// <param name="newsletterId">Newsletter ID</param> /// <param name="subscribe">Subscribing/unsubscribing flag</param> /// <param name="siteId">Site ID</param> private void LogActivity(UserInfo ui, int newsletterId, bool subscribe, int siteId) { if ((sb == null) || (ui == null) || (CMSContext.ViewMode != ViewModeEnum.LiveSite) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteId) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(ui)) { return; } if (sb.SubscriberType == SiteObjectType.USER) { if (subscribe && ActivitySettingsHelper.NewsletterSubscribeEnabled(siteId) || !subscribe && ActivitySettingsHelper.NewsletterUnsubscribeEnabled(siteId)) { Newsletter news = NewsletterProvider.GetNewsletter(newsletterId); if ((news != null) && news.NewsletterLogActivity) { var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = sb.SubscriberSiteID, Type = PredefinedActivityType.NEWSLETTER_UNSUBSCRIBING, TitleData = news.NewsletterName, ItemID = newsletterId, URL = URLHelper.CurrentRelativePath, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); } } } }
/// <summary> /// Logs activity. /// </summary> /// <param name="bci">Blog comment info</param> /// <param name="nodeId">Docuemnt node ID</param> /// <param name="culture">Docuemnt culture</param> private void LogCommentActivity(BlogCommentInfo bci, int nodeId, string culture) { if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bci == null) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser)) { return; } string siteName = CMSContext.CurrentSiteName; if (!ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.BlogPostCommentsEnabled(siteName)) { return; } if (bci.CommentPostDocumentID > 0) { // Load blog post settings and check if logging is enabled for current post TreeProvider tree = new TreeProvider(); TreeNode blogPost = DocumentHelper.GetDocument(bci.CommentPostDocumentID, tree); if ((blogPost != null) && ValidationHelper.GetBoolean(blogPost.GetValue("BlogLogActivity"), false)) { TreeNode blogNode = BlogHelper.GetParentBlog(bci.CommentPostDocumentID, false); string blogName = null; if (blogNode != null) { blogName = blogNode.DocumentName; } int contactID = ModuleCommands.OnlineMarketingGetCurrentContactID(); var data = new ActivityData() { ContactID = contactID, SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.BLOG_COMMENT, TitleData = blogName, ItemID = bci.CommentID, URL = URLHelper.CurrentRelativePath, ItemDetailID = (blogNode != null ? blogNode.NodeID : 0), NodeID = nodeId, Culture = culture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); Dictionary <string, object> contactData = new Dictionary <string, object>(); contactData.Add("ContactEmail", bci.CommentEmail); contactData.Add("ContactLastName", bci.CommentUserName); contactData.Add("ContactWebSite", bci.CommentUrl); ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactID); } } }
/// <summary> /// Logs activity. /// </summary> /// <param name="bpsi">Blog subscription info</param> /// <param name="nodeId">Docuemnt node ID</param> /// <param name="culture">Document culture</param> private void LogActivity(BlogPostSubscriptionInfo bpsi, int nodeId, string culture) { if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (bpsi == null) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser)) { return; } string siteName = CMSContext.CurrentSiteName; if (!ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.BlogPostSubscriptionEnabled(siteName)) { return; } if (bpsi.SubscriptionPostDocumentID > 0) { TreeProvider tree = new TreeProvider(); TreeNode blogPost = DocumentHelper.GetDocument(bpsi.SubscriptionPostDocumentID, tree); if ((blogPost != null) && ValidationHelper.GetBoolean(blogPost.GetValue("BlogLogActivity"), false)) { string blogName = null; TreeNode blogNode = BlogHelper.GetParentBlog(bpsi.SubscriptionPostDocumentID, false); if (blogNode != null) { blogName = blogNode.DocumentName; } // Update contact info according to subscribtion int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); Dictionary <string, object> contactData = new Dictionary <string, object>(); contactData.Add("ContactEmail", bpsi.SubscriptionEmail); ModuleCommands.OnlineMarketingUpdateContactFromExternalSource(contactData, false, contactId); var data = new ActivityData() { ContactID = contactId, SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.SUBSCRIPTION_BLOG_POST, ItemDetailID = (blogNode != null ? blogNode.NodeID : 0), TitleData = bpsi.SubscriptionEmail, URL = URLHelper.CurrentRelativePath, NodeID = nodeId, Value = TextHelper.LimitLength(blogName, 250), Culture = culture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); } } }
/// <summary> /// Logs rating activity /// </summary> /// <param name="value">Rating value</param> private void LogActivity(double value) { if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser)) { return; } string siteName = CMSContext.CurrentSiteName; if (!ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ContentRatingEnabled(siteName)) { return; } bool logActivity = false; TreeNode currentDoc = CMSContext.CurrentDocument; if (currentDoc != null) { if (CMSContext.CurrentDocument.DocumentLogVisitActivity == null) { logActivity = ValidationHelper.GetBoolean(currentDoc.GetInheritedValue("DocumentLogVisitActivity", SiteInfoProvider.CombineWithDefaultCulture(siteName)), false); } else { logActivity = currentDoc.DocumentLogVisitActivity == true; } if (logActivity) { var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.RATING, TitleData = String.Format("{0} ({1})", value.ToString(), currentDoc.DocumentName), URL = URLHelper.CurrentRelativePath, NodeID = currentDoc.NodeID, Value = value.ToString(), Culture = currentDoc.DocumentCulture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); } } }
/// <summary> /// Logs activity /// </summary> /// <param name="skuId">SKU ID</param> /// <param name="skuName">Product name</param> /// <param name="siteId">Site ID</param> private void LogProductAddedToWLActivity(int skuId, string skuName, int siteId) { if ((currentUser == null) || (CMSContext.ViewMode != ViewModeEnum.LiveSite) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteId) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(currentUser) || !ActivitySettingsHelper.AddingProductToWLEnabled(siteId)) { return; } var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = siteId, Type = PredefinedActivityType.PRODUCT_ADDED_TO_WISHLIST, TitleData = skuName, ItemID = skuId, URL = URLHelper.CurrentRelativePath, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <summary> /// Log activity /// </summary> /// <param name="ari">Report info</param> private void LogActivity(AbuseReportInfo ari) { if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || (ari == null) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(ari.ReportSiteID) || !ActivitySettingsHelper.AbuseReportEnabled(ari.ReportSiteID)) { return; } var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = ari.ReportSiteID, Type = PredefinedActivityType.ABUSE_REPORT, TitleData = ari.ReportTitle, ItemID = ari.ReportID, URL = URLHelper.CurrentRelativePath, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); }
/// <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); }
/// <summary> /// Logs activity for unsubscribing. /// </summary> /// <param name="sb">Subscriber (optional - can be null if subscriber ID is used)</param> /// <param name="subscriberId">Subscriber ID (optional - can be zero if subscriber object is used)</param> /// <param name="newsletterId">Newsletter ID</param> /// <param name="siteId">Site ID</param> /// <param name="issueId">Issue ID</param> /// <param name="issueGuid">Issue GUID</param> /// <param name="contactId">Contact ID is present if the mail is sent to a contact group</param> private void LogActivity(Subscriber sb, int subscriberId, int newsletterId, int siteId, int issueId, Guid issueGuid, int contactId) { // Check if activities logging is enabled if ((newsletterId <= 0) || (CMSContext.ViewMode != ViewModeEnum.LiveSite) || !ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteId) || !ActivitySettingsHelper.NewsletterSubscribeEnabled(siteId)) { return; } // Load subscriber info object according to its ID if not given if (sb == null) { if (subscriberId <= 0) { return; } sb = SubscriberProvider.GetSubscriber(subscriberId); } if (sb == null) { return; } Newsletter news = NewsletterProvider.GetNewsletter(newsletterId); if ((news != null) && news.NewsletterLogActivity) { bool isFromContactGroup = (contactId > 0); // Try to retrieve contact IDs for particular subscriber from membership relations if (!isFromContactGroup) { contactId = ActivityTrackingHelper.GetContactID(sb); } if (contactId > 0) { // Load additional info (issue id) if ((issueId <= 0) && (issueGuid != Guid.Empty)) { Issue issue = IssueProvider.GetIssue(issueGuid, siteId); if (issue != null) { issueId = issue.IssueID; } } var data = new ActivityData() { ContactID = contactId, SiteID = sb.SubscriberSiteID, Type = PredefinedActivityType.NEWSLETTER_UNSUBSCRIBING, TitleData = news.NewsletterName, ItemID = newsletterId, URL = URLHelper.CurrentRelativePath, ItemDetailID = issueId, Value = (isFromContactGroup ? "contactgroup(" + sb.SubscriberRelatedID + ")" : null) }; ActivityLogProvider.LogActivity(data); } } }
/// <summary> /// On btnRegister click. /// </summary> protected void btnRegister_Click(object sender, EventArgs e) { string currentSiteName = CMSContext.CurrentSiteName; // Check banned ip if (!BannedIPInfoProvider.IsAllowed(currentSiteName, BanControlEnum.AllNonComplete)) { lblError.Visible = true; lblError.Text = GetString("General.BannedIP"); return; } // Exit if problem occurs if (errorOccurs) { return; } string result = null; Validator val = new Validator(); // Check name fields if required if (this.RequireName) { result = val.NotEmpty(txtFirstName.Text.Trim(), GetString("eventmanager.firstnamerequired")) .NotEmpty(txtLastName.Text.Trim(), GetString("eventmanager.lastnamerequired")).Result; } // Check e-mail field if (string.IsNullOrEmpty(result)) { result = val.IsEmail(txtEmail.Text.Trim(), GetString("eventmanager.emailrequired")).Result; } // Check phone field if required if (this.RequirePhone && string.IsNullOrEmpty(result)) { result = val.NotEmpty(txtPhone.Text.Trim(), GetString("eventmanager.phonerequired")).Result; } if (string.IsNullOrEmpty(result)) { DateTime now = DateTime.Now; // Allow registration if opened if ((openFrom == DataHelper.DATETIME_NOT_SELECTED || openFrom < now) && (openTo == DataHelper.DATETIME_NOT_SELECTED || now <= openTo) && (now <= eventDate)) { if (EventNode != null) { if (!EventAttendeeInfoProvider.IsRegisteredForEvent(EventNode.NodeID, txtEmail.Text.Trim())) { // Add new attendant to the event EventAttendeeInfo eai = AddAttendantToEvent(); if (eai != null) { // Log activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(currentSiteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) && ActivitySettingsHelper.EventBookingEnabled(currentSiteName)) { if (ValidationHelper.GetBoolean(EventNode.GetValue("EventLogActivity"), false)) { var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.EVENT_BOOKING, TitleData = EventNode.DocumentName, ItemID = eai.AttendeeID, URL = URLHelper.CurrentRelativePath, ItemDetailID = EventNode.DocumentID, NodeID = EventNode.NodeID, Culture = EventNode.DocumentCulture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); } } // Send invitation e-mail TimeZoneInfo tzi = null; CMSContext.GetDateTimeForControl(this, DateTime.Now, out tzi); EventProvider.SendInvitation(currentSiteName, EventNode, eai, tzi); lblRegInfo.Text = GetString("eventmanager.registrationsucceeded"); lblRegInfo.Visible = true; // Hide registration form pnlReg.Visible = false; } } else { // User is already registered lblError.Text = GetString("eventmanager.attendeeregistered"); lblError.Visible = true; } } else { // Event does not exist lblError.Text = GetString("eventmanager.eventnotexist"); lblError.Visible = true; // Hide registration form pnlReg.Visible = false; } } else { // Event registration is not opened lblError.Text = GetString("eventmanager.notopened"); lblError.Visible = true; // Hide registration form pnlReg.Visible = false; } } else { // Display error message lblError.Text = result; lblError.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { // If StopProcessing flag is set, do nothing if (StopProcessing) { Visible = false; return; } string subscriptionHash = QueryHelper.GetString("subscriptionhash", string.Empty); 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 { lblInfo.Text = ResHelper.GetString("newsletter.approval_failed"); return; } } if (string.IsNullOrEmpty(subscriptionHash)) { this.Visible = false; return; } // Try to approve subscription SubscriberProvider.ApprovalResult result = SubscriberProvider.ApproveSubscription(subscriptionHash, false, CMSContext.CurrentSiteName, datetime); switch (result) { // Approving subscription was successful case SubscriberProvider.ApprovalResult.Success: if (!String.IsNullOrEmpty(this.SuccessfulApprovalText)) { lblInfo.Text = this.SuccessfulApprovalText; } else { lblInfo.Text = ResHelper.GetString("newsletter.successful_approval"); } // Log newsletter subscription activity if ((CMSContext.ViewMode == ViewModeEnum.LiveSite)) { SubscriberNewsletterInfo sni = SubscriberNewsletterInfoProvider.GetSubscriberNewsletterInfo(subscriptionHash); if (sni != null) { // Load subscriber info and make sure activity modul is enabled Subscriber sb = SubscriberProvider.GetSubscriber(sni.SubscriberID); if ((sb != null) && ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(sb.SubscriberSiteID)) { int siteId = sb.SubscriberSiteID; Newsletter news = NewsletterProvider.GetNewsletter(sni.NewsletterID); if (news.NewsletterLogActivity && ActivitySettingsHelper.NewsletterSubscribeEnabled(siteId)) { // Under what contacs this subscriber belogs to? int contactId = ActivityTrackingHelper.GetContactID(sb); if (contactId > 0) { ModuleCommands.OnlineMarketingUpdateContactFromExternalData(sb, contactId); ModuleCommands.OnlineMarketingCreateRelation(sb.SubscriberID, MembershipType.NEWSLETTER_SUBSCRIBER, contactId); 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); } } } } } break; // Subscription was already approved case SubscriberProvider.ApprovalResult.Failed: if (!String.IsNullOrEmpty(this.UnsuccessfulApprovalText)) { lblInfo.Text = this.UnsuccessfulApprovalText; } else { lblInfo.Text = ResHelper.GetString("newsletter.approval_failed"); } break; case SubscriberProvider.ApprovalResult.TimeExceeded: if (!String.IsNullOrEmpty(this.UnsuccessfulApprovalText)) { lblInfo.Text = this.UnsuccessfulApprovalText; } else { lblInfo.Text = ResHelper.GetString("newsletter.approval_timeexceeded"); } break; // Subscription not found default: case SubscriberProvider.ApprovalResult.NotFound: if (!String.IsNullOrEmpty(this.UnsuccessfulApprovalText)) { lblInfo.Text = this.UnsuccessfulApprovalText; } else { lblInfo.Text = ResHelper.GetString("newsletter.approval_invalid"); } break; } }