Skip to content

Commit

Permalink
Merge pull request #756 from johnhenley/issues/subscribe-to-topic-imp…
Browse files Browse the repository at this point in the history
…rovements-753

ENH: changes to subscription options
  • Loading branch information
WillStrohl committed Apr 18, 2024
2 parents fe333c4 + 999df3a commit b70daa2
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 49 deletions.
12 changes: 0 additions & 12 deletions Dnn.CommunityForums/App_LocalResources/SharedResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -657,18 +657,6 @@
<data name="[RESX:Preview].Text" xml:space="preserve">
<value>Preview</value>
</data>
<data name="[RESX:ForumSubscribe:FALSE].Text" xml:space="preserve">
<value>Subscribe to this forum</value>
</data>
<data name="[RESX:ForumSubscribe:TRUE].Text" xml:space="preserve">
<value>Unsubscribe from forum</value>
</data>
<data name="[RESX:TopicSubscribe:FALSE].Text" xml:space="preserve">
<value>Subscribe to this topic</value>
</data>
<data name="[RESX:TopicSubscribe:TRUE].Text" xml:space="preserve">
<value>Unsubscribe from topic</value>
</data>
<data name="[RESX:Avatar].Text" xml:space="preserve">
<value>Avatar</value>
</data>
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 @@ -425,7 +425,7 @@ private string ParseForumRow(string Template, DotNetNuke.Modules.ActiveForums.En
if (canSubscribe)
{
bool IsSubscribed = new DotNetNuke.Modules.ActiveForums.Controllers.SubscriptionController().Subscribed(PortalId, ForumModuleId, UserId, ForumId);
string sAlt = "[RESX:ForumSubscribe:" + IsSubscribed.ToString().ToUpper() + "]";
string sAlt = "[RESX:Subscribe]";
string sImg = ThemePath + "images/email_unchecked.png";
if (IsSubscribed)
{
Expand All @@ -436,7 +436,7 @@ private string ParseForumRow(string Template, DotNetNuke.Modules.ActiveForums.En
subControl.DisplayMode = 1;
subControl.UserId = CurrentUserId;
subControl.ImageURL = sImg;
subControl.Text = "[RESX:ForumSubscribe:" + IsSubscribed.ToString().ToUpper() + "]";
subControl.Text = "[RESX:Subscribe]";

Template = Template.Replace("[AF:CONTROL:TOGGLESUBSCRIBE]", subControl.Render());
}
Expand Down
6 changes: 3 additions & 3 deletions Dnn.CommunityForums/CustomControls/UserControls/SubmitForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -710,18 +710,18 @@ private string GetOptions()
bHasOptions = true;
}

if (canSubscribe)
if (canSubscribe && !UserPrefTopicSubscribe) /* if user has preference set for auto subscribe, no need to show them the subscribe option */
{
if (TopicId > 0)
{
var subControl = new ToggleSubscribe(ForumModuleId, ForumInfo.ForumID, TopicId, 1);
subControl.Checked = (new DotNetNuke.Modules.ActiveForums.Controllers.SubscriptionController().Subscribed(PortalId, ForumModuleId, UserId, ForumInfo.ForumID, TopicId));
subControl.Text = "[RESX:TopicSubscribe:" + (new DotNetNuke.Modules.ActiveForums.Controllers.SubscriptionController().Subscribed(PortalId, ForumModuleId, UserId, ForumInfo.ForumID, TopicId)).ToString().ToUpper() + "]";
subControl.Text = "[RESX:Subscribe]";
sb.Append("<tr><td colspan=\"2\">" + subControl.Render() + "</td></tr>");
}
else
{
sb.Append("<tr><td colspan=\"2\"><asp:checkbox id=\"chkSubscribe\" Text=\"[RESX:TopicSubscribe:FALSE]\" TextAlign=\"right\" cssclass=\"afcheckbox\" runat=\"server\" /></td></tr>");
sb.Append("<tr><td colspan=\"2\"><asp:checkbox id=\"chkSubscribe\" Text=\"[RESX:Subscribe]\" TextAlign=\"right\" cssclass=\"afcheckbox\" runat=\"server\" /></td></tr>");
}
bHasOptions = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ private string ParseControls(string sOutput)
{
var subControl = new ToggleSubscribe(ForumModuleId, ForumId, TopicId, 1);
subControl.Checked = _isSubscribedTopic;
subControl.Text = "[RESX:TopicSubscribe:" + _isSubscribedTopic.ToString().ToUpper() + "]";
subControl.Text = "[RESX:Subscribe]";
sbOutput.Replace("[TOPICSUBSCRIBE]", subControl.Render());
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ private string ParseControls(string Template)
{
Controls.ToggleSubscribe subControl = new Controls.ToggleSubscribe(ForumModuleId, ForumId, -1, 0);
subControl.Checked = IsSubscribedForum;
subControl.Text = "[RESX:ForumSubscribe:" + IsSubscribedForum.ToString().ToUpper() + "]";
subControl.Text = "[RESX:Subscribe]";
sOutput = sOutput.Replace("[FORUMSUBSCRIBE]", subControl.Render());
}
else
Expand Down
5 changes: 3 additions & 2 deletions Dnn.CommunityForums/controls/af_quickreply.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ protected override void OnLoad(EventArgs e)
}
btnToolBar.Visible = UseFilter;
divSubscribe.Visible = AllowSubscribe;
if (AllowSubscribe)
divSubscribe.Visible = !UserPrefTopicSubscribe; /* if user has preference set for auto subscribe, no need to show them the subscribe option */
if (divSubscribe.Visible)
{
var subControl = new ToggleSubscribe(ForumModuleId, ForumId, TopicId, 1);
subControl.Checked = new DotNetNuke.Modules.ActiveForums.Controllers.SubscriptionController().Subscribed(PortalId, ForumModuleId, UserId, ForumId, TopicId);
subControl.Text = "[RESX:TopicSubscribe:" + (new DotNetNuke.Modules.ActiveForums.Controllers.SubscriptionController().Subscribed(PortalId, ForumModuleId, UserId, ForumId, TopicId)).ToString().ToUpper() + "]";
subControl.Text = "[RESX:Subscribe]";
divSubscribe.InnerHtml = subControl.Render();
}
if (Utilities.InputIsValid(Request.Form["txtBody"]) && Request.IsAuthenticated & ((!(string.IsNullOrEmpty(Request.Form["hidReply1"])) && string.IsNullOrEmpty(Request.Form["hidReply2"])) | Request.Browser.IsMobileDevice))
Expand Down
22 changes: 3 additions & 19 deletions Dnn.CommunityForums/controls/af_subscribe.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,7 @@ protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

string SubscribeText = null;
if (mode == 0)
{
SubscribeText = GetSharedResource("[RESX:ForumSubscribe:" + IsSubscribed.ToString().ToUpper() + "]");
}
else
{
SubscribeText = GetSharedResource("[RESX:TopicSubscribe:" + IsSubscribed.ToString().ToUpper() + "]");
}
string SubscribeText = GetSharedResource("[RESX:Subscribe]");
chkSubscribe.Text = SubscribeText;
chkSubscribe.Checked = IsSubscribed;
if (UseAjax)
Expand Down Expand Up @@ -98,16 +90,8 @@ private void ToggleSubscribe()
IsSubscribed = false;
}
chkSubscribe.Checked = IsSubscribed;
if (mode == 0)
{
chkSubscribe.Text = GetSharedResource("[RESX:ForumSubscribe:" + IsSubscribed.ToString().ToUpper() + "]");
}
else
{
chkSubscribe.Text = GetSharedResource("[RESX:TopicSubscribe:" + IsSubscribed.ToString().ToUpper() + "]");
}


chkSubscribe.Text = GetSharedResource("[RESX:Subscribe]");

}
#endregion
}
Expand Down
6 changes: 2 additions & 4 deletions Dnn.CommunityForums/scripts/afcommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ function amaf_topicSubscribe(mid, fid, tid) {
}).done(function (data) {
amaf_UpdateTopicSubscriberCount(mid, fid, tid);
$('input[type=checkbox].amaf-chk-subs')
.prop('checked', data)
.siblings('label[for=amaf-chk-subs]').html(data ? amaf.resx.TopicSubscribeTrue : amaf.resx.TopicSubscribeFalse);
.prop('checked', data);
}).fail(function (xhr, status) {
alert('error subscribing to topic');
});
Expand Down Expand Up @@ -134,8 +133,7 @@ function amaf_forumSubscribe(mid, fid) {
}).done(function (data) {
amaf_UpdateForumSubscriberCount(mid, fid);
$('input[type=checkbox].amaf-chk-subs')
.prop('checked', data)
.siblings('label[for=amaf-chk-subs]').html(data ? amaf.resx.ForumSubscribeTrue : amaf.resx.ForumSubscribeFalse);
.prop('checked', data);
$('img#amaf-sub-' + fid).each(function () {
var imgSrc = $(this).attr('src');
if (data) {
Expand Down
6 changes: 1 addition & 5 deletions Dnn.CommunityForums/scripts/resx.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ amaf.resx = {
PinConfirm: '[RESX:Confirm:Pin]',
UnPinConfim: '[RESX:Confirm:UnPin]',
LockConfirm: '[RESX:Confirm:Lock]',
UnLockConfirm: '[RESX:Confirm:UnLock]',
TopicSubscribeTrue: '[RESX:TopicSubscribe:TRUE]',
TopicSubscribeFalse: '[RESX:TopicSubscribe:FALSE]',
ForumSubscribeTrue: '[RESX:ForumSubscribe:TRUE]',
ForumSubscribeFalse: '[RESX:ForumSubscribe:FALSE]'
UnLockConfirm: '[RESX:Confirm:UnLock]'
};


0 comments on commit b70daa2

Please sign in to comment.