From 44bac7dea1698d38b0c2fbe2814ce588fc4180d1 Mon Sep 17 00:00:00 2001 From: hydrox Date: Fri, 1 Jun 2007 06:02:55 +0000 Subject: [PATCH] *) blog-comments can now be moderated git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3778 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Blog.html | 1 + htroot/BlogComments.html | 2 +- htroot/BlogComments.java | 18 +++++++++++++++++- source/de/anomic/data/blogBoardComments.java | 10 ++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/htroot/Blog.html b/htroot/Blog.html index e6dad42a1..4a5b4fe50 100644 --- a/htroot/Blog.html +++ b/htroot/Blog.html @@ -49,6 +49,7 @@ diff --git a/htroot/BlogComments.html b/htroot/BlogComments.html index 81c08b2e4..a3fd78e25 100644 --- a/htroot/BlogComments.html +++ b/htroot/BlogComments.html @@ -24,7 +24,7 @@
#[page]#

#[date]# | by #[author]# - #(admin)#::| delete#(/admin)# + #(admin)#::| delete #(moderate)#::| allow#(/moderate)##(/admin)#

#{/entries}# diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java index 5f3c2bd5a..1f84494e4 100644 --- a/htroot/BlogComments.java +++ b/htroot/BlogComments.java @@ -193,7 +193,13 @@ public class BlogComments { } } - if(post.containsKey("preview")) { + if(hasRights && post.containsKey("allow") && post.containsKey("page") && post.containsKey("comment")) { + blogBoardComments.CommentEntry entry = switchboard.blogCommentDB.read((String) post.get("comment")); + entry.allow(); + switchboard.blogCommentDB.write(entry); + } + + if(post.containsKey("preview")) { //preview the page prop.put("mode", 1);//preview prop.put("mode_pageid", pagename); @@ -240,6 +246,7 @@ public class BlogComments { //show all commments try { Iterator i = page.comments().iterator(); + int commentMode = page.getCommentMode(); String pageid; blogBoardComments.CommentEntry entry; boolean xml = false; @@ -258,6 +265,9 @@ public class BlogComments { continue; entry = switchboard.blogCommentDB.read(pageid); + if (commentMode == 2 && !hasRights && !entry.isAllowed()) + continue; + prop.put("mode", 0); prop.put("mode_entries_"+count+"_pageid",entry.key()); if(!xml) { @@ -277,6 +287,12 @@ public class BlogComments { prop.put("mode_entries_"+count+"_admin", 1); prop.put("mode_entries_"+count+"_admin_pageid",page.key()); prop.put("mode_entries_"+count+"_admin_commentid",pageid); + if(!entry.isAllowed()) { + prop.put("mode_entries_"+count+"_admin_moderate", 1); + prop.put("mode_entries_"+count+"_admin_moderate_pageid",page.key()); + prop.put("mode_entries_"+count+"_admin_moderate_commentid",pageid); + + } } else prop.put("mode_entries_"+count+"_admin", 0); ++count; diff --git a/source/de/anomic/data/blogBoardComments.java b/source/de/anomic/data/blogBoardComments.java index defcc7fb4..3629341ac 100644 --- a/source/de/anomic/data/blogBoardComments.java +++ b/source/de/anomic/data/blogBoardComments.java @@ -209,6 +209,16 @@ public class blogBoardComments { return b; } + public boolean isAllowed() { + Boolean moderated = (Boolean) record.get("moderated"); + if (moderated == null) return false; + return moderated.booleanValue(); + } + + public void allow() { + record.put("moderated", new Boolean(true)); + } + } public String write(CommentEntry page) {