protected void grdContact_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     int id = Convert.ToInt32(commentsGrid.DataKeys[e.RowIndex].Values[0].ToString());
     var comment = new Comment(id);
     comment.Delete();
     FillGrid();
 }
Beispiel #2
0
        public static XPathNodeIterator Comment(int commentID)
        {
            XmlDocument xd = new XmlDocument();
            Businesslogic.Comment c = new uForum.Businesslogic.Comment(commentID);

            return c.ToXml(xd).CreateNavigator().Select(".");
        }
        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 = new Topic(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 #4
0
        public static XPathNodeIterator Comment(int commentID)
        {
            XmlDocument xd = new XmlDocument();

            Businesslogic.Comment c = new uForum.Businesslogic.Comment(commentID);

            return(c.ToXml(xd).CreateNavigator().Select("."));
        }
Beispiel #5
0
        public static int CommentPageNumber(int commentId, int itemsPerPage)
        {
            Businesslogic.Comment c = new uForum.Businesslogic.Comment(commentId);

            int position = c.Position - 1;

            return((int)(position / itemsPerPage));
        }
Beispiel #6
0
        public static int CommentPageNumber(int commentId, int itemsPerPage)
        {
            Businesslogic.Comment c = new uForum.Businesslogic.Comment(commentId);

                int position = c.Position - 1;

                return (int)(position / itemsPerPage);
        }
Beispiel #7
0
        public static bool CanSeeComment(int commentId)
        {
            var comment = new Comment(commentId);
            if(comment.IsSpam == false)
                return true;

            var currentMember = Member.GetCurrentMember();

            if(currentMember != null && comment.IsSpam)
                if(IsModerator() || comment.MemberId == currentMember.Id)
                    return true;

            return false;
        }
Beispiel #8
0
        private static string NiceCommentUrl(int topicId, Comment c, int itemsPerPage)
        {
            string url = uForum.Library.Xslt.NiceTopicUrl(topicId);
            if (!string.IsNullOrEmpty(url))
            {

                int position = c.Position - 1;

                int page = (int)(position / itemsPerPage);

                url += "?p=" + page.ToString() + "#comment" + c.Id.ToString();
            }

            return url;
        }
Beispiel #9
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 #10
0
        public static string NiceCommentUrl(int topicId, int commentId, int itemsPerPage)
        {
            string url = NiceTopicUrl(topicId);

            if (!string.IsNullOrEmpty(url))
            {
                Businesslogic.Comment c = new uForum.Businesslogic.Comment(commentId);

                int position = c.Position - 1;

                int page = (int)(position / itemsPerPage);


                url += "?p=" + page.ToString() + "#comment" + c.Id.ToString();
            }

            return(url);
        }
Beispiel #11
0
        public List<Comment> Comments()
        {
            var comments = new List<Comment>();

            try
            {
                using (var dr = Data.SqlHelper.ExecuteReader("SELECT * FROM forumComments WHERE topicId = @topicId", Data.SqlHelper.CreateParameter("@id", Id.ToString(CultureInfo.InvariantCulture))))
                {
                    while (dr.Read())
                    {
                        var comment = new Comment
                                          {
                                              Id = dr.GetInt("id"),
                                              TopicId = dr.GetInt("topicId"),
                                              MemberId = dr.GetInt("memberId"),
                                              Body = dr.GetString("body"),
                                              Created = dr.GetDateTime("created")
                                          };

                        comments.Add(comment);
                    }
                }
            }
            catch (Exception ex)
            {
                umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString());
            }

            return comments;
        }
Beispiel #12
0
        public static Comment Create(int topicId, string body, int memberId)
        {
            Comment c = new Comment();
            c.TopicId = topicId;
            c.Body = body;
            c.MemberId = memberId;
            c.Created = DateTime.Now;
            c.Position = (Topic.GetTopic(topicId).Replies) + 1;
            c.Exists = true;
            c.Save();

            return c;
        }
Beispiel #13
0
        public static string NiceCommentUrl(int topicId, int commentId, int itemsPerPage)
        {
            string url = NiceTopicUrl(topicId);
            if (!string.IsNullOrEmpty(url)) {
                Businesslogic.Comment c = new uForum.Businesslogic.Comment(commentId);

                int position = c.Position - 1;

                int page = (int)(position / itemsPerPage);

                url += "?p=" + page.ToString() + "#comment" + c.Id.ToString();
            }

            return url;
        }
Beispiel #14
0
        public static Comment GetComment(int id, bool getSpamComment)
        {
            var query = string.Format("SELECT * FROM forumComments WHERE {0} id = {1}", getSpamComment ? "" : " (forumComments.isSpam IS NULL OR forumComments.isSpam != 1) AND ", id);

            var comment = new Comment();

            using (var dr = Data.SqlHelper.ExecuteReader(query))
            {
                if (dr.Read())
                {
                    comment.Id = dr.GetInt("id");
                    comment.TopicId = dr.GetInt("topicId");
                    comment.MemberId = dr.GetInt("memberId");
                    comment.Exists = true;
                    comment.Body = dr.GetString("body");
                    if (dr.IsNull("isSpam") == false)
                        comment.IsSpam = dr.GetBoolean("isSpam");

                    comment.Created = dr.GetDateTime("created");
                    comment.Position = dr.GetInt("position");
                }
                else
                {
                    comment.Exists = false;
                }
            }

            return comment;
        }
Beispiel #15
0
        public List<Comment> Comments()
        {
            List<Comment> lc = new List<Comment>();

            umbraco.DataLayer.IRecordsReader dr = Data.SqlHelper.ExecuteReader(
                "SELECT * FROM forumComments WHERE topicId = " + Id.ToString()
            );

            try {
                //Sql effiecient way of fetching collection of comments instead of one by one..
                while (dr.Read()) {
                    Comment c = new Comment();
                    c.Id = dr.GetInt("id");
                    c.TopicId = dr.GetInt("topicId");
                    c.MemberId = dr.GetInt("memberId");

                    c.Body = dr.GetString("body");

                    c.Created = dr.GetDateTime("created");

                    lc.Add(c);
                }
            } catch (Exception ex) {
                umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString());
            }

            dr.Close();
            dr.Dispose();

            return lc;
        }