Beispiel #1
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            Guid unsubscribeGuid = QueryHelper.GetGuid("unsubscribe", Guid.Empty);

            if (unsubscribeGuid != Guid.Empty)
            {
                ForumSubscriptionInfo fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(unsubscribeGuid);
                if (fsi != null)
                {
                    ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(fsi.SubscriptionID);

                    lblInfoText.Visible = true;
                    lblInfoText.Text    = UnsubscriptionText;
                }
                else
                {
                    lblInfoText.Visible  = true;
                    lblInfoText.Text     = UnsuccessfulUnsubscriptionText;
                    lblInfoText.CssClass = "ErrorLabel";
                    return;
                }
            }
            else
            {
                Visible = false;
            }
        }
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Forums
        Guid subGuid = QueryHelper.GetGuid("subGuid", Guid.Empty);

        if (subGuid != Guid.Empty)
        {
            ForumSubscriptionInfo fsi = null;

            if (subGuid != Guid.Empty)
            {
                fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subGuid);
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Forum.UnsubscribeUnsuccessfull");
                return;
            }

            if (fsi != null)
            {
                ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(fsi.SubscriptionID);

                lblInfo.Visible = true;
                lblInfo.Text    = GetString("Unsubscribe.Unsubscribed");
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = GetString("forum.invalidsubscribeid");
            }
        }
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLower())
        {
        case "delete":
            if (!CheckPermissions("cms.forums", CMSAdminControl.PERMISSION_MODIFY))
            {
                return;
            }

            // Delete ForumSubscriptionInfo object from database
            ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(Convert.ToInt32(actionArgument), chkSendConfirmationEmail.Checked);

            break;
        }

        this.RaiseOnAction(actionName, actionArgument);
    }
    /// <summary>
    /// Handles the Click event of the btnApprove control.
    /// </summary>
    protected void btnUnsubscribe_Click(object sender, EventArgs e)
    {
        if (UserID != MembershipContext.AuthenticatedUser.UserID)
        {
            // Check permissions
            if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
            {
                return;
            }
        }

        DataSet ds = ForumSubscriptionInfoProvider.GetSubscriptions("(SubscriptionUserID = " + UserID + ") AND (SubscriptionPostID = " + PostID + ") AND (ISNULL(SubscriptionApproved, 1) = 1)", null, 0, "SubscriptionID");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            ForumSubscriptionInfo fsi = new ForumSubscriptionInfo(ds.Tables[0].Rows[0]);
            ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(fsi);
            RefreshParentWindow();
        }
    }
Beispiel #5
0
    /// <summary>
    /// On action event handling.
    /// </summary>
    /// <param name="actionName">Name of the action</param>
    /// <param name="actionArgument">Value of the action</param>
    void forumSubscriptions_OnAction(string actionName, object actionArgument)
    {
        int id = ValidationHelper.GetInteger(actionArgument, 0);

        DataSet ds = null;

        if (actionName.ToLowerCSafe() == "forumunsubscribe")
        {
            ds = ForumSubscriptionInfoProvider.GetSubscriptions("(SubscriptionUserID = " + UserID + ") AND (SubscriptionForumID = " + id + ") AND (SubscriptionPostID IS NULL) AND (ISNULL(SubscriptionApproved, 1) = 1) ", null, 0, "SubscriptionID");
        }
        else
        {
            ds = ForumSubscriptionInfoProvider.GetSubscriptions("(SubscriptionUserID = " + UserID + ") AND (SubscriptionPostID = " + id + ") AND (ISNULL(SubscriptionApproved, 1) = 1)", null, 0, "SubscriptionID");
        }

        ForumSubscriptionInfo fsi = new ForumSubscriptionInfo(ds.Tables[0].Rows[0]);

        switch (actionName.ToLowerCSafe())
        {
        case "forumunsubscribe":
        case "postunsubscribe":
            if (RaiseOnCheckPermissions(PERMISSION_MANAGE, this))
            {
                if (StopProcessing)
                {
                    return;
                }
            }

            try
            {
                ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(fsi);
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }

            break;
        }
    }
    /// <summary>
    /// Handles the Click event of the btnApprove control.
    /// </summary>
    protected void btnUnsubscribe_Click(object sender, EventArgs e)
    {
        if (UserID != MembershipContext.AuthenticatedUser.UserID)
        {
            // Check permissions
            if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
            {
                return;
            }
        }

        var query = new ObjectQuery <ForumSubscriptionInfo>().Where(new WhereCondition().WhereNull("SubscriptionApproved").Or().WhereEquals("SubscriptionApproved", 1)).And().WhereEquals("SubscriptionUserID", UserID).And().WhereEquals("SubscriptionPostID", PostID).Column("SubscriptionID").TopN(1);

        ForumSubscriptionInfo fsi = query.FirstOrDefault();

        if (fsi != null)
        {
            ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(fsi);
            RefreshParentWindow();
        }
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        int subscriptionId = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerCSafe())
        {
        case "delete":
            if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
            {
                return;
            }

            // Delete ForumSubscriptionInfo object from database
            ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(subscriptionId, chkSendConfirmationEmail.Checked);
            break;

        case "approve":
            if (!CheckPermissions("cms.forums", PERMISSION_MODIFY))
            {
                return;
            }
            // Approve ForumSubscriptionInfo object
            ForumSubscriptionInfo fsi = ForumSubscriptionInfoProvider.GetForumSubscriptionInfo(subscriptionId);
            if ((fsi != null) && !fsi.SubscriptionApproved)
            {
                fsi.SubscriptionApproved = true;
                ForumSubscriptionInfoProvider.SetForumSubscriptionInfo(fsi);
                if (chkSendConfirmationEmail.Checked)
                {
                    ForumSubscriptionInfoProvider.SendConfirmationEmail(fsi, true, null, null);
                }
            }
            break;
        }

        RaiseOnAction(actionName, actionArgument);
    }
