Skip to content

Commit

Permalink
Fixed retrieval of modulesettings/tabmodulesettings
Browse files Browse the repository at this point in the history
  • Loading branch information
skamphuis committed Aug 10, 2018
1 parent bfb7681 commit e1494fe
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 50 deletions.
7 changes: 3 additions & 4 deletions API/MetaWebLog/Handler.ashx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions Base/NewsArticleModuleBase.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Components/ArticleController.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions Components/Common.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Components/EmailTemplateController.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Components/LatestArticleController.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
11 changes: 6 additions & 5 deletions LatestArticles.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion LatestArticlesOptions.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions LatestComments.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions NewsArchives.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions Print.aspx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions Providers/FileProvider/CoreFileProvider.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions Rss.aspx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion RssComments.aspx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
11 changes: 5 additions & 6 deletions ucSubmitNews.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ucViewOptions.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e1494fe

Please sign in to comment.