Skip to content

Commit d656ba2

Browse files
authored
Merge pull request #1344 from johnhenley/issues/tabid-in-urls-1343
TASK: Refactor TabId access when constructing URLs
2 parents 50790fd + 0a6d6c8 commit d656ba2

File tree

4 files changed

+21
-26
lines changed

4 files changed

+21
-26
lines changed

Dnn.CommunityForums/Entities/ForumGroupInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public partial class ForumGroupInfo : DotNetNuke.Services.Tokens.IPropertyAccess
6868
public string RawUrl { get; set; }
6969

7070
[IgnoreColumn]
71-
public int TabId => this.ModuleInfo.TabID;
71+
public int TabId => this.GetTabId();
7272

7373
[IgnoreColumn]
7474
public string ThemeLocation => Utilities.ResolveUrl(SettingsBase.GetModuleSettings(this.ModuleId).ThemeLocation);

Dnn.CommunityForums/Entities/ForumInfo.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,10 @@ public int SubscriberCount
389389
public string ParentForumUrlPrefix => this.ParentForumId > 0 ? new Controllers.ForumController().GetById(this.ParentForumId, this.ModuleId).PrefixURL : string.Empty;
390390

391391
[IgnoreColumn]
392-
public int TabId => this.ModuleInfo.TabID;
392+
public int TabId => this.GetTabId();
393393

394394
[IgnoreColumn]
395-
public string ForumURL => URL.ForumLink(this.TabId, this);
395+
public string ForumURL => URL.ForumLink(this.GetTabId(), this);
396396

397397
[IgnoreColumn]
398398
public List<DotNetNuke.Modules.ActiveForums.Entities.ForumInfo> SubForums
@@ -651,9 +651,9 @@ public string RssLink
651651
{
652652
if (this.FeatureSettings.AllowRSS)
653653
{
654-
var url = new Uri(Utilities.NavigateURL(this.TabId));
654+
var url = new Uri(Utilities.NavigateURL(this.GetTabId()));
655655
this.rssLink =
656-
$"{url.Scheme}://{url.Host}:{url.Port}/DesktopModules/ActiveForums/feeds.aspx?portalid={this.PortalId}&forumid={this.ForumID}&tabid={this.TabId}&moduleid={this.ModuleId}" +
656+
$"{url.Scheme}://{url.Host}:{url.Port}/DesktopModules/ActiveForums/feeds.aspx?portalid={this.PortalId}&forumid={this.ForumID}&tabid={this.GetTabId()}&moduleid={this.ModuleId}" +
657657
(this.SocialGroupId > 0 ? $"&GroupId={this.SocialGroupId}" : string.Empty);
658658
}
659659
else
@@ -822,7 +822,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
822822
case "forumgroupid":
823823
return PropertyAccess.FormatString(this.ForumGroupId.ToString(), format);
824824
case "forummainlink":
825-
return PropertyAccess.FormatString(Utilities.NavigateURL(this.TabId), format);
825+
return PropertyAccess.FormatString(Utilities.NavigateURL(this.GetTabId()), format);
826826
case "grouplink":
827827
case "forumgrouplink":
828828
return PropertyAccess.FormatString(new ControlUtils().BuildUrl(
@@ -986,7 +986,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
986986

987987
private int GetTabId()
988988
{
989-
return this.ModuleInfo.TabID > 0 ? this.ModuleInfo.TabID : this.PortalSettings.ActiveTab.TabID == -1 || this.PortalSettings.ActiveTab.TabID == this.PortalSettings.HomeTabId ? this.TabId : this.PortalSettings.ActiveTab.TabID;
989+
return this.PortalSettings.ActiveTab.TabID == -1 || this.PortalSettings.ActiveTab.TabID == this.PortalSettings.HomeTabId ? this.TabId : this.PortalSettings.ActiveTab.TabID;
990990
}
991991

992992
internal string GetCacheKey() => string.Format(this.cacheKeyTemplate, this.ModuleId, this.ForumID);

Dnn.CommunityForums/Entities/LikeInfo.cs

-5
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,6 @@ public string GetProperty(string propertyName, string format, System.Globalizati
259259
return string.Empty;
260260
}
261261

262-
private int GetTabId()
263-
{
264-
return this.Forum.PortalSettings.ActiveTab.TabID == -1 || this.Forum.PortalSettings.ActiveTab.TabID == this.Forum.PortalSettings.HomeTabId ? this.Forum.TabId : this.Forum.PortalSettings.ActiveTab.TabID;
265-
}
266-
267262
internal string GetCacheKey() => string.Format(this.cacheKeyTemplate, this.ModuleId, this.ContentId);
268263

269264
internal void UpdateCache() => DotNetNuke.Modules.ActiveForums.DataCache.ContentCacheStore(this.ModuleId, this.GetCacheKey(), this);

Dnn.CommunityForums/Entities/TopicInfo.cs

+14-14
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
615615

616616
case "subjectlink":
617617
{
618-
string sTopicURL = new ControlUtils().BuildUrl(this.Forum.PortalSettings.PortalId, GetTabId(), this.Forum.ModuleId, this.Forum.ForumGroup.PrefixURL, this.Forum.PrefixURL, this.Forum.ForumGroupId, this.Forum.ForumID, this.TopicId, this.TopicUrl, -1, -1, string.Empty, 1, -1, this.Forum.SocialGroupId);
618+
string sTopicURL = new ControlUtils().BuildUrl(this.Forum.PortalSettings.PortalId, this.GetTabId(), this.Forum.ModuleId, this.Forum.ForumGroup.PrefixURL, this.Forum.PrefixURL, this.Forum.ForumGroupId, this.Forum.ForumID, this.TopicId, this.TopicUrl, -1, -1, string.Empty, 1, -1, this.Forum.SocialGroupId);
619619
string sPollImage = (this.Topic.TopicType == TopicTypes.Poll ? DotNetNuke.Modules.ActiveForums.Services.Tokens.TokenReplacer.GetTokenFormatString("[POLLIMAGE]", this.Forum.PortalSettings, accessingUser.Profile.PreferredLocale) : string.Empty);
620620
string slink;
621621
var @params = new List<string>
@@ -664,7 +664,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
664664
}
665665

666666
string sLastReadURL = string.Empty;
667-
string sTopicURL = new ControlUtils().BuildUrl(this.Forum.PortalSettings.PortalId, GetTabId(), this.Forum.ModuleId, this.Forum.ForumGroup.PrefixURL, this.Forum.PrefixURL, this.Forum.ForumGroupId, this.Forum.ForumID, this.TopicId, this.TopicUrl, -1, -1, string.Empty, 1, -1, this.Forum.SocialGroupId);
667+
string sTopicURL = new ControlUtils().BuildUrl(this.Forum.PortalSettings.PortalId, this.GetTabId(), this.Forum.ModuleId, this.Forum.ForumGroup.PrefixURL, this.Forum.PrefixURL, this.Forum.ForumGroupId, this.Forum.ForumID, this.TopicId, this.TopicUrl, -1, -1, string.Empty, 1, -1, this.Forum.SocialGroupId);
668668
int? userLastReplyRead = new Controllers.ForumUserController(this.ModuleId).GetByUserId(
669669
accessingUser.PortalID,
670670
accessingUser.UserID).GetLastReplyRead(this);
@@ -682,7 +682,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
682682
@params.Add($"{Literals.GroupId}={this.Forum.SocialGroupId}");
683683
}
684684

685-
sLastReadURL = Utilities.NavigateURL(GetTabId(),
685+
sLastReadURL = Utilities.NavigateURL(this.GetTabId(),
686686
string.Empty,
687687
@params.ToArray());
688688
}
@@ -699,7 +699,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
699699
@params.Add($"{Literals.GroupId}={this.Forum.SocialGroupId}");
700700
}
701701

702-
sLastReadURL = Utilities.NavigateURL(GetTabId(), string.Empty, @params.ToArray());
702+
sLastReadURL = Utilities.NavigateURL(this.GetTabId(), string.Empty, @params.ToArray());
703703
}
704704

705705
if (sTopicURL.EndsWith("/"))
@@ -725,8 +725,8 @@ public string GetProperty(string propertyName, string format, System.Globalizati
725725
@params.Add($"{Literals.GroupId}={this.Forum.SocialGroupId}");
726726
}
727727

728-
string sLastReplyURL = Utilities.NavigateURL(GetTabId(), string.Empty, @params.ToArray());
729-
string sTopicURL = new ControlUtils().BuildUrl(this.Forum.PortalSettings.PortalId, GetTabId(), this.Forum.ModuleId, this.Forum.ForumGroup.PrefixURL, this.Forum.PrefixURL, this.Forum.ForumGroupId, this.Forum.ForumID, this.TopicId, this.TopicUrl, -1, -1, string.Empty, 1, -1, this.Forum.SocialGroupId);
728+
string sLastReplyURL = Utilities.NavigateURL(this.GetTabId(), string.Empty, @params.ToArray());
729+
string sTopicURL = new ControlUtils().BuildUrl(this.Forum.PortalSettings.PortalId, this.GetTabId(), this.Forum.ModuleId, this.Forum.ForumGroup.PrefixURL, this.Forum.PrefixURL, this.Forum.ForumGroupId, this.Forum.ForumID, this.TopicId, this.TopicUrl, -1, -1, string.Empty, 1, -1, this.Forum.SocialGroupId);
730730
if (!(string.IsNullOrEmpty(sTopicURL)))
731731
{
732732
if (sTopicURL.EndsWith("/"))
@@ -816,7 +816,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
816816
}
817817

818818
return PropertyAccess.FormatString(
819-
Utilities.NavigateURL(GetTabId(),
819+
Utilities.NavigateURL(this.GetTabId(),
820820
string.Empty,
821821
@params.ToArray()),
822822
format);
@@ -840,7 +840,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
840840
}
841841

842842
return PropertyAccess.FormatString(
843-
Utilities.NavigateURL(GetTabId(),
843+
Utilities.NavigateURL(this.GetTabId(),
844844
string.Empty,
845845
@params.ToArray()),
846846
format);
@@ -1087,7 +1087,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
10871087
PageSize = 10;
10881088
}
10891089

1090-
return PropertyAccess.FormatString(Utilities.GetLastPostSubject(this.LastReply.ReplyId, this.TopicId, this.ForumId, GetTabId(), this.LastReply.Content.Subject, length, pageSize: PageSize, replyCount: this.ReplyCount, canRead: true), format);
1090+
return PropertyAccess.FormatString(Utilities.GetLastPostSubject(this.LastReply.ReplyId, this.TopicId, this.ForumId, this.GetTabId(), this.LastReply.Content.Subject, length, pageSize: PageSize, replyCount: this.ReplyCount, canRead: true), format);
10911091
}
10921092

10931093
case "lastpostauthordisplaynamelink":
@@ -1201,7 +1201,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
12011201
}
12021202

12031203
return PropertyAccess.FormatString(
1204-
Utilities.NavigateURL(GetTabId(), string.Empty, @params.ToArray()),
1204+
Utilities.NavigateURL(this.GetTabId(), string.Empty, @params.ToArray()),
12051205
format);
12061206
}
12071207

@@ -1242,7 +1242,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
12421242
}
12431243

12441244
return PropertyAccess.FormatString(
1245-
Utilities.NavigateURL(GetTabId(), string.Empty, @params.ToArray()),
1245+
Utilities.NavigateURL(this.GetTabId(), string.Empty, @params.ToArray()),
12461246
format);
12471247
}
12481248

@@ -1283,7 +1283,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
12831283
}
12841284

12851285
return PropertyAccess.FormatString(
1286-
Utilities.NavigateURL(GetTabId(), string.Empty, @params.ToArray()),
1286+
Utilities.NavigateURL(this.GetTabId(), string.Empty, @params.ToArray()),
12871287
format);
12881288
}
12891289

@@ -1440,7 +1440,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
14401440
}
14411441

14421442
return PropertyAccess.FormatString(
1443-
Utilities.NavigateURL(GetTabId(), string.Empty, editParams.ToArray()),
1443+
Utilities.NavigateURL(this.GetTabId(), string.Empty, editParams.ToArray()),
14441444
format);
14451445
}
14461446

@@ -1466,7 +1466,7 @@ public string GetProperty(string propertyName, string format, System.Globalizati
14661466
};
14671467

14681468
return PropertyAccess.FormatString(
1469-
Utilities.NavigateURL(GetTabId(), string.Empty, @params.ToArray()),
1469+
Utilities.NavigateURL(this.GetTabId(), string.Empty, @params.ToArray()),
14701470
format);
14711471
}
14721472
return string.Empty;

0 commit comments

Comments
 (0)