コード例 #1
0
    /// <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);
        }
    }
コード例 #2
0
    /// <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);
        }
    }
コード例 #3
0
 /// <summary>
 /// Block selected subscriber.
 /// </summary>
 private void Block(object actionArgument)
 {
     CheckAuthorization();
     SubscriberInfoProvider.BlockSubscriber(ValidationHelper.GetInteger(actionArgument, 0));
 }
コード例 #4
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that threw event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void UniGridSubscribers_OnAction(string actionName, object actionArgument)
    {
        // Check 'manage subscribers' permission
        CheckAuthorization();

        int subscriberId = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerCSafe())
        {
        // Renew subscription
        case "subscribe":
            SubscriberInfoProvider.RenewSubscription(subscriberId, newsletterId, chkSendConfirmation.Checked);
            break;

        // Unsubscribe selected subscriber
        case "unsubscribe":
            SubscriberInfoProvider.Unsubscribe(subscriberId, newsletterId, chkSendConfirmation.Checked);
            break;

        // Delete subscription
        case "remove":
            SubscriberInfoProvider.DeleteSubscription(subscriberId, newsletterId, chkSendConfirmation.Checked);
            break;

        // Approve selected subscription
        case "approve":
        {
            SubscriberNewsletterInfo subscriptionInfo = SubscriberNewsletterInfoProvider.GetSubscriberNewsletterInfo(subscriberId, newsletterId);
            if ((subscriptionInfo != null) && (!subscriptionInfo.SubscriptionApproved))
            {
                subscriptionInfo.SubscriptionApproved     = true;
                subscriptionInfo.SubscriptionApprovedWhen = DateTime.Now;
                SubscriberNewsletterInfoProvider.SetSubscriberNewsletterInfo(subscriptionInfo);
            }
        }
        break;

        // Reject selected subscription
        case "reject":
        {
            SubscriberNewsletterInfo subscriptionInfo = SubscriberNewsletterInfoProvider.GetSubscriberNewsletterInfo(subscriberId, newsletterId);
            if ((subscriptionInfo != null) && (subscriptionInfo.SubscriptionApproved))
            {
                subscriptionInfo.SubscriptionApproved     = false;
                subscriptionInfo.SubscriptionApprovedWhen = DateTime.MinValue;
                SubscriberNewsletterInfoProvider.SetSubscriberNewsletterInfo(subscriptionInfo);
            }
        }
        break;

        // Block selected subscriber
        case "block":
            SubscriberInfoProvider.BlockSubscriber(subscriberId);
            break;

        // Un-block selected subscriber
        case "unblock":
            SubscriberInfoProvider.UnblockSubscriber(subscriberId);
            break;
        }
    }