From e1494fe92869995002d80890573e596ca324659e Mon Sep 17 00:00:00 2001 From: Stefan Kamphuis Date: Fri, 10 Aug 2018 19:08:37 +0200 Subject: [PATCH] Fixed retrieval of modulesettings/tabmodulesettings --- API/MetaWebLog/Handler.ashx.vb | 7 +++--- Base/NewsArticleModuleBase.vb | 8 +++---- Components/ArticleController.vb | 3 +-- Components/Common.vb | 27 ++++++++++++++++++++++ Components/EmailTemplateController.vb | 4 ++-- Components/LatestArticleController.vb | 2 +- LatestArticles.ascx.vb | 11 +++++---- LatestArticlesOptions.ascx.vb | 2 +- LatestComments.ascx.vb | 4 ++-- NewsArchives.ascx.vb | 13 +++++------ Print.aspx.vb | 6 ++--- Providers/FileProvider/CoreFileProvider.vb | 3 --- Rss.aspx.vb | 10 ++++---- RssComments.aspx.vb | 2 +- ucSubmitNews.ascx.vb | 11 ++++----- ucViewOptions.ascx.vb | 2 +- 16 files changed, 65 insertions(+), 50 deletions(-) diff --git a/API/MetaWebLog/Handler.ashx.vb b/API/MetaWebLog/Handler.ashx.vb index 2cd328b..bd90454 100755 --- a/API/MetaWebLog/Handler.ashx.vb +++ b/API/MetaWebLog/Handler.ashx.vb @@ -23,7 +23,7 @@ Namespace Ventrian.NewsArticles.API.MetaWebLog Private ReadOnly Property PortalSettings() As PortalSettings Get - Return PortalController.GetCurrentPortalSettings() + Return PortalController.Instance.GetCurrentPortalSettings() End Get End Property @@ -108,8 +108,7 @@ Namespace Ventrian.NewsArticles.API.MetaWebLog Dim check As Boolean = False - Dim objModuleController As New ModuleController - Dim settings As Hashtable = objModuleController.GetModuleSettings(moduleId) + Dim settings As Hashtable = Common.GetModuleSettings(moduleId) If (user.IsSuperUser) Then Return True @@ -437,7 +436,7 @@ Namespace Ventrian.NewsArticles.API.MetaWebLog Throw New MetaException("01", "You do not have permission to post articles") End If - Dim objSettings As Hashtable = objModuleController.GetModuleSettings(objTabModule.ModuleID) + Dim objSettings As Hashtable = Common.GetModuleSettings(objTabModule.ModuleID) Dim objArticleSettings As New ArticleSettings(objSettings, PortalSettings, objTabModule) Dim objArticle As New ArticleInfo diff --git a/Base/NewsArticleModuleBase.vb b/Base/NewsArticleModuleBase.vb index d4e88ef..396a54c 100755 --- a/Base/NewsArticleModuleBase.vb +++ b/Base/NewsArticleModuleBase.vb @@ -45,10 +45,8 @@ Namespace Ventrian.NewsArticles.Base Try _articleSettings = New ArticleSettings(Settings, PortalSettings, ModuleConfiguration) Catch - Dim objModuleController As New ModuleController() - - Dim objSettings As Hashtable = objModuleController.GetModuleSettings(ModuleId) - Dim objTabSettings As Hashtable = objModuleController.GetTabModuleSettings(TabModuleId) + Dim objSettings As Hashtable = ModuleConfiguration.ModuleSettings + Dim objTabSettings As Hashtable = ModuleConfiguration.TabModuleSettings For Each item As DictionaryEntry In objTabSettings If (objSettings.ContainsKey(item.Key) = False) Then @@ -57,7 +55,7 @@ Namespace Ventrian.NewsArticles.Base Next _articleSettings = New ArticleSettings(objSettings, PortalSettings, ModuleConfiguration) - objModuleController.UpdateModuleSetting(ModuleId, "ResetArticleSettings", "true") + ModuleController.Instance.UpdateModuleSetting(ModuleId, "ResetArticleSettings", "true") End Try End If Return _articleSettings diff --git a/Components/ArticleController.vb b/Components/ArticleController.vb index f007b05..75f6f34 100755 --- a/Components/ArticleController.vb +++ b/Components/ArticleController.vb @@ -288,8 +288,7 @@ Namespace Ventrian.NewsArticles Public Function GetSearchItems(ByVal ModInfo As DotNetNuke.Entities.Modules.ModuleInfo) As DotNetNuke.Services.Search.SearchItemInfoCollection Implements DotNetNuke.Entities.Modules.ISearchable.GetSearchItems - Dim objModuleController As New ModuleController - Dim settings As Hashtable = objModuleController.GetModuleSettings(ModInfo.ModuleID) + Dim settings As Hashtable = Common.GetModuleSettings(ModInfo.ModuleID) settings = GetTabModuleSettings(ModInfo.TabModuleID, settings) Dim doSearch As Boolean = False diff --git a/Components/Common.vb b/Components/Common.vb index b3b028a..312a178 100755 --- a/Components/Common.vb +++ b/Components/Common.vb @@ -39,6 +39,17 @@ Namespace Ventrian.NewsArticles End Sub + Friend Shared Function GetModuleInfo(moduleId As Integer, optional tabId As integer = -1) As ModuleInfo + Dim mdlInfo As ModuleInfo = ModuleController.Instance.GetModule(moduleID, tabId, False) + return mdlInfo + End Function + Friend Shared Function GetModuleSettings(moduleId As integer) As Hashtable + return GetModuleInfo(moduleId).ModuleSettings + End Function + Friend Shared Function GetTabModuleSettings(moduleId As integer, tabId As integer) As Hashtable + return GetModuleInfo(moduleId, tabId).ModuleSettings + End Function + #End Region #Region " Public Shared Methods " @@ -771,6 +782,22 @@ Namespace Ventrian.NewsArticles Return Regex.Replace(HTML, pattern, String.Empty) End Function + public Shared Function JoinHashTables(ParamArray ht As Hashtable()) As Hashtable + dim retval as New Hashtable + + For Each objHt As Hashtable In ht + For Each key As Object In objHt.Keys + If retval.ContainsKey(key) Then + retval(key) = objHt(key) + Else + retval.Add(key, objHt(key)) + End If + Next + Next + return retval + End Function + + #End Region End Class diff --git a/Components/EmailTemplateController.vb b/Components/EmailTemplateController.vb index b5a7d9f..5afe075 100755 --- a/Components/EmailTemplateController.vb +++ b/Components/EmailTemplateController.vb @@ -83,8 +83,8 @@ Namespace Ventrian.NewsArticles Public Function GetApproverDistributionList(ByVal moduleID As Integer) As String - Dim settings As PortalSettings = PortalController.GetCurrentPortalSettings() - Dim moduleSettings As Hashtable = PortalSettings.GetModuleSettings(moduleID) + Dim settings As PortalSettings = PortalSettings.Current + Dim moduleSettings As Hashtable = Common.GetModuleSettings(moduleID) Dim distributionList As String = "" If (moduleSettings.Contains(ArticleConstants.PERMISSION_APPROVAL_SETTING)) Then diff --git a/Components/LatestArticleController.vb b/Components/LatestArticleController.vb index 64fa536..8639b1d 100755 --- a/Components/LatestArticleController.vb +++ b/Components/LatestArticleController.vb @@ -10,7 +10,7 @@ Namespace Ventrian.NewsArticles Public Function ExportModule(ByVal ModuleID As Integer) As String Implements IPortable.ExportModule Dim objModuleController As New ModuleController - Dim settings As Hashtable = objModuleController.GetModuleSettings(ModuleID) + Dim settings As Hashtable = Common.GetModuleSettings(ModuleID) Dim objLatestLayoutController As New LatestLayoutController() diff --git a/LatestArticles.ascx.vb b/LatestArticles.ascx.vb index b9a2c0f..212098f 100755 --- a/LatestArticles.ascx.vb +++ b/LatestArticles.ascx.vb @@ -57,12 +57,13 @@ Namespace Ventrian.NewsArticles Get If (_articleSettings Is Nothing) Then - _settings = DotNetNuke.Entities.Portals.PortalSettings.GetModuleSettings(_articleModuleID) - - Dim objModuleController As New ModuleController + Dim objModuleController As New ModuleController Dim objModule As ModuleInfo = objModuleController.GetModule(_articleModuleID, _articleTabID) + + _settings = objModule.ModuleSettings + If Not (objModule Is Nothing) Then - Dim objSettings As Hashtable = DotNetNuke.Entities.Portals.PortalSettings.GetTabModuleSettings(objModule.TabModuleID) + Dim objSettings As Hashtable = objModule.TabModuleSettings For Each key As String In objSettings.Keys If (_settings.ContainsKey(key) = False) Then @@ -122,7 +123,7 @@ Namespace Ventrian.NewsArticles _serverTimeZone = PortalSettings.TimeZoneOffset Dim objModuleSettingController As New ModuleController - Dim newsSettings As Hashtable = objModuleSettingController.GetModuleSettings(_articleModuleID) + Dim newsSettings As Hashtable = Common.GetModuleSettings(_articleModuleID) If Not (newsSettings Is Nothing) Then If (newsSettings.Contains(ArticleConstants.SERVER_TIMEZONE)) Then diff --git a/LatestArticlesOptions.ascx.vb b/LatestArticlesOptions.ascx.vb index 28058e3..818e429 100755 --- a/LatestArticlesOptions.ascx.vb +++ b/LatestArticlesOptions.ascx.vb @@ -655,7 +655,7 @@ Namespace Ventrian.NewsArticles Public Function GetAuthorList(ByVal moduleID As Integer) As ArrayList - Dim moduleSettings As Hashtable = DotNetNuke.Entities.Portals.PortalSettings.GetModuleSettings(moduleID) + Dim moduleSettings As Hashtable = Common.GetModuleSettings(moduleID) Dim distributionList As String = "" Dim userList As New ArrayList diff --git a/LatestComments.ascx.vb b/LatestComments.ascx.vb index 30e528d..3c0a2a2 100755 --- a/LatestComments.ascx.vb +++ b/LatestComments.ascx.vb @@ -30,12 +30,12 @@ Namespace Ventrian.NewsArticles Get If (_articleSettings Is Nothing) Then - Dim _settings As Hashtable = DotNetNuke.Entities.Portals.PortalSettings.GetModuleSettings(_articleModuleID) + Dim _settings As Hashtable = Common.GetModuleSettings(_articleModuleID) Dim objModuleController As New ModuleController Dim objModule As ModuleInfo = objModuleController.GetModule(_articleModuleID, _articleTabID) If Not (objModule Is Nothing) Then - Dim objSettings As Hashtable = DotNetNuke.Entities.Portals.PortalSettings.GetTabModuleSettings(objModule.TabModuleID) + Dim objSettings As Hashtable = objModule.TabModuleSettings For Each key As String In objSettings.Keys If (_settings.ContainsKey(key) = False) Then diff --git a/NewsArchives.ascx.vb b/NewsArchives.ascx.vb index 5dc42d9..2d7bb33 100755 --- a/NewsArchives.ascx.vb +++ b/NewsArchives.ascx.vb @@ -40,12 +40,11 @@ Namespace Ventrian.NewsArticles Get If (_articleSettings Is Nothing) Then - Dim objModuleController As New ModuleController() - Dim _settings As Hashtable = objModuleController.GetModuleSettings(ArchiveSettings.ModuleId) + Dim _settings As Hashtable = Common.GetModuleSettings(ArchiveSettings.ModuleId) - Dim objModule As ModuleInfo = objModuleController.GetModule(ArchiveSettings.ModuleId, ArchiveSettings.TabId) + Dim objModule As ModuleInfo = Common.GetModuleInfo(ArchiveSettings.ModuleId, ArchiveSettings.TabId) If Not (objModule Is Nothing) Then - Dim tabModuleSettings As Hashtable = objModuleController.GetTabModuleSettings(objModule.TabModuleID) + Dim tabModuleSettings As Hashtable = objModule.TabModuleSettings For Each strKey As String In tabModuleSettings.Keys _settings(strKey) = tabModuleSettings(strKey) Next @@ -197,7 +196,7 @@ Namespace Ventrian.NewsArticles Exit Sub End If - Dim newsSettings As Hashtable = objModuleSettingController.GetTabModuleSettings(mi.TabModuleID) + Dim newsSettings As Hashtable = mi.TabModuleSettings Dim excludeCategoriesRestrictive As New List(Of Integer) For Each objCategory As CategoryInfo In Categories @@ -338,7 +337,7 @@ Namespace Ventrian.NewsArticles Exit Sub End If - Dim moduleSettings As Hashtable = objModuleSettingController.GetModuleSettings(mi.ModuleID) + Dim moduleSettings As Hashtable = mi.ModuleSettings Dim objCategoriesSelected As New List(Of CategoryInfo) Dim objCategories As List(Of CategoryInfo) = objCategoryController.GetCategoriesAll(ArchiveSettings.ModuleId, parentID, Nothing, authorId, ArchiveSettings.CategoryMaxDepth, ArticleSettings.ShowPending, ArticleSettings.CategorySortType) @@ -381,7 +380,7 @@ Namespace Ventrian.NewsArticles Dim mi As ModuleInfo = objModuleSettingController.GetModule(ArchiveSettings.ModuleId, ArchiveSettings.TabId) If Not (mi Is Nothing) Then - Dim newsSettings As Hashtable = objModuleSettingController.GetTabModuleSettings(mi.TabModuleID) + Dim newsSettings As Hashtable = mi.TabModuleSettings Dim authorId As Integer = Null.NullInteger If (ArticleSettings.AuthorLoggedInUserFilter) Then diff --git a/Print.aspx.vb b/Print.aspx.vb index 785e46f..abecb99 100755 --- a/Print.aspx.vb +++ b/Print.aspx.vb @@ -277,10 +277,8 @@ Namespace Ventrian.NewsArticles Get If (_articleSettings Is Nothing) Then Dim objModuleController As New ModuleController - Dim settings As Hashtable = objModuleController.GetModuleSettings(_moduleID) - 'Add TabModule Settings - settings = DotNetNuke.Entities.Portals.PortalSettings.GetTabModuleSettings(_tabModuleID, settings) - Dim objModule As ModuleInfo = objModuleController.GetModule(_moduleID, _tabID) + Dim objModule As ModuleInfo = Common.GetModuleInfo(_moduleID, _tabID) + Dim settings As Hashtable =Common.JoinHashTables(objModule.ModuleSettings, objModule.TabModuleSettings) _articleSettings = New ArticleSettings(settings, Me.PortalSettings, objModule) End If Return _articleSettings diff --git a/Providers/FileProvider/CoreFileProvider.vb b/Providers/FileProvider/CoreFileProvider.vb index 76f944e..ca8cfed 100755 --- a/Providers/FileProvider/CoreFileProvider.vb +++ b/Providers/FileProvider/CoreFileProvider.vb @@ -30,9 +30,6 @@ Namespace Ventrian.NewsArticles Dim folder As String = "" - Dim objModuleController As New ModuleController() - Dim objSettings As Hashtable = objModuleController.GetModuleSettings(moduleID) - If (folderID <> Null.NullInteger) Then Dim objFolderController As New FolderController Dim objFolder As FolderInfo = objFolderController.GetFolderInfo(objPortalSettings.PortalId, folderID) diff --git a/Rss.aspx.vb b/Rss.aspx.vb index 8ceb995..d3eb6f8 100755 --- a/Rss.aspx.vb +++ b/Rss.aspx.vb @@ -695,15 +695,14 @@ Namespace Ventrian.NewsArticles Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings) Dim objModuleController As New ModuleController - Dim objModule As ModuleInfo = objModuleController.GetModule(m_moduleID, m_tabID) + Dim objModule As ModuleInfo = Common.GetModuleInfo(m_moduleID, m_tabID) Dim articleSettings As ArticleSettings If Not (objModule Is Nothing) Then Dim objTabController As New TabController() Dim objTab As TabInfo = objTabController.GetTab(objModule.TabID, _portalSettings.PortalId, False) - Dim settings As Hashtable = objModuleController.GetModuleSettings(objModule.ModuleID) - settings = PortalSettings.GetTabModuleSettings(objModule.TabModuleID, settings) + Dim settings As Hashtable =Common.JoinHashTables(objModule.ModuleSettings, objModule.TabModuleSettings) articleSettings = New ArticleSettings(settings, _portalSettings, objModule) If (settings.Contains(ArticleConstants.LAUNCH_LINKS)) Then launchLinks = Convert.ToBoolean(settings(ArticleConstants.LAUNCH_LINKS).ToString()) @@ -720,9 +719,8 @@ Namespace Ventrian.NewsArticles If (settings.Contains(ArticleConstants.ENABLE_SYNDICATION_HTML_SETTING)) Then _enableSyndicationHtml = Convert.ToBoolean(settings(ArticleConstants.ENABLE_SYNDICATION_HTML_SETTING).ToString()) End If - Dim settingsModule As Hashtable = objModuleController.GetModuleSettings(objModule.ModuleID) - If (settingsModule.Contains(ArticleConstants.SYNDICATION_SUMMARY_LENGTH)) Then - _syndicationSummaryLength = Convert.ToInt32(settingsModule(ArticleConstants.SYNDICATION_SUMMARY_LENGTH).ToString()) + If (objModule.ModuleSettings.Contains(ArticleConstants.SYNDICATION_SUMMARY_LENGTH)) Then + _syndicationSummaryLength = Convert.ToInt32(objModule.ModuleSettings(ArticleConstants.SYNDICATION_SUMMARY_LENGTH).ToString()) End If If (settings.Contains(ArticleConstants.SHOW_PENDING_SETTING)) Then showPending = Convert.ToBoolean(settings(ArticleConstants.SHOW_PENDING_SETTING).ToString()) diff --git a/RssComments.aspx.vb b/RssComments.aspx.vb index bcfc079..0499bc7 100755 --- a/RssComments.aspx.vb +++ b/RssComments.aspx.vb @@ -173,7 +173,7 @@ Namespace Ventrian.NewsArticles Dim articleSettings As ArticleSettings If Not (objModule Is Nothing) Then - Dim settings As Hashtable = objModuleController.GetTabModuleSettings(objModule.TabModuleID) + Dim settings As Hashtable = objModule.TabModuleSettings articleSettings = New ArticleSettings(settings, _portalSettings, objModule) If (settings.Contains(ArticleConstants.LAUNCH_LINKS)) Then launchLinks = Convert.ToBoolean(settings(ArticleConstants.LAUNCH_LINKS).ToString()) diff --git a/ucSubmitNews.ascx.vb b/ucSubmitNews.ascx.vb index 1ce2319..ed7be15 100755 --- a/ucSubmitNews.ascx.vb +++ b/ucSubmitNews.ascx.vb @@ -372,7 +372,7 @@ Namespace Ventrian.NewsArticles Public Function GetAuthorList(ByVal moduleID As Integer) As ArrayList - Dim moduleSettings As Hashtable = DotNetNuke.Entities.Portals.PortalSettings.GetModuleSettings(moduleID) + Dim moduleSettings As Hashtable = Common.GetModuleSettings(moduleId) Dim distributionList As String = "" Dim userList As New ArrayList @@ -594,7 +594,7 @@ Namespace Ventrian.NewsArticles Dim folderLinked As String = "" Dim objModuleController As New ModuleController() - Dim objSettingsLinked As Hashtable = objModuleController.GetModuleSettings(drpMirrorModule.SelectedValue.Split("-"c)(1)) + Dim objSettingsLinked As Hashtable = Common.GetModuleSettings(drpMirrorModule.SelectedValue.Split("-"c)(1)) If (objSettingsLinked.ContainsKey(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING)) Then If (IsNumeric(objSettingsLinked(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))) Then @@ -614,7 +614,7 @@ Namespace Ventrian.NewsArticles Dim folder As String = "" - Dim objSettings As Hashtable = objModuleController.GetModuleSettings(ModuleId) + Dim objSettings As Hashtable = Common.GetModuleSettings(ModuleId) If (objSettings.ContainsKey(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING)) Then If (IsNumeric(objSettings(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))) Then @@ -963,8 +963,7 @@ Namespace Ventrian.NewsArticles 'Copy Files Dim folderLinked As String = "" - Dim objModuleController As New ModuleController() - Dim objSettingsLinked As Hashtable = objModuleController.GetModuleSettings(objArticleMirrored.ModuleID) + Dim objSettingsLinked As Hashtable = Common.GetModuleSettings(objArticleMirrored.ModuleID) If (objSettingsLinked.ContainsKey(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING)) Then If (IsNumeric(objSettingsLinked(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))) Then @@ -984,7 +983,7 @@ Namespace Ventrian.NewsArticles Dim folder As String = "" - Dim objSettings As Hashtable = objModuleController.GetModuleSettings(ModuleId) + Dim objSettings As Hashtable = Common.GetModuleSettings(ModuleId) If (objSettings.ContainsKey(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING)) Then If (IsNumeric(objSettings(ArticleConstants.DEFAULT_FILES_FOLDER_SETTING))) Then diff --git a/ucViewOptions.ascx.vb b/ucViewOptions.ascx.vb index da726b2..7dc5cb2 100755 --- a/ucViewOptions.ascx.vb +++ b/ucViewOptions.ascx.vb @@ -1367,7 +1367,7 @@ Namespace Ventrian.NewsArticles Public Function GetAuthorList(ByVal moduleID As Integer) As ArrayList - Dim moduleSettings As Hashtable = DotNetNuke.Entities.Portals.PortalSettings.GetModuleSettings(moduleID) + Dim moduleSettings As Hashtable = Common.GetModuleSettings(moduleID) Dim distributionList As String = "" Dim userList As New ArrayList