fixed a bug with the topic visit order and another one with the anyUnread
function (it needs to ignore archived topics)
This commit is contained in:
@@ -834,16 +834,17 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
|
||||
conn = datapool.getConnection();
|
||||
|
||||
// Build a query. The idea here is that we want to see the topic IDs of all topics within the
|
||||
// conference which (a) are not hidden and (b) have one or more messages unread by this user.
|
||||
// The need for the user's settings for both (a) and (b) necessitates the use of the LEFT JOIN
|
||||
// to topicsettings, which in turn necessitates the IFNULL guards on references to topicsettings
|
||||
// conference which (a) are not archived, (b) are not hidden and (c) have one or more messages unread
|
||||
// by this user. The need for the user's settings for both (b) and (c) necessitates the use of the LEFT
|
||||
// JOIN to topicsettings, which in turn necessitates the IFNULL guards on references to topicsettings
|
||||
// columns in the WHERE clause (as there's only a topicsettings row if the user has read anything
|
||||
// in this topic or otherwise set it).
|
||||
Statement stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("SELECT t.topicid FROM topics t LEFT JOIN topicsettings s "
|
||||
+ "ON t.topicid = s.topicid AND s.uid = ");
|
||||
sql.append(sig.realUID()).append(" WHERE t.confid = ").append(confid);
|
||||
sql.append(" AND IFNULL(s.hidden,0) = 0 AND (t.top_message - IFNULL(s.last_message,-1)) > 0 LIMIT 1;");
|
||||
sql.append(" AND t.archived = 0 AND IFNULL(s.hidden,0) = 0 "
|
||||
+ "AND (t.top_message - IFNULL(s.last_message,-1)) > 0 LIMIT 1;");
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
|
||||
|
||||
@@ -250,14 +250,14 @@ public class ConfDisplay extends VeniceServlet
|
||||
|
||||
} // end getInterval
|
||||
|
||||
private static void restorePosts(ServletRequest request, ConferenceContext conf)
|
||||
private static boolean restorePosts(ServletRequest request, ConferenceContext conf, TopicContext curr_topic)
|
||||
{
|
||||
String xtopic = request.getParameter("rtop");
|
||||
if (StringUtil.isStringEmpty(xtopic))
|
||||
return;
|
||||
return true;
|
||||
String xcount = request.getParameter("rct");
|
||||
if (StringUtil.isStringEmpty(xcount))
|
||||
return;
|
||||
return true;
|
||||
|
||||
TopicContext topic;
|
||||
try
|
||||
@@ -268,19 +268,19 @@ public class ConfDisplay extends VeniceServlet
|
||||
catch (NumberFormatException nfe)
|
||||
{ // the topic number was invalid - forget it
|
||||
logger.warn("restorePosts: error translating topic number");
|
||||
return;
|
||||
return true;
|
||||
|
||||
} // end catch
|
||||
catch (DataException de)
|
||||
{ // could not get the topic...
|
||||
logger.warn("restorePosts: DataException getting topic - " + de.getMessage(),de);
|
||||
return;
|
||||
return true;
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // no access to the topic
|
||||
logger.warn("restorePosts: AccessError getting topic - " + ae.getMessage(),ae);
|
||||
return;
|
||||
return true;
|
||||
|
||||
} // end catch
|
||||
|
||||
@@ -291,7 +291,7 @@ public class ConfDisplay extends VeniceServlet
|
||||
if ((nunread<=0) || (nunread>topic.getTotalMessages()))
|
||||
{ // must be in the range [1, #messages]...
|
||||
logger.warn("restorePosts: unread post count out of range");
|
||||
return;
|
||||
return true;
|
||||
|
||||
} // end if
|
||||
|
||||
@@ -299,7 +299,7 @@ public class ConfDisplay extends VeniceServlet
|
||||
catch (NumberFormatException nfe)
|
||||
{ // the number of unread posts was invalid - forget it
|
||||
logger.warn("restorePosts: error translating unread post count");
|
||||
return;
|
||||
return true;
|
||||
|
||||
} // end catch
|
||||
|
||||
@@ -314,6 +314,8 @@ public class ConfDisplay extends VeniceServlet
|
||||
|
||||
} // end catch
|
||||
|
||||
return (topic.getTopicID()!=curr_topic.getTopicID());
|
||||
|
||||
} // end restorePosts
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
@@ -356,11 +358,11 @@ public class ConfDisplay extends VeniceServlet
|
||||
setMyLocation(request,on_error + "&topic=" + topic.getTopicNumber());
|
||||
|
||||
// if this request is restoring the number of unread posts in another topic, try to do so
|
||||
restorePosts(request,conf);
|
||||
boolean do_readnew = restorePosts(request,conf,topic);
|
||||
|
||||
// determine what the post interval is we want to display
|
||||
PostInterval piv = getInterval(engine,request,topic,on_error);
|
||||
boolean read_new = !(StringUtil.isStringEmpty(request.getParameter("rnm")));
|
||||
boolean read_new = do_readnew && !(StringUtil.isStringEmpty(request.getParameter("rnm")));
|
||||
boolean show_adv = !(StringUtil.isStringEmpty(request.getParameter("shac")));
|
||||
|
||||
// Create the post display.
|
||||
|
||||
@@ -36,7 +36,6 @@ public class TopicVisitOrder
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private int confid;
|
||||
private short[] topics;
|
||||
private boolean[] unread;
|
||||
private int ndx_next;
|
||||
@@ -46,9 +45,8 @@ public class TopicVisitOrder
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected TopicVisitOrder(int confid, List topiclist)
|
||||
protected TopicVisitOrder(List topiclist)
|
||||
{
|
||||
this.confid = confid;
|
||||
this.topics = new short[topiclist.size()];
|
||||
this.unread = new boolean[topiclist.size()];
|
||||
|
||||
@@ -65,6 +63,25 @@ public class TopicVisitOrder
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Map getInternalMap(HttpSession session)
|
||||
{
|
||||
Map rc = (Map)(session.getAttribute(ATTRIBUTE));
|
||||
if (rc==null)
|
||||
{ // create a new HashMap
|
||||
rc = Collections.synchronizedMap(new HashMap());
|
||||
session.setAttribute(ATTRIBUTE,rc);
|
||||
|
||||
} // end if
|
||||
|
||||
return rc;
|
||||
|
||||
} // end getInternalMap
|
||||
|
||||
private int moveNext()
|
||||
{
|
||||
int i = ndx_next;
|
||||
@@ -88,23 +105,17 @@ public class TopicVisitOrder
|
||||
|
||||
public static TopicVisitOrder initialize(HttpSession session, int confid, List topic_list)
|
||||
{
|
||||
TopicVisitOrder tvo = new TopicVisitOrder(confid,topic_list);
|
||||
session.setAttribute(ATTRIBUTE,tvo);
|
||||
TopicVisitOrder tvo = new TopicVisitOrder(topic_list);
|
||||
Map tvo_map = getInternalMap(session);
|
||||
tvo_map.put(new Integer(confid),tvo);
|
||||
return tvo;
|
||||
|
||||
} // end initialize
|
||||
|
||||
public static TopicVisitOrder retrieve(HttpSession session, int confid)
|
||||
{
|
||||
TopicVisitOrder tvo = (TopicVisitOrder)(session.getAttribute(ATTRIBUTE));
|
||||
if (tvo!=null)
|
||||
{ // make sure the conference is OK
|
||||
if (tvo.confid!=confid) // wrong conference - remove this
|
||||
tvo = null;
|
||||
|
||||
} // end if
|
||||
|
||||
return tvo;
|
||||
Map tvo_map = getInternalMap(session);
|
||||
return (TopicVisitOrder)(tvo_map.get(new Integer(confid)));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
|
||||
Reference in New Issue
Block a user