Skip to content

Commit 0e3d756

Browse files
authored
09.01.00 RC3 Prep (#1577)
* TASK: Release Prep 09.01.00 RC3 * FIX: Subscribe button toggle needs to be passed the moduleId of the actual module (viewer or forums), not the module Id of the forums. * Add token replacement for subscription UI controls to allow either a checkbox or a button * rework to handle viewer module * rework to handle viewer module
1 parent 128ea3f commit 0e3d756

File tree

28 files changed

+1691
-783
lines changed

28 files changed

+1691
-783
lines changed

Dnn.CommunityForums/App_LocalResources/LegacyTokenResources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,4 +420,10 @@
420420
<data name="[SUBJECTLINK].Text" xml:space="preserve">
421421
<value>&lt;a href="{0}" class="dcf-topic-link"&gt;[FORUMTOPIC:SUBJECT]&lt;/a&gt;</value>
422422
</data>
423+
<data name="[TOPICSUBSCRIBE].Text" xml:space="preserve">
424+
<value>&lt;input id="amaf-chk-subs" type="checkbox" checked="[FORUMTOPIC:SUBSCRIBED]" class="amaf-chk-subs" onclick="{0}" /&gt;&lt;label for="amaf-chk-subs"&gt;[RESX:Subscribe]&lt;/label&gt;</value>
425+
</data>
426+
<data name="[FORUMSUBSCRIBE].Text" xml:space="preserve">
427+
<value>&lt;input id="amaf-chk-subs" type="checkbox" checked="[FORUM:SUBSCRIBED]" class="amaf-chk-subs" onclick="{0}" /&gt;&lt;label for="amaf-chk-subs"&gt;[RESX:Subscribe]&lt;/label&gt;</value>
428+
</data>
423429
</root>

Dnn.CommunityForums/CustomControls/HTML/ToggleSubscribe.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,10 @@ public string Render()
5858
if (this.DisplayMode == 0)
5959
{
6060
sb.Append("<span class=\"afnormal\">");
61-
sb.Append("<input id=\"dcf-btn-subs\" type=\"button\" ");
61+
sb.Append("<input id=\"amaf-chk-subs\" class=\"amaf-chk-subs\" type=\"checkbox\" ");
6262
if (this.Checked)
6363
{
64-
sb.Append("class=\"dcf-btn-subs dnnSecondaryAction\" value=\"[RESX:Unsubscribe]\" ");
65-
}
66-
else
67-
{
68-
sb.Append("class=\"dcf-btn-subs dnnPrimaryAction\" value=\"[RESX:Subscribe]\" ");
64+
sb.Append("checked=\"checked\" ");
6965
}
7066

7167
if (this.ToggleMode == 0)
@@ -77,6 +73,7 @@ public string Render()
7773
sb.Append(" onclick=\"amaf_topicSubscribe(" + this.ModuleId + "," + this.ForumId + "," + this.TopicId + ");\" />");
7874
}
7975

76+
sb.Append("<label for=\"amaf-chk-subs\">" + this.Text + "</label>");
8077
sb.Append("</span>");
8178
}
8279
else

