Implemented 'unread replies' counter of a thread

main
Inga 🏳‍🌈 15 years ago
parent 4373412fa9
commit e32ca392d6
  1. 2
      Builder/IISMainHandler/build.txt
  2. 2
      Builder/IISUploadHandler/build.txt
  3. 2
      Common/UploadManager.cs
  4. 27
      Common/dataobjects/Thread.cs
  5. 2
      Core/DB/IDBConnection.cs
  6. 5
      IISMainHandler/handlers/BoardsHandler.cs
  7. 3
      IISMainHandler/handlers/ThreadHandler.cs
  8. 2
      MySQLConnector/Connection.cs
  9. 4
      templates/Full/Board.xslt
  10. 9
      templates/Full/elems/ThreadInfo.xslt

@ -59,7 +59,7 @@ namespace FLocal.Common {
int? uploadId = null; int? uploadId = null;
try { try {
if(Config.instance.mainConnection.GetCountByConditions(Upload.TableSpec.instance, condition, new JoinSpec[0]) > 0) { if(Config.instance.mainConnection.GetCountByConditions(Upload.TableSpec.instance, condition) > 0) {
throw new _AlreadyUploadedException(); throw new _AlreadyUploadedException();
} }
Config.Transactional(transaction => { Config.Transactional(transaction => {

@ -179,7 +179,29 @@ namespace FLocal.Common.dataobjects {
result.Add(new XElement("firstPost", this.firstPost.exportToXmlWithoutThread(context, false))); result.Add(new XElement("firstPost", this.firstPost.exportToXmlWithoutThread(context, false)));
} }
if(context.account != null) { if(context.account != null) {
result.Add(new XElement("afterLastRead", this.getLastReadId(context.account) + 1)); int lastReadId = this.getLastReadId(context.account);
result.Add(
new XElement("afterLastRead", lastReadId + 1),
new XElement(
"totalNewPosts",
Config.instance.mainConnection.GetCountByConditions(
Post.TableSpec.instance,
new ComplexCondition(
ConditionsJoinType.AND,
new ComparisonCondition(
Post.TableSpec.instance.getColumnSpec(Post.TableSpec.FIELD_THREADID),
ComparisonType.EQUAL,
this.id.ToString()
),
new ComparisonCondition(
Post.TableSpec.instance.getIdSpec(),
ComparisonType.GREATERTHAN,
lastReadId.ToString()
)
)
)
)
);
} }
if(additional.Length > 0) { if(additional.Length > 0) {
result.Add(additional); result.Add(additional);
@ -307,8 +329,7 @@ namespace FLocal.Common.dataobjects {
ComparisonType.LESSTHAN, ComparisonType.LESSTHAN,
minPost.id.ToString() minPost.id.ToString()
) )
), )
new JoinSpec[0]
); );
if(count > 0) { if(count > 0) {
return (s == "0") ? null : s; //if there are some unread posts earlier than minPost return (s == "0") ? null : s; //if there are some unread posts earlier than minPost

@ -10,7 +10,7 @@ namespace FLocal.Core.DB {
List<string> LoadIdsByConditions(ITableSpec table, conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, bool allowHugeLists); List<string> LoadIdsByConditions(ITableSpec table, conditions.AbstractCondition conditions, Diapasone diapasone, JoinSpec[] joins, SortSpec[] sorts, bool allowHugeLists);
long GetCountByConditions(ITableSpec table, conditions.AbstractCondition conditions, JoinSpec[] joins); long GetCountByConditions(ITableSpec table, conditions.AbstractCondition conditions, params JoinSpec[] joins);
Transaction beginTransaction(System.Data.IsolationLevel iso); Transaction beginTransaction(System.Data.IsolationLevel iso);

@ -23,7 +23,7 @@ namespace FLocal.IISHandler.handlers {
override protected XElement[] getSpecificData(WebContext context) { override protected XElement[] getSpecificData(WebContext context) {
return new XElement[] { return new XElement[] {
new XElement("categories", from category in Category.allCategories select category.exportToXmlForMainPage(context)), new XElement("categories", from category in Category.allCategories select category.exportToXmlForMainPage(context)),
new XElement("totalRegistered", Config.instance.mainConnection.GetCountByConditions(User.TableSpec.instance, new EmptyCondition(), new JoinSpec[0])), new XElement("totalRegistered", Config.instance.mainConnection.GetCountByConditions(User.TableSpec.instance, new EmptyCondition())),
new XElement("activity", new XElement("activity",
new XElement("threshold", Config.instance.ActivityThreshold.ToString()), new XElement("threshold", Config.instance.ActivityThreshold.ToString()),
new XElement("sessions", Config.instance.mainConnection.GetCountByConditions( new XElement("sessions", Config.instance.mainConnection.GetCountByConditions(
@ -32,8 +32,7 @@ namespace FLocal.IISHandler.handlers {
Session.TableSpec.instance.getColumnSpec(Session.TableSpec.FIELD_LASTACTIVITY), Session.TableSpec.instance.getColumnSpec(Session.TableSpec.FIELD_LASTACTIVITY),
ComparisonType.GREATEROREQUAL, ComparisonType.GREATEROREQUAL,
DateTime.Now.Subtract(Config.instance.ActivityThreshold).ToUTCString() DateTime.Now.Subtract(Config.instance.ActivityThreshold).ToUTCString()
), )
new JoinSpec[0]
)) ))
), ),
new XElement("currentDate", DateTime.Now.ToXml()), new XElement("currentDate", DateTime.Now.ToXml()),

@ -42,8 +42,7 @@ namespace FLocal.IISHandler.handlers {
ComparisonType.LESSTHAN, ComparisonType.LESSTHAN,
int.Parse(context.requestParts[2].PHPSubstring(1)).ToString() int.Parse(context.requestParts[2].PHPSubstring(1)).ToString()
) )
), )
new JoinSpec[0]
) )
} }
}, },

@ -157,7 +157,7 @@ namespace FLocal.MySQLConnector {
} }
} }
public long GetCountByConditions(ITableSpec table, FLocal.Core.DB.conditions.AbstractCondition conditions, JoinSpec[] joins) { public long GetCountByConditions(ITableSpec table, FLocal.Core.DB.conditions.AbstractCondition conditions, params JoinSpec[] joins) {
using(DbConnection connection = this.createConnection()) { using(DbConnection connection = this.createConnection()) {
using(DbCommand command = connection.CreateCommand()) { using(DbCommand command = connection.CreateCommand()) {

@ -106,8 +106,8 @@
<tr> <tr>
<td align="left" width="55%" class="tdheader">Òåìà</td> <td align="left" width="55%" class="tdheader">Òåìà</td>
<td align="left" nowrap="nowrap" width="15%" class="tdheader">Àâòîð</td> <td align="left" nowrap="nowrap" width="15%" class="tdheader">Àâòîð</td>
<td nowrap="nowrap" width="5%" class="tdheader" align="center">Ïðîñìîòðû</td> <td nowrap="nowrap" width="5%" class="tdheader" align="center">Ïðîñìîòðîâ</td>
<td nowrap="nowrap" width="5%" class="tdheader" align="center">Îòâåòû</td> <td nowrap="nowrap" width="5%" class="tdheader" align="center">Ïîñòîâ</td>
<td nowrap="nowrap" width="20%" class="tdheader" align="center">Ïîñëåäíåå</td> <td nowrap="nowrap" width="20%" class="tdheader" align="center">Ïîñëåäíåå</td>
</tr> </tr>
<!-- BEGIN POST LOOP DO NOT DELETE --> <!-- BEGIN POST LOOP DO NOT DELETE -->

@ -58,12 +58,11 @@
</td> </td>
<td align="center" nowrap="nowrap" class="lighttable"> <td align="center" nowrap="nowrap" class="lighttable">
<span class="separate"><xsl:value-of select="totalPosts"/></span> <span class="separate"><xsl:value-of select="totalPosts"/></span>
<a class="cup separate" href="/postlist.php?Cat=&amp;Board=Common&amp;page=0&amp;fullview=&amp;src=&amp;sb=5&amp;o=&amp;cupthread=479355&amp;cupmaxnumber=9559703&amp;showlite=" > <xsl:if test="totalNewPosts and totalNewPosts!='0'">
<font class="new"><i>(10)</i></font> <a class="cup separate">
</a> <font class="new"><i>(<xsl:value-of select="totalNewPosts"/>)</i></font>
<a class="cup separate" href="/postlist.php?Cat=&amp;Board=Common&amp;page=0&amp;fullview=&amp;src=&amp;sb=5&amp;o=&amp;cupthread=479355&amp;cupdisc=1&amp;showlite=" >
<font class="new2"><i>(41)</i></font>
</a> </a>
</xsl:if>
</td> </td>
<td nowrap="nowrap" align="center"> <td nowrap="nowrap" align="center">
<xsl:apply-templates select="lastPostDate/date" mode="dateTime"/> <xsl:apply-templates select="lastPostDate/date" mode="dateTime"/>

Loading…
Cancel
Save