2002-01-06 19:05:37 -07:00
|
|
|
// 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 <http://www.mozilla.org/MPL/>.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
2006-01-25 21:40:34 -07:00
|
|
|
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@users.sf.net>,
|
2002-01-06 19:05:37 -07:00
|
|
|
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
2004-07-11 02:08:27 -06:00
|
|
|
// Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
2002-01-06 19:05:37 -07:00
|
|
|
//
|
|
|
|
// Contributor(s):
|
|
|
|
|
|
|
|
importClass(java.awt.Dimension);
|
|
|
|
importPackage(java.util);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.core);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.except);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.ui);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.ui.conf);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.ui.conf.view);
|
|
|
|
importPackage(Packages.com.silverwrist.venice.ui.helpers);
|
|
|
|
|
|
|
|
SCALING_NUM = 1;
|
|
|
|
SCALING_DENOM = 2;
|
|
|
|
|
|
|
|
// get the request object and the community
|
|
|
|
rinput = bsf.lookupBean("request");
|
|
|
|
comm = rinput.getCommunity(true,"top.js.vs");
|
|
|
|
|
|
|
|
// get the current conference
|
|
|
|
currc = new CurrentConference(rinput);
|
|
|
|
conf = currc.getConference(true,"conf/conferences.js.vs?cc=" + comm.communityID);
|
|
|
|
|
|
|
|
// get the current topic
|
|
|
|
on_error = "conf/topics.js.vs?cc=" + comm.communityID + "&conf=" + conf.confID;
|
|
|
|
topic = currc.getTopic(true,on_error);
|
|
|
|
|
|
|
|
// if we need to restore posts in another topic, do so
|
|
|
|
read_new = true;
|
|
|
|
if (rinput.hasParameter("rtop") && rinput.hasParameter("rct"))
|
|
|
|
{ // retrieve the "other topic"
|
|
|
|
other_topic = currc.getOptionalTopic("rtop");
|
|
|
|
if (other_topic!=null)
|
|
|
|
{ // get the number of unread messages
|
|
|
|
nunread = rinput.getParameterInt("rct",0);
|
|
|
|
if ((nunread>0) && (nunread<=other_topic.totalMessages))
|
|
|
|
{ // set the unread message count
|
|
|
|
try
|
|
|
|
{ // reset the unread messages
|
|
|
|
other_topic.unreadMessages = nunread;
|
|
|
|
|
|
|
|
} // end try
|
|
|
|
catch (e)
|
|
|
|
{ // it didn't work - ignore the error
|
|
|
|
logger.warn("exception setting unread messages: " + e);
|
|
|
|
|
|
|
|
} // end catch
|
|
|
|
|
|
|
|
if (topic.topicID==other_topic.topicID)
|
|
|
|
read_new = false; // don't do a read new if we just restored this topic
|
|
|
|
|
|
|
|
} // end if
|
|
|
|
else // ignore this
|
|
|
|
logger.warn("number of unread messages out of range");
|
|
|
|
|
|
|
|
} // end if
|
|
|
|
|
|
|
|
} // end if
|
|
|
|
|
|
|
|
// get the post interval
|
|
|
|
piv = currc.getPostInterval(on_error);
|
|
|
|
|
|
|
|
// get the "read new" parameter
|
|
|
|
if (read_new)
|
|
|
|
read_new = rinput.hasParameter("rnm");
|
|
|
|
|
|
|
|
rc = null;
|
|
|
|
try
|
|
|
|
{ // create the view
|
|
|
|
rc = new PostsView(comm,currc);
|
|
|
|
logger.debug(rc.unread + " unread messages");
|
|
|
|
|
|
|
|
// fill in parameters
|
|
|
|
rc.first = piv.first;
|
|
|
|
rc.last = piv.last;
|
|
|
|
rc.showAdvanced = rinput.hasParameter("shac");
|
|
|
|
rc.noBozos = rinput.hasParameter("nbz");
|
|
|
|
rc.messages = topic.getMessages(piv.first,piv.last);
|
|
|
|
rc.topCustom = conf.getCustomBlock(ConferenceContext.CUST_BLOCK_TOP);
|
|
|
|
rc.bottomCustom = conf.getCustomBlock(ConferenceContext.CUST_BLOCK_BOTTOM);
|
|
|
|
rc.title = topic.name;
|
2002-04-24 00:39:29 -06:00
|
|
|
html = vlib.queryHTMLRendering(rinput);
|
2002-01-06 19:05:37 -07:00
|
|
|
rc.subtitle = topic.totalMessages + " Total; " + rc.unread + " New; Last: "
|
2002-04-24 00:39:29 -06:00
|
|
|
+ html.formatDate(topic.lastUpdateDate);
|
2002-01-06 19:05:37 -07:00
|
|
|
|
|
|
|
// do a "read new" on this topic
|
|
|
|
if (read_new)
|
|
|
|
topic.unreadMessages = 0;
|
|
|
|
|
|
|
|
// visit the topic
|
|
|
|
visit_order = currc.getTopicVisitOrder();
|
|
|
|
if (visit_order!=null)
|
|
|
|
visit_order.visit(topic.topicNumber);
|
|
|
|
rc.topicVisitOrder = visit_order;
|
|
|
|
|
|
|
|
// get the aliases list and synthesize the topic stem and QID
|
|
|
|
aliases = conf.aliases;
|
|
|
|
tmp = aliases.get(0).toString() + "." + topic.topicNumber;
|
|
|
|
rc.topicStem = tmp + ".";
|
|
|
|
rc.pageQID = "go/" + comm.alias + "!" + tmp;
|
|
|
|
|
|
|
|
if (conf.displayPostPictures() && rinput.user.displayPostPictures())
|
2004-07-11 02:08:27 -06:00
|
|
|
{ // set up the user photo dimensions
|
2002-01-06 19:05:37 -07:00
|
|
|
old_psz = rinput.engine.getUserPhotoSize();
|
|
|
|
rc.photoDims = new Dimension((old_psz.width * SCALING_NUM) / SCALING_DENOM,
|
|
|
|
(old_psz.height * SCALING_NUM) / SCALING_DENOM);
|
|
|
|
|
|
|
|
} // end if
|
|
|
|
|
|
|
|
rc.buildInternals(rinput.user); // build the bozo filter and user photo lists in compiled code
|
|
|
|
|
|
|
|
} // end try
|
|
|
|
catch (e)
|
|
|
|
{ // handle an exception here
|
|
|
|
etype = vlib.exceptionType(e) + "";
|
|
|
|
if (etype.match("DataException"))
|
|
|
|
rc = new ErrorBox("Database Error","Database error listing messages: " + e.message,on_error);
|
|
|
|
else if (etype.match("AccessError"))
|
|
|
|
{ // unable to get message list - maybe we weren't logged in
|
|
|
|
if (rinput.user.isLoggedIn())
|
|
|
|
rc = new ErrorBox("Access Error",e.message,on_error);
|
|
|
|
else
|
|
|
|
rc = new LogInOrCreate();
|
|
|
|
|
|
|
|
} // end else if
|
|
|
|
else
|
|
|
|
rc = e;
|
|
|
|
|
|
|
|
} // end catch
|
|
|
|
|
|
|
|
vlib.output(rc); // all done!
|