public static JsonComment SaveComment(string[] vals) { WebUtils.CheckRightsForAdminCommentsPages(false); var gId = new Guid(vals[0]); string author = vals[1]; string email = vals[2]; string website = vals[3]; string cont = vals[4]; foreach (Post p in Post.Posts.ToArray()) { foreach (Comment c in p.Comments.ToArray()) { if (c.Id == gId) { c.Author = author; c.Email = email; c.Website = string.IsNullOrEmpty(website) ? null : new Uri(website); c.Content = cont; // need to mark post as "dirty" p.DateModified = DateTime.Now; p.Save(); return(JsonComments.GetComment(gId)); } } } return(new JsonComment()); }
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); }
public static JsonComment SaveComment(string id, string author, string email, string website, string cont) { // There really needs to be validation here so people aren't just posting willy-nilly // as anyone they want. if (!Security.IsAuthorizedTo(Rights.CreateComments)) { throw new System.Security.SecurityException("Can not create comment"); } var gId = new Guid(id); var jc = new JsonComment(); foreach (var p in Post.Posts.ToArray()) { foreach (var c in p.Comments.Where(c => c.Id == gId).ToArray()) { c.Author = author; c.Email = email; c.Website = new Uri(website); c.Content = cont; // need to mark post as "dirty" p.DateModified = DateTime.Now; p.Save(); return(JsonComments.GetComment(gId)); } } return(jc); }
public static IEnumerable LoadComments(int page) { WebUtils.CheckRightsForAdminCommentsPages(false); var commentList = JsonComments.GetComments(CommentType.Approved, page); CommentCounter = commentList.Count; return(commentList); }
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); }
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."); } }
public static string LoadPager(int page) { WebUtils.CheckRightsForAdminCommentsPages(false); return(JsonComments.GetPager(page)); }
public static JsonComment GetComment(string id) { WebUtils.CheckRightsForAdminCommentsPages(false); return(JsonComments.GetComment(new Guid(id))); }
public static string LoadPager(int page) { Security.DemandUserHasRight(BlogEngine.Core.Rights.AccessAdminPages, true); return(JsonComments.GetPager(page)); }