/// <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()) { // Remove subscription case REMOVE: mSubscriptionService.RemoveSubscription(subscriberId, mNewsletter.NewsletterID, false); break; // Approve subscription case APPROVE: SubscriberNewsletterInfoProvider.ApproveSubscription(subscriberId, mNewsletter.NewsletterID); break; } } catch (Exception exception) { LogAndShowError("Newsletter subscriber", "NEWSLETTERS", exception); } }
/// <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="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"); } Func <bool> subscriberIsUserAndIsDisabled = () => { var user = GetSubscriberUser(subscriber); return((user != null) && !user.UserEnabled); }; switch (actionName.ToUpperInvariant()) { // Remove subscription case REMOVE: mSubscriptionService.RemoveSubscription(subscriberId, mNewsletter.NewsletterID, chkSendConfirmation.Checked); break; // Approve subscription case APPROVE: if (subscriberIsUserAndIsDisabled()) { return; } 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 exception) { LogAndShowError("Newsletter subscriber", "NEWSLETTERS", exception); } }
/// <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; } }
/// <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) { try { var subscriber = SubscriberInfoProvider.GetSubscriberInfo(mSubscriberID); switch (actionName.ToUpperInvariant()) { case REMOVE: mSubscriptionService.RemoveSubscription(subscriber.SubscriberID, newsletter.NewsletterID, chkSendConfirmation.Checked); break; case APPROVE: SubscriberNewsletterInfoProvider.ApproveSubscription(mSubscriberID, newsletter.NewsletterID); break; } } // Exception might be thrown when one of the object does not exist, especially when newsletter gets deleted before refreshing this page. catch (Exception exception) { LogAndShowError("Subscriber subscriptions", "NEWSLETTERS", exception); } }