Esempio n. 1
0
        public CommentTest()
        {
            LoginTest login = new LoginTest();
            AddDependentObject(login);

            mComment = new Comment();
            mComment.IpAddress = "127.0.0.1";
            mComment.Created = mComment.Modified = DateTime.UtcNow;
            mComment.Text = Guid.NewGuid().ToString(); ;
            mComment.OwnerLogin = login.Login;
        }
Esempio n. 2
0
        public static bool HasAccess(ISession session, DBlog.Data.Comment comment, string ticket)
        {
            if (comment.PostComments == null || comment.PostComments.Count == 0)
            {
                return(true);
            }

            foreach (PostComment pi in comment.PostComments)
            {
                if (TransitPost.GetAccess(session, pi.Post, ticket))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 3
0
        public TransitComment(ISession session, DBlog.Data.Comment o, bool hasaccess)
            : base(o.Id)
        {
            if (hasaccess)
            {
                Text         = o.Text;
                IpAddress    = o.IpAddress;
                LoginName    = o.OwnerLogin.Name;
                LoginWebsite = o.OwnerLogin.Website;
            }

            LoginId = o.OwnerLogin.Id;

            ParentCommentId = (o.Threads != null && o.Threads.Count > 0) ?
                              ((Thread)o.Threads[0]).ParentComment.Id : 0;

            Created  = o.Created;
            Modified = o.Modified;
        }
Esempio n. 4
0
        public TransitAssociatedComment(ISession session, int id, DBlog.Data.Comment o, bool hasaccess)
            : base(id)
        {
            AssociatedId = id;
            CommentId    = o.Id;

            if (hasaccess)
            {
                CommentIpAddress = o.IpAddress;
                CommentText      = o.Text;
                if (o.OwnerLogin != null)
                {
                    CommentLoginName    = o.OwnerLogin.Name;
                    CommentLoginWebsite = o.OwnerLogin.Website;
                }
                CommentCreated  = o.Created;
                CommentModified = o.Modified;
                CommentLevel    = GetLevel(o);
            }
        }
Esempio n. 5
0
        public static int GetLevel(Comment comment)
        {
            int result = 0;
            do
            {
                if (comment.Threads == null)
                    break;

                if (comment.Threads.Count == 0)
                    break;

                result++;

                comment = ((Thread)comment.Threads[0]).ParentComment;
            }
            while (comment != null);

            return result;
        }
Esempio n. 6
0
 public TransitComment(ISession session, DBlog.Data.Comment o, string ticket)
     : this(session, o, HasAccess(session, o, ticket))
 {
 }
Esempio n. 7
0
 public TransitAssociatedComment(ISession session, int id, DBlog.Data.Comment o)
     : this(session, id, o, true)
 {
 }