Dnn.CommunityForums/CustomControls/UserControls/ForumView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ private string ParseForumRow(string template, DotNetNuke.Modules.ActiveForums.En
392392
if (DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasRequiredPerm(fi.Security.SubscribeRoleIds, this.ForumUser.UserRoleIds))
393393
{
394394
bool isSubscribed = new DotNetNuke.Modules.ActiveForums.Controllers.SubscriptionController().Subscribed(this.PortalId, this.ForumModuleId, this.UserId, this.ForumId);
395-
var subControl = new ToggleSubscribe(this.ForumModuleId, fi.ForumID, -1, 0);
395+
var subControl = new ToggleSubscribe(this.ModuleId, fi.ForumID, -1, 0);
396396
subControl.Checked = isSubscribed;
397397
subControl.DisplayMode = 1;
398398
subControl.UserId = this.CurrentUserId;

Dnn.CommunityForums/CustomControls/UserControls/SubmitForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ private string GetOptions()
793793
{
794794
if (this.TopicId > 0)
795795
{
796-
var subControl = new ToggleSubscribe(this.ForumModuleId, this.ForumInfo.ForumID, this.TopicId, 1);
796+
var subControl = new ToggleSubscribe(this.ModuleId, this.ForumInfo.ForumID, this.TopicId, 1);
797797
subControl.Checked = new DotNetNuke.Modules.ActiveForums.Controllers.SubscriptionController().Subscribed(this.PortalId, this.ForumModuleId, this.UserId, this.ForumInfo.ForumID, this.TopicId);
798798
subControl.Text = "[RESX:Subscribe]";
799799
sb.Append("<tr><td colspan=\"2\">" + subControl.Render() + "</td></tr>");

Dnn.CommunityForums/CustomControls/UserControls/TopicView.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,6 @@ private void BindTopic()
666666
ctlQuickReply.ModApprove = this.bModerate;
667667
ctlQuickReply.IsTrusted = this.isTrusted;
668668
ctlQuickReply.Subject = Utilities.GetSharedResource("[RESX:SubjectPrefix]") + " " + this.topic.Subject;
669-
ctlQuickReply.AllowSubscribe = this.Request.IsAuthenticated && this.bSubscribe;
670669
ctlQuickReply.AllowHTML = this.topic.Forum.FeatureSettings.AllowHTML;
671670
ctlQuickReply.AllowScripts = this.topic.Forum.FeatureSettings.AllowScript;
672671
ctlQuickReply.ForumId = this.ForumId;
@@ -761,7 +760,7 @@ private string ParseControls(string sOutput)
761760
// Subscribe Option
762761
if (this.bSubscribe)
763762
{
764-
var subControl = new ToggleSubscribe(this.ForumModuleId, this.ForumId, this.TopicId, 1);
763+
var subControl = new ToggleSubscribe(this.ModuleId, this.ForumId, this.TopicId, 1);
765764
subControl.Checked = this.isSubscribedTopic;
766765
subControl.Text = "[RESX:Subscribe]";
767766
sbOutput.Replace("[TOPICSUBSCRIBE]", subControl.Render());
@@ -817,12 +816,12 @@ private string ParseControls(string sOutput)
817816

818817
if (this.topic.IsLocked)
819818
{
820-
sbOutput.Replace("[ADDREPLY]", "<span class=\"dcf-topic-lock-locked-label-" + this.TopicId.ToString() + "\" class=\"afnormal\">[RESX:TopicLocked]</span><a href=\"" + Utilities.NavigateURL(this.TabId, string.Empty, @params.ToArray()) + "\" class=\"dnnPrimaryAction dcf-topic-reply-link dcf-topic-reply-locked\">[RESX:AddReply]</a>");
819+
sbOutput.Replace("[ADDREPLY]", "<span class=\"dcf-topic-lock-locked-label-" + this.TopicId.ToString() + " afnormal\">[RESX:TopicLocked]</span><a href=\"" + Utilities.NavigateURL(this.TabId, string.Empty, @params.ToArray()) + "\" class=\"dnnPrimaryAction dcf-topic-reply-link dcf-topic-reply-locked\">[RESX:AddReply]</a>");
821820
sbOutput.Replace("[QUICKREPLY]", "<div class=\"dcf-quickreply-wrapper\" style=\"display:none;\"><asp:placeholder id=\"plhQuickReply\" runat=\"server\" /></div>");
822821
}
823822
else
824823
{
825-
sbOutput.Replace("[ADDREPLY]", "<span class=\"dcf-topic-lock-locked-label-" + this.TopicId.ToString() + "\" class=\"afnormal\"></span><a href=\"" + Utilities.NavigateURL(this.TabId, string.Empty, @params.ToArray()) + "\" class=\"dnnPrimaryAction dcf-topic-reply-link dcf-topic-reply-unlocked\">[RESX:AddReply]</a>");
824+
sbOutput.Replace("[ADDREPLY]", "<span class=\"dcf-topic-lock-locked-label-" + this.TopicId.ToString() + " afnormal\"></span><a href=\"" + Utilities.NavigateURL(this.TabId, string.Empty, @params.ToArray()) + "\" class=\"dnnPrimaryAction dcf-topic-reply-link dcf-topic-reply-unlocked\">[RESX:AddReply]</a>");
826825
sbOutput.Replace("[QUICKREPLY]", "<div class=\"dcf-quickreply-wrapper\" style=\"display:block;\"><asp:placeholder id=\"plhQuickReply\" runat=\"server\" /></div>");
827826
}
828827
}
@@ -1020,6 +1019,10 @@ private string ParseTopic(string sOutput)
10201019
}
10211020
}
10221021

1022+
/* this handles token replacement for anything outside of the [TOPIC] or [REPLIES] sections */
1023+
sOutput = DotNetNuke.Modules.ActiveForums.Services.Tokens.TokenReplacer.MapLegacyTopicTokenSynonyms(new StringBuilder(sOutput), this.PortalSettings, this.ForumUser.UserInfo?.Profile?.PreferredLocale).ToString();
1024+
sOutput = DotNetNuke.Modules.ActiveForums.Services.Tokens.TokenReplacer.ReplaceTopicTokens(new StringBuilder(sOutput), this.topic, this.PortalSettings, this.MainSettings, new Services.URLNavigator().NavigationManager(), this.ForumUser, this.Request.Url, this.Request.RawUrl).ToString();
1025+
10231026
return sOutput;
10241027
}
10251028

Dnn.CommunityForums/CustomControls/UserControls/TopicsView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ private string ParseControls(string Template)
384384
// Forum Subscription Control
385385
if (this.bSubscribe)
386386
{
387-
Controls.ToggleSubscribe subControl = new Controls.ToggleSubscribe(this.ForumModuleId, this.ForumId, -1, 0);
387+
Controls.ToggleSubscribe subControl = new Controls.ToggleSubscribe(this.ModuleId, this.ForumId, -1, 0);
388388
subControl.Checked = this.isSubscribedForum;
389389
subControl.Text = "[RESX:Subscribe]";
390390
sOutput = sOutput.Replace("[FORUMSUBSCRIBE]", subControl.Render());

Dnn.CommunityForums/DnnCommunityForums.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
<ItemGroup>
5454
<PackageReference Include="coverlet.collector" Version="6.0.0" />
55-
<PackageReference Include="datatables.net-dt" Version="2.3.3" />
5655
<PackageReference Include="DotNetNuke.Abstractions" Version="9.11.0" />
5756
<PackageReference Include="DotNetNuke.Web" Version="9.11.0" />
5857
<PackageReference Include="DotNetNuke.Web.Client" Version="9.11.0" />

Dnn.CommunityForums/Entities/ForumGroupInfo.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
namespace DotNetNuke.Modules.ActiveForums.Entities
2222
{
2323
using System;
24+
using System.Linq;
2425

2526
using DotNetNuke.ComponentModel.DataAnnotations;
2627
using DotNetNuke.Entities.Modules;
@@ -224,6 +225,39 @@ internal ModuleInfo LoadModuleInfo()
224225
return this.moduleInfo = DotNetNuke.Entities.Modules.ModuleController.Instance.GetModule(this.ModuleId, DotNetNuke.Common.Utilities.Null.NullInteger, false);
225226
}
226227

228+
[IgnoreColumn]
229+
public bool RunningInViewer
230+
{
231+
get
232+
{
233+
return this.PortalSettings.ActiveTab != null && this.PortalSettings.ActiveTab.Modules.Cast<DotNetNuke.Entities.Modules.ModuleInfo>().Any(
234+
m => m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleFriendlyName + " Viewer", StringComparison.OrdinalIgnoreCase) ||
235+
m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleName + " Viewer", StringComparison.OrdinalIgnoreCase));
236+
}
237+
}
238+
239+
[IgnoreColumn]
240+
public int ForumsOrViewerModuleId
241+
{
242+
get
243+
{
244+
if (!this.RunningInViewer)
245+
{
246+
return this.ModuleId;
247+
}
248+
249+
if (this.PortalSettings.ActiveTab != null)
250+
{
251+
foreach (DotNetNuke.Entities.Modules.ModuleInfo module in this.PortalSettings.ActiveTab.Modules.Cast<DotNetNuke.Entities.Modules.ModuleInfo>().Where(m => m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleFriendlyName + " Viewer", StringComparison.OrdinalIgnoreCase) || m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleName + " Viewer", StringComparison.OrdinalIgnoreCase)))
252+
{
253+
return module.ModuleID;
254+
}
255+
}
256+
257+
return DotNetNuke.Common.Utilities.Null.NullInteger;
258+
}
259+
}
260+
227261
[IgnoreColumn]
228262
public DotNetNuke.Services.Tokens.CacheLevel Cacheability
229263
{

Dnn.CommunityForums/Entities/ForumInfo.cs

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,39 @@ internal string GetForumFolderIconCss(DotNetNuke.Modules.ActiveForums.Entities.F
785785
}
786786
}
787787

788+
[IgnoreColumn]
789+
public bool RunningInViewer
790+
{
791+
get
792+
{
793+
return this.PortalSettings.ActiveTab != null && this.PortalSettings.ActiveTab.Modules.Cast<DotNetNuke.Entities.Modules.ModuleInfo>().Any(
794+
m => m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleFriendlyName + " Viewer", StringComparison.OrdinalIgnoreCase) ||
795+
m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleName + " Viewer", StringComparison.OrdinalIgnoreCase));
796+
}
797+
}
798+
799+
[IgnoreColumn]
800+
public int ForumsOrViewerModuleId
801+
{
802+
get
803+
{
804+
if (!this.RunningInViewer)
805+
{
806+
return this.ModuleId;
807+
}
808+
809+
if (this.PortalSettings.ActiveTab != null)
810+
{
811+
foreach (DotNetNuke.Entities.Modules.ModuleInfo module in this.PortalSettings.ActiveTab.Modules.Cast<DotNetNuke.Entities.Modules.ModuleInfo>().Where(m => m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleFriendlyName + " Viewer", StringComparison.OrdinalIgnoreCase) || m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleName + " Viewer", StringComparison.OrdinalIgnoreCase)))
812+
{
813+
return module.ModuleID;
814+
}
815+
}
816+
817+
return DotNetNuke.Common.Utilities.Null.NullInteger;
818+
}
819+
}
820+
788821
/// <inheritdoc/>
789822
[IgnoreColumn]
790823
public DotNetNuke.Services.Tokens.CacheLevel Cacheability => DotNetNuke.Services.Tokens.CacheLevel.notCacheable;
@@ -818,7 +851,6 @@ public string GetProperty(string propertyName, string format, System.Globalizati
818851
propertyName = propertyName.ToLowerInvariant();
819852
try
820853
{
821-
822854
switch (propertyName)
823855
{
824856
case "forumid":
@@ -889,6 +921,62 @@ public string GetProperty(string propertyName, string format, System.Globalizati
889921
case "modlink":
890922
var modLink = Utilities.NavigateURL(this.GetTabId(), this.portalSettings, string.Empty, new[] { $"{ParamKeys.ViewType}={Views.ModerateTopics}", $"{ParamKeys.ForumId}={this.ForumID}" });
891923
return PropertyAccess.FormatString(modLink, format);
924+
925+
case "subscribe-unsubscribe-label":
926+
{
927+
var bSubscribe = DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasRequiredPerm(this.Security.SubscribeRoleIds, DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.GetUsersRoleIds(this.PortalSettings, accessingUser));
928+
if (bSubscribe)
929+
{
930+
return PropertyAccess.FormatString(
931+
!new DotNetNuke.Modules.ActiveForums.Controllers.SubscriptionController().Subscribed(portalId: this.PortalSettings.PortalId, moduleId: this.ModuleId, userId: accessingUser.UserID, forumId: this.ForumID)
932+
? Utilities.GetSharedResource("[RESX:Subscribe]")
933+
: Utilities.GetSharedResource("[RESX:Unsubscribe]"),
934+
format);
935+
}
936+
937+
return string.Empty;
938+
}
939+
940+
case "subscribed":
941+
{
942+
var bSubscribe = DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasRequiredPerm(this.Security.SubscribeRoleIds, DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.GetUsersRoleIds(this.PortalSettings, accessingUser));
943+
if (bSubscribe)
944+
{
945+
return PropertyAccess.FormatString(
946+
new DotNetNuke.Modules.ActiveForums.Controllers.SubscriptionController().Subscribed(portalId: this.PortalSettings.PortalId, moduleId: this.ModuleId, userId: accessingUser.UserID, forumId: this.ForumID)
947+
? "true"
948+
: "false",
949+
format);
950+
}
951+
952+
return string.Empty;
953+
}
954+
955+
case "subscribe-unsubscribe-cssclass":
956+
{
957+
var bSubscribe = DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasRequiredPerm(this.Security.SubscribeRoleIds, DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.GetUsersRoleIds(this.PortalSettings, accessingUser));
958+
if (bSubscribe)
959+
{
960+
return PropertyAccess.FormatString(
961+
!new DotNetNuke.Modules.ActiveForums.Controllers.SubscriptionController().Subscribed(portalId: this.PortalSettings.PortalId, moduleId: this.ModuleId, userId: accessingUser.UserID, forumId: this.ForumID)
962+
? "dnnPrimaryAction"
963+
: "dnnSecondaryAction",
964+
format);
965+
}
966+
967+
return string.Empty;
968+
}
969+
970+
case "subscribeonclick":
971+
{
972+
var bSubscribe = DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.HasRequiredPerm(this.Security.SubscribeRoleIds, DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.GetUsersRoleIds(this.PortalSettings, accessingUser));
973+
if (bSubscribe)
974+
{
975+
return PropertyAccess.FormatString($"javascript:amaf_forumSubscribe({this.ForumsOrViewerModuleId},{this.ForumID});", format);
976+
}
977+
978+
return string.Empty;
979+
}
892980
}
893981
}
894982
catch (Exception ex)

Dnn.CommunityForums/Entities/ForumUserInfo.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public ForumUserInfo(DotNetNuke.Entities.Portals.PortalSettings portalSettings,
5757
this.PortalId = portalSettings.PortalId;
5858
this.userInfo = userInfo;
5959
}
60+
6061
public ForumUserInfo(DotNetNuke.Entities.Portals.PortalSettings portalSettings)
6162
{
6263
this.portalSettings = portalSettings;
@@ -511,14 +512,41 @@ internal int GetLastTopicReplyRead(DotNetNuke.Modules.ActiveForums.Entities.Topi
511512
}
512513

513514
[IgnoreColumn]
514-
public DotNetNuke.Services.Tokens.CacheLevel Cacheability
515+
public bool RunningInViewer
516+
{
517+
get
518+
{
519+
return this.PortalSettings.ActiveTab != null && this.PortalSettings.ActiveTab.Modules.Cast<DotNetNuke.Entities.Modules.ModuleInfo>().Any(
520+
m => m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleFriendlyName + " Viewer", StringComparison.OrdinalIgnoreCase) ||
521+
m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleName + " Viewer", StringComparison.OrdinalIgnoreCase));
522+
}
523+
}
524+
525+
[IgnoreColumn]
526+
public int ForumsOrViewerModuleId
515527
{
516528
get
517529
{
518-
return DotNetNuke.Services.Tokens.CacheLevel.notCacheable;
530+
if (!this.RunningInViewer)
531+
{
532+
return this.ModuleId;
533+
}
534+
535+
if (this.PortalSettings.ActiveTab != null)
536+
{
537+
foreach (DotNetNuke.Entities.Modules.ModuleInfo module in this.PortalSettings.ActiveTab.Modules.Cast<DotNetNuke.Entities.Modules.ModuleInfo>().Where(m => m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleFriendlyName + " Viewer", StringComparison.OrdinalIgnoreCase) || m.ModuleDefinition.DefinitionName.Equals(Globals.ModuleName + " Viewer", StringComparison.OrdinalIgnoreCase)))
538+
{
539+
return module.ModuleID;
540+
}
541+
}
542+
543+
return DotNetNuke.Common.Utilities.Null.NullInteger;
519544
}
520545
}
521546

547+
[IgnoreColumn]
548+
public DotNetNuke.Services.Tokens.CacheLevel Cacheability => DotNetNuke.Services.Tokens.CacheLevel.notCacheable;
549+
522550
public string GetProperty(string propertyName, string format, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, Scope accessLevel, ref bool propertyNotFound)
523551
{
524552

0 commit comments

Comments
 (0)