implementation of the "bozo filter" on a topic level, including a topic-level

"Manage" screen (to hang "Rename Topic" from later, too).
This commit is contained in:
Eric J. Bowersox
2001-11-09 00:10:36 +00:00
parent bc859178f2
commit 0bb2e795a4
13 changed files with 727 additions and 38 deletions

View File

@@ -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