Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Move Topic/Reply functions to Web API #740

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
593c4de
modernize modMove topic to use web api
johnhenley Aug 4, 2023
4f3b2b8
migrate move topic to web api
johnhenley Aug 4, 2023
ccf102f
various fixes/changes for web api
johnhenley Aug 6, 2023
cfdcbe1
migrate 'mark as answer' to web api
johnhenley Aug 7, 2023
660efd6
continue migration of move topic to web api
johnhenley Aug 7, 2023
466fe52
move delete topic from handler to web api
johnhenley Aug 13, 2023
15a09bb
Merge branch 'dev' into modernize/webapi-topics-replies
johnhenley Aug 13, 2023
758873e
Merge branch 'dev' into modernize/webapi-topics-replies
johnhenley Aug 13, 2023
3038d6b
move delete post (topics/replies) from handler to web api
johnhenley Aug 13, 2023
542c83b
resync dev
johnhenley Aug 14, 2023
162b6b9
Merge branch 'issues/395-web-api-from-viewer' into modernize/webapi-t…
johnhenley Aug 14, 2023
07029ad
handle child portals in webapi calls (prepend sf_siteroot if needed)
johnhenley Aug 14, 2023
94b15f4
moving topic 'quick edit' to web api
johnhenley Aug 16, 2023
97ded70
resync dev
johnhenley Aug 16, 2023
2325fff
resync dev
johnhenley Dec 1, 2023
93ea1b1
resync
johnhenley Feb 13, 2024
d324311
resync
johnhenley Feb 13, 2024
7b3a1e4
resync dev
johnhenley Feb 24, 2024
4495b7f
pull in topics/replies modernizations
johnhenley Feb 24, 2024
bd58048
resync dev
johnhenley Mar 5, 2024
aeea888
modernize webapi topics/replies
johnhenley Mar 5, 2024
01a5e6b
Refactor/centralize topic icon logic from grid / search results
johnhenley Mar 6, 2024
2876b2e
Sync UpdateModuleLastContentModifiedOnDate in TopicsController
johnhenley Mar 6, 2024
a8e4254
Converting Load topic to web api
johnhenley Mar 6, 2024
c58c55d
Correct [Scope] attribute
johnhenley Mar 6, 2024
42f8208
modernize webapi topics
johnhenley Mar 8, 2024
5a7aef5
resync dev
johnhenley Mar 12, 2024
b50010c
resync dev
johnhenley Mar 12, 2024
8496bc0
remove incorrect deprecated attribute
johnhenley Mar 14, 2024
91febad
ContentInfo DateCreated/DateUpdated are now readonly properties and u…
johnhenley Mar 14, 2024
8604ae3
ContentInfo DateCreated/DateUpdated are now readonly properties and u…
johnhenley Mar 14, 2024
c577c1d
Updates to ForumView
johnhenley Mar 15, 2024
e1b3ebd
Updates to Topic Loading Web API
johnhenley Mar 15, 2024
ad0f6d4
Don't move deprecated classes to deprecated folder; leave in existing…
johnhenley Mar 18, 2024
3aa9b3b
Add DAL2 for Tags (and categories, a subclass of tag)
johnhenley Mar 18, 2024
6d9edb4
Add DAL2 for Tags (and categories, a subclass of tag)
johnhenley Mar 18, 2024
37de3fa
Move "quick edit" topic save to Web API
johnhenley Mar 19, 2024
2d18853
Modernized FilterInfo
johnhenley Mar 26, 2024
ffd808a
Deprecated methods for unused stored procedures replaced by DAL2
johnhenley Mar 26, 2024
7ddb3cc
resync dev
johnhenley Mar 28, 2024
a228884
Various changes to topics logic; keep Topics_Delete procedure for now
johnhenley Mar 29, 2024
2b96bde
Push ModuleId to DAL2 controllers for scope
johnhenley Apr 1, 2024
b236da4
webapi for topic move
johnhenley Apr 3, 2024
8b27b99
resync dev
johnhenley Apr 4, 2024
656a37f
resync dev
johnhenley Apr 4, 2024
8d39345
Don't use autopopulated DateTime properties on activeforums_Content u…
johnhenley Apr 5, 2024
be8ba5c
resync dev
johnhenley Apr 5, 2024
b526f0f
resync dev
johnhenley Apr 5, 2024
a9acfd5
Merge branch 'dev81/4-webapi/1-topics-replies-390-400' of https://git…
johnhenley Apr 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Dnn.CommunityForums/Controllers/CategoryController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Community Forums
// Copyright (c) 2013-2021
// by DNN Community
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//

