Skip to content

Commit

Permalink
Merge pull request #1157 from johnhenley/issues/forum-delete-1156
Browse files Browse the repository at this point in the history
FIX: Delete forum not working; delete should remove subscriptions
  • Loading branch information
johnhenley authored Nov 13, 2024
2 parents ecf002a + b7fd2ab commit 91abdf3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
5 changes: 3 additions & 2 deletions Dnn.CommunityForums/Controllers/ForumController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@ public int Forums_Save(int portalId, DotNetNuke.Modules.ActiveForums.Entities.Fo

public void Forums_Delete(int portalId, int forumId, int moduleId)
{
// TODO: When these methods are updated to use DAL2 for update, uncomment Cacheable attribute on forumInfo
DotNetNuke.Modules.ActiveForums.DataProvider.Instance().Forums_Delete(portalId, moduleId, forumId);
//TODO: When these methods are updated to use DAL2 for update, uncomment Cacheable attribute on forumInfo
DotNetNuke.Modules.ActiveForums.DataProvider.Instance().Forums_Delete(portalId: portalId, moduleId: moduleId, forumId: forumId);
DataCache.ClearSettingsCache(moduleId);
}

internal static void IterateForumsList(System.Collections.Generic.List<DotNetNuke.Modules.ActiveForums.Entities.ForumInfo> forums, DotNetNuke.Modules.ActiveForums.Entities.ForumUserInfo forumUserInfo,
Expand Down
8 changes: 5 additions & 3 deletions Dnn.CommunityForums/Controllers/ForumGroupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
namespace DotNetNuke.Modules.ActiveForums.Controllers
{
using System.Collections;
using DotNetNuke.Modules.ActiveForums.Entities;

internal partial class ForumGroupController : DotNetNuke.Modules.ActiveForums.Controllers.RepositoryControllerBase<DotNetNuke.Modules.ActiveForums.Entities.ForumGroupInfo>
{
Expand Down Expand Up @@ -69,10 +70,11 @@ public int Groups_Save(int portalId, DotNetNuke.Modules.ActiveForums.Entities.Fo
return forumGroupInfo.ForumGroupId;
}

public void Groups_Delete(int forumGroupId, int moduleId)
public void Groups_Delete(int moduleId, int forumGroupId)
{
// TODO: When these methods are updated to use DAL2 for update, uncomment Cacheable attribute on forumGroupInfo
DataProvider.Instance().Groups_Delete(moduleId, forumGroupId);
//TODO: When these methods are updated to use DAL2 for update, uncomment Cacheable attribute on forumGroupInfo
DataProvider.Instance().Groups_Delete(moduleID: moduleId, forumGroupID: forumGroupId);
DataCache.ClearSettingsCache(moduleId);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2013-2024 by DNN Community
// Copyright (c) 2013-2024 by DNN Community
//
// DNN Community licenses this file to you under the MIT license.
//
Expand Down Expand Up @@ -338,14 +338,14 @@ private void cbEditorAction_Callback(object sender, Controls.CallBackEventArgs e
case "deleteforum":
{
var forumId = Utilities.SafeConvertInt(e.Parameters[1]);
new DotNetNuke.Modules.ActiveForums.Controllers.ForumController().Forums_Delete(this.PortalId, this.ModuleId, forumId);
new DotNetNuke.Modules.ActiveForums.Controllers.ForumController().Forums_Delete(portalId: this.PortalId, moduleId: this.ModuleId, forumId: forumId);
break;
}

case "deletegroup":
{
var groupId = Utilities.SafeConvertInt(e.Parameters[1]);
new DotNetNuke.Modules.ActiveForums.Controllers.ForumGroupController().Groups_Delete(this.ModuleId, groupId);
new DotNetNuke.Modules.ActiveForums.Controllers.ForumGroupController().Groups_Delete(moduleId: this.ModuleId, forumGroupId: groupId);
break;
}
}
Expand Down
27 changes: 27 additions & 0 deletions Dnn.CommunityForums/sql/08.02.00.SqlDataProvider
Original file line number Diff line number Diff line change
Expand Up @@ -2169,3 +2169,30 @@ GO
/* issue 1042 - end - mark answer */

/* --------------------- */



/* issue 1156 - begin - deleting a forum should remove subscriptions */

/* activeforums_Forums_Delete -- delete from activeforums_Subscriptions when deleting forum */
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}[{objectQualifier}activeforums_Forums_Delete]') AND type in (N'P', N'PC'))
DROP PROCEDURE {databaseOwner}[{objectQualifier}activeforums_Forums_Delete]
GO
CREATE PROCEDURE {databaseOwner}[{objectQualifier}activeforums_Forums_Delete]
@PortalId int,
@ModuleId int,
@ForumId int
AS
declare @ParentForumId int,
@ForumGroupId int
SELECT @ParentForumId = ParentForumId, @ForumGroupId = ForumGroupId
FROM {databaseOwner}[{objectQualifier}activeforums_Forums]
WHERE ForumId = @ForumId
DELETE FROM {databaseOwner}[{objectQualifier}activeforums_ForumTopics] WHERE ForumId = @ForumId
DELETE FROM {databaseOwner}[{objectQualifier}activeforums_Forums] WHERE ForumId = @ForumId
DELETE FROM {databaseOwner}[{objectQualifier}activeforums_Subscriptions] WHERE ForumId = @ForumId
EXEC {databaseOwner}[{objectQualifier}activeforums_Forums_RepairSort] @ForumGroupId, @ParentForumId
GO
/* issue 1156 - end - deleting a forum should remove subscriptions */

/* --------------------- */

0 comments on commit 91abdf3

Please sign in to comment.