Пример #1
0
    protected void BtnActionClick(object sender, EventArgs e)
    {
        if (BlogSettings.Instance.EnableCommentsModeration &&
            BlogSettings.Instance.IsCommentsEnabled)
        {
            bool found = false;
            foreach (Post p in Post.Posts.ToArray())
            {
                foreach (Comment c in p.Comments.ToArray())
                {
                    if (c.Id.ToString() == _id)
                    {
                        string desc = p.Description;
                        p.Description = (desc ?? string.Empty) + " ";
                        p.Description = desc;

                        if (_urlReferrer.Contains("/Comments/Default.aspx"))
                        {
                            c.IsApproved = BlogSettings.Instance.ModerationType != BlogSettings.Moderation.Auto;
                        }

                        if (_urlReferrer.Contains("/Comments/Approved.aspx"))
                        {
                            c.IsApproved = false;
                        }

                        if (_urlReferrer.Contains("/Comments/Spam.aspx"))
                        {
                            c.IsApproved = true;
                        }

                        // moderator should match anti-spam service
                        if (BlogSettings.Instance.ModerationType == BlogSettings.Moderation.Auto)
                        {
                            CommentHandlers.ReportMistake(c);
                        }

                        // now moderator can be set to admin role
                        c.ModeratedBy = HttpContext.Current.User.Identity.Name;

                        p.Save();
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    break;
                }
            }
        }

        Reload();
    }
Пример #2
0
    protected void ReportAndUpdate(Comment comment)
    {
        // moderator should match anti-spam service
        if (BlogSettings.Instance.ModerationType == 1)
        {
            CommentHandlers.ReportMistake(comment);
        }

        // now moderator can be set to logged in user
        comment.ModeratedBy = HttpContext.Current.User.Identity.Name;
        UpdateComment(comment);
    }
Пример #3
0
        public JsonResponse Approve(string[] vals)
        {
            this.response.Success = false;

            if (!Security.IsAuthorizedTo(Rights.ModerateComments))
            {
                response.Message = Resources.labels.notAuthorized;
                return(response);
            }

            if (string.IsNullOrEmpty(vals[0]))
            {
                return(response);
            }

            try
            {
                foreach (var p in Post.Posts.ToArray())
                {
                    foreach (var c in from c in p.Comments.ToArray() from t in vals where c.Id == new Guid(t) select c)
                    {
                        if (BlogSettings.Instance.AddIpToWhitelistFilterOnApproval)
                        {
                            CommentHandlers.AddIpToFilter(c.IP, false);
                        }

                        CommentHandlers.ReportMistake(c);

                        c.ModeratedBy = Security.CurrentUser.Identity.Name;
                        p.ApproveComment(c);
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.Log("Api.Comments.Approve", ex);
                response.Message = string.Format(Resources.labels.errorApprovingComment, vals[0]);
                return(response);
            }

            response.Success = true;
            response.Message = Resources.labels.selectedCommentRestored;
            return(response);
        }
Пример #4
0
 protected void btnAllowIP_Click(object sender, EventArgs e)
 {
     CommentHandlers.AddIpToFilter(CurrentComment.IP, false, true);
 }
Пример #5
0
 protected void RejectComment(Comment comment)
 {
     comment.IsApproved = false;
     CommentHandlers.AddIpToFilter(comment.IP, true, true);
     ReportAndUpdate(comment);
 }
Пример #6
0
 protected void ApproveComment(Comment comment)
 {
     comment.IsApproved = true;
     CommentHandlers.AddIpToFilter(comment.IP, false, false);
     ReportAndUpdate(comment);
 }