Esempio n. 1
0
        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);
                    }
                }
            }
        }
Esempio n. 2
0
        void Action_BeforePerform(object sender, ActionEventArgs e)
        {
            Action a = (Action)sender;

            if (a.Alias == "ExternalVote")
            {
                var memberId = OurUmbraco.Powers.BusinessLogic.Data.SqlHelper.ExecuteScalar <int>("SELECT memberId FROM externalUrls WHERE (@id = id)", OurUmbraco.Powers.BusinessLogic.Data.SqlHelper.CreateParameter("@id", e.ItemId));
                e.ReceiverId = memberId;
            }
        }
Esempio n. 3
0
        void TopicVote(object sender, ActionEventArgs e)
        {
            var ts = new TopicService(ApplicationContext.Current.DatabaseContext);

            Action a = (Action)sender;

            if (a.Alias == "LikeTopic" || a.Alias == "DisLikeTopic")
            {
                var t = ts.GetById(e.ItemId);
                e.ReceiverId = t.MemberId;
            }
        }
Esempio n. 4
0
        void CommentScoring(object sender, ActionEventArgs e)
        {
            Action a = (Action)sender;

            if (a.Alias == "LikeComment" || a.Alias == "DisLikeComment" || a.Alias == "TopicSolved")
            {
                int score = Xslt.Score(e.ItemId, a.DataBaseTable);

                //we then add the sum of the total score to the
                Data.SqlHelper.ExecuteNonQuery("UPDATE forumComments SET score = @score WHERE id = @id", Data.SqlHelper.CreateParameter("@id", e.ItemId), Data.SqlHelper.CreateParameter("@score", score));
            }
        }
Esempio n. 5
0
        void TopicService_Created(object sender, TopicEventArgs e)
        {
            if (e.Topic != null && e.Topic.MemberId > 0)
            {
                var ms = ApplicationContext.Current.Services.MemberService;
                var member = ms.GetById(e.Topic.MemberId);
                member.IncreaseForumPostCount();
                ms.Save(member);

                Action a = new Action("NewTopic");
                a.Perform(member.Id, e.Topic.Id, "New topic created");
            }
        }
Esempio n. 6
0
        void CommentService_Created(object sender, CommentEventArgs e)
        {
            if (e.Comment != null && e.Comment.MemberId > 0)
            {
                var ms = ApplicationContext.Current.Services.MemberService;
                var member = ms.GetById(e.Comment.MemberId);
                member.IncreaseForumPostCount();
                ms.Save(member);

                Action a = new Action("NewComment");
                a.Perform(member.Id, e.Comment.Id, "New comment created");
            }
        }
Esempio n. 7
0
        void ProjectVote(object sender, ActionEventArgs e)
        {
            Action a = (Action)sender;

            if (a.Alias == "ProjectUp" || a.Alias == "ProjectDown")
            {
                var contentService = ApplicationContext.Current.Services.ContentService;
                var content        = contentService.GetById(e.ItemId);

                e.ReceiverId = content.GetValue <int>("owner");

                e.ExtraReceivers = Utils.GetProjectContributors(content.Id);
            }
        }
Esempio n. 8
0
        void TopicScoring(object sender, ActionEventArgs e)
        {
            if (!e.Cancel)
            {
                Action a = (Action)sender;

                if (a.Alias == "LikeTopic" || a.Alias == "DisLikeTopic")
                {
                    int topicScore = Xslt.Score(e.ItemId, a.DataBaseTable);

                    //this uses a non-standard coloumn in the forum schema, so this is added manually..
                    Data.SqlHelper.ExecuteNonQuery("UPDATE forumTopics SET score = @score WHERE id = @id", Data.SqlHelper.CreateParameter("@id", e.ItemId), Data.SqlHelper.CreateParameter("@score", topicScore));
                }
            }
        }
Esempio n. 9
0
        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;
                }
            }
        }
Esempio n. 10
0
        void Action_AfterPerform(object sender, ActionEventArgs e)
        {
            Action a = (Action)sender;

            if (a.Alias == "ProjectUp")
            {
                var contentService = ApplicationContext.Current.Services.ContentService;
                var content        = contentService.GetById(e.ItemId);
                if (content.GetValue <bool>("approved") == false &&
                    Xslt.Score(content.Id, "powersProject") >= 15)
                {
                    content.SetValue("approved", true);
                    contentService.SaveAndPublishWithStatus(content);
                }
            }
        }