/// <summary> /// Performs action on given subscriber. /// </summary> /// <param name="subscriberId">Id of subscriber</param> /// <param name="actionName">Name of action</param> private void DoSubscriberAction(int subscriberId, string actionName) { try { // Check manage subscribers permission var subscriber = SubscriberInfoProvider.GetSubscriberInfo(subscriberId); if (!subscriber.CheckPermissions(PermissionsEnum.Modify, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser)) { RedirectToAccessDenied(subscriber.TypeInfo.ModuleName, "ManageSubscribers"); } switch (actionName.ToUpperInvariant()) { // Subscribe case SUBSCRIBE: var subscription = SubscriberNewsletterInfoProvider.GetSubscriberNewsletterInfo(subscriberId, mNewsletter.NewsletterID); if ((subscription == null) || subscription.SubscriptionEnabled) { return; } SubscriberInfoProvider.RenewSubscription(subscriberId, mNewsletter.NewsletterID, chkSendConfirmation.Checked); SubscriberNewsletterInfoProvider.SetApprovalStatus(subscriberId, mNewsletter.NewsletterID, !chkRequireOptIn.Checked); if (chkRequireOptIn.Checked) { IssueInfoProvider.SendDoubleOptInEmail(subscriberId, mNewsletter.NewsletterID); } break; // Unsubscribe case UNSUBSCRIBE: SubscriberInfoProvider.Unsubscribe(subscriberId, mNewsletter.NewsletterID, chkSendConfirmation.Checked); break; // Remove subscription case REMOVE: SubscriberInfoProvider.DeleteSubscription(subscriberId, mNewsletter.NewsletterID, chkSendConfirmation.Checked); break; // Approve subscription case APPROVE: SubscriberNewsletterInfoProvider.ApproveSubscription(subscriberId, mNewsletter.NewsletterID); break; // Block selected subscriber case BLOCK: SubscriberInfoProvider.BlockSubscriber(subscriberId); break; // Un-block selected subscriber case UNBLOCK: SubscriberInfoProvider.UnblockSubscriber(subscriberId); break; } } catch (Exception e) { LogAndShowError("Newsletter subscriber", "NEWSLETTERS", e); } }
/// <summary> /// Performs action on given subscriber. /// </summary> /// <param name="newsletter">Newsletter info</param> /// <param name="actionName">Name of action</param> private void DoSubscriberAction(NewsletterInfo newsletter, string actionName) { switch (actionName.ToUpperInvariant()) { // Renew subscription case SUBSCRIBE: var subscriberNewsletterInfo = SubscriberNewsletterInfoProvider.GetSubscriberNewsletterInfo(mSubscriberId, newsletter.NewsletterID); if (subscriberNewsletterInfo.SubscriptionEnabled) { return; } bool requireDoubleOptIn = chkRequireOptIn.Checked && newsletter.NewsletterEnableOptIn; SubscriberInfoProvider.RenewSubscription(mSubscriberId, newsletter.NewsletterID, chkSendConfirmation.Checked && !requireDoubleOptIn); bool approved = true; // Check if double opt-in is enabled and if confirmation e-mail checkbox was checked if (requireDoubleOptIn) { IssueInfoProvider.SendDoubleOptInEmail(mSubscriberId, newsletter.NewsletterID); approved = false; } SubscriberNewsletterInfoProvider.SetApprovalStatus(mSubscriberId, newsletter.NewsletterID, approved); break; // Unsubscribe case UNSUBSCRIBE: SubscriberInfoProvider.Unsubscribe(mSubscriberId, newsletter.NewsletterID, chkSendConfirmation.Checked); break; // Remove subscription case REMOVE: SubscriberInfoProvider.DeleteSubscription(mSubscriberId, newsletter.NewsletterID, chkSendConfirmation.Checked); break; // Approve subscription case APPROVE: SubscriberNewsletterInfoProvider.ApproveSubscription(mSubscriberId, newsletter.NewsletterID); break; } }