using System.Collections.Generic;
using System.Linq;

namespace DotNetNuke.Modules.ActiveForums.Controllers
{
internal partial class CategoryController : RepositoryControllerBase<DotNetNuke.Modules.ActiveForums.Entities.CategoryInfo> { }
}
16 changes: 11 additions & 5 deletions Dnn.CommunityForums/Controllers/ReplyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,29 @@ public int Reply_QuickCreate(int PortalId, int ModuleId, int ForumId, int TopicI
{
int replyId = -1;
DotNetNuke.Modules.ActiveForums.Entities.ReplyInfo ri = new DotNetNuke.Modules.ActiveForums.Entities.ReplyInfo();
ri.TopicId = TopicId;
ri.ReplyToId = ReplyToId;
ri.IsApproved = IsApproved;
ri.IsDeleted = false;
ri.StatusId = -1;
ri.Content = new DotNetNuke.Modules.ActiveForums.Entities.ContentInfo();
ri.Content.AuthorId = UserId;
ri.Content.AuthorName = DisplayName;
ri.Content.Subject = Subject;
ri.Content.Body = Body;
ri.Content.IPAddress = IPAddress;
ri.Content.Summary = string.Empty;
ri.IsApproved = IsApproved;
ri.IsDeleted = false;
ri.ReplyToId = ReplyToId;
ri.StatusId = -1;
ri.TopicId = TopicId;
replyId = Reply_Save(PortalId, ModuleId, ri);
Utilities.UpdateModuleLastContentModifiedOnDate(ModuleId);
return replyId;
}
public int Reply_Save(int PortalId, int ModuleId, DotNetNuke.Modules.ActiveForums.Entities.ReplyInfo ri)
{
ri.Content.DateUpdated = DateTime.UtcNow;
if (ri.ReplyId < 1)
{
ri.Content.DateCreated = DateTime.UtcNow;
}
// Clear profile Cache to make sure the LastPostDate is updated for Flood Control
UserProfileController.Profiles_ClearCache(ModuleId, ri.Content.AuthorId);

Expand Down
11 changes: 9 additions & 2 deletions Dnn.CommunityForums/Controllers/TopicController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//T
// Community Forums
// Copyright (c) 2013-2021
// by DNN Community
Expand Down Expand Up @@ -49,7 +49,9 @@ public DotNetNuke.Modules.ActiveForums.Entities.TopicInfo GetById(int TopicId)
public static int QuickCreate(int PortalId, int ModuleId, int ForumId, string Subject, string Body, int UserId, string DisplayName, bool IsApproved, string IPAddress)
{
int topicId = -1;
DotNetNuke.Modules.ActiveForums.Entities.TopicInfo ti = new DotNetNuke.Modules.ActiveForums.Entities.TopicInfo();
DotNetNuke.Modules.ActiveForums.Entities.TopicInfo ti = new DotNetNuke.Modules.ActiveForums.Entities.TopicInfo();
ti.Content = new DotNetNuke.Modules.ActiveForums.Entities.ContentInfo();

ti.ForumId = ForumId;
ti.AnnounceEnd = Utilities.NullDate();
ti.AnnounceStart = Utilities.NullDate();
Expand Down Expand Up @@ -170,6 +172,11 @@ public static int SaveToForum(int ModuleId, int ForumId, int TopicId, int LastRe
}
public static int Save(DotNetNuke.Modules.ActiveForums.Entities.TopicInfo ti)
{
ti.Content.DateUpdated = DateTime.UtcNow;
if (ti.TopicId < 1)
{
ti.Content.DateCreated = DateTime.UtcNow;
}
UserProfileController.Profiles_ClearCache(ti.ModuleId, ti.Content.AuthorId);
if (ti.IsApproved && ti.Author.AuthorId > 0)
{ //TODO: put this in a better place and make it consistent with reply counter
Expand Down
8 changes: 4 additions & 4 deletions Dnn.CommunityForums/CustomControls/HTML/CategoriesList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public string RenderEdit()
{
sb.Append("<li>");
sb.Append("<input type=\"checkbox\"");
if (IsSelected(dr["TagName"].ToString()))
if (IsSelected(Utilities.SafeConvertInt(dr["TagId"].ToString())))
{
sb.Append(" checked=\"checked\" ");
sSelected += dr["TagId"].ToString() + ";";
Expand All @@ -247,19 +247,19 @@ public string RenderEdit()
}
return sb.ToString();
}
private bool IsSelected(string TagName)
private bool IsSelected(int CategoryId) /* Category is stored in Tag table with 'isCategory' = true */
{
if (string.IsNullOrEmpty(SelectedValues))
{
return false;
}
else
{
foreach (string s in SelectedValues.Split('|'))
foreach (string s in SelectedValues.Split(';'))
{
if (! (string.IsNullOrEmpty(s)))
{
if (s.ToLowerInvariant().Trim() == TagName.ToLowerInvariant().Trim())
if (Utilities.SafeConvertInt(s.Trim()) == CategoryId)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Dnn.CommunityForums/CustomControls/HTML/TopicBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ private string ParseDataRow(IDataRecord row, string tmp)

if (_canEdit)
{
tmp = tmp.Replace("[AF:QUICKEDITLINK]", "<span class=\"af-icon16 af-icon16-gear\" onclick=\"amaf_quickEdit(" + row["TopicId"].ToString() + ");\"></span>");
tmp = tmp.Replace("[AF:QUICKEDITLINK]", "<span class=\"af-icon16 af-icon16-gear\" onclick=\"amaf_quickEdit(" + ModuleId + "," + ForumId + row["TopicId"].ToString() + ");\"></span>");
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions Dnn.CommunityForums/CustomControls/UserControls/ForumView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public string BuildForumView()
int tmpGroupCount = 0;
if (Forums != null)
{
foreach (var fi in Forums.Where(f => !SubsOnly || f.ParentForumId > 0).Take(Globals.ForumCount))
foreach (var fi in Forums.Where(f => !SubsOnly || f.ParentForumId > 0).OrderBy(f => f.ForumGroup.SortOrder).ThenBy(f => f.SortOrder).Take(Globals.ForumCount))
{
bool canView = DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasPerm(fi.Security.View, ForumUser.UserRoles);
if ((UserInfo.IsSuperUser) || (canView) || (!fi.ForumGroup.Hidden))
Expand Down Expand Up @@ -710,7 +710,7 @@ private string GetForumName(bool CanView, bool Hidden, int TabID, int ForumID, s
}
return sOut;
}
#endregion
#endregion
}

}
12 changes: 6 additions & 6 deletions Dnn.CommunityForums/CustomControls/UserControls/TopicView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ private string ParseContent(DataRow dr, string tempate, int rowcount)
var avatarDisabled = dr.GetBoolean("AvatarDisabled");
var userRoles = dr.GetString("UserRoles");
var isUserOnline = dr.GetBoolean("IsUserOnline");
var replyStatusId = dr.GetInt("StatusId");
var replyStatusId = replyId > 0 ? dr.GetInt("StatusId") : 0;
var totalPoints = _enablePoints ? dr.GetInt("UserTotalPoints") : 0;
var answerCount = dr.GetInt("AnswerCount");
var rewardPoints = dr.GetInt("RewardPoints");
Expand Down Expand Up @@ -1372,9 +1372,9 @@ private string ParseContent(DataRow dr, string tempate, int rowcount)
if (_bModDelete || ((_bDelete && authorId == UserId && !_bLocked) && ((replyId == 0 && _replyCount == 0) || replyId > 0)))
{
if (_useListActions)
sbOutput.Replace("[ACTIONS:DELETE]", "<li onclick=\"amaf_postDel(" + topicId + "," + replyId + ");\" title=\"[RESX:Delete]\"><i class=\"fa fa-trash-o fa-fw fa-blue\"></i><span class=\"dcf-link-text\">[RESX:Delete]</span></li>");
sbOutput.Replace("[ACTIONS:DELETE]", "<li onclick=\"amaf_postDel(" + ForumModuleId + "," + ForumId + "," + topicId + "," + replyId + ");\" title=\"[RESX:Delete]\"><i class=\"fa fa-trash-o fa-fw fa-blue\"></i><span class=\"dcf-link-text\">[RESX:Delete]</span></li>");
else
sbOutput.Replace("[ACTIONS:DELETE]", "<a href=\"javascript:void(0);\" class=\"af-actions\" onclick=\"amaf_postDel(" + topicId + "," + replyId + ");\" title=\"[RESX:Delete]\"><i class=\"fa fa-trash-o fa-fw fa-blue\"></i><span class=\"dcf-link-text\">[RESX:Delete]</span></a>");
sbOutput.Replace("[ACTIONS:DELETE]", "<a href=\"javascript:void(0);\" class=\"af-actions\" onclick=\"amaf_postDel(" + ForumModuleId + "," + ForumId + "," + topicId + "," + replyId + ");\" title=\"[RESX:Delete]\"><i class=\"fa fa-trash-o fa-fw fa-blue\"></i><span class=\"dcf-link-text\">[RESX:Delete]</span></a>");
}
else
{
Expand Down Expand Up @@ -1446,7 +1446,7 @@ private string ParseContent(DataRow dr, string tempate, int rowcount)

if (_bModMove)
{
sbOutput.Replace("[ACTIONS:MOVE]", "<li onclick=\"javascript:amaf_openMove([TOPICID])\"';\" title=\"[RESX:Move]\"><i class=\"fa fa-exchange fa-rotate-90 fa-blue\"></i><span class=\"dcf-link-text\">[RESX:Move]</span></li>");
sbOutput.Replace("[ACTIONS:MOVE]", "<li onclick=\"javascript:amaf_openMove(" + ModuleId + "," + ForumId + ",[TOPICID])\"';\" title=\"[RESX:Move]\"><i class=\"fa fa-exchange fa-rotate-90 fa-blue\"></i><span class=\"dcf-link-text\">[RESX:Move]</span></li>");
}
else
{
Expand Down Expand Up @@ -1493,9 +1493,9 @@ private string ParseContent(DataRow dr, string tempate, int rowcount)
{
// Can mark answer
if (_useListActions)
sbOutput.Replace("[ACTIONS:ANSWER]", "<li class=\"af-markanswer\" onclick=\"amaf_markAnswer(" + topicId.ToString() + "," + replyId.ToString() + ");\" title=\"[RESX:Status:SelectAnswer]\"><em></em>[RESX:Status:SelectAnswer]</li>");
sbOutput.Replace("[ACTIONS:ANSWER]", "<li class=\"af-markanswer\" onclick=\"amaf_MarkAsAnswer(" + ModuleId.ToString() + "," + ForumId.ToString() + "," + topicId.ToString() + "," + replyId.ToString() + ");\" title=\"[RESX:Status:SelectAnswer]\"><em></em>[RESX:Status:SelectAnswer]</li>");
else
sbOutput.Replace("[ACTIONS:ANSWER]", "<a class=\"af-actions af-markanswer\" href=\"#\" onclick=\"amaf_markAnswer(" + topicId.ToString() + "," + replyId.ToString() + "); return false;\" title=\"[RESX:Status:SelectAnswer]\"><em></em>[RESX:Status:SelectAnswer]</a>");
sbOutput.Replace("[ACTIONS:ANSWER]", "<a class=\"af-actions af-markanswer\" href=\"#\" onclick=\"amaf_MarkAsAnswer(" + ModuleId.ToString() + "," + ForumId.ToString() + "," + topicId.ToString() + "," + replyId.ToString() + "); return false;\" title=\"[RESX:Status:SelectAnswer]\"><em></em>[RESX:Status:SelectAnswer]</a>");
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions Dnn.CommunityForums/CustomControls/UserControls/TopicsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ private string ParseControls(string Template)
sOutput = sOutput.Replace("[GROUPNAME]", GroupName);
if (bModDelete)
{
sOutput = sOutput.Replace("[ACTIONS:DELETE]", "<a href=\"javascript:void(0)\" onclick=\"amaf_modDel([TOPICID]);\" style=\"vertical-align:middle;\" title=\"[RESX:DeleteTopic]\" /><i class=\"fa fa-trash-o fa-fw fa-blue\"></i></a>");
sOutput = sOutput.Replace("[ACTIONS:DELETE]", "<a href=\"javascript:void(0)\" onclick=\"amaf_modDel(" + ModuleId + "," + ForumId + ",[TOPICID]);\" style=\"vertical-align:middle;\" title=\"[RESX:DeleteTopic]\" /><i class=\"fa fa-trash-o fa-fw fa-blue\"></i></a>");
}
else
{
Expand All @@ -624,7 +624,7 @@ private string ParseControls(string Template)
string[] EditParams = { ParamKeys.ViewType + "=post", "action=te", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=0-0" };
sOutput = sOutput.Replace("[ACTIONS:EDIT]", "<a title=\"[RESX:EditTopic]\" href=\"" + NavigateUrl(TabId, "", EditParams) + "\"><i class=\"fa fa-pencil-square-o fa-fw fa-blue\"></i></a>");
sOutput = sOutput.Replace("0-0", "[TOPICID]");
sOutput = sOutput.Replace("[AF:QUICKEDITLINK]", "<a href=\"javascript:void(0)\" title=\"[RESX:TopicQuickEdit]\" onclick=\"amaf_quickEdit([TOPICID]);\"><i class=\"fa fa-cog fa-fw fa-blue\"></i></a>");
sOutput = sOutput.Replace("[AF:QUICKEDITLINK]", "<a href=\"javascript:void(0)\" title=\"[RESX:TopicQuickEdit]\" onclick=\"amaf_quickEdit(" + ModuleId + "," + ForumId + ",[TOPICID]);\"><i class=\"fa fa-cog fa-fw fa-blue\"></i></a>");
}
else
{
Expand All @@ -633,7 +633,7 @@ private string ParseControls(string Template)
}
if (bModMove)
{
sOutput = sOutput.Replace("[ACTIONS:MOVE]", "<a href=\"javascript:void(0)\" onclick=\"javascript:amaf_openMove([TOPICID]);\" title=\"[RESX:MoveTopic]\" style=\"vertical-align:middle;\" /><i class=\"fa fa-exchange fa-rotate-90 fa-blue\"></i></a>");
sOutput = sOutput.Replace("[ACTIONS:MOVE]", "<a href=\"javascript:void(0)\" onclick=\"javascript:amaf_openMove(" + ModuleId + "," + ForumId + ",[TOPICID]);\" title=\"[RESX:MoveTopic]\" style=\"vertical-align:middle;\" /><i class=\"fa fa-exchange fa-rotate-90 fa-blue\"></i></a>");
}
else
{
Expand Down
5 changes: 4 additions & 1 deletion Dnn.CommunityForums/DnnCommunityForums.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,8 @@
<Compile Include="class\DataRowExtensions.cs" />
<Compile Include="class\DataRecordExtensions.cs" />
<Compile Include="class\Injector.cs" />
<Compile Include="components\Replies\Replies.cs" />
<Compile Include="Controllers\CategoryController.cs" />
<Compile Include="Controllers\ContentController.cs" />
<Compile Include="Controllers\PermissionController.cs" />
<Compile Include="Controllers\ControllerBase.cs" />
Expand All @@ -1132,6 +1134,7 @@
<Compile Include="Entities\CategoryInfo.cs" />
<Compile Include="DAL2\Reply\ReplyController.cs" />
<Compile Include="DAL2\Reply\Reply.cs" />
<Compile Include="Entities\CategoryInfo.cs" />
<Compile Include="Entities\ContentInfo.cs" />
<Compile Include="Deprecated\API.cs" />
<Compile Include="Entities\ForumCollection.cs" />
Expand Down Expand Up @@ -1197,6 +1200,7 @@
<Compile Include="Services\Controllers\ControllerBase.cs" />
<Compile Include="Entities\Token.cs" />
<Compile Include="Services\Controllers\ForumController.cs" />
<Compile Include="Services\Controllers\ReplyController.cs" />
<Compile Include="Services\Controllers\TopicController.cs" />
<Compile Include="Services\Controllers\UserController.cs" />
<Compile Include="Services\Controllers\LikeController.cs" />
Expand Down Expand Up @@ -1795,7 +1799,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="class\API\" />
<Folder Include="components\Replies\" />
<Folder Include="components\Security\" />
<Folder Include="Legacy\" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Dnn.CommunityForums/Entities/ReplyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public DotNetNuke.Modules.ActiveForums.Entities.ForumInfo Forum

internal DotNetNuke.Modules.ActiveForums.Entities.ForumInfo GetForum()
{
return new DotNetNuke.Modules.ActiveForums.Controllers.ForumController().GetById(ForumId);
return new DotNetNuke.Modules.ActiveForums.Controllers.ForumController().GetById(ForumId); /* can't get using moduleId since ModuleId comes from Forum */
}

[IgnoreColumn()]
Expand Down
Loading