From b92a00172e1d1372065922e76ddac8620a6d5004 Mon Sep 17 00:00:00 2001 From: auron_x Date: Fri, 3 Mar 2006 16:47:41 +0000 Subject: [PATCH] *) modified Blog - added delete-option - fixed displaying of admin options git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1805 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Blog.html | 16 +++++++++++++--- htroot/Blog.java | 17 +++++++++++++++++ source/de/anomic/data/blogBoard.java | 7 +++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/htroot/Blog.html b/htroot/Blog.html index ca879e716..decc5eea1 100644 --- a/htroot/Blog.html +++ b/htroot/Blog.html @@ -13,7 +13,7 @@ - +
#[date]#by #[author]#

#[subject]#


#[page]#
link#(admin)#:: - edit#(/admin)#
link#(admin)#:: - edit - delete#(/admin)#

#{/entries}# @@ -27,7 +27,6 @@

Subject:

Text:

- @@ -46,7 +45,6 @@

Subject:

Text:

- @@ -55,6 +53,18 @@

Access denied

To edit or create blog-entries you need to be logged in as Admin or User that has Blog rights. +:: + +

Are you sure...

+... that you want to delete #[subject]# by #[author]#?

+
+ + + +

+
+ +
#(/mode)# #%env/templates/footer.template%# diff --git a/htroot/Blog.java b/htroot/Blog.java index 942429273..58a302226 100644 --- a/htroot/Blog.java +++ b/htroot/Blog.java @@ -53,6 +53,10 @@ public class Blog { author = de.anomic.yacy.yacyCore.seedDB.mySeed.get("Name", "anonymous"); } } + + if(hasRights && post.containsKey("delete") && post.get("delete").equals("sure")) { + switchboard.blogDB.delete(pagename); + } if (post.containsKey("submit") && (hasRights)) { // store a new/edited blog-entry @@ -103,6 +107,15 @@ public class Blog { } else prop.put("mode",3); //access denied (no rights) } + else if(post.containsKey("delete") && post.get("delete").equals("try")) { + if(hasRights) { + prop.put("mode",4); + prop.put("mode_pageid",pagename); + prop.put("mode_author",page.author()); + prop.put("mode_subject",page.subject()); + } + else prop.put("mode",3); //access denied (no rights) + } else { wikiCode wikiTransformer=new wikiCode(switchboard); // show blog-entry/entries @@ -155,6 +168,10 @@ public class Blog { prop.put("mode_entries_0_author", page.author()); prop.put("mode_entries_0_date", dateString(page.date())); prop.put("mode_entries_0_page", wikiTransformer.transform(page.page())); + if(hasRights) { + prop.put("mode_entries_0_admin", 1); + prop.put("mode_entries_0_admin_pageid",page.key()); + } } } diff --git a/source/de/anomic/data/blogBoard.java b/source/de/anomic/data/blogBoard.java index 584af8287..deb9e050f 100644 --- a/source/de/anomic/data/blogBoard.java +++ b/source/de/anomic/data/blogBoard.java @@ -222,6 +222,13 @@ public class blogBoard { } } + public void delete(String key) { + key = normalize(key); + try { + datbase.remove(key); + } catch (IOException e) { } + } + public Iterator keys(boolean up) throws IOException { return datbase.keys(up, false); }