Skip to content

Commit 7c01299

Browse files
Merge pull request #974 from johnhenley/issues/forum-icons-973
FIX: Forum icon not changing when new topic
2 parents 4f21a20 + fb8c3af commit 7c01299

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

Dnn.CommunityForums/Controllers/ForumController.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using System.Text;
2525
using System.Xml;
2626
using DotNetNuke.Data;
27+
using DotNetNuke.Modules.ActiveForums.API;
2728
using DotNetNuke.Modules.ActiveForums.Data;
2829
using Microsoft.ApplicationBlocks.Data;
2930

@@ -472,7 +473,19 @@ public static int CreateSocialGroupForum(int portalId, int moduleId, int socialG
472473
}
473474
public static int Forum_GetByTopicId(int TopicId)
474475
{
475-
return new DotNetNuke.Data.SqlDataProvider().ExecuteScalar<int>( "activeforums_ForumGetByTopicId", TopicId);
476+
return new DotNetNuke.Data.SqlDataProvider().ExecuteScalar<int>("activeforums_ForumGetByTopicId", TopicId);
477+
}
478+
public static DateTime Forum_GetLastReadTopicByUser(int ForumId, int UserId)
479+
{
480+
try
481+
{
482+
return DataContext.Instance().ExecuteQuery<DateTime>(System.Data.CommandType.Text, "SELECT LastAccessDate FROM {databaseOwner}{objectQualifier}activeforums_Forums_Tracking WHERE ForumId = @0 AND UserId = @1", ForumId, UserId).FirstOrDefault();
483+
}
484+
catch (Exception ex)
485+
{
486+
Exceptions.LogException(ex);
487+
return DateTime.MinValue;
488+
}
476489
}
477490
internal static bool RecalculateTopicPointers(int forumId)
478491
{

Dnn.CommunityForums/Controllers/ReplyController.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public void Reply_Delete(int PortalId, int ForumId, int TopicId, int ReplyId, in
5858
{
5959
var ri = GetById(ReplyId);
6060
DataProvider.Instance().Reply_Delete(ForumId, TopicId, ReplyId, DelBehavior);
61+
DotNetNuke.Modules.ActiveForums.Controllers.ForumController.UpdateForumLastUpdates(ForumId);
62+
6163
DataCache.ContentCacheClear(ri.ModuleId, string.Format(CacheKeys.ForumInfo, ri.ModuleId, ForumId));
6264
DataCache.CacheClearPrefix(ri.ModuleId, string.Format(CacheKeys.ForumViewPrefix, ri.ModuleId));
6365
DataCache.CacheClearPrefix(ri.ModuleId, string.Format(CacheKeys.TopicViewPrefix, ri.ModuleId));
@@ -126,7 +128,9 @@ public int Reply_Save(int PortalId, int ModuleId, DotNetNuke.Modules.ActiveForum
126128
DataCache.CacheClearPrefix(ri.ModuleId, string.Format(CacheKeys.ForumViewPrefix, ri.ModuleId));
127129
DataCache.CacheClearPrefix(ri.ModuleId, string.Format(CacheKeys.TopicViewPrefix, ri.ModuleId));
128130
DataCache.CacheClearPrefix(ri.ModuleId, string.Format(CacheKeys.TopicsViewPrefix, ri.ModuleId));
129-
return Convert.ToInt32(DataProvider.Instance().Reply_Save(PortalId, ri.TopicId, ri.ReplyId, ri.ReplyToId, ri.StatusId, ri.IsApproved, ri.IsDeleted, ri.Content.Subject.Trim(), ri.Content.Body.Trim(), ri.Content.DateCreated, ri.Content.DateUpdated, ri.Content.AuthorId, ri.Content.AuthorName, ri.Content.IPAddress));
131+
int replyId = Convert.ToInt32(DataProvider.Instance().Reply_Save(PortalId, ri.TopicId, ri.ReplyId, ri.ReplyToId, ri.StatusId, ri.IsApproved, ri.IsDeleted, ri.Content.Subject.Trim(), ri.Content.Body.Trim(), ri.Content.DateCreated, ri.Content.DateUpdated, ri.Content.AuthorId, ri.Content.AuthorName, ri.Content.IPAddress));
132+
DotNetNuke.Modules.ActiveForums.Controllers.ForumController.UpdateForumLastUpdates(ri.ForumId);
133+
return replyId;
130134
}
131135
public DotNetNuke.Modules.ActiveForums.Entities.ReplyInfo ApproveReply(int PortalId, int TabId, int ModuleId, int ForumId, int TopicId, int ReplyId)
132136
{
@@ -139,7 +143,7 @@ public DotNetNuke.Modules.ActiveForums.Entities.ReplyInfo ApproveReply(int Porta
139143
}
140144
reply.IsApproved = true;
141145
rc.Reply_Save(PortalId, ModuleId, reply);
142-
DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, ReplyId);
146+
DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, ReplyId);
143147

144148
if (forum.ModApproveTemplateId > 0 & reply.Author.AuthorId > 0)
145149
{

Dnn.CommunityForums/Controllers/TopicController.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
using System.Runtime.InteropServices;
3434
using System.Text.RegularExpressions;
3535
using System.Web;
36+
using System.Web.Http.Controllers;
3637
using System.Xml.Linq;
3738

3839
namespace DotNetNuke.Modules.ActiveForums.Controllers
@@ -87,6 +88,7 @@ public static int QuickCreate(int PortalId, int ModuleId, int ForumId, string Su
8788
if (topicId > 0)
8889
{
8990
DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, topicId, -1);
91+
9092
if (UserId > 0)
9193
{
9294
//TODO: update this to be consistent with reply count
@@ -173,14 +175,15 @@ public static void Move(int TopicId, int NewForumId)
173175
DataCache.CacheClearPrefix(ti.ModuleId, string.Format(CacheKeys.TopicViewPrefix, ti.ModuleId));
174176
DataCache.CacheClearPrefix(ti.ModuleId, string.Format(CacheKeys.TopicsViewPrefix, ti.ModuleId));
175177
}
176-
public static int SaveToForum(int ModuleId, int ForumId, int TopicId, int LastReplyId = -1)
178+
public static void SaveToForum(int ModuleId, int ForumId, int TopicId, int LastReplyId = -1)
177179
{
180+
DataProvider.Instance().Topics_SaveToForum(ForumId, TopicId, LastReplyId);
178181
Utilities.UpdateModuleLastContentModifiedOnDate(ModuleId);
182+
DotNetNuke.Modules.ActiveForums.Controllers.ForumController.UpdateForumLastUpdates(ForumId);
179183
DataCache.ContentCacheClear(ModuleId, string.Format(CacheKeys.ForumInfo, ModuleId, ForumId));
180184
DataCache.CacheClearPrefix(ModuleId, string.Format(CacheKeys.ForumViewPrefix, ModuleId));
181185
DataCache.CacheClearPrefix(ModuleId, string.Format(CacheKeys.TopicViewPrefix, ModuleId));
182186
DataCache.CacheClearPrefix(ModuleId, string.Format(CacheKeys.TopicsViewPrefix, ModuleId));
183-
return Convert.ToInt32(DataProvider.Instance().Topics_SaveToForum(ForumId, TopicId, LastReplyId));
184187
}
185188
public static int Save(DotNetNuke.Modules.ActiveForums.Entities.TopicInfo ti)
186189
{

Dnn.CommunityForums/CustomControls/UserControls/ForumView.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ private string ParseForumRow(string Template, DotNetNuke.Modules.ActiveForums.En
390390
bool canView = DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasPerm(fi.Security.View, ForumUser.UserRoles);
391391
bool canSubscribe = DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasPerm(fi.Security.Subscribe, ForumUser.UserRoles);
392392
bool canRead = DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasPerm(fi.Security.Read, ForumUser.UserRoles);
393-
string sIcon = TemplateUtils.ShowIcon(canView, fi.ForumID, CurrentUserId, fi.LastPostDateTime, fi.LastRead, fi.LastPostID);
393+
string sIcon = TemplateUtils.ShowIcon(canView, fi.ForumID, CurrentUserId, fi.LastPostDateTime, DotNetNuke.Modules.ActiveForums.Controllers.ForumController.Forum_GetLastReadTopicByUser(fi.ForumID, CurrentUserId), fi.LastPostID);
394394
string sIconImage = "<img alt=\"" + fi.ForumName + "\" src=\"" + ThemePath + "images/" + sIcon + "\" />";
395395

396396
if (Template.Contains("[FORUMICON]"))

Dnn.CommunityForums/components/Topics/TopicsController.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System.Data;
2323
using System.Data.SqlTypes;
2424
using System.Linq;
25+
using System.Runtime.Remoting.Messaging;
2526
using System.Text.RegularExpressions;
2627
using DotNetNuke.Common.Controls;
2728
using DotNetNuke.Entities.Modules;
@@ -48,9 +49,17 @@ public class TopicsController : DotNetNuke.Entities.Modules.ModuleSearchBase, Do
4849
[Obsolete(message: "Deprecated in Community Forums. Scheduled removal in 10.00.00. Use DotNetNuke.Modules.ActiveForums.Controllers.TopicController.Save(TopicInfo ti)")]
4950
public int TopicSave(int PortalId, int ModuleId, DotNetNuke.Modules.ActiveForums.Entities.TopicInfo ti) => DotNetNuke.Modules.ActiveForums.Controllers.TopicController.Save(ti);
5051
[Obsolete(message: "Deprecated in Community Forums. Scheduled removal in 10.00.00. Use DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(int ModuleId, int ForumId, int TopicId, int LastReplyId)")]
51-
public int Topics_SaveToForum(int ForumId, int TopicId, int PortalId, int ModuleId) => DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, -1);
52+
public int Topics_SaveToForum(int ForumId, int TopicId, int PortalId, int ModuleId)
53+
{
54+
DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, -1);
55+
return -1;
56+
}
5257
[Obsolete(message: "Deprecated in Community Forums. Scheduled removal in 10.00.00. Use DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(int ModuleId, int ForumId, int TopicId, int LastReplyId)")]
53-
public int Topics_SaveToForum(int ForumId, int TopicId, int PortalId, int ModuleId, int LastReplyId) => DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, LastReplyId);
58+
public int Topics_SaveToForum(int ForumId, int TopicId, int PortalId, int ModuleId, int LastReplyId)
59+
{
60+
Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, LastReplyId);
61+
return -1;
62+
}
5463
[Obsolete("Deprecated in Community Forums. Scheduled removal in 10.00.00. Use DotNetNuke.Modules.ActiveForums.Controllers.TopicController.GetById(int TopicId)")]
5564
public DotNetNuke.Modules.ActiveForums.Entities.TopicInfo Topics_Get(int PortalId, int ModuleId, int TopicId) => new DotNetNuke.Modules.ActiveForums.Controllers.TopicController().GetById(TopicId);
5665
[Obsolete("Deprecated in Community Forums. Scheduled removal in 10.00.00. Use DotNetNuke.Modules.ActiveForums.Controllers.TopicController.GetById(int TopicId)")]

0 commit comments

Comments
 (0)