void TopicSolved(object sender, ActionEventArgs e) { var ts = new TopicService(ApplicationContext.Current.DatabaseContext); var cs = new CommentService(ApplicationContext.Current.DatabaseContext, ts); Action a = (Action)sender; if (a.Alias == "TopicSolved") { var c = cs.GetById(e.ItemId); if (c != null) { var t = ts.GetById(c.TopicId); //if performer and author of the topic is the same... go ahead.. if ((e.PerformerId == t.MemberId || ModeratorRoles.Split(',').Any(x => Roles.IsUserInRole(x))) && t.Answer == 0) { //receiver of points is the comment author. e.ReceiverId = c.MemberId; //remove any previous votes by the author on this comment to ensure the solution is saved instead of just the vote a.ClearVotes(e.PerformerId, e.ItemId); //this uses a non-standard coloumn in the forum schema, so this is added manually.. t.Answer = c.Id; ts.Save(t); } } } }
void CommentVote(object sender, ActionEventArgs e) { Action a = (Action)sender; var ts = new TopicService(ApplicationContext.Current.DatabaseContext); var cs = new CommentService(ApplicationContext.Current.DatabaseContext, ts); if (a.Alias == "LikeComment" || a.Alias == "DisLikeComment") { var c = cs.GetById(e.ItemId); if (c != null) { e.ReceiverId = c.MemberId; } } else if (a.Alias == "TopicSolved") { var c = cs.GetById(e.ItemId); var t = ts.GetById(c.TopicId); e.Cancel = t.Answer > 0; } }
public void Flag(Flag flag) { var post = string.Format("A {0} has been flagged as spam for a moderator to check\n", flag.TypeOfPost); var member = Members.GetById(flag.MemberId); post = post + string.Format("Flagged by member {0} https://our.umbraco.org/member/{1}\n", member.Name, member.Id); var topicId = flag.Id; var posterId = 0; var ts = new TopicService(ApplicationContext.Current.DatabaseContext); if (flag.TypeOfPost == "comment") { var cs = new CommentService(ApplicationContext.Current.DatabaseContext, ts); var comment = cs.GetById(flag.Id); topicId = comment.TopicId; posterId = comment.MemberId; } var topic = ts.GetById(topicId); if (flag.TypeOfPost == "thread") { posterId = topic.MemberId; } post = post + string.Format("Topic title: *{0}*\nLink to author: http://our.umbraco.org/member/{1}\n Link to {2}: http://our.umbraco.org{3}{4}\n\n", topic.Title, posterId, flag.TypeOfPost, topic.GetUrl(), flag.TypeOfPost == "comment" ? "#comment-" + flag.Id : string.Empty); SendSlackNotification(post); }