protected string GetCommentsList()
        {
            string             commentList   = "";
            string             commentHeader = "";
            string             commentFooter = "";
            List <JsonComment> jsonComments;

            if (BlogSettings.Instance.EnableCommentsModeration)
            {
                jsonComments   = JsonComments.GetComments(CommentType.Pending, 10, 1);
                commentHeader  = "<h2>" + Resources.labels.recentPendingComments + "</h2>";
                commentFooter += "<a class=\"viewAction\" href=\"Comments/Pending.aspx\">View all pending comments</a>";
            }
            else
            {
                commentHeader  = "<h2>" + Resources.labels.recentComments + "</h2>";
                jsonComments   = JsonComments.GetComments(CommentType.Approved, 10, 1);
                commentFooter += "<a class=\"viewAction\" href=\"Comments/Approved.aspx\">View all comments</a>";
            }

            if (jsonComments.Count > 0)
            {
                commentList += "<ul>";
                commentList  = jsonComments.Aggregate(commentList, (current, jc) => current + string.Format("<li>{0}<span class='teaser'>{1}</span></li>", jc.Title, jc.Teaser));
                commentList += "</ul>";
                commentList += commentFooter;
            }
            return(commentHeader + commentList);
        }
예제 #2
0
        public static IEnumerable LoadComments(int page)
        {
            WebUtils.CheckRightsForAdminCommentsPages(false);

            var commentList = JsonComments.GetComments(CommentType.Approved, page);

            CommentCounter = commentList.Count;
            return(commentList);
        }
예제 #3
0
        public static IEnumerable LoadComments(int page)
        {
            Security.DemandUserHasRight(BlogEngine.Core.Rights.AccessAdminPages, true);

            var commentList = JsonComments.GetComments(CommentType.Pingback, page);

            CommentCounter = commentList.Count;
            return(commentList);
        }
예제 #4
0
        public List <JsonComment> GetComments(CommentType commentType, int pageSize, int page)
        {
            try
            {
                Rights right;
                switch (commentType)
                {
                case CommentType.Approved:
                    right = Rights.ViewPublicComments;
                    break;

                case CommentType.Pending:
                    right = Rights.ViewUnmoderatedComments;
                    break;

                case CommentType.Pingback:
                    right = Rights.ViewPublicComments;
                    break;

                case CommentType.Spam:
                    right = Rights.ModerateComments;
                    break;

                default:
                    throw new Exception("Cannot determine comment type.");
                }

                if (!Security.IsAuthorizedTo(right))
                {
                    throw new UnauthorizedAccessException();
                }

                return(JsonComments.GetComments(commentType, pageSize, page));
            }
            catch (Exception ex)
            {
                Utils.Log("Api.Comments.GetComments", ex);
                throw new Exception("Error on Api.Comments.GetComments.  Check the log for more info.");
            }
        }