Exemplo n.º 1
0
    /// <summary>
    /// Handle mass actions.
    /// </summary>
    protected void btnAction_Click(object sender, EventArgs e)
    {
        if (drpAction.SelectedValue != "SELECT")
        {
            ArrayList list = gridComments.SelectedItems;
            if (list.Count > 0)
            {
                foreach (string commnentId in list)
                {
                    BlogCommentInfo bci = BlogCommentInfoProvider.GetBlogCommentInfo(Convert.ToInt32(commnentId));
                    switch (drpAction.SelectedValue.ToLower())
                    {
                    case "delete":
                        // Delete specified comment
                        BlogCommentInfoProvider.DeleteBlogCommentInfo(bci);
                        break;

                    case "approve":
                        if (!bci.CommentApproved)
                        {
                            // Set comment as 'approved'
                            bci.CommentApproved         = true;
                            bci.CommentApprovedByUserID = CMSContext.CurrentUser.UserID;
                            BlogCommentInfoProvider.SetBlogCommentInfo(bci);
                        }
                        break;

                    case "reject":
                        if (bci.CommentApproved)
                        {
                            // Set comment as 'reject'
                            bci.CommentApproved         = false;
                            bci.CommentApprovedByUserID = 0;
                            BlogCommentInfoProvider.SetBlogCommentInfo(bci);
                        }
                        break;

                    case "spam":
                        if (!bci.CommentIsSpam)
                        {
                            bci.CommentIsSpam = true;
                            BlogCommentInfoProvider.SetBlogCommentInfo(bci);
                        }
                        break;

                    case "nospam":
                        if (bci.CommentIsSpam)
                        {
                            bci.CommentIsSpam = false;
                            BlogCommentInfoProvider.SetBlogCommentInfo(bci);
                        }
                        break;
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Deletes blog comment. Called when the "Delete comment" button is pressed.
    /// Expects the CreateBlogComment method to be run first.
    /// </summary>
    private bool DeleteBlogComment()
    {
        // Prepare the parameters
        string where = "CommentText LIKE 'My new%'";
        string blogWhere = "NodeName LIKE 'MyNewBlog%'";

        // Get the data
        DataSet comments = BlogCommentInfoProvider.GetComments(where, blogWhere);
        if (!DataHelper.DataSourceIsEmpty(comments))
        {
            // Create object from DataRow
            BlogCommentInfo modifyComment = new BlogCommentInfo(comments.Tables[0].Rows[0]);

            // Delete the blog comment
            BlogCommentInfoProvider.DeleteBlogCommentInfo(modifyComment);

            return true;
        }

        return false;
    }
    protected void gridComments_OnAction(string actionName, object actionArgument)
    {
        int commentId = ValidationHelper.GetInteger(actionArgument, 0);

        switch (actionName.ToLowerCSafe())
        {
        case "delete":
            // Delete specified comment
            BlogCommentInfoProvider.DeleteBlogCommentInfo(commentId);
            break;

        case "approve":
            BlogCommentInfo bci = BlogCommentInfoProvider.GetBlogCommentInfo(commentId);
            if (bci != null)
            {
                if (bci.CommentApproved)
                {
                    // Set comment as 'rejected'
                    bci.CommentApproved         = false;
                    bci.CommentApprovedByUserID = 0;
                }
                else
                {
                    // Set comment as 'approved'
                    bci.CommentApproved         = true;
                    bci.CommentApprovedByUserID = currentUser.UserID;
                }
                BlogCommentInfoProvider.SetBlogCommentInfo(bci);
            }
            break;

        case "edit":
            // JavaScript
            break;
        }
    }
    /// <summary>
    /// Handle mass actions.
    /// </summary>
    protected void btnAction_Click(object sender, EventArgs e)
    {
        if (drpAction.SelectedValue != "SELECT")
        {
            List <string> list = gridComments.SelectedItems;
            if (list.Count > 0)
            {
                foreach (string commnentId in list)
                {
                    BlogCommentInfo bci = BlogCommentInfoProvider.GetBlogCommentInfo(Convert.ToInt32(commnentId));
                    switch (drpAction.SelectedValue.ToLowerCSafe())
                    {
                    case "delete":
                        // Delete specified comment
                        BlogCommentInfoProvider.DeleteBlogCommentInfo(bci);
                        break;

                    case "approve":
                        if (!bci.CommentApproved)
                        {
                            // Set comment as 'approved'
                            bci.CommentApproved         = true;
                            bci.CommentApprovedByUserID = MembershipContext.AuthenticatedUser.UserID;
                            BlogCommentInfoProvider.SetBlogCommentInfo(bci);
                        }
                        break;

                    case "reject":
                        if (bci.CommentApproved)
                        {
                            // Set comment as 'reject'
                            bci.CommentApproved         = false;
                            bci.CommentApprovedByUserID = 0;
                            BlogCommentInfoProvider.SetBlogCommentInfo(bci);
                        }
                        break;

                    case "spam":
                        if (!bci.CommentIsSpam)
                        {
                            bci.CommentIsSpam = true;
                            BlogCommentInfoProvider.SetBlogCommentInfo(bci);
                        }
                        break;

                    case "nospam":
                        if (bci.CommentIsSpam)
                        {
                            bci.CommentIsSpam = false;
                            BlogCommentInfoProvider.SetBlogCommentInfo(bci);
                        }
                        break;
                    }
                }
            }
        }

        // Clear selection
        gridComments.ResetSelection();

        ReloadData();
    }
Exemplo n.º 5
0
    private void mBlogComment_OnCommentAction(string actionName, object actionArgument)
    {
        // Get comment ID
        int             commentId = ValidationHelper.GetInteger(actionArgument, 0);
        BlogCommentInfo bci;

        switch (actionName.ToLowerCSafe())
        {
        case "delete":
            // Check 'Manage' permission
            if (!isUserAuthorized)
            {
                AccessDenied("cms.blog", "Manage");
            }

            // Delete comment
            BlogCommentInfoProvider.DeleteBlogCommentInfo(commentId);

            ReloadData();

            break;

        case "approve":
            // Check 'Manage' permission
            if (!isUserAuthorized)
            {
                AccessDenied("cms.blog", "Manage");
            }

            // Set comment as 'approved'
            bci = BlogCommentInfoProvider.GetBlogCommentInfo(commentId);
            var currentUser = MembershipContext.AuthenticatedUser;

            if ((bci != null) && (currentUser != null))
            {
                bci.CommentApprovedByUserID = currentUser.UserID;
                bci.CommentApproved         = true;
                BlogCommentInfoProvider.SetBlogCommentInfo(bci);
            }

            ReloadData();
            break;

        case "reject":
            // Check 'Manage' permission
            if (!isUserAuthorized)
            {
                AccessDenied("cms.blog", "Manage");
            }

            // Set comment as 'rejected'
            bci = BlogCommentInfoProvider.GetBlogCommentInfo(commentId);
            if (bci != null)
            {
                bci.CommentApprovedByUserID = 0;
                bci.CommentApproved         = false;
                BlogCommentInfoProvider.SetBlogCommentInfo(bci);
            }

            ReloadData();
            break;
        }
    }