Beispiel #8
0
    /// <summary>
    /// Check that subscription hash is valid and subscription didn't expire
    /// </summary>
    /// <param name="subscriptionHash">Subscription hash to check</param>
    /// <param name="requestTime">Date time of subscription request</param>
    /// <param name="checkOnly">Indicates if only check will be performed</param>
    private void CheckAndSubscribe(string subscriptionHash, string requestTime, bool checkOnly)
    {
        // Get date and time
        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
            {
                DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_failed")));
                return;
            }
        }

        // Initialize opt-in result
        OptInApprovalResultEnum result = OptInApprovalResultEnum.NotFound;

        // Check only data consistency
        if (checkOnly)
        {
            if (SubscriptionObject != null)
            {
                // Validate hash
                result = ForumSubscriptionInfoProvider.ValidateHash(SubscriptionObject, subscriptionHash, SiteContext.CurrentSiteName, datetime);
                if ((result == OptInApprovalResultEnum.Success) && (SubscriptionObject.SubscriptionApproved))
                {
                    result = OptInApprovalResultEnum.NotFound;
                }
            }
        }
        else
        {
            // Try to approve subscription
            result = ForumSubscriptionInfoProvider.ApproveSubscription(SubscriptionObject, mSubscriptionHash, false, SiteContext.CurrentSiteName, datetime);
        }

        // Process result
        switch (result)
        {
        // Approving subscription was successful
        case OptInApprovalResultEnum.Success:
            if (!checkOnly)
            {
                ShowInfo(DataHelper.GetNotEmpty(SuccessfulConfirmationText, GetString("general.subscription_approval")));
                ForumSubscriptionInfoProvider.LogSubscriptionActivity(SubscriptionObject, null, QueryHelper.GetInteger("cid", 0), QueryHelper.GetInteger("siteid", 0), QueryHelper.GetText("url", ""), QueryHelper.GetInteger("docid", 0), QueryHelper.GetText("camp", ""), PredefinedActivityType.SUBSCRIPTION_FORUM_POST, true);
            }
            break;

        // Subscription was already approved
        case OptInApprovalResultEnum.Failed:
            DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_failed")));
            break;

        case OptInApprovalResultEnum.TimeExceeded:
            ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(SubscriptionObject);
            DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_timeexceeded")));
            break;

        // Subscription not found
        default:
        case OptInApprovalResultEnum.NotFound:
            DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_invalid")));
            break;
        }
    }
