Exemplo n.º 1
0
    /// <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);
                }
            }
        }
    }