Skip to content

Commit

Permalink
Merge pull request #977 from DNNCommunity/dev
Browse files Browse the repository at this point in the history
Sync dev and master
  • Loading branch information
WillStrohl authored Jul 10, 2024
2 parents 1b168a4 + 9eed248 commit 236abd5
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 39 deletions.
15 changes: 14 additions & 1 deletion Dnn.CommunityForums/Controllers/ForumController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System.Text;
using System.Xml;
using DotNetNuke.Data;
using DotNetNuke.Modules.ActiveForums.API;
using DotNetNuke.Modules.ActiveForums.Data;
using Microsoft.ApplicationBlocks.Data;

Expand Down Expand Up @@ -472,7 +473,19 @@ public static int CreateSocialGroupForum(int portalId, int moduleId, int socialG
}
public static int Forum_GetByTopicId(int TopicId)
{
return new DotNetNuke.Data.SqlDataProvider().ExecuteScalar<int>( "activeforums_ForumGetByTopicId", TopicId);
return new DotNetNuke.Data.SqlDataProvider().ExecuteScalar<int>("activeforums_ForumGetByTopicId", TopicId);
}
public static DateTime Forum_GetLastReadTopicByUser(int ForumId, int UserId)
{
try
{
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();
}
catch (Exception ex)
{
Exceptions.LogException(ex);
return DateTime.MinValue;
}
}
internal static bool RecalculateTopicPointers(int forumId)
{
Expand Down
8 changes: 6 additions & 2 deletions Dnn.CommunityForums/Controllers/ReplyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public void Reply_Delete(int PortalId, int ForumId, int TopicId, int ReplyId, in
{
var ri = GetById(ReplyId);
DataProvider.Instance().Reply_Delete(ForumId, TopicId, ReplyId, DelBehavior);
DotNetNuke.Modules.ActiveForums.Controllers.ForumController.UpdateForumLastUpdates(ForumId);

DataCache.ContentCacheClear(ri.ModuleId, string.Format(CacheKeys.ForumInfo, ri.ModuleId, ForumId));
DataCache.CacheClearPrefix(ri.ModuleId, string.Format(CacheKeys.ForumViewPrefix, ri.ModuleId));
DataCache.CacheClearPrefix(ri.ModuleId, string.Format(CacheKeys.TopicViewPrefix, ri.ModuleId));
Expand Down Expand Up @@ -126,7 +128,9 @@ public int Reply_Save(int PortalId, int ModuleId, DotNetNuke.Modules.ActiveForum
DataCache.CacheClearPrefix(ri.ModuleId, string.Format(CacheKeys.ForumViewPrefix, ri.ModuleId));
DataCache.CacheClearPrefix(ri.ModuleId, string.Format(CacheKeys.TopicViewPrefix, ri.ModuleId));
DataCache.CacheClearPrefix(ri.ModuleId, string.Format(CacheKeys.TopicsViewPrefix, ri.ModuleId));
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));
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));
DotNetNuke.Modules.ActiveForums.Controllers.ForumController.UpdateForumLastUpdates(ri.ForumId);
return replyId;
}
public DotNetNuke.Modules.ActiveForums.Entities.ReplyInfo ApproveReply(int PortalId, int TabId, int ModuleId, int ForumId, int TopicId, int ReplyId)
{
Expand All @@ -139,7 +143,7 @@ public DotNetNuke.Modules.ActiveForums.Entities.ReplyInfo ApproveReply(int Porta
}
reply.IsApproved = true;
rc.Reply_Save(PortalId, ModuleId, reply);
DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, ReplyId);
DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, ReplyId);

if (forum.ModApproveTemplateId > 0 & reply.Author.AuthorId > 0)
{
Expand Down
7 changes: 5 additions & 2 deletions Dnn.CommunityForums/Controllers/TopicController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Http.Controllers;
using System.Xml.Linq;

namespace DotNetNuke.Modules.ActiveForums.Controllers
Expand Down Expand Up @@ -87,6 +88,7 @@ public static int QuickCreate(int PortalId, int ModuleId, int ForumId, string Su
if (topicId > 0)
{
DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, topicId, -1);

if (UserId > 0)
{
//TODO: update this to be consistent with reply count
Expand Down Expand Up @@ -173,14 +175,15 @@ public static void Move(int TopicId, int NewForumId)
DataCache.CacheClearPrefix(ti.ModuleId, string.Format(CacheKeys.TopicViewPrefix, ti.ModuleId));
DataCache.CacheClearPrefix(ti.ModuleId, string.Format(CacheKeys.TopicsViewPrefix, ti.ModuleId));
}
public static int SaveToForum(int ModuleId, int ForumId, int TopicId, int LastReplyId = -1)
public static void SaveToForum(int ModuleId, int ForumId, int TopicId, int LastReplyId = -1)
{
DataProvider.Instance().Topics_SaveToForum(ForumId, TopicId, LastReplyId);
Utilities.UpdateModuleLastContentModifiedOnDate(ModuleId);
DotNetNuke.Modules.ActiveForums.Controllers.ForumController.UpdateForumLastUpdates(ForumId);
DataCache.ContentCacheClear(ModuleId, string.Format(CacheKeys.ForumInfo, ModuleId, ForumId));
DataCache.CacheClearPrefix(ModuleId, string.Format(CacheKeys.ForumViewPrefix, ModuleId));
DataCache.CacheClearPrefix(ModuleId, string.Format(CacheKeys.TopicViewPrefix, ModuleId));
DataCache.CacheClearPrefix(ModuleId, string.Format(CacheKeys.TopicsViewPrefix, ModuleId));
return Convert.ToInt32(DataProvider.Instance().Topics_SaveToForum(ForumId, TopicId, LastReplyId));
}
public static int Save(DotNetNuke.Modules.ActiveForums.Entities.TopicInfo ti)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private string ParseForumRow(string Template, DotNetNuke.Modules.ActiveForums.En
bool canView = DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasPerm(fi.Security.View, ForumUser.UserRoles);
bool canSubscribe = DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasPerm(fi.Security.Subscribe, ForumUser.UserRoles);
bool canRead = DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasPerm(fi.Security.Read, ForumUser.UserRoles);
string sIcon = TemplateUtils.ShowIcon(canView, fi.ForumID, CurrentUserId, fi.LastPostDateTime, fi.LastRead, fi.LastPostID);
string sIcon = TemplateUtils.ShowIcon(canView, fi.ForumID, CurrentUserId, fi.LastPostDateTime, DotNetNuke.Modules.ActiveForums.Controllers.ForumController.Forum_GetLastReadTopicByUser(fi.ForumID, CurrentUserId), fi.LastPostID);
string sIconImage = "<img alt=\"" + fi.ForumName + "\" src=\"" + ThemePath + "images/" + sIcon + "\" />";

if (Template.Contains("[FORUMICON]"))
Expand Down
4 changes: 3 additions & 1 deletion Dnn.CommunityForums/ReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@

<h4>Bug Fixes</h4>
<ul>
<li>BUG: Not redirected to new page after submitting edits to an existing reply (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/issues/963">Issue 963</a>, thanks <a href="https://github.com/johnhenley" target="_blank">@johnhenley</a>!)</li>
<li>BUG: Email notifications being sent for topics that have not cleared moderation (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/issues/971">Issue 971</a>, thanks <a href="https://github.com/johnhenley" target="_blank">@johnhenley</a>!)</li>
<li>BUG: After Update to 8.1.1 Visited / Read forums icons not reflecting actual status anymore. (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/issues/973">Issue 973</a>, thanks <a href="https://github.com/johnhenley" target="_blank">@johnhenley</a>!)</li>
<li>BUG: Redirect after editing a post comment (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/issues/962">Issue 962</a>, thanks <a href="https://github.com/johnhenley" target="_blank">@johnhenley</a>!)</li>
<li>BUG: Clicking Save in forum control panel restores default security when forum is not inheriting security from group (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/issues/964">Issue 964</a>, thanks <a href="https://github.com/johnhenley" target="_blank">@johnhenley</a>!)</li>
<!--<li>FIXED: (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/issues/">Issue </a>, thanks <a href="https://github.com/" target="_blank">@</a>!)</li>-->
</ul>
Expand Down
13 changes: 11 additions & 2 deletions Dnn.CommunityForums/components/Topics/TopicsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Data;
using System.Data.SqlTypes;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text.RegularExpressions;
using DotNetNuke.Common.Controls;
using DotNetNuke.Entities.Modules;
Expand All @@ -48,9 +49,17 @@ public class TopicsController : DotNetNuke.Entities.Modules.ModuleSearchBase, Do
[Obsolete(message: "Deprecated in Community Forums. Scheduled removal in 10.00.00. Use DotNetNuke.Modules.ActiveForums.Controllers.TopicController.Save(TopicInfo ti)")]
public int TopicSave(int PortalId, int ModuleId, DotNetNuke.Modules.ActiveForums.Entities.TopicInfo ti) => DotNetNuke.Modules.ActiveForums.Controllers.TopicController.Save(ti);
[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)")]
public int Topics_SaveToForum(int ForumId, int TopicId, int PortalId, int ModuleId) => DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, -1);
public int Topics_SaveToForum(int ForumId, int TopicId, int PortalId, int ModuleId)
{
DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, -1);
return -1;
}
[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)")]
public int Topics_SaveToForum(int ForumId, int TopicId, int PortalId, int ModuleId, int LastReplyId) => DotNetNuke.Modules.ActiveForums.Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, LastReplyId);
public int Topics_SaveToForum(int ForumId, int TopicId, int PortalId, int ModuleId, int LastReplyId)
{
Controllers.TopicController.SaveToForum(ModuleId, ForumId, TopicId, LastReplyId);
return -1;
}
[Obsolete("Deprecated in Community Forums. Scheduled removal in 10.00.00. Use DotNetNuke.Modules.ActiveForums.Controllers.TopicController.GetById(int TopicId)")]
public DotNetNuke.Modules.ActiveForums.Entities.TopicInfo Topics_Get(int PortalId, int ModuleId, int TopicId) => new DotNetNuke.Modules.ActiveForums.Controllers.TopicController().GetById(TopicId);
[Obsolete("Deprecated in Community Forums. Scheduled removal in 10.00.00. Use DotNetNuke.Modules.ActiveForums.Controllers.TopicController.GetById(int TopicId)")]
Expand Down
56 changes: 26 additions & 30 deletions Dnn.CommunityForums/controls/af_post.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected override void OnInit(EventArgs e)
{
if (!_canEdit && (Request.Params[ParamKeys.action].ToLowerInvariant() == PostActions.TopicEdit || Request.Params[ParamKeys.action].ToLowerInvariant() == PostActions.ReplyEdit))
Response.Redirect(NavigateUrl(TabId));
}
}

if (CanCreate == false && CanReply == false)
Response.Redirect(NavigateUrl(TabId, "", "ctl=login") + "?returnurl=" + Server.UrlEncode(Request.RawUrl));
Expand Down Expand Up @@ -819,28 +819,18 @@ private void SaveTopic()
DataCache.CacheClearPrefix(ForumModuleId, string.Format(CacheKeys.TopicsViewPrefix, ForumModuleId));
DataCache.CacheClearPrefix(ForumModuleId, string.Format(CacheKeys.ForumViewPrefix, ForumModuleId));

if (ti.IsApproved == false)
if (!ti.IsApproved)
{
DotNetNuke.Modules.ActiveForums.Controllers.TopicController.QueueUnapprovedTopicAfterAction(PortalId, TabId, ForumModuleId, _fi.ForumGroupId, ForumId, TopicId, 0, ti.Content.AuthorId);

string[] @params = { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", ParamKeys.ConfirmActionId + "=" + ConfirmActions.MessagePending };
Response.Redirect(NavigateUrl(ForumTabId, "", @params), false);
}
if (!_isEdit)
{
DotNetNuke.Modules.ActiveForums.Controllers.TopicController.QueueApprovedTopicAfterAction(PortalId, TabId, ModuleId, ForumInfo.ForumGroupId, ForumId, TopicId, 0, ti.Content.AuthorId);
}

if (ti.IsApproved == false)
{
string[] @params = { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", ParamKeys.ConfirmActionId + "=" + ConfirmActions.MessagePending };
Response.Redirect(NavigateUrl(TabId, "", @params), false);
Context.ApplicationInstance.CompleteRequest();
}
else
{
if (ti != null)
if (!_isEdit)
{
ti.TopicId = TopicId;
DotNetNuke.Modules.ActiveForums.Controllers.TopicController.QueueApprovedTopicAfterAction(PortalId, TabId, ModuleId, ForumInfo.ForumGroupId, ForumId, TopicId, 0, ti.Content.AuthorId);
}
ControlUtils ctlUtils = new ControlUtils();
string sUrl = ctlUtils.BuildUrl(TabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, ti.TopicUrl, -1, -1, string.Empty, 1, -1, SocialGroupId);
Expand All @@ -849,6 +839,7 @@ private void SaveTopic()
sUrl = Utilities.NavigateURL(ForumTabId, "", ParamKeys.TopicId + "=" + TopicId);
}
Response.Redirect(sUrl, false);
Context.ApplicationInstance.CompleteRequest();
}
}
catch (Exception ex)
Expand Down Expand Up @@ -972,27 +963,32 @@ private void SaveReply()
new SubscriptionController().Subscription_Update(PortalId, ForumModuleId, ForumId, TopicId, 1, authorId, ForumUser.UserRoles);
}
}
if (ri.IsApproved == false)
if (!ri.IsApproved)
{
DotNetNuke.Modules.ActiveForums.Controllers.ReplyController.QueueUnapprovedReplyAfterAction(PortalId, TabId, ForumModuleId, _fi.ForumGroupId, ForumId, TopicId, tmpReplyId, ri.Content.AuthorId);

string[] @params = { ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ViewType + "=confirmaction", ParamKeys.ConfirmActionId + "=" + ConfirmActions.MessagePending };
Response.Redirect(Utilities.NavigateURL(TabId, "", @params), false);
Context.ApplicationInstance.CompleteRequest();
}
if (!_isEdit)
{
DotNetNuke.Modules.ActiveForums.Controllers.ReplyController.QueueApprovedReplyAfterAction(PortalId, TabId, ModuleId, _fi.ForumGroupId, ForumId, TopicId, tmpReplyId, ri.Content.AuthorId);
}
var fullURL = new ControlUtils().BuildUrl(TabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, ri.Topic.TopicUrl, -1, -1, string.Empty, 1, tmpReplyId, SocialGroupId);
if (fullURL.Contains("~/"))
{
fullURL = Utilities.NavigateURL(TabId, "", new[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + tmpReplyId });
}
if (fullURL.EndsWith("/"))
{
fullURL += Utilities.UseFriendlyURLs(ForumModuleId) ? String.Concat("#", tmpReplyId) : String.Concat("?", ParamKeys.ContentJumpId, "=", tmpReplyId);
}
Response.Redirect(fullURL);
else
{
if (!_isEdit)
{
DotNetNuke.Modules.ActiveForums.Controllers.ReplyController.QueueApprovedReplyAfterAction(PortalId, TabId, ModuleId, _fi.ForumGroupId, ForumId, TopicId, tmpReplyId, ri.Content.AuthorId);
}
var fullURL = new ControlUtils().BuildUrl(TabId, ForumModuleId, ForumInfo.ForumGroup.PrefixURL, ForumInfo.PrefixURL, ForumInfo.ForumGroupId, ForumInfo.ForumID, TopicId, ri.Topic.TopicUrl, -1, -1, string.Empty, 1, tmpReplyId, SocialGroupId);
if (fullURL.Contains("~/"))
{
fullURL = Utilities.NavigateURL(TabId, "", new[] { ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + tmpReplyId });
}
if (fullURL.EndsWith("/"))
{
fullURL += Utilities.UseFriendlyURLs(ForumModuleId) ? String.Concat("#", tmpReplyId) : String.Concat("?", ParamKeys.ContentJumpId, "=", tmpReplyId);
}
Response.Redirect(fullURL, false);
Context.ApplicationInstance.CompleteRequest();
}
}
catch (Exception)
{
Expand Down

0 comments on commit 236abd5

Please sign in to comment.