Beispiel #9
0
    /// <summary>
    /// Check that subscription hash is valid and subscription didn't expire
    /// </summary>
    /// <param name="subscriptionHash">Subscription hash to check</param>
    /// <param name="requestTime">Date time of subscription request</param>
    /// <param name="checkOnly">Indicates if only check will be performed</param>
    private void CheckAndSubscribe(string subscriptionHash, string requestTime, bool checkOnly)
    {
        // Get date and time
        DateTime datetime = DateTimeHelper.ZERO_TIME;

        // Get date and time
        if (!string.IsNullOrEmpty(requestTime))
        {
            try
            {
                datetime = DateTimeUrlFormatter.Parse(requestTime);
            }
            catch
            {
                DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_failed")));
                return;
            }
        }

        // Initialize opt-in result
        OptInApprovalResultEnum result = OptInApprovalResultEnum.NotFound;

        // Check only data consistency
        if (checkOnly)
        {
            if (SubscriptionObject != null)
            {
                // Validate hash
                result = ForumSubscriptionInfoProvider.ValidateHash(SubscriptionObject, subscriptionHash, SiteContext.CurrentSiteName, datetime);
                if ((result == OptInApprovalResultEnum.Success) && (SubscriptionObject.SubscriptionApproved))
                {
                    result = OptInApprovalResultEnum.NotFound;
                }
            }
        }
        else
        {
            // Try to approve subscription
            result = ForumSubscriptionInfoProvider.ApproveSubscription(SubscriptionObject, mSubscriptionHash, false, SiteContext.CurrentSiteName, datetime);
        }

        // Process result
        switch (result)
        {
        // Approving subscription was successful
        case OptInApprovalResultEnum.Success:
            if (!checkOnly)
            {
                ShowInfo(DataHelper.GetNotEmpty(SuccessfulConfirmationText, GetString("general.subscription_approval")));
                ForumSubscriptionInfoProvider.LogSubscriptionActivity(SubscriptionObject, null, QueryHelper.GetInteger("cid", 0), QueryHelper.GetInteger("siteid", 0), QueryHelper.GetText("url", ""), QueryHelper.GetInteger("docid", 0), QueryHelper.GetText("camp", ""), true);
                Service.Resolve <ICurrentContactMergeService>().UpdateCurrentContactEmail(SubscriptionObject.SubscriptionEmail, MembershipContext.AuthenticatedUser);
            }
            break;

        // Subscription was already approved
        case OptInApprovalResultEnum.Failed:
            DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_failed")));
            break;

        case OptInApprovalResultEnum.TimeExceeded:
            ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(SubscriptionObject);
            DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_timeexceeded")));
            break;

        // Subscription not found
        default:
            DisplayError(DataHelper.GetNotEmpty(UnsuccessfulConfirmationText, GetString("general.subscription_invalid")));
            break;
        }
    }
    /// <summary>
    /// Check that subscription hash is valid and subscription didn't expire
    /// </summary>
    /// <param name="subGuid">Subscription GUID for subscriptions without</param>
    /// <param name="subscriptionHash">Subscription hash to check</param>
    /// <param name="requestTime">Date time of subscription request</param>
    /// <param name="checkOnly">Indicates if only check will be performed</param>
    private void CheckAndUnsubscribe(Guid subGuid, string subscriptionHash, string requestTime, bool checkOnly)
    {
        OptInApprovalResultEnum result = OptInApprovalResultEnum.NotFound;

        // Get date and time
        DateTime datetime = DateTimeHelper.ZERO_TIME;

        if (!string.IsNullOrEmpty(requestTime))
        {
            try
            {
                datetime = DateTimeUrlFormatter.Parse(requestTime);
            }
            catch
            {
                DisplayError(GetString("general.unsubscription_unsuccessful"));

                return;
            }
        }

        if (subGuid != Guid.Empty)
        {
            if (SubscriptionObject != null)
            {
                if (!checkOnly)
                {
                    ForumSubscriptionInfoProvider.DeleteForumSubscriptionInfo(SubscriptionObject);
                }
                result = OptInApprovalResultEnum.Success;
            }
        }
        // Check if subscription approval hash is supplied
        else if (!string.IsNullOrEmpty(subscriptionHash))
        {
            result = checkOnly
                ? ForumSubscriptionInfoProvider.ValidateHash(SubscriptionObject, subscriptionHash, SiteContext.CurrentSiteName, datetime)
                : ForumSubscriptionInfoProvider.Unsubscribe(subscriptionHash, true, SiteContext.CurrentSiteName, datetime);
        }

        switch (result)
        {
        // Approving subscription was successful
        case OptInApprovalResultEnum.Success:
            if (!checkOnly)
            {
                ShowInfo(DataHelper.GetNotEmpty(SuccessfulUnsubscriptionText, GetString("Unsubscribe.Unsubscribed")));
            }
            break;

        // Subscription was already approved
        case OptInApprovalResultEnum.Failed:
            DisplayError(DataHelper.GetNotEmpty(UnsuccessfulUnsubscriptionText, GetString("general.unsubscription_unsuccessful")));
            break;

        case OptInApprovalResultEnum.TimeExceeded:
            DisplayError(DataHelper.GetNotEmpty(UnsuccessfulUnsubscriptionText, GetString("general.unsubscription_timeexceeded")));
            break;

        // Subscription not found
        default:
            DisplayError(DataHelper.GetNotEmpty(UnsuccessfulUnsubscriptionText, GetString("general.unsubscription_NotSubscribed")));
            break;
        }
    }