From 0bb2e795a45e1a9dadc5e879d17f081c315991b2 Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Fri, 9 Nov 2001 00:10:36 +0000 Subject: [PATCH] implementation of the "bozo filter" on a topic level, including a topic-level "Manage" screen (to hang "Rename Topic" from later, too). --- setup/database.sql | 18 +- src/com/silverwrist/util/OptionSet.java | 146 +++++++++++++++ .../silverwrist/venice/core/TopicContext.java | 8 + .../core/impl/BackgroundConferencePurge.java | 1 + .../core/impl/TopicUserContextImpl.java | 161 +++++++++++++++- .../venice/servlets/ConfDisplay.java | 11 +- .../venice/servlets/PostOperations.java | 19 ++ .../venice/servlets/TopicOperations.java | 48 ++++- .../venice/servlets/format/ManageTopic.java | 175 ++++++++++++++++++ .../venice/servlets/format/TopicPosts.java | 48 ++++- web/format/manage_topic.jsp | 71 +++++++ web/format/posts.jsp | 59 ++++-- web/images/bn_filter_user.gif | Bin 0 -> 937 bytes 13 files changed, 727 insertions(+), 38 deletions(-) create mode 100644 src/com/silverwrist/util/OptionSet.java create mode 100644 src/com/silverwrist/venice/servlets/format/ManageTopic.java create mode 100644 web/format/manage_topic.jsp create mode 100644 web/images/bn_filter_user.gif diff --git a/setup/database.sql b/setup/database.sql index 087a537..49c65be 100644 --- a/setup/database.sql +++ b/setup/database.sql @@ -306,15 +306,6 @@ CREATE TABLE confhotlist ( INDEX inorder (uid, sequence) ); -# The "bozo filter" list for a conference, for use by users in filtering out -# the rantings of other users who are bozos. -CREATE TABLE confbozo ( - confid INT NOT NULL, - uid INT NOT NULL, - bozo_uid INT NOT NULL, - PRIMARY KEY (confid, uid, bozo_uid) -); - # The table describing topics within a conference. CREATE TABLE topics ( topicid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, @@ -343,6 +334,15 @@ CREATE TABLE topicsettings ( PRIMARY KEY (topicid, uid) ); +# The "bozo filter" list for a topic, for use by users in filtering out +# the rantings of other users who are bozos. +CREATE TABLE topicbozo ( + topicid INT NOT NULL, + uid INT NOT NULL, + bozo_uid INT NOT NULL, + PRIMARY KEY (topicid, uid, bozo_uid) +); + # The "header" for a posted message. CREATE TABLE posts ( postid BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, diff --git a/src/com/silverwrist/util/OptionSet.java b/src/com/silverwrist/util/OptionSet.java new file mode 100644 index 0000000..dd5c093 --- /dev/null +++ b/src/com/silverwrist/util/OptionSet.java @@ -0,0 +1,146 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.util; + +import java.util.BitSet; + +public class OptionSet extends BitSet +{ + /*-------------------------------------------------------------------------------- + * Static data members + *-------------------------------------------------------------------------------- + */ + + private static final String ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + + "!#$%&()*+,-./:;<=>?@[]^_`{|}~"; + + /*-------------------------------------------------------------------------------- + * Constructors + *-------------------------------------------------------------------------------- + */ + + public OptionSet() + { + super(); + + } // end constructor + + public OptionSet(int nbits) + { + super(Math.min(nbits,ALPHA.length())); + + } // end constructor + + public OptionSet(char[] options) + { + super(); // initialize all bits to 0 + for (int i=0; i=0) + super.set(ndx); + + } // end for + + } // end constructor + + public OptionSet(String options) + { + this(options.toCharArray()); + + } // end constructor + + private StringBuffer asStringBuffer() + { + StringBuffer b = new StringBuffer(); + for (int i=0; i=ALPHA.length()) + throw new IndexOutOfBoundsException(); + super.clear(bitIndex); + + } // end clear + + public boolean get(int bitIndex) + { + if (bitIndex>=ALPHA.length()) + throw new IndexOutOfBoundsException(); + return super.get(bitIndex); + + } // end get + + public void set(int bitIndex) + { + if (bitIndex>=ALPHA.length()) + throw new IndexOutOfBoundsException(); + super.set(bitIndex); + + } // end set + + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + + public void assign(char[] options) + { + int i; + for (i=0; i=0) + super.set(ndx); + + } // end for + + } // end assign + + public void assign(String options) + { + assign(options.toCharArray()); + + } // end assign + + public char[] asCharArray() + { + return asStringBuffer().toString().toCharArray(); + + } // end asCharArray + + public String asString() + { + return asStringBuffer().toString(); + + } // end asString + +} // end class OptionSet diff --git a/src/com/silverwrist/venice/core/TopicContext.java b/src/com/silverwrist/venice/core/TopicContext.java index 559c260..bd1cb80 100644 --- a/src/com/silverwrist/venice/core/TopicContext.java +++ b/src/com/silverwrist/venice/core/TopicContext.java @@ -90,5 +90,13 @@ public interface TopicContext public abstract List getActiveReaders() throws DataException, AccessError; + public abstract boolean isBozo(int other_uid) throws DataException; + + public abstract void setBozo(int other_uid, boolean bozo) throws DataException; + + public abstract boolean canSetBozo(int other_uid); + + public abstract List getBozos() throws DataException; + } // end interface TopicContext diff --git a/src/com/silverwrist/venice/core/impl/BackgroundConferencePurge.java b/src/com/silverwrist/venice/core/impl/BackgroundConferencePurge.java index b7c96f1..3450d2e 100644 --- a/src/com/silverwrist/venice/core/impl/BackgroundConferencePurge.java +++ b/src/com/silverwrist/venice/core/impl/BackgroundConferencePurge.java @@ -96,6 +96,7 @@ class BackgroundConferencePurge implements Runnable { // delete the topic header and settings rows first stmt.executeUpdate("DELETE FROM topics WHERE topicid = " + topicids[i] + ";"); stmt.executeUpdate("DELETE FROM topicsettings WHERE topicid = " + topicids[i] + ";"); + stmt.executeUpdate("DELETE FROM topicbozo WHERE topicid = " + topicids[i] + ";"); // figure out how many posts are in this topic and create a BackgroundTopicPurge. sql.setLength(0); diff --git a/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java b/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java index 2a781df..736f002 100644 --- a/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java +++ b/src/com/silverwrist/venice/core/impl/TopicUserContextImpl.java @@ -54,6 +54,7 @@ class TopicUserContextImpl implements TopicContext private boolean hidden; private int unread; private boolean deleted = false; + private HashSet bozo_uids = null; /*-------------------------------------------------------------------------------- * Constructors @@ -99,6 +100,7 @@ class TopicUserContextImpl implements TopicContext this.name = name; this.hidden = false; this.unread = 1; + this.bozo_uids = new HashSet(); // no bozos yet } // end constructor @@ -160,6 +162,18 @@ class TopicUserContextImpl implements TopicContext } // end refresh + private void loadBozo(Connection conn) throws SQLException + { + Statement stmt = conn.createStatement(); + StringBuffer sql = new StringBuffer("SELECT bozo_uid FROM topicbozo WHERE topicid = "); + sql.append(topicid).append(" AND uid = ").append(conf.realUID()).append(';'); + ResultSet rs = stmt.executeQuery(sql.toString()); + bozo_uids = new HashSet(); + while (rs.next()) + bozo_uids.add(new Integer(rs.getInt(1))); + + } // end loadBozo + /*-------------------------------------------------------------------------------- * Implementations from interface TopicContext *-------------------------------------------------------------------------------- @@ -874,7 +888,8 @@ class TopicUserContextImpl implements TopicContext Statement stmt = conn.createStatement(); // lock some tables while we do the critical parts of the delete - stmt.executeUpdate("LOCK TABLES confs WRITE, topics WRITE, topicsettings WRITE, posts READ;"); + stmt.executeUpdate("LOCK TABLES confs WRITE, topics WRITE, topicsettings WRITE, topicbozo WRITE, " + + "posts READ;"); try { // first delete the topic record itself StringBuffer sql = new StringBuffer("DELETE FROM topics WHERE topicid = "); @@ -886,6 +901,11 @@ class TopicUserContextImpl implements TopicContext sql.append("DELETE FROM topicsettings WHERE topicid = ").append(topicid).append(';'); stmt.executeUpdate(sql.toString()); + // and all topicbozo records + sql.setLength(0); + sql.append("DELETE FROM topicbozo WHERE topicid = ").append(topicid).append(';'); + stmt.executeUpdate(sql.toString()); + // and indicate that we updated the conference conf.touchUpdate(conn,new java.util.Date()); @@ -1068,6 +1088,145 @@ class TopicUserContextImpl implements TopicContext } // end getActiveReaders + public boolean isBozo(int other_uid) throws DataException + { + if (deleted || conf.userIsAnonymous() || (other_uid==conf.realUID())) + return false; // no-op + + if (bozo_uids==null) + { // the bozo UIDs need to be loaded! + Connection conn = null; + try + { // load the bozo filter UIDs from the database + conn = datapool.getConnection(); + loadBozo(conn); + + } // end try + catch (SQLException e) + { // this becomes a DataException + logger.error("DB error getting bozo list: " + e.getMessage(),e); + throw new DataException("unable to get bozo filter listing: " + e.getMessage(),e); + + } // end catch + finally + { // make sure we release the connection before we go + if (conn!=null) + datapool.releaseConnection(conn); + + } // end finally + + } // end if + + return bozo_uids.contains(new Integer(other_uid)); + + } // end isBozo + + public void setBozo(int other_uid, boolean bozo) throws DataException + { + if (deleted || conf.userIsAnonymous() || (other_uid==conf.realUID())) + return; // no-op + + Connection conn = null; + try + { // figure out what to do here + conn = datapool.getConnection(); + refresh(conn); + if (deleted) + return; // one more check to make sure we're not deleted + if (bozo_uids==null) + loadBozo(conn); // load the bozo filter if we don't already have it + + Integer uid_key = new Integer(other_uid); + Statement stmt; + StringBuffer sql; + if (bozo) + { // this user is a bozo... + if (!(bozo_uids.contains(uid_key))) + { // add them to the bozo list + sql = new StringBuffer("INSERT INTO topicbozo (topicid, uid, bozo_uid) VALUES ("); + sql.append(topicid).append(", ").append(conf.realUID()).append(", ").append(other_uid).append(");"); + stmt = conn.createStatement(); + stmt.executeUpdate(sql.toString()); + bozo_uids.add(uid_key); + + } // end if + // else this is a no-op + + } // end if + else + { // this user is no longer a bozo + if (bozo_uids.contains(uid_key)) + { // remove them from the bozo list + sql = new StringBuffer("DELETE FROM topicbozo WHERE topicid = "); + sql.append(topicid).append(" AND uid = ").append(conf.realUID()).append(" AND bozo_uid = "); + sql.append(other_uid).append(';'); + stmt = conn.createStatement(); + stmt.executeUpdate(sql.toString()); + bozo_uids.remove(uid_key); + + } // end if + // else this is a no-op + + } // end else + + } // end try + catch (SQLException e) + { // this becomes a DataException + logger.error("DB error updating bozo list: " + e.getMessage(),e); + throw new DataException("unable to update bozo filter list: " + e.getMessage(),e); + + } // end catch + finally + { // make sure we release the connection before we go + if (conn!=null) + datapool.releaseConnection(conn); + + } // end finally + + } // end setBozo + + public boolean canSetBozo(int other_uid) + { + // 1. You can't set bozo filters on a deleted topic. + // 2. You can't set bozo filters if you're the anonymous user. + // 3. You can't bozo-filter yourself, silly. + return !(deleted || conf.userIsAnonymous() || (other_uid==conf.realUID())); + + } // end canSetBozoFilter + + public List getBozos() throws DataException + { + if (deleted || conf.userIsAnonymous()) + return Collections.EMPTY_LIST; // no-op + + if (bozo_uids==null) + { // the bozo UIDs need to be loaded! + Connection conn = null; + try + { // load the bozo filter UIDs from the database + conn = datapool.getConnection(); + loadBozo(conn); + + } // end try + catch (SQLException e) + { // this becomes a DataException + logger.error("DB error getting bozo list: " + e.getMessage(),e); + throw new DataException("unable to get bozo filter listing: " + e.getMessage(),e); + + } // end catch + finally + { // make sure we release the connection before we go + if (conn!=null) + datapool.releaseConnection(conn); + + } // end finally + + } // end if + + return Collections.unmodifiableList(new ArrayList(bozo_uids)); + + } // end getBozos + /*-------------------------------------------------------------------------------- * External operations usable only from within the package *-------------------------------------------------------------------------------- diff --git a/src/com/silverwrist/venice/servlets/ConfDisplay.java b/src/com/silverwrist/venice/servlets/ConfDisplay.java index d9449c4..4a107b9 100644 --- a/src/com/silverwrist/venice/servlets/ConfDisplay.java +++ b/src/com/silverwrist/venice/servlets/ConfDisplay.java @@ -364,12 +364,13 @@ public class ConfDisplay extends VeniceServlet PostInterval piv = getInterval(engine,request,topic,on_error); boolean read_new = do_readnew && !(StringUtil.isStringEmpty(request.getParameter("rnm"))); boolean show_adv = !(StringUtil.isStringEmpty(request.getParameter("shac"))); + boolean no_bozos = !(StringUtil.isStringEmpty(request.getParameter("nbz"))); // Create the post display. - TopicPosts tpos = null; try { // create the display - tpos = new TopicPosts(request,engine,comm,conf,topic,piv.getFirst(),piv.getLast(),read_new,show_adv); + return new TopicPosts(request,engine,comm,conf,topic,piv.getFirst(),piv.getLast(),read_new,show_adv, + no_bozos); } // end try catch (DataException de) @@ -383,8 +384,6 @@ public class ConfDisplay extends VeniceServlet } // end catch - return tpos; - } // end if (messages in a topic) else { // we're displaying the conference's topic list @@ -403,8 +402,6 @@ public class ConfDisplay extends VeniceServlet if (read_new) { // we need to generate a TopicPosts view - TopicPosts tpos = null; - try { // generate a topic list first List topic_list = conf.getTopicList(opts.getViewOption(conf.getConfID()), @@ -433,7 +430,7 @@ public class ConfDisplay extends VeniceServlet PostInterval piv = getInterval(engine,request,topic,on_error); // create the topic posts view - return new TopicPosts(request,engine,comm,conf,topic,piv.getFirst(),piv.getLast(),true,false); + return new TopicPosts(request,engine,comm,conf,topic,piv.getFirst(),piv.getLast(),true,false,false); } // end try catch (DataException de) diff --git a/src/com/silverwrist/venice/servlets/PostOperations.java b/src/com/silverwrist/venice/servlets/PostOperations.java index f6d6a44..17d5e18 100644 --- a/src/com/silverwrist/venice/servlets/PostOperations.java +++ b/src/com/silverwrist/venice/servlets/PostOperations.java @@ -133,6 +133,25 @@ public class PostOperations extends VeniceServlet } // end if ("scribble") + if (cmd.equals("BY") || cmd.equals("BN")) + { // we want to add or remove the bozo filter from the user here + try + { // attempt to set the bozo filter status + topic.setBozo(msg.getCreatorUID(),cmd.equals("BY")); + + // go back and display stuff + throw new RedirectResult(location); + + } // end try + catch (DataException de) + { // there was a database error + return new ErrorBox("Database Error","Database error setting filter status: " + de.getMessage(), + location); + + } // end catch + + } // end if + if (cmd.equals("NUKE")) { // nuking requires confirmation try diff --git a/src/com/silverwrist/venice/servlets/TopicOperations.java b/src/com/silverwrist/venice/servlets/TopicOperations.java index 9539b99..fb9d7c7 100644 --- a/src/com/silverwrist/venice/servlets/TopicOperations.java +++ b/src/com/silverwrist/venice/servlets/TopicOperations.java @@ -183,9 +183,51 @@ public class TopicOperations extends VeniceServlet } // end if (delete) - // unrecognized command - logger.error("invalid command to TopicOperations.doGet: " + cmd); - return new ErrorBox("Internal Error","Invalid command to TopicOperations.doGet",location); + if (cmd.equals("RB")) + { // "RB" = "Remove Bozo" (UID specified as parameter "u") + int uid = -1; + try + { // get the user ID to un-bozo + String foo = request.getParameter("u"); + if (foo!=null) + uid = Integer.parseInt(foo); + + } // end try + catch (NumberFormatException nfe) + { // just don't do anything on error + uid = -1; + + } // end catch + + try + { // remove "bozo" status from this user + if (uid>0) + topic.setBozo(uid,false); + setMyLocation(request,"topicops?" + locator); + return new ManageTopic(user,comm,conf,topic); + + } // end try + catch (DataException de) + { // whoops! this is a problem! + return new ErrorBox("Database Error","Database error removing filtered user: " + de.getMessage(), + "topicops?" + locator); + + } // end catch + + } // end if (remove bozo) + + // unrecognized command - load the "Manage Topic menu" + try + { // return that "Manage Topic" page + setMyLocation(request,"topicops?" + locator); + return new ManageTopic(user,comm,conf,topic); + + } // end try + catch (DataException de) + { // whoops! this is a problem! + return new ErrorBox("Database Error","Database error loading manage page: " + de.getMessage(),location); + + } // end catch } // end doVeniceGet diff --git a/src/com/silverwrist/venice/servlets/format/ManageTopic.java b/src/com/silverwrist/venice/servlets/format/ManageTopic.java new file mode 100644 index 0000000..570d49a --- /dev/null +++ b/src/com/silverwrist/venice/servlets/format/ManageTopic.java @@ -0,0 +1,175 @@ +/* + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at . + * + * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + * WARRANTY OF ANY KIND, either express or implied. See the License for the specific + * language governing rights and limitations under the License. + * + * The Original Code is the Venice Web Communities System. + * + * The Initial Developer of the Original Code is Eric J. Bowersox , + * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.venice.servlets.format; + +import java.util.*; +import javax.servlet.*; +import javax.servlet.http.*; +import com.silverwrist.venice.core.*; + +public class ManageTopic implements JSPRender +{ + /*-------------------------------------------------------------------------------- + * Static data members + *-------------------------------------------------------------------------------- + */ + + // Attribute name for request attribute + protected static final String ATTR_NAME = "com.silverwrist.venice.content.ManageTopic"; + + /*-------------------------------------------------------------------------------- + * Attributes + *-------------------------------------------------------------------------------- + */ + + private CommunityContext comm; // the community we're in + private ConferenceContext conf; // the conference being listed + private TopicContext topic; // the topic being managed + private String locator = null; // the locator we use + private List bozos_list; // the list of "bozo" users + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + public ManageTopic(UserContext user, CommunityContext comm, ConferenceContext conf, TopicContext topic) + throws DataException + { + this.comm = comm; + this.conf = conf; + this.topic = topic; + + // Load up the list of bozos, sorting them in user name order. + List bozo_uids = topic.getBozos(); + if (bozo_uids.size()>0) + { // use a TreeMap to do the sorting + TreeMap load_map = new TreeMap(); + Iterator it = bozo_uids.iterator(); + while (it.hasNext()) + { // fill in the list of user profiles + Integer uid = (Integer)(it.next()); + UserProfile prof = user.getProfile(uid.intValue()); + load_map.put(prof.getUserName(),prof); + + } // end while + + bozos_list = new ArrayList(load_map.values()); + + } // end if + else // no bozos - just set empty list + bozos_list = Collections.EMPTY_LIST; + + } // end constructor + + /*-------------------------------------------------------------------------------- + * External static functions + *-------------------------------------------------------------------------------- + */ + + public static ManageTopic retrieve(ServletRequest request) + { + return (ManageTopic)(request.getAttribute(ATTR_NAME)); + + } // end retrieve + + /*-------------------------------------------------------------------------------- + * Implementations from interface VeniceContent + *-------------------------------------------------------------------------------- + */ + + public String getPageTitle(RenderData rdat) + { + return "Manage Topic: " + topic.getName(); + + } // end getPageTitle + + public String getPageQID() + { + return null; + + } // end getPageQID + + /*-------------------------------------------------------------------------------- + * Implementations from interface JSPRender + *-------------------------------------------------------------------------------- + */ + + public void store(ServletRequest request) + { + request.setAttribute(ATTR_NAME,this); + + } // end store + + public String getTargetJSPName() + { + return "manage_topic.jsp"; + + } // end getTargetJSPName + + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + + public int getCommunityID() + { + return comm.getCommunityID(); + + } // end getCommunityID + + public int getConfID() + { + return conf.getConfID(); + + } // end getConfID + + public int getTopicNumber() + { + return topic.getTopicNumber(); + + } // end getTopicID + + public String getTopicName() + { + return topic.getName(); + + } // end getConfName + + public String getLocator() + { + if (locator==null) + locator = "sig=" + comm.getCommunityID() + "&conf=" + conf.getConfID() + "&top=" + + topic.getTopicNumber(); + return locator; + + } // end getLocator + + public int getNumBozos() + { + return bozos_list.size(); + + } // end getNumBozos() + + public Iterator getBozosIterator() + { + return bozos_list.iterator(); + + } // end getBozosIterator + +} // end class ManageTopic diff --git a/src/com/silverwrist/venice/servlets/format/TopicPosts.java b/src/com/silverwrist/venice/servlets/format/TopicPosts.java index d47f0a3..f484c06 100644 --- a/src/com/silverwrist/venice/servlets/format/TopicPosts.java +++ b/src/com/silverwrist/venice/servlets/format/TopicPosts.java @@ -48,12 +48,14 @@ public class TopicPosts implements JSPRender private int first; private int last; private boolean show_advanced; + private boolean no_bozos; private int unread; private List messages; private TopicVisitOrder visit_order; private String topic_stem; private String topic_qid; private String cache_locator = null; + private HashSet bozo_uids = new HashSet(); /*-------------------------------------------------------------------------------- * Constructor @@ -62,12 +64,12 @@ public class TopicPosts implements JSPRender public TopicPosts(HttpServletRequest request, VeniceEngine engine, CommunityContext comm, ConferenceContext conf, TopicContext topic, int first, int last, boolean read_new, - boolean show_advanced) throws DataException, AccessError + boolean show_advanced, boolean no_bozos) throws DataException, AccessError { if (logger.isDebugEnabled()) logger.debug("TopicPosts: comm=" + comm.getCommunityID() + ", conf=" + conf.getConfID() + ", topic=" + topic.getTopicNumber() + ", range=[" + first + ", " + last + "], rnm=" + read_new - + ", shac=" + show_advanced); + + ", shac=" + show_advanced + ", nbz=" + no_bozos); this.engine = engine; this.comm = comm; this.conf = conf; @@ -75,6 +77,7 @@ public class TopicPosts implements JSPRender this.first = first; this.last = last; this.show_advanced = show_advanced; + this.no_bozos = no_bozos; this.unread = topic.getUnreadMessages(); if (read_new) topic.setUnreadMessages(0); @@ -88,6 +91,23 @@ public class TopicPosts implements JSPRender topic_stem = (String)(aliases.get(0)) + "." + topic.getTopicNumber() + "."; topic_qid = "go/" + comm.getAlias() + "!" + (String)(aliases.get(0)) + "." + topic.getTopicNumber(); + // build up the list of users IN THIS VIEW that are bozo-filtered + HashSet saw_users = new HashSet(); + Iterator it = messages.iterator(); + while (it.hasNext()) + { // get the user IDs of all messages on this page + TopicMessageContext msg = (TopicMessageContext)(it.next()); + Integer the_uid = new Integer(msg.getCreatorUID()); + if (!(saw_users.contains(the_uid))) + { // only check user IDs once per display operation + saw_users.add(the_uid); + if (topic.isBozo(the_uid.intValue())) + bozo_uids.add(the_uid); + + } // end if + + } // end while + } // end constructor /*-------------------------------------------------------------------------------- @@ -426,4 +446,28 @@ public class TopicPosts implements JSPRender } // end displayAttachmentInNewWindow + public boolean bozoFilterUser(int uid) + { + if (no_bozos) + return false; + else + return bozo_uids.contains(new Integer(uid)); + + } // end bozoFilterUser + + public boolean showBozoFilteredIndicator(int uid) + { + if (no_bozos) + return bozo_uids.contains(new Integer(uid)); + else + return false; + + } // end showBozoFilteredIndicator + + public boolean showFilterButton(int uid) + { + return !(bozo_uids.contains(new Integer(uid))) && topic.canSetBozo(uid); + + } // end showFilterButton + } // end class TopicPosts diff --git a/web/format/manage_topic.jsp b/web/format/manage_topic.jsp new file mode 100644 index 0000000..8c1c81b --- /dev/null +++ b/web/format/manage_topic.jsp @@ -0,0 +1,71 @@ +<%-- + The contents of this file are subject to the Mozilla Public License Version 1.1 + (the "License"); you may not use this file except in compliance with the License. + You may obtain a copy of the License at . + + Software distributed under the License is distributed on an "AS IS" basis, WITHOUT + WARRANTY OF ANY KIND, either express or implied. See the License for the specific + language governing rights and limitations under the License. + + The Original Code is the Venice Web Communities System. + + The Initial Developer of the Original Code is Eric J. Bowersox , + for Silverwrist Design Studios. Portions created by Eric J. Bowersox are + Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + + Contributor(s): +--%> +<%@ page import = "java.util.*" %> +<%@ page import = "com.silverwrist.util.StringUtil" %> +<%@ page import = "com.silverwrist.venice.core.*" %> +<%@ page import = "com.silverwrist.venice.servlets.Variables" %> +<%@ page import = "com.silverwrist.venice.servlets.format.*" %> +<% + ManageTopic data = ManageTopic.retrieve(request); + Variables.failIfNull(data); + RenderData rdat = RenderConfig.createRenderData(application,request,response); +%> +<% if (rdat.useHTMLComments()) { %><% } %> +<% rdat.writeContentHeader(out,"Manage Topic:",data.getTopicName()); %> + +<%= rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2) %> + ">Return to Topic +

+ +<%= rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2) %> +

Filtered users:
+ <% if (data.getNumBozos()>0) { %> + + <% Iterator it = data.getBozosIterator(); %> + <% while (it.hasNext()) { %> + <% UserProfile prof = (UserProfile)(it.next()); %> + + + + + <% } // end while %> +
+ ">" ALT="Remove" BORDER=0 WIDTH=16 + HEIGHT=16> + <%= rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2) %> + <"><%= prof.getUserName() %>> + (<%= StringUtil.encodeHTML(prof.getGivenName()) %> + <%= StringUtil.encodeHTML(prof.getFamilyName()) %>) +

+ + + + + +
+ " ALT="Remove" BORDER=0 WIDTH=16 HEIGHT=16> + <%= rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2) %> + Click this symbol to cease filtering this user in this topic. +
+ <% } else { %> +

No users currently filtered.
+ <% } // end if %> + diff --git a/web/format/posts.jsp b/web/format/posts.jsp index 5446781..21c7bb3 100644 --- a/web/format/posts.jsp +++ b/web/format/posts.jsp @@ -39,7 +39,7 @@ - + + + -
+ <% if (rdat.useHTMLComments()) { %><% } %> ">" ALT="Topic List" WIDTH=80 HEIGHT=24 @@ -68,7 +68,13 @@   <% } // end if %> <% } // end if %> + ">" ALT="Manage" WIDTH=80 HEIGHT=24 + BORDER=0> 
  <% if (rdat.useHTMLComments()) { %><% } %> <% if (data.canFreezeTopic()) { %> @@ -103,7 +109,6 @@ <% } // end if %>
 
<% if (rdat.useHTMLComments()) { %><% } %> @@ -159,7 +164,7 @@ <% if (data.showAdvanced()) { %>
diff --git a/web/images/bn_filter_user.gif b/web/images/bn_filter_user.gif new file mode 100644 index 0000000000000000000000000000000000000000..42b22aabee42ebe11962f874a2c54b24e3d200cb GIT binary patch literal 937 zcmV;a16KS;Nk%v~VNd`V0Q3L=%*QPYW@cuYGtB>)GXMZ)nPz4)05fJY zGiCq)GXMYp00000EC2ui08juJ000I4U;!8a0hE+EnnZfOFc8G@JJaXzvhZ-kD%>ex zhztxQq;k0=JP1dqNjDfw0aOCXYBfX+TEoK&MGl@`G4$BQ9!IAKmNdNp4!YdyH{8$u zFgHS2d?$r`d^3fHeP9O<2VfMDI&^n0I)H#R0yQ-^2LUQSDuQ`fs4E8hZH<_z5K{GzAy4A6=2U=Jcr;g2#_9B6dUH}XV-1BWnkW$>T9UG8r9Eo9p z-~mv;pd$kW3lu1D004mqgn<48Kp0X$!HIfzQ0B_k>Xm^pUz`>sa6~fA3yr87ZvqNVX zwCd?br;8N0AxuCwWC5!X4tGXiApnB~4jc$bdV@EB3bh$@Scx0=N(Kps2ryW>MuG@W zt}KcwgP?B!x|1#iz(4@wp(|f#Mw-t1NCg!N{Olf88ZW(^07PIk_V! zXu}WzX~Ydg_9((igct^p06JgVFxg~(L{QHUMApZbM64Xr7Y(b-6o3RY0>#`xNLDu^ zTL~C|-vgTbk>oTmT%pG=xzM7T3`DZ_B|AW+6ee};bmCW$Lte5F4M7N@!w*>|$zxSO zL6}fF_)+(zdOCd*Cq8*Rb3>=+ijDMJ>90EgGHPlbuS_N(Z0*Fhl4CRumZn~X#8`W#@ehaU9<#HP@ Lz4PKLKnMUk{snwK literal 0 HcmV?d00001
- <% } // end if %> + <% } // end if (showing advanced controls) %> <%= rdat.getStdFontTag(ColorSelectors.CONTENT_FOREGROUND,2) %> "><%= msg.getPostNumber() %> of @@ -168,26 +173,40 @@ <% if (data.showAdvanced() && msg.isHidden()) { %> (Hidden) <% } // end if %> -
- <%= msg.getPseud() %> - ( - " TARGET="_blank"><%= poster %>, - <%= rdat.formatDateForDisplay(msg.getPostDate()) %> - ) - <% if (msg.hasAttachment()) { %> - TARGET="_blank"<% } %> >" - ALT="(Attachment <%= msg.getAttachmentFilename() %> - <%= msg.getAttachmentLength() %> bytes)" - WIDTH=16 HEIGHT=16 BORDER=0> + <% if (data.showAdvanced() && data.showBozoFilteredIndicator(msg.getCreatorUID())) { %> + (User filtered; + ">remove filter) + <% } // end if %> + <% if (!(data.bozoFilterUser(msg.getCreatorUID()))) { %> +
+ <%= msg.getPseud() %> + ( + " TARGET="_blank"><%= poster %>, + <%= rdat.formatDateForDisplay(msg.getPostDate()) %> + ) + <% if (msg.hasAttachment()) { %> + TARGET="_blank"<% } %> >" + ALT="(Attachment <%= msg.getAttachmentFilename() %> - <%= msg.getAttachmentLength() %> bytes)" + WIDTH=16 HEIGHT=16 BORDER=0> + <% } // end if %> + <% } // end if (message not bozo-filtered) %>

<% if (msg.isScribbled()) { %> (Scribbled by <%= data.getMessageBodyText(msg) %> on <%= rdat.formatDateForDisplay(msg.getScribbleDate()) %>)

+ <% } else if (data.bozoFilterUser(msg.getCreatorUID())) { %> + + ">(Message from Filtered User: + <%= msg.getNumLines() %> <% if (msg.getNumLines()==1) { %>Line<% } else { %>Lines<% } %>) +

<% } else if (msg.isHidden() && !(data.showAdvanced())) { %>

<% } // end if (can scribble) %> <% } // end if (not already scribbled) %> + <% if (data.showFilterButton(msg.getCreatorUID())) { %> + ">" ALT="Filter User" WIDTH=80 HEIGHT=24 + BORDER=0>

+ <% } // end if (can bozo filter) %> <% if (msg.canNuke()) { %> ">" ALT="Nuke" WIDTH=80 HEIGHT=24 @@ -290,6 +314,9 @@   <% } // end if %> <% } // end if %> + ">" ALT="Manage" WIDTH=80 HEIGHT=24 + BORDER=0>