Beispiel #1
0
        void TopicSolved(object sender, ActionEventArgs e)
        {
            uPowers.BusinessLogic.Action a = (uPowers.BusinessLogic.Action)sender;

            if (a.Alias == "TopicSolved")
            {
                Comment c = new Comment(e.ItemId);

                if (c != null)
                {
                    Topic t = Topic.GetTopic(c.TopicId);

                    int answer = our.Data.SqlHelper.ExecuteScalar <int>("SELECT answer FROM forumTopics where id = @id", Data.SqlHelper.CreateParameter("@id", t.Id));

                    //if performer and author of the topic is the same... go ahead..

                    if (e.PerformerId == t.MemberId && 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..
                        our.Data.SqlHelper.ExecuteNonQuery("UPDATE forumTopics SET answer = @answer WHERE id = @id", Data.SqlHelper.CreateParameter("@id", t.Id), Data.SqlHelper.CreateParameter("@answer", c.Id));
                    }
                }
            }
        }
Beispiel #2
0
        void TopicVote(object sender, ActionEventArgs e)
        {
            uPowers.BusinessLogic.Action a = (uPowers.BusinessLogic.Action)sender;

            if (a.Alias == "LikeTopic" || a.Alias == "DisLikeTopic")
            {
                Topic t = Topic.GetTopic(e.ItemId);
                e.ReceiverId = t.MemberId;
            }
        }
Beispiel #3
0
        void Action_BeforePerform(object sender, ActionEventArgs e)
        {
            uPowers.BusinessLogic.Action a = (uPowers.BusinessLogic.Action)sender;

            if (a.Alias == "ExternalVote")
            {
                var memberId = uPowers.BusinessLogic.Data.SqlHelper.ExecuteScalar <int>("SELECT memberId FROM externalUrls WHERE (@id = id)", uPowers.BusinessLogic.Data.SqlHelper.CreateParameter("@id", e.ItemId));
                e.ReceiverId = memberId;
            }
        }
Beispiel #4
0
        void CommentScoring(object sender, ActionEventArgs e)
        {
            uPowers.BusinessLogic.Action a = (uPowers.BusinessLogic.Action)sender;

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

                //we then add the sum of the total score to the
                our.Data.SqlHelper.ExecuteNonQuery("UPDATE forumComments SET score = @score WHERE id = @id", Data.SqlHelper.CreateParameter("@id", e.ItemId), Data.SqlHelper.CreateParameter("@score", score));
            }
        }
Beispiel #5
0
        void ProjectVote(object sender, ActionEventArgs e)
        {
            uPowers.BusinessLogic.Action a = (uPowers.BusinessLogic.Action)sender;

            if (a.Alias == "ProjectUp" || a.Alias == "ProjectDown")
            {
                Document d = new Document(e.ItemId);

                e.ReceiverId = (int)d.getProperty("owner").Value;

                e.ExtraReceivers = Utills.GetProjectContributors(d.Id);
            }
        }
Beispiel #6
0
        void TopicScoring(object sender, ActionEventArgs e)
        {
            if (!e.Cancel)
            {
                uPowers.BusinessLogic.Action a = (uPowers.BusinessLogic.Action)sender;

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

                    //this uses a non-standard coloumn in the forum schema, so this is added manually..
                    our.Data.SqlHelper.ExecuteNonQuery("UPDATE forumTopics SET score = @score WHERE id = @id", Data.SqlHelper.CreateParameter("@id", e.ItemId), Data.SqlHelper.CreateParameter("@score", topicScore));
                }
            }
        }
Beispiel #7
0
        void CommentVote(object sender, ActionEventArgs e)
        {
            uPowers.BusinessLogic.Action a = (uPowers.BusinessLogic.Action)sender;

            if (a.Alias == "LikeComment" || a.Alias == "DisLikeComment")
            {
                Comment c = new Comment(e.ItemId);
                if (c != null)
                {
                    e.ReceiverId = c.MemberId;
                }
            }
            else if (a.Alias == "TopicSolved")
            {
                Topic t         = Topic.GetTopic(new Comment(e.ItemId).TopicId);
                bool  hasAnswer = (our.Data.SqlHelper.ExecuteScalar <int>("SELECT answer FROM forumTopics where id = @id", Data.SqlHelper.CreateParameter("@id", t.Id)) > 0);

                e.Cancel = hasAnswer;
            }
        }
Beispiel #8
0
        void Action_AfterPerform(object sender, ActionEventArgs e)
        {
            uPowers.BusinessLogic.Action a = (uPowers.BusinessLogic.Action)sender;

            if (a.Alias == "ProjectUp")
            {
                Document d = new Document(e.ItemId);

                if (d.getProperty("approved").Value != null &&
                    d.getProperty("approved").Value.ToString() != "1" &&
                    uPowers.Library.Xslt.Score(d.Id, "powersProject") >= 15)
                {
                    //set approved flag
                    d.getProperty("approved").Value = true;

                    d.Save();
                    d.Publish(new umbraco.BusinessLogic.User(0));

                    umbraco.library.UpdateDocumentCache(d.Id);
                    umbraco.library.RefreshContent();
                }
            }
        }