GetAllCommentsForMember() public method

Returns all comments that a given member has created
public GetAllCommentsForMember ( int memberId ) : IEnumerable
memberId int
return IEnumerable
Esempio n. 1
0
        private static bool NewAndPostsALot(IMember member)
        {
            var ts = new TopicService(ApplicationContext.Current.DatabaseContext);
            var topics = ts.GetAuthorLatestTopics(member.Id);
            var topicsInHourAfterSignup = new List<ReadOnlyTopic>();
            var topicsInFirstDayAfterSignup = new List<ReadOnlyTopic>();

            foreach (var topic in topics)
            {
                if((topic.Created - member.CreateDate).Hours <= 1)
                    topicsInHourAfterSignup.Add(topic);

                if ((topic.Created - member.CreateDate).Days <= 1)
                    topicsInFirstDayAfterSignup.Add(topic);
            }

            if (topicsInHourAfterSignup.Count >= 3)
                return true;

            if (topicsInFirstDayAfterSignup.Count >= 5)
                return true;

            var cs = new CommentService(ApplicationContext.Current.DatabaseContext, ts);
            var comments = cs.GetAllCommentsForMember(member.Id);

            var commentsInHourAfterSignup = new List<Comment>();
            var commentsInFirstDayAfterSignup = new List<Comment>();

            foreach (var comment in comments)
            {
                if ((comment.Created - member.CreateDate).Hours <= 1)
                    commentsInHourAfterSignup.Add(comment);

                if ((comment.Created - member.CreateDate).Days <= 1)
                    commentsInFirstDayAfterSignup.Add(comment);
            }

            if (commentsInHourAfterSignup.Count >= 3)
                return true;

            if (commentsInFirstDayAfterSignup.Count >= 5)
                return true;

            return false;
        }
Esempio n. 2
0
        public void DeleteMemberPlus(int id)
        {
            if (Members.IsHq() == false)
                throw new Exception("You cannot delete this member");

            var memberService = UmbracoContext.Application.Services.MemberService;
            var member = memberService.GetById(id);

            if (member == null)
                throw new Exception("Member not found");

            var topicService = new TopicService(ApplicationContext.Current.DatabaseContext);
            var commentService = new CommentService(ApplicationContext.Current.DatabaseContext, topicService);
            var comments = commentService.GetAllCommentsForMember(member.Id);
            foreach (var comment in comments)
            {
                commentService.Delete(comment);
            }

            var topics = topicService.GetLatestTopicsForMember(member.Id, false, 100);
            foreach (var topic in topics)
            {
                // Only delete if this member started the topic
                if(topic.MemberId == member.Id)
                    topicService.Delete(topic);
            }

            memberService.Delete(member);
        }
Esempio n. 3
0
        public int ApproveMember(int id)
        {
            if (Members.IsAdmin() == false)
                throw new Exception("You cannot approve this member");

            var memberService = UmbracoContext.Application.Services.MemberService;
            var member = memberService.GetById(id);

            if (member == null)
                throw new Exception("Member not found");

            var minimumKarma = 71;
            if (member.GetValue<int>("reputationCurrent") < minimumKarma)
            {
                member.SetValue("reputationCurrent", minimumKarma);
                member.SetValue("reputationTotal", minimumKarma);
                memberService.Save(member);
            }

            var rolesForUser = Roles.GetRolesForUser(member.Username);
            if(rolesForUser.Contains("potentialspam"))
                memberService.DissociateRole(member.Id, "potentialspam");
            if(rolesForUser.Contains("newaccount"))
                memberService.DissociateRole(member.Id, "newaccount");

            var topicService = new TopicService(ApplicationContext.Current.DatabaseContext);
            var commentService = new CommentService(ApplicationContext.Current.DatabaseContext, topicService);
            var comments = commentService.GetAllCommentsForMember(member.Id);
            foreach (var comment in comments)
            {
                if (comment.IsSpam)
                {
                    comment.IsSpam = false;
                    commentService.Save(comment);
                }
            }

            var topics = topicService.GetLatestTopicsForMember(member.Id, false, 100);
            foreach (var topic in topics)
            {
                if (topic.IsSpam)
                {
                    topic.IsSpam = false;
                    topicService.Save(topic);
                }
            }

            return minimumKarma;
        }
Esempio n. 4
0
        public int ApproveMember(int id)
        {
            if (Members.IsAdmin() == false)
                throw new Exception("You cannot approve this member");

            var memberService = UmbracoContext.Application.Services.MemberService;
            var member = memberService.GetById(id);

            if (member == null)
                throw new Exception("Member not found");

            var minimumKarma = 71;
            if (member.GetValue<int>("reputationCurrent") < minimumKarma)
            {
                member.SetValue("reputationCurrent", minimumKarma);
                member.SetValue("reputationTotal", minimumKarma);
                memberService.Save(member);
            }

            var rolesForUser = Roles.GetRolesForUser(member.Username);
            if(rolesForUser.Contains("potentialspam"))
                memberService.DissociateRole(member.Id, "potentialspam");
            if(rolesForUser.Contains("newaccount"))
                memberService.DissociateRole(member.Id, "newaccount");

            var topicService = new TopicService(ApplicationContext.Current.DatabaseContext);
            var commentService = new CommentService(ApplicationContext.Current.DatabaseContext, topicService);
            var comments = commentService.GetAllCommentsForMember(member.Id);
            foreach (var comment in comments)
            {
                if (comment.IsSpam)
                {
                    comment.IsSpam = false;
                    commentService.Save(comment);
                    var topic = topicService.GetById(comment.TopicId);
                    var topicUrl = topic.GetUrl();
                    var commentUrl = string.Format("{0}#comment-{1}", topicUrl, comment.Id);
                    var memberName = member.Name;
                    commentService.SendNotifications(comment, memberName, commentUrl);
                }
            }

            var topics = topicService.GetLatestTopicsForMember(member.Id, false, 100);
            foreach (var topic in topics)
            {
                if (topic.IsSpam)
                {
                    topic.IsSpam = false;
                    topicService.Save(topic);
                    topicService.SendNotifications(topic, member.Name, topic.GetUrl());
                }
            }

            var newForumTopicNotification = new NotificationsCore.Notifications.AccountApproved();
            newForumTopicNotification.SendNotification(member.Email);

            SendSlackNotification(BuildBlockedNotifactionPost(Members.GetCurrentMember().Name, member.Id, false));

            return minimumKarma;
        }