diff --git a/.yo-rc.json b/.yo-rc.json new file mode 100644 index 00000000..f7a4977a --- /dev/null +++ b/.yo-rc.json @@ -0,0 +1,26 @@ +{ + "generator-dotnetnuke": { + "promptValues": { + "projType": "library", + "dnnVersion": "9.13.0", + "npm": true, + "projectname": "Blog", + "projectdescription": "The DotNetNuke Blog module is an easy to use content publishing module that is tightly integrated with the core DotNetNuke framework. It can be used in single or multi-author environments and also permits content authoring using off-site tools such as Windows Live Writer.", + "yourname": "Peter Donker", + "email": "peter@bring2mind.net", + "companyfull": "DotNetNuke Community", + "companyshort": "DotNetNuke", + "companyUrl": "www.dnncommunity.org", + "dnnHost": "http://dnndev.me", + "dnnRoot": "DL/", + "namespace": "DotNetNuke.Modules.Blog", + "Name": "Core", + "Namespace": "DotNetNuke.Blog.Core", + "Separate": false + }, + "Company": "DotNetNuke", + "Project": "Blog", + "Namespace": "DotNetNuke.Blog", + "Solution": "DotNetNuke.Blog" + } +} diff --git a/DotNetNuke.Modules.Blog.sln b/DotNetNuke.Blog.sln similarity index 73% rename from DotNetNuke.Modules.Blog.sln rename to DotNetNuke.Blog.sln index 412f6f3e..ff4721ea 100644 --- a/DotNetNuke.Modules.Blog.sln +++ b/DotNetNuke.Blog.sln @@ -1,29 +1,35 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.1.32328.378 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DotNetNuke.Modules.Blog", "Server\Blog\DotNetNuke.Modules.Blog.vbproj", "{4E2BCA3B-927C-4AF2-9999-B1C074FD0539}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Build", "build\Build.csproj", "{22A9DE4E-9CFD-4ABA-8C82-87D1C22F2FD9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4E2BCA3B-927C-4AF2-9999-B1C074FD0539}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4E2BCA3B-927C-4AF2-9999-B1C074FD0539}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4E2BCA3B-927C-4AF2-9999-B1C074FD0539}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4E2BCA3B-927C-4AF2-9999-B1C074FD0539}.Release|Any CPU.Build.0 = Release|Any CPU - {22A9DE4E-9CFD-4ABA-8C82-87D1C22F2FD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {22A9DE4E-9CFD-4ABA-8C82-87D1C22F2FD9}.Release|Any CPU.ActiveCfg = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {A4DC134D-8514-4096-8B8B-8AB593421020} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32328.378 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DotNetNuke.Modules.Blog", "Server\Blog\DotNetNuke.Modules.Blog.vbproj", "{4E2BCA3B-927C-4AF2-9999-B1C074FD0539}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Build", "build\Build.csproj", "{22A9DE4E-9CFD-4ABA-8C82-87D1C22F2FD9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetNuke.Modules.Blog.Core", "Server\Core\DotNetNuke.Modules.Blog.Core.csproj", "{18CBD81C-C31C-465D-8865-70957DF4711C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4E2BCA3B-927C-4AF2-9999-B1C074FD0539}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E2BCA3B-927C-4AF2-9999-B1C074FD0539}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E2BCA3B-927C-4AF2-9999-B1C074FD0539}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E2BCA3B-927C-4AF2-9999-B1C074FD0539}.Release|Any CPU.Build.0 = Release|Any CPU + {22A9DE4E-9CFD-4ABA-8C82-87D1C22F2FD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22A9DE4E-9CFD-4ABA-8C82-87D1C22F2FD9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18CBD81C-C31C-465D-8865-70957DF4711C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18CBD81C-C31C-465D-8865-70957DF4711C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18CBD81C-C31C-465D-8865-70957DF4711C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18CBD81C-C31C-465D-8865-70957DF4711C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A4DC134D-8514-4096-8B8B-8AB593421020} + EndGlobalSection +EndGlobal diff --git a/License.md b/License.md new file mode 100644 index 00000000..5c100fc3 --- /dev/null +++ b/License.md @@ -0,0 +1,10 @@ +Copyright (c) 2025 DotNetNuke, All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/Server/Blog/Admin.ascx.vb b/Server/Blog/Admin.ascx.vb index a5763e86..9e714ee4 100644 --- a/Server/Blog/Admin.ascx.vb +++ b/Server/Blog/Admin.ascx.vb @@ -18,173 +18,175 @@ ' DEALINGS IN THE SOFTWARE. ' -Imports DotNetNuke.Modules.Blog.Common.Globals +Imports DotNetNuke.Modules.Blog.Core.Common +Imports DotNetNuke.Modules.Blog.Core.Data +Imports DotNetNuke.Modules.Blog.Core.Entities.Terms Public Class Admin - Inherits BlogModuleBase - - Private _totalPosts As Integer = -1 - - Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init - AddJavascriptFile("jquery.dynatree.min.js", "jquery.dynatree", "1.2.4", 60) - AddCssFile("dynatree.css", "dynatree", "1.2.4") - End Sub - - Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load - - If Not BlogContext.Security.IsEditor Then - Throw New Exception("You do not have access to this resource. Please check your login status.") - End If - - If Not IsPostBack Then - DataBind() - End If - - UI.Utilities.ClientAPI.AddButtonConfirm(cmdEditTagsML, LocalizeString("LeavePage.Confirm")) - UI.Utilities.ClientAPI.AddButtonConfirm(cmdEditCategoriesML, LocalizeString("LeavePage.Confirm")) - - End Sub - - Private Sub cmdEditTagsML_Click(sender As Object, e As EventArgs) Handles cmdEditTagsML.Click - SaveChanges() - Response.Redirect(EditUrl("TermsEditML"), False) - End Sub - - Private Sub cmdEditCategoriesML_Click(sender As Object, e As EventArgs) Handles cmdEditCategoriesML.Click - SaveChanges() - If Settings.VocabularyId > -1 Then - Response.Redirect(EditUrl("VocabularyId", Settings.VocabularyId.ToString, "TermsEditML"), False) - End If - End Sub - - Private Sub cmdCreateVocabulary_Click(sender As Object, e As EventArgs) Handles cmdCreateVocabulary.Click - Settings.VocabularyId = Integration.Integration.CreateNewVocabulary(PortalId).VocabularyId - Settings.UpdateSettings() - DataBind() - End Sub - - Private Sub ddVocabularyId_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddVocabularyId.SelectedIndexChanged - Settings.VocabularyId = ddVocabularyId.SelectedValue.ToInt - Settings.UpdateSettings() - DataBind() - End Sub - - Private Sub cmdCancel_Click(sender As Object, e As EventArgs) Handles cmdCancel.Click - Response.Redirect(DotNetNuke.Common.NavigateURL(TabId), False) - End Sub - - Private Sub cmdUpdateSettings_Click(sender As Object, e As EventArgs) Handles cmdUpdate.Click - SaveChanges() - Response.Redirect(DotNetNuke.Common.NavigateURL(TabId), False) - End Sub - - Private Sub SaveChanges() - Settings.AllowAttachments = chkAllowAttachments.Checked - Settings.SummaryModel = CType(ddSummaryModel.SelectedValue.ToInt, SummaryType) - Settings.AllowMultipleCategories = chkAllowMultipleCategories.Checked - Settings.AllowWLW = chkAllowWLW.Checked - Settings.WLWRecentPostsMax = txtWLWRecentPostsMax.Text.ToInt - Settings.VocabularyId = ddVocabularyId.SelectedValue.ToInt - Settings.ModifyPageDetails = chkModifyPageDetails.Checked - Settings.AutoGenerateMissingSummary = chkAutoGenerateMissingSummary.Checked - Settings.AutoGeneratedSummaryLength = Integer.Parse(txtAutoGeneratedSummaryLength.Text.Trim) - Settings.FacebookAppId = txtFacebookAppId.Text.Trim - Settings.FacebookProfileIdProperty = Integer.Parse(ddFacebookProfileIdProperty.SelectedValue) - Settings.RssAllowContentInFeed = chkRssAllowContentInFeed.Checked - Settings.RssDefaultCopyright = txtRssDefaultCopyright.Text - Settings.RssDefaultNrItems = Integer.Parse(txtRssDefaultNrItems.Text) - Settings.RssEmail = txtEmail.Text - Settings.RssImageHeight = Integer.Parse(txtRssImageHeight.Text) - Settings.RssImageWidth = Integer.Parse(txtRssImageWidth.Text) - Settings.RssImageSizeAllowOverride = chkRssImageSizeAllowOverride.Checked - Settings.RssMaxNrItems = Integer.Parse(txtRssMaxNrItems.Text) - Settings.RssTtl = Integer.Parse(txtRssTtl.Text) - Settings.IncrementViewCount = Integer.Parse(txtIncrementViewCount.Text) - - Settings.UpdateSettings() - If treeState.Value <> Entities.Terms.TermsController.GetCategoryTreeAsJson(Categories) Then - Dim categoryTree As List(Of DynatreeItem) = Newtonsoft.Json.JsonConvert.DeserializeObject(Of List(Of DynatreeItem))(treeState.Value) - Dim ReturnedIds As New List(Of Integer) - Dim i As Integer = 1 - For Each rootNode As DynatreeItem In categoryTree - AddOrUpdateCategory(-1, i, rootNode, ReturnedIds) - i += 1 - Next - Dim deleteCategories As New List(Of Entities.Terms.TermInfo) - For Each t As Entities.Terms.TermInfo In Categories.Values - If Not ReturnedIds.Contains(t.TermId) Then deleteCategories.Add(t) - Next - For Each categoryToDelete As Entities.Terms.TermInfo In deleteCategories - DotNetNuke.Entities.Content.Common.Util.GetTermController().DeleteTerm(categoryToDelete) - Next - Categories = Entities.Terms.TermsController.GetTermsByVocabulary(ModuleId, Settings.VocabularyId, BlogContext.Locale, True) ' clear the cache - End If - End Sub - - Private Sub AddOrUpdateCategory(parentId As Integer, viewOrder As Integer, category As DynatreeItem, ByRef returnedIds As List(Of Integer)) - If String.IsNullOrEmpty(category.title) Then Exit Sub - Dim termId As Integer = -1 - If IsNumeric(category.key) Then termId = Integer.Parse(category.key) - termId = Data.DataProvider.Instance.SetTerm(termId, Settings.VocabularyId, parentId, viewOrder, category.title, "", UserId) - returnedIds.Add(termId) - Dim i As Integer = 1 - For Each subCategory As DynatreeItem In category.children - AddOrUpdateCategory(termId, i, subCategory, returnedIds) - i += 1 - Next - End Sub - - Public Overrides Sub DataBind() - MyBase.DataBind() - - chkAllowAttachments.Checked = Settings.AllowAttachments - Try - ddSummaryModel.Items.FindByValue(CInt(Settings.SummaryModel).ToString).Selected = True - Catch ex As Exception - End Try - cmdEditTagsML.Enabled = BlogContext.IsMultiLingualSite - cmdEditCategoriesML.Enabled = BlogContext.IsMultiLingualSite And Settings.VocabularyId > -1 - chkAllowMultipleCategories.Checked = Settings.AllowMultipleCategories - chkAllowWLW.Checked = Settings.AllowWLW - chkModifyPageDetails.Checked = Settings.ModifyPageDetails - chkAutoGenerateMissingSummary.Checked = Settings.AutoGenerateMissingSummary - txtAutoGeneratedSummaryLength.Text = Settings.AutoGeneratedSummaryLength.ToString - txtFacebookAppId.Text = Settings.FacebookAppId - ddFacebookProfileIdProperty.DataSource = DotNetNuke.Entities.Profile.ProfileController.GetPropertyDefinitionsByPortal(PortalId, True, False) - ddFacebookProfileIdProperty.DataBind() - ddFacebookProfileIdProperty.Items.Insert(0, New ListItem(LocalizeString("NoneSpecified"), "-1")) - Try - ddFacebookProfileIdProperty.Items.FindByValue(Settings.FacebookProfileIdProperty.ToString).Selected = True - Catch ex As Exception - End Try - chkRssAllowContentInFeed.Checked = Settings.RssAllowContentInFeed - txtRssDefaultCopyright.Text = Settings.RssDefaultCopyright - txtRssDefaultNrItems.Text = Settings.RssDefaultNrItems.ToString - txtEmail.Text = Settings.RssEmail - txtRssImageHeight.Text = Settings.RssImageHeight.ToString - txtRssImageWidth.Text = Settings.RssImageWidth.ToString - chkRssImageSizeAllowOverride.Checked = Settings.RssImageSizeAllowOverride - txtRssMaxNrItems.Text = Settings.RssMaxNrItems.ToString - txtRssTtl.Text = Settings.RssTtl.ToString - txtIncrementViewCount.Text = Settings.IncrementViewCount.ToString - - txtWLWRecentPostsMax.Text = Settings.WLWRecentPostsMax.ToString - ddVocabularyId.Items.Clear() - ddVocabularyId.DataSource = GetPortalVocabularies(PortalId) - ddVocabularyId.DataBind() - ddVocabularyId.Items.Insert(0, New ListItem(LocalizeString("NoneSpecified"), "-1")) - Try - ddVocabularyId.Items.FindByValue(Settings.VocabularyId.ToString).Selected = True - Catch ex As Exception - End Try - - treeState.Value = Entities.Terms.TermsController.GetCategoryTreeAsJson(Categories) - - If Not DotNetNuke.Services.Localization.LocaleController.Instance.GetLocales(PortalId).Count > 1 Then - cmdEditTagsML.Visible = False - cmdEditCategoriesML.Visible = False - End If - - End Sub + Inherits BlogModuleBase + + Private _totalPosts As Integer = -1 + + Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init + AddJavascriptFile("jquery.dynatree.min.js", "jquery.dynatree", "1.2.4", 60) + AddCssFile("dynatree.css", "dynatree", "1.2.4") + End Sub + + Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load + + If Not BlogContext.Security.IsEditor Then + Throw New Exception("You do not have access to this resource. Please check your login status.") + End If + + If Not IsPostBack Then + DataBind() + End If + + UI.Utilities.ClientAPI.AddButtonConfirm(cmdEditTagsML, LocalizeString("LeavePage.Confirm")) + UI.Utilities.ClientAPI.AddButtonConfirm(cmdEditCategoriesML, LocalizeString("LeavePage.Confirm")) + + End Sub + + Private Sub cmdEditTagsML_Click(sender As Object, e As EventArgs) Handles cmdEditTagsML.Click + SaveChanges() + Response.Redirect(EditUrl("TermsEditML"), False) + End Sub + + Private Sub cmdEditCategoriesML_Click(sender As Object, e As EventArgs) Handles cmdEditCategoriesML.Click + SaveChanges() + If Settings.VocabularyId > -1 Then + Response.Redirect(EditUrl("VocabularyId", Settings.VocabularyId.ToString, "TermsEditML"), False) + End If + End Sub + + Private Sub cmdCreateVocabulary_Click(sender As Object, e As EventArgs) Handles cmdCreateVocabulary.Click + Settings.VocabularyId = Core.Integration.Integration.CreateNewVocabulary(PortalId).VocabularyId + Settings.UpdateSettings() + DataBind() + End Sub + + Private Sub ddVocabularyId_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddVocabularyId.SelectedIndexChanged + Settings.VocabularyId = ddVocabularyId.SelectedValue.ToInt + Settings.UpdateSettings() + DataBind() + End Sub + + Private Sub cmdCancel_Click(sender As Object, e As EventArgs) Handles cmdCancel.Click + Response.Redirect(DotNetNuke.Common.NavigateURL(TabId), False) + End Sub + + Private Sub cmdUpdateSettings_Click(sender As Object, e As EventArgs) Handles cmdUpdate.Click + SaveChanges() + Response.Redirect(DotNetNuke.Common.NavigateURL(TabId), False) + End Sub + + Private Sub SaveChanges() + Settings.AllowAttachments = chkAllowAttachments.Checked + Settings.SummaryModel = CType(ddSummaryModel.SelectedValue.ToInt, SummaryType) + Settings.AllowMultipleCategories = chkAllowMultipleCategories.Checked + Settings.AllowWLW = chkAllowWLW.Checked + Settings.WLWRecentPostsMax = txtWLWRecentPostsMax.Text.ToInt + Settings.VocabularyId = ddVocabularyId.SelectedValue.ToInt + Settings.ModifyPageDetails = chkModifyPageDetails.Checked + Settings.AutoGenerateMissingSummary = chkAutoGenerateMissingSummary.Checked + Settings.AutoGeneratedSummaryLength = Integer.Parse(txtAutoGeneratedSummaryLength.Text.Trim) + Settings.FacebookAppId = txtFacebookAppId.Text.Trim + Settings.FacebookProfileIdProperty = Integer.Parse(ddFacebookProfileIdProperty.SelectedValue) + Settings.RssAllowContentInFeed = chkRssAllowContentInFeed.Checked + Settings.RssDefaultCopyright = txtRssDefaultCopyright.Text + Settings.RssDefaultNrItems = Integer.Parse(txtRssDefaultNrItems.Text) + Settings.RssEmail = txtEmail.Text + Settings.RssImageHeight = Integer.Parse(txtRssImageHeight.Text) + Settings.RssImageWidth = Integer.Parse(txtRssImageWidth.Text) + Settings.RssImageSizeAllowOverride = chkRssImageSizeAllowOverride.Checked + Settings.RssMaxNrItems = Integer.Parse(txtRssMaxNrItems.Text) + Settings.RssTtl = Integer.Parse(txtRssTtl.Text) + Settings.IncrementViewCount = Integer.Parse(txtIncrementViewCount.Text) + + Settings.UpdateSettings() + If treeState.Value <> TermsController.GetCategoryTreeAsJson(Categories) Then + Dim categoryTree As List(Of DynatreeItem) = Newtonsoft.Json.JsonConvert.DeserializeObject(Of List(Of DynatreeItem))(treeState.Value) + Dim ReturnedIds As New List(Of Integer) + Dim i As Integer = 1 + For Each rootNode As DynatreeItem In categoryTree + AddOrUpdateCategory(-1, i, rootNode, ReturnedIds) + i += 1 + Next + Dim deleteCategories As New List(Of TermInfo) + For Each t As TermInfo In Categories.Values + If Not ReturnedIds.Contains(t.TermId) Then deleteCategories.Add(t) + Next + For Each categoryToDelete As TermInfo In deleteCategories + DotNetNuke.Entities.Content.Common.Util.GetTermController().DeleteTerm(categoryToDelete) + Next + Categories = TermsController.GetTermsByVocabulary(ModuleId, Settings.VocabularyId, BlogContext.Locale, True) ' clear the cache + End If + End Sub + + Private Sub AddOrUpdateCategory(parentId As Integer, viewOrder As Integer, category As DynatreeItem, ByRef returnedIds As List(Of Integer)) + If String.IsNullOrEmpty(category.title) Then Exit Sub + Dim termId As Integer = -1 + If IsNumeric(category.key) Then termId = Integer.Parse(category.key) + termId = DataProvider.Instance.SetTerm(termId, Settings.VocabularyId, parentId, viewOrder, category.title, "", UserId) + returnedIds.Add(termId) + Dim i As Integer = 1 + For Each subCategory As DynatreeItem In category.children + AddOrUpdateCategory(termId, i, subCategory, returnedIds) + i += 1 + Next + End Sub + + Public Overrides Sub DataBind() + MyBase.DataBind() + + chkAllowAttachments.Checked = Settings.AllowAttachments + Try + ddSummaryModel.Items.FindByValue(CInt(Settings.SummaryModel).ToString).Selected = True + Catch ex As Exception + End Try + cmdEditTagsML.Enabled = BlogContext.IsMultiLingualSite + cmdEditCategoriesML.Enabled = BlogContext.IsMultiLingualSite And Settings.VocabularyId > -1 + chkAllowMultipleCategories.Checked = Settings.AllowMultipleCategories + chkAllowWLW.Checked = Settings.AllowWLW + chkModifyPageDetails.Checked = Settings.ModifyPageDetails + chkAutoGenerateMissingSummary.Checked = Settings.AutoGenerateMissingSummary + txtAutoGeneratedSummaryLength.Text = Settings.AutoGeneratedSummaryLength.ToString + txtFacebookAppId.Text = Settings.FacebookAppId + ddFacebookProfileIdProperty.DataSource = DotNetNuke.Entities.Profile.ProfileController.GetPropertyDefinitionsByPortal(PortalId, True, False) + ddFacebookProfileIdProperty.DataBind() + ddFacebookProfileIdProperty.Items.Insert(0, New ListItem(LocalizeString("NoneSpecified"), "-1")) + Try + ddFacebookProfileIdProperty.Items.FindByValue(Settings.FacebookProfileIdProperty.ToString).Selected = True + Catch ex As Exception + End Try + chkRssAllowContentInFeed.Checked = Settings.RssAllowContentInFeed + txtRssDefaultCopyright.Text = Settings.RssDefaultCopyright + txtRssDefaultNrItems.Text = Settings.RssDefaultNrItems.ToString + txtEmail.Text = Settings.RssEmail + txtRssImageHeight.Text = Settings.RssImageHeight.ToString + txtRssImageWidth.Text = Settings.RssImageWidth.ToString + chkRssImageSizeAllowOverride.Checked = Settings.RssImageSizeAllowOverride + txtRssMaxNrItems.Text = Settings.RssMaxNrItems.ToString + txtRssTtl.Text = Settings.RssTtl.ToString + txtIncrementViewCount.Text = Settings.IncrementViewCount.ToString + + txtWLWRecentPostsMax.Text = Settings.WLWRecentPostsMax.ToString + ddVocabularyId.Items.Clear() + ddVocabularyId.DataSource = Globals.GetPortalVocabularies(PortalId) + ddVocabularyId.DataBind() + ddVocabularyId.Items.Insert(0, New ListItem(LocalizeString("NoneSpecified"), "-1")) + Try + ddVocabularyId.Items.FindByValue(Settings.VocabularyId.ToString).Selected = True + Catch ex As Exception + End Try + + treeState.Value = TermsController.GetCategoryTreeAsJson(Categories) + + If Not DotNetNuke.Services.Localization.LocaleController.Instance.GetLocales(PortalId).Count > 1 Then + cmdEditTagsML.Visible = False + cmdEditCategoriesML.Visible = False + End If + + End Sub End Class \ No newline at end of file diff --git a/Server/Blog/Blog.ascx b/Server/Blog/Blog.ascx index d7fb8d57..5aee9d06 100644 --- a/Server/Blog/Blog.ascx +++ b/Server/Blog/Blog.ascx @@ -1,5 +1,5 @@ <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Blog.ascx.vb" Inherits="DotNetNuke.Modules.Blog.Blog" %> -<%@ Register TagPrefix="blog" Assembly="DotNetNuke.Modules.Blog" Namespace="DotNetNuke.Modules.Blog.Templating" %> +<%@ Register TagPrefix="blog" Assembly="DotNetNuke.Modules.Blog.Core" Namespace="DotNetNuke.Modules.Blog.Core.Templating" %> <%@ Register TagPrefix="blog" TagName="comments" Src="controls/Comments.ascx" %> <%@ Register TagPrefix="blog" TagName="management" Src="controls/ManagementPanel.ascx" %> diff --git a/Server/Blog/Blog.ascx.designer.vb b/Server/Blog/Blog.ascx.designer.vb index 4e498dfc..06fccc24 100644 --- a/Server/Blog/Blog.ascx.designer.vb +++ b/Server/Blog/Blog.ascx.designer.vb @@ -31,21 +31,21 @@ Partial Public Class Blog ''' Protected WithEvents ctlManagement As Global.DotNetNuke.Modules.Blog.Controls.ManagementPanel - ''' - '''vtContents control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents vtContents As Global.DotNetNuke.Modules.Blog.Templating.ViewTemplate + ''' + '''vtContents control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents vtContents As Global.DotNetNuke.Modules.Blog.Core.Templating.ViewTemplate - ''' - '''ctlComments control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents ctlComments As Global.DotNetNuke.Modules.Blog.Controls.Comments + ''' + '''ctlComments control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents ctlComments As Global.DotNetNuke.Modules.Blog.Controls.Comments End Class diff --git a/Server/Blog/Blog.ascx.vb b/Server/Blog/Blog.ascx.vb index f43330d6..13c873c5 100644 --- a/Server/Blog/Blog.ascx.vb +++ b/Server/Blog/Blog.ascx.vb @@ -23,574 +23,574 @@ Imports DotNetNuke.Entities.Modules Imports DotNetNuke.Services.Localization Imports DotNetNuke.Entities.Modules.Actions Imports DotNetNuke.Entities.Portals -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.Templating -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Modules.Blog.Entities.Terms -Imports DotNetNuke.Modules.Blog.Entities.Comments +Imports DotNetNuke.Modules.Blog.Core.Common +Imports DotNetNuke.Modules.Blog.Core.Entities.Posts +Imports DotNetNuke.Modules.Blog.Core.Entities.Blogs +Imports DotNetNuke.Modules.Blog.Core.Templating +Imports DotNetNuke.Modules.Blog.Core.Entities.Terms +Imports DotNetNuke.Modules.Blog.Core.Entities.Comments Public Class Blog - Inherits BlogModuleBase - Implements IActionable + Inherits BlogModuleBase + Implements IActionable #Region " Private Members " - Private _urlParameters As New List(Of String) - Private _pageSize As Integer = -1 - Private _totalRecords As Integer = 0 - Private _reqPage As Integer = 1 - Private _usePaging As Boolean = False + Private _urlParameters As New List(Of String) + Private _pageSize As Integer = -1 + Private _totalRecords As Integer = 0 + Private _reqPage As Integer = 1 + Private _usePaging As Boolean = False #End Region #Region " Event Handlers " - Private Sub Page_Init1(sender As Object, e As EventArgs) Handles Me.Init - Integration.BlogModuleController.CheckupOnImportedFiles(ModuleId) - ctlComments.ModuleConfiguration = ModuleConfiguration - ctlComments.BlogContext = BlogContext - ctlManagement.ModuleConfiguration = ModuleConfiguration - ctlManagement.BlogContext = BlogContext - End Sub - - Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load - - ViewSettings.TemplateSettings.ReadValue("pagesize", _pageSize) - Request.Params.ReadValue("Page", _reqPage) - - If Context.Items("BlogPageInitialized") Is Nothing Then - - ' wlw style detection post redirect? - If Not String.IsNullOrEmpty(Settings.StyleDetectionUrl) And BlogContext.WLWRequest Then - ' we have a style detection post in storage and it's being requested - Dim url As String = Settings.StyleDetectionUrl - Settings.StyleDetectionUrl = "" - Settings.UpdateSettings() - Response.Redirect(url, False) - End If - - If BlogContext.ContentItemId = -1 AndAlso BlogContext.LegacyEntryId > -1 Then - ' we have a legacy url - Dim p As PostInfo = PostsController.GetPostByLegacyEntryId(BlogContext.LegacyEntryId, PortalId, BlogContext.Locale) - If p IsNot Nothing Then - Response.RedirectPermanent(p.PermaLink(PortalSettings), False) - End If - End If - - If Not IsPostBack And BlogContext.ContentItemId > -1 Then - Dim viewCountTimeout As Integer = Settings.IncrementViewCount * 1000 'in milliseconds - Dim scriptBlock As String = "(function ($, Sys) {$(document).ready(function () {setTimeout(function(){blogService.viewPost(" & BlogContext.BlogId.ToString & ", " & BlogContext.ContentItemId.ToString & ")}," & viewCountTimeout.ToString & ")});} (jQuery, window.Sys));" - Page.ClientScript.RegisterClientScriptBlock([GetType], "PostViewScript", scriptBlock, True) - End If - - AddWLWManifestLink() - - If Settings.ModifyPageDetails OrElse ViewSettings.ModifyPageDetails Then - ' force modify on all modules orlse modify on selected modules only? - If BlogContext.Post IsNot Nothing Then - Page.Title = BlogContext.Post.LocalizedTitle - Page.Description = DotNetNuke.Common.Utilities.HtmlUtils.Clean(BlogContext.Post.LocalizedSummary, False) - Page.KeyWords = String.Join(",", BlogContext.Post.Terms.ToStringArray) - 'AddOpenGraphMetaTags() - ElseIf BlogContext.Blog IsNot Nothing Then - Page.Title = BlogContext.Blog.LocalizedTitle - Page.Description = DotNetNuke.Common.Utilities.HtmlUtils.Clean(BlogContext.Blog.LocalizedDescription, False) - ElseIf BlogContext.Author IsNot Nothing Then - Page.Title = BlogContext.Author.DisplayName - Page.Description = DotNetNuke.Common.Utilities.HtmlUtils.Clean(BlogContext.Author.Profile.Biography, False) - ElseIf BlogContext.Term IsNot Nothing Then - Page.Title = BlogContext.Term.LocalizedName - Page.Description = DotNetNuke.Common.Utilities.HtmlUtils.Clean(BlogContext.Term.LocalizedDescription, False) - End If - - If _reqPage > 1 Then - Page.Title = String.Format(Localization.GetString("PageTitle.Format", LocalResourceFile), Page.Title, _reqPage) - End If - - End If - - If BlogContext.Post IsNot Nothing AndAlso BlogContext.Blog IsNot Nothing Then - AddOpenGraphMetaTags() - If ViewSettings.AddCanonicalTag Then - AddCanonicalTag(True) - End If - If BlogContext.Blog.EnablePingBackReceive Then - AddPingBackLink() - End If - If BlogContext.Blog.EnableTrackBackReceive Then - AddTrackBackBlurb() - End If - Else - AddCanonicalTag(False) - End If + Private Sub Page_Init1(sender As Object, e As EventArgs) Handles Me.Init + Core.Integration.BlogModuleController.CheckupOnImportedFiles(ModuleId) + ctlComments.ModuleConfiguration = ModuleConfiguration + ctlComments.BlogContext = BlogContext + ctlManagement.ModuleConfiguration = ModuleConfiguration + ctlManagement.BlogContext = BlogContext + End Sub + + Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load + + _pageSize = ViewSettings.TemplateSettings.ReadValue("pagesize", _pageSize) + _reqPage = Request.Params.ReadValue("Page", _reqPage) + + If Context.Items("BlogPageInitialized") Is Nothing Then + + ' wlw style detection post redirect? + If Not String.IsNullOrEmpty(Settings.StyleDetectionUrl) And BlogContext.WLWRequest Then + ' we have a style detection post in storage and it's being requested + Dim url As String = Settings.StyleDetectionUrl + Settings.StyleDetectionUrl = "" + Settings.UpdateSettings() + Response.Redirect(url, False) + End If - Context.Items("BlogPageInitialized") = True - End If + If BlogContext.ContentItemId = -1 AndAlso BlogContext.LegacyEntryId > -1 Then + ' we have a legacy url + Dim p As PostInfo = PostsController.GetPostByLegacyEntryId(BlogContext.LegacyEntryId, PortalId, BlogContext.Locale) + If p IsNot Nothing Then + Response.RedirectPermanent(p.PermaLink(PortalSettings), False) + End If + End If - DataBind() + If Not IsPostBack And BlogContext.ContentItemId > -1 Then + Dim viewCountTimeout As Integer = Settings.IncrementViewCount * 1000 'in milliseconds + Dim scriptBlock As String = "(function ($, Sys) {$(document).ready(function () {setTimeout(function(){blogService.viewPost(" & BlogContext.BlogId.ToString & ", " & BlogContext.ContentItemId.ToString & ")}," & viewCountTimeout.ToString & ")});} (jQuery, window.Sys));" + Page.ClientScript.RegisterClientScriptBlock([GetType], "PostViewScript", scriptBlock, True) + End If - End Sub + AddWLWManifestLink() - Private Sub AddCanonicalTag(HasBlogContext As Boolean) + If Settings.ModifyPageDetails OrElse ViewSettings.ModifyPageDetails Then + ' force modify on all modules orlse modify on selected modules only? If BlogContext.Post IsNot Nothing Then - Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Post.PermaLink))) + Page.Title = BlogContext.Post.LocalizedTitle + Page.Description = DotNetNuke.Common.Utilities.HtmlUtils.Clean(BlogContext.Post.LocalizedSummary, False) + Page.KeyWords = String.Join(",", BlogContext.Post.Terms.ToStringArray) + 'AddOpenGraphMetaTags() ElseIf BlogContext.Blog IsNot Nothing Then - Page.Header.Controls.Add(New LiteralControl(String.Format("", PortalSettings.Current.ActiveTab.FullUrl))) + Page.Title = BlogContext.Blog.LocalizedTitle + Page.Description = DotNetNuke.Common.Utilities.HtmlUtils.Clean(BlogContext.Blog.LocalizedDescription, False) ElseIf BlogContext.Author IsNot Nothing Then - Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.ModuleUrls.GetUrl(False, False, False, True, False)))) + Page.Title = BlogContext.Author.DisplayName + Page.Description = DotNetNuke.Common.Utilities.HtmlUtils.Clean(BlogContext.Author.Profile.Biography, False) ElseIf BlogContext.Term IsNot Nothing Then - Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Term.PermaLink(PortalSettings)))) - Else - Page.Header.Controls.Add(New LiteralControl(String.Format("", PortalSettings.Current.ActiveTab.FullUrl))) + Page.Title = BlogContext.Term.LocalizedName + Page.Description = DotNetNuke.Common.Utilities.HtmlUtils.Clean(BlogContext.Term.LocalizedDescription, False) End If - If HasBlogContext Then - - ElseIf Not HasBlogContext And BlogContext.Term IsNot Nothing Then - ElseIf Not HasBlogContext And BlogContext.Author IsNot Nothing Then + If _reqPage > 1 Then + Page.Title = String.Format(Localization.GetString("PageTitle.Format", LocalResourceFile), Page.Title, _reqPage) + End If - Else + End If + If BlogContext.Post IsNot Nothing AndAlso BlogContext.Blog IsNot Nothing Then + AddOpenGraphMetaTags() + If ViewSettings.AddCanonicalTag Then + AddCanonicalTag(True) + End If + If BlogContext.Blog.EnablePingBackReceive Then + AddPingBackLink() End If - End Sub + If BlogContext.Blog.EnableTrackBackReceive Then + AddTrackBackBlurb() + End If + Else + AddCanonicalTag(False) + End If + + Context.Items("BlogPageInitialized") = True + End If + + DataBind() + + End Sub + + Private Sub AddCanonicalTag(HasBlogContext As Boolean) + If BlogContext.Post IsNot Nothing Then + Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Post.PermaLink))) + ElseIf BlogContext.Blog IsNot Nothing Then + Page.Header.Controls.Add(New LiteralControl(String.Format("", PortalSettings.Current.ActiveTab.FullUrl))) + ElseIf BlogContext.Author IsNot Nothing Then + Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.ModuleUrls.GetUrl(False, False, False, True, False)))) + ElseIf BlogContext.Term IsNot Nothing Then + Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Term.PermaLink(PortalSettings)))) + Else + Page.Header.Controls.Add(New LiteralControl(String.Format("", PortalSettings.Current.ActiveTab.FullUrl))) + End If + If HasBlogContext Then + + ElseIf Not HasBlogContext And BlogContext.Term IsNot Nothing Then + + ElseIf Not HasBlogContext And BlogContext.Author IsNot Nothing Then + + Else + + End If + End Sub #End Region #Region " Open Graph Meta Tags " - Private Sub AddOpenGraphMetaTags() - Dim URL As String = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + Private Sub AddOpenGraphMetaTags() + Dim URL As String = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Post.PermaLink))) Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Post.PermaLink))) - Page.Header.Controls.Add(New LiteralControl(String.Format("", CleanStringForXmlAttribute(BlogContext.Post.LocalizedTitle)))) - Page.Header.Controls.Add(New LiteralControl(String.Format("", CleanStringForXmlAttribute(BlogContext.Post.LocalizedTitle)))) - Dim description As String = CleanStringForXmlAttribute(DotNetNuke.Common.Utilities.HtmlUtils.Clean(BlogContext.Post.LocalizedSummary, False)) - If (Not String.IsNullOrEmpty(description)) Then + Page.Header.Controls.Add(New LiteralControl(String.Format("", Globals.CleanStringForXmlAttribute(BlogContext.Post.LocalizedTitle)))) + Page.Header.Controls.Add(New LiteralControl(String.Format("", Globals.CleanStringForXmlAttribute(BlogContext.Post.LocalizedTitle)))) + Dim description As String = Globals.CleanStringForXmlAttribute(DotNetNuke.Common.Utilities.HtmlUtils.Clean(BlogContext.Post.LocalizedSummary, False)) + If (Not String.IsNullOrEmpty(description)) Then Page.Header.Controls.Add(New LiteralControl(String.Format("", description))) Page.Header.Controls.Add(New LiteralControl(String.Format("", description))) End If - If Not String.IsNullOrEmpty(BlogContext.Post.Image) Then - Dim strPath As String = String.Format("{0}?TabId={1}&ModuleId={2}&Blog={3}&Post={4}&w=1200&h=630&c=1&key={5}", glbImageHandlerPath, TabId.ToString, Settings.ModuleId.ToString, BlogContext.BlogId.ToString, BlogContext.ContentItemId.ToString, BlogContext.Post.Image) + If Not String.IsNullOrEmpty(BlogContext.Post.Image) Then + Dim strPath As String = String.Format("{0}?TabId={1}&ModuleId={2}&Blog={3}&Post={4}&w=1200&h=630&c=1&key={5}", Globals.glbImageHandlerPath, TabId.ToString, Settings.ModuleId.ToString, BlogContext.BlogId.ToString, BlogContext.ContentItemId.ToString, BlogContext.Post.Image) Page.Header.Controls.Add(New LiteralControl(String.Format("", URL + ResolveUrl(strPath)))) Page.Header.Controls.Add(New LiteralControl(String.Format("", URL + ResolveUrl(strPath)))) Page.Header.Controls.Add(New LiteralControl(String.Format(""))) End If - Page.Header.Controls.Add(New LiteralControl(String.Format("", CleanStringForXmlAttribute(PortalSettings.PortalName)))) - If Not String.IsNullOrEmpty(Settings.FacebookAppId) Then - Page.Header.Controls.Add(New LiteralControl(String.Format("", Settings.FacebookAppId))) - End If - Page.Header.Controls.Add(New LiteralControl(String.Format("", "article"))) - If Not String.IsNullOrEmpty(BlogContext.Post.Locale) Then - Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Post.Locale.Replace("-", "_")))) - ElseIf Not String.IsNullOrEmpty(BlogContext.Blog.Locale) Then - Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Blog.Locale.Replace("-", "_")))) - Else - Page.Header.Controls.Add(New LiteralControl(String.Format("", PortalSettings.DefaultLanguage.Replace("-", "_")))) - End If - Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Post.LastModifiedOnDate.ToString("u")))) - If Settings.FacebookProfileIdProperty <> -1 Then - Dim author As DotNetNuke.Entities.Users.UserInfo = BlogContext.Author - If author Is Nothing Then - author = BlogContext.Post.CreatedByUser(PortalId) - End If - If author IsNot Nothing Then - Dim pp As DotNetNuke.Entities.Profile.ProfilePropertyDefinition = author.Profile.ProfileProperties.GetById(Settings.FacebookProfileIdProperty) - If pp IsNot Nothing AndAlso Not String.IsNullOrEmpty(pp.PropertyValue) Then - Page.Header.Controls.Add(New LiteralControl(String.Format("", pp.PropertyValue))) + Page.Header.Controls.Add(New LiteralControl(String.Format("", Globals.CleanStringForXmlAttribute(PortalSettings.PortalName)))) + If Not String.IsNullOrEmpty(Settings.FacebookAppId) Then + Page.Header.Controls.Add(New LiteralControl(String.Format("", Settings.FacebookAppId))) End If - End If - End If - End Sub + Page.Header.Controls.Add(New LiteralControl(String.Format("", "article"))) + If Not String.IsNullOrEmpty(BlogContext.Post.Locale) Then + Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Post.Locale.Replace("-", "_")))) + ElseIf Not String.IsNullOrEmpty(BlogContext.Blog.Locale) Then + Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Blog.Locale.Replace("-", "_")))) + Else + Page.Header.Controls.Add(New LiteralControl(String.Format("", PortalSettings.DefaultLanguage.Replace("-", "_")))) + End If + Page.Header.Controls.Add(New LiteralControl(String.Format("", BlogContext.Post.LastModifiedOnDate.ToString("u")))) + If Settings.FacebookProfileIdProperty <> -1 Then + Dim author As DotNetNuke.Entities.Users.UserInfo = BlogContext.Author + If author Is Nothing Then + author = BlogContext.Post.CreatedByUser(PortalId) + End If + If author IsNot Nothing Then + Dim pp As DotNetNuke.Entities.Profile.ProfilePropertyDefinition = author.Profile.ProfileProperties.GetById(Settings.FacebookProfileIdProperty) + If pp IsNot Nothing AndAlso Not String.IsNullOrEmpty(pp.PropertyValue) Then + Page.Header.Controls.Add(New LiteralControl(String.Format("", pp.PropertyValue))) + End If + End If + End If + End Sub #End Region #Region " Public Methods " - Private Sub AddWLWManifestLink() - If Context.Items("WLWManifestLinkAdded") Is Nothing Then - Dim link As New HtmlLink() - link.Attributes.Add("rel", "wlwmanifest") - link.Attributes.Add("type", "application/wlwmanifest+xml") - If ViewSettings.BlogModuleId = -1 Then - link.Attributes.Add("href", ResolveUrl(ManifestFilePath(TabId, ModuleId))) - Else - link.Attributes.Add("href", ResolveUrl(ManifestFilePath(TabId, ViewSettings.BlogModuleId))) - End If - Page.Header.Controls.Add(link) - Context.Items("WLWManifestLinkAdded") = True - End If - End Sub - - Private Sub AddPingBackLink() - If Context.Items("PingBackLinkAdded") Is Nothing Then - Dim pingbackUrl As String = Services.BlogRouteMapper.GetRoute(Services.BlogRouteMapper.ServiceControllers.Comments, "Pingback") - pingbackUrl &= String.Format("?tabId={0}&moduleId={1}&blogId={2}&postId={3}", TabId, BlogContext.BlogModuleId, BlogContext.BlogId, BlogContext.ContentItemId) - Dim link As New HtmlGenericControl("link") - link.Attributes.Add("rel", "pingback") - link.Attributes.Add("href", pingbackUrl) - Page.Header.Controls.Add(link) - Context.Items("PingBackLinkAdded") = True - End If - End Sub - - Private Sub AddTrackBackBlurb() - If Context.Items("TrackBackBlurbAdded") Is Nothing Then - Dim trackbackUrl As String = Services.BlogRouteMapper.GetRoute(Services.BlogRouteMapper.ServiceControllers.Comments, "Trackback") - trackbackUrl &= String.Format("?tabId={0}&moduleId={1}&blogId={2}&postId={3}", TabId, BlogContext.BlogModuleId, BlogContext.BlogId, BlogContext.ContentItemId) - Dim postUrl As String = BlogContext.Post.PermaLink(PortalSettings) - Dim sb As New StringBuilder - sb.AppendLine("") - litTrackback.Text = sb.ToString - Context.Items("TrackBackBlurbAdded") = True - End If - End Sub -#End Region - -#Region " Template Data Retrieval " - Private Sub vtContents_GetData(ByVal DataSource As String, ByVal Parameters As Dictionary(Of String, String), ByRef Replacers As System.Collections.Generic.List(Of GenericTokenReplace), ByRef Arguments As System.Collections.Generic.List(Of String()), callingObject As Object) Handles vtContents.GetData - - Select Case DataSource.ToLower - - Case "blogs" - - Dim blogList As IEnumerable(Of BlogInfo) = BlogsController.GetBlogsByModule(BlogContext.BlogModuleId, UserId, BlogContext.Locale).Values.Where(Function(b) b.Published = True).OrderBy(Function(b) b.Title) - Parameters.ReadValue("pagesize", _pageSize) - If _pageSize > 0 Then - _usePaging = True - Dim startRec As Integer = ((_reqPage - 1) * _pageSize) + 1 - Dim endRec As Integer = _reqPage * _pageSize - Dim i As Integer = 1 - For Each b As BlogInfo In blogList - If i >= startRec And i <= endRec Then - If BlogContext.ParentModule IsNot Nothing Then - b.ParentTabID = BlogContext.ParentModule.TabID - End If - Replacers.Add(New BlogTokenReplace(Me, b)) - End If - i += 1 - Next - Else - For Each b As BlogInfo In blogList - If BlogContext.ParentModule IsNot Nothing Then - b.ParentTabID = BlogContext.ParentModule.TabID + Private Sub AddWLWManifestLink() + If Context.Items("WLWManifestLinkAdded") Is Nothing Then + Dim link As New HtmlLink() + link.Attributes.Add("rel", "wlwmanifest") + link.Attributes.Add("type", "application/wlwmanifest+xml") + If ViewSettings.BlogModuleId = -1 Then + link.Attributes.Add("href", ResolveUrl(Globals.ManifestFilePath(TabId, ModuleId))) + Else + link.Attributes.Add("href", ResolveUrl(Globals.ManifestFilePath(TabId, ViewSettings.BlogModuleId))) End If - Replacers.Add(New BlogTokenReplace(Me, b)) - Next + Page.Header.Controls.Add(link) + Context.Items("WLWManifestLinkAdded") = True End If - - Case "posts" - - Parameters.ReadValue("pagesize", _pageSize) - EnsurePostList(_pageSize) - For Each e As PostInfo In PostList - If BlogContext.ParentModule IsNot Nothing Then - e.ParentTabID = BlogContext.ParentModule.TabID - End If - Replacers.Add(New BlogTokenReplace(Me, e)) - Next - - Case "postspager" - - Parameters.ReadValue("pagesize", _pageSize) - EnsurePostList(_pageSize) - Dim pagerType As String = "allpages" - Parameters.ReadValue("pagertype", pagerType) - Dim remdr As Integer = 0 - Dim nrPages As Integer = Math.DivRem(_totalRecords, _pageSize, remdr) - If remdr > 0 Then - nrPages += 1 + End Sub + + Private Sub AddPingBackLink() + If Context.Items("PingBackLinkAdded") Is Nothing Then + Dim pingbackUrl As String = Api.BlogRouteMapper.GetRoute(Api.BlogRouteMapper.ServiceControllers.Comments, "Pingback") + pingbackUrl &= String.Format("?tabId={0}&moduleId={1}&blogId={2}&postId={3}", TabId, BlogContext.BlogModuleId, BlogContext.BlogId, BlogContext.ContentItemId) + Dim link As New HtmlGenericControl("link") + link.Attributes.Add("rel", "pingback") + link.Attributes.Add("href", pingbackUrl) + Page.Header.Controls.Add(link) + Context.Items("PingBackLinkAdded") = True End If - If nrPages < 2 Then - Else - Replacers.Add(New BlogTokenReplace(Me)) - Select Case pagerType.ToLower - Case "allpages" - For i As Integer = 1 To nrPages - Dim s As String() = {"page=" & i.ToString, "pageiscurrent=" & CBool(i = _reqPage).ToString, "pagename=" & i.ToString, "pagetype=number"} - Arguments.Add(s) - Next - Case "somepages" - If _reqPage > 3 Then - Dim s As String() = {"page=1", "pageiscurrent=False", "pagename=1", "pagetype=firstpage"} - Arguments.Add(s) - End If - For i As Integer = Math.Max(_reqPage - 2, 1) To Math.Min(_reqPage + 2, nrPages) - Dim s As String() = {"page=" & i.ToString, "pageiscurrent=" & CBool(i = _reqPage).ToString, "pagename=" & i.ToString, "pagetype=number"} - Arguments.Add(s) - Next - If _reqPage < nrPages - 3 Then - Dim s As String() = {"page=" & nrPages.ToString, "pageiscurrent=False", "pagename=" & nrPages.ToString, "pagetype=lastpage"} - Arguments.Add(s) - End If - Case "newerolder" - If _reqPage > 1 Then - Dim s As String() = {"page=" & (_reqPage - 1).ToString, "pageiscurrent=False", "pagename=" & LocalizeString("Newer"), "pagetype=previous"} - Arguments.Add(s) - End If - If _reqPage < nrPages Then - Dim s As String() = {"page=" & (_reqPage + 1).ToString, "pageiscurrent=False", "pagename=" & LocalizeString("Older"), "pagetype=next"} - Arguments.Add(s) - End If - End Select + End Sub + + Private Sub AddTrackBackBlurb() + If Context.Items("TrackBackBlurbAdded") Is Nothing Then + Dim trackbackUrl As String = Api.BlogRouteMapper.GetRoute(Api.BlogRouteMapper.ServiceControllers.Comments, "Trackback") + trackbackUrl &= String.Format("?tabId={0}&moduleId={1}&blogId={2}&postId={3}", TabId, BlogContext.BlogModuleId, BlogContext.BlogId, BlogContext.ContentItemId) + Dim postUrl As String = BlogContext.Post.PermaLink(PortalSettings) + Dim sb As New StringBuilder + sb.AppendLine("") + litTrackback.Text = sb.ToString + Context.Items("TrackBackBlurbAdded") = True End If + End Sub +#End Region - Case "terms" +#Region " Template Data Retrieval " + Private Sub vtContents_GetData(ByVal DataSource As String, ByVal Parameters As Dictionary(Of String, String), ByRef Replacers As System.Collections.Generic.List(Of GenericTokenReplace), ByRef Arguments As System.Collections.Generic.List(Of String()), callingObject As Object) Handles vtContents.GetData + + Select Case DataSource.ToLower + + Case "blogs" + + Dim blogList As IEnumerable(Of BlogInfo) = BlogsController.GetBlogsByModule(BlogContext.BlogModuleId, UserId, BlogContext.Locale).Values.Where(Function(b) b.Published = True).OrderBy(Function(b) b.Title) + _pageSize = Parameters.ReadValue("pagesize", _pageSize) + If _pageSize > 0 Then + _usePaging = True + Dim startRec As Integer = ((_reqPage - 1) * _pageSize) + 1 + Dim endRec As Integer = _reqPage * _pageSize + Dim i As Integer = 1 + For Each b As BlogInfo In blogList + If i >= startRec And i <= endRec Then + If BlogContext.ParentModule IsNot Nothing Then + b.ParentTabID = BlogContext.ParentModule.TabID + End If + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, b)) + End If + i += 1 + Next + Else + For Each b As BlogInfo In blogList + If BlogContext.ParentModule IsNot Nothing Then + b.ParentTabID = BlogContext.ParentModule.TabID + End If + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, b)) + Next + End If - If callingObject IsNot Nothing AndAlso TypeOf callingObject Is PostInfo Then - For Each t As TermInfo In CType(callingObject, PostInfo).Terms - Replacers.Add(New BlogTokenReplace(Me, BlogContext.Post, t)) - Next - ElseIf BlogContext.Post IsNot Nothing Then - For Each t As TermInfo In BlogContext.Post.Terms - Replacers.Add(New BlogTokenReplace(Me, BlogContext.Post, t)) - Next - Else - For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale) - Replacers.Add(New BlogTokenReplace(Me, Nothing, t)) - Next - End If - _usePaging = False + Case "posts" + + _pageSize = Parameters.ReadValue("pagesize", _pageSize) + EnsurePostList(_pageSize) + For Each e As PostInfo In PostList + If BlogContext.ParentModule IsNot Nothing Then + e.ParentTabID = BlogContext.ParentModule.TabID + End If + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, e)) + Next + + Case "postspager" + + _pageSize = Parameters.ReadValue("pagesize", _pageSize) + EnsurePostList(_pageSize) + Dim pagerType As String = "allpages" + pagerType = Parameters.ReadValue("pagertype", pagerType) + Dim remdr As Integer = 0 + Dim nrPages As Integer = Math.DivRem(_totalRecords, _pageSize, remdr) + If remdr > 0 Then + nrPages += 1 + End If + If nrPages < 2 Then + Else + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings)) + Select Case pagerType.ToLower + Case "allpages" + For i As Integer = 1 To nrPages + Dim s As String() = {"page=" & i.ToString, "pageiscurrent=" & CBool(i = _reqPage).ToString, "pagename=" & i.ToString, "pagetype=number"} + Arguments.Add(s) + Next + Case "somepages" + If _reqPage > 3 Then + Dim s As String() = {"page=1", "pageiscurrent=False", "pagename=1", "pagetype=firstpage"} + Arguments.Add(s) + End If + For i As Integer = Math.Max(_reqPage - 2, 1) To Math.Min(_reqPage + 2, nrPages) + Dim s As String() = {"page=" & i.ToString, "pageiscurrent=" & CBool(i = _reqPage).ToString, "pagename=" & i.ToString, "pagetype=number"} + Arguments.Add(s) + Next + If _reqPage < nrPages - 3 Then + Dim s As String() = {"page=" & nrPages.ToString, "pageiscurrent=False", "pagename=" & nrPages.ToString, "pagetype=lastpage"} + Arguments.Add(s) + End If + Case "newerolder" + If _reqPage > 1 Then + Dim s As String() = {"page=" & (_reqPage - 1).ToString, "pageiscurrent=False", "pagename=" & LocalizeString("Newer"), "pagetype=previous"} + Arguments.Add(s) + End If + If _reqPage < nrPages Then + Dim s As String() = {"page=" & (_reqPage + 1).ToString, "pageiscurrent=False", "pagename=" & LocalizeString("Older"), "pagetype=next"} + Arguments.Add(s) + End If + End Select + End If - Case "allterms" + Case "terms" - For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale) - Replacers.Add(New BlogTokenReplace(Me, Nothing, t)) - Next - _usePaging = False + If callingObject IsNot Nothing AndAlso TypeOf callingObject Is PostInfo Then + For Each t As TermInfo In CType(callingObject, PostInfo).Terms + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, BlogContext.Post, t)) + Next + ElseIf BlogContext.Post IsNot Nothing Then + For Each t As TermInfo In BlogContext.Post.Terms + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, BlogContext.Post, t)) + Next + Else + For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale) + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, Nothing, t)) + Next + End If + _usePaging = False - Case "keywords", "tags" + Case "allterms" - If callingObject IsNot Nothing AndAlso TypeOf callingObject Is PostInfo Then - For Each t As TermInfo In CType(callingObject, PostInfo).PostTags - If BlogContext.ParentModule IsNot Nothing Then - t.ParentTabID = BlogContext.ParentModule.TabID - End If - Replacers.Add(New BlogTokenReplace(Me, BlogContext.Post, t)) - Next - ElseIf BlogContext.Post IsNot Nothing Then - For Each t As TermInfo In BlogContext.Post.PostTags - If BlogContext.ParentModule IsNot Nothing Then - t.ParentTabID = BlogContext.ParentModule.TabID - End If - Replacers.Add(New BlogTokenReplace(Me, BlogContext.Post, t)) - Next - Else - For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale).Where(Function(x) x.VocabularyId = 1).ToList - If BlogContext.ParentModule IsNot Nothing Then - t.ParentTabID = BlogContext.ParentModule.TabID - End If - Replacers.Add(New BlogTokenReplace(Me, Nothing, t)) - Next - End If - _usePaging = False - - Case "allkeywords", "alltags" - - For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale).Where(Function(x) x.VocabularyId = 1).ToList - If BlogContext.ParentModule IsNot Nothing Then - t.ParentTabID = BlogContext.ParentModule.TabID - End If - Replacers.Add(New BlogTokenReplace(Me, Nothing, t)) - Next - _usePaging = False - - Case "categories" - - If callingObject IsNot Nothing AndAlso TypeOf callingObject Is PostInfo Then - For Each t As TermInfo In CType(callingObject, PostInfo).PostCategories - Replacers.Add(New BlogTokenReplace(Me, BlogContext.Post, t)) - Next - ElseIf BlogContext.Post IsNot Nothing Then - For Each t As TermInfo In BlogContext.Post.PostCategories - Replacers.Add(New BlogTokenReplace(Me, BlogContext.Post, t)) - Next - ElseIf ViewSettings.Categories = "" Then - For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale).Where(Function(x) x.VocabularyId <> 1).ToList - Replacers.Add(New BlogTokenReplace(Me, Nothing, t)) - Next - Else - For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale).Where(Function(x) ViewSettings.CategoryList.Contains(x.VocabularyId)).ToList - Replacers.Add(New BlogTokenReplace(Me, Nothing, t)) - Next - End If - _usePaging = False - - Case "allcategories" - - For Each t As TermInfo In TermsController.GetTermsByVocabulary(BlogContext.BlogModuleId, Settings.VocabularyId, BlogContext.Locale).Values - If BlogContext.ParentModule IsNot Nothing Then - t.ParentTabID = BlogContext.ParentModule.TabID - End If - Replacers.Add(New BlogTokenReplace(Me, Nothing, t)) - Next - _usePaging = False - - Case "selectcategories" - - For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale).Where(Function(x) ViewSettings.CategoryList.Contains(x.TermId)).ToList - If BlogContext.ParentModule IsNot Nothing Then - t.ParentTabID = BlogContext.ParentModule.TabID - End If - Replacers.Add(New BlogTokenReplace(Me, Nothing, t)) - Next - _usePaging = False - - Case "comments" - - If callingObject IsNot Nothing AndAlso TypeOf callingObject Is PostInfo Then - For Each c As CommentInfo In CommentsController.GetCommentsByContentItem(CType(callingObject, PostInfo).ContentItemId, False, UserId) - Replacers.Add(New BlogTokenReplace(Me, BlogContext.Post, c)) - Next - _usePaging = False - ElseIf BlogContext.Post IsNot Nothing Then - For Each c As CommentInfo In CommentsController.GetCommentsByContentItem(BlogContext.Post.ContentItemId, False, UserId) - Replacers.Add(New BlogTokenReplace(Me, BlogContext.Post, c)) - Next - _usePaging = False - Else - Parameters.ReadValue("pagesize", _pageSize) - If _pageSize < 1 Then _pageSize = 10 ' we will not list "all Posts" - For Each c As CommentInfo In CommentsController.GetCommentsByModule(BlogContext.BlogModuleId, UserId, _reqPage - 1, _pageSize, "CREATEDONDATE DESC", _totalRecords).Values - Replacers.Add(New BlogTokenReplace(Me, BlogContext.Post, c)) - Next - End If + For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale) + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, Nothing, t)) + Next + _usePaging = False - Case "allcomments" - - Parameters.ReadValue("pagesize", _pageSize) - Dim loadPosts As Boolean = False - Parameters.ReadValue("loadposts", loadPosts) - If _pageSize < 1 Then _pageSize = 10 ' we will not list "all Posts" - For Each c As CommentInfo In CommentsController.GetCommentsByModule(BlogContext.BlogModuleId, UserId, _reqPage - 1, _pageSize, "CREATEDONDATE DESC", _totalRecords).Values - If loadPosts Then - Replacers.Add(New BlogTokenReplace(Me, PostsController.GetPost(c.ContentItemId, BlogContext.BlogModuleId, BlogContext.Locale), c)) - Else - Replacers.Add(New BlogTokenReplace(Me, Nothing, c)) - End If - Next - - Case "calendar", "blogcalendar" - - For Each bci As BlogCalendarInfo In BlogsController.GetBlogCalendar(BlogContext.BlogModuleId, BlogContext.BlogId, BlogContext.ShowLocale) - If BlogContext.ParentModule IsNot Nothing Then - bci.ParentTabID = BlogContext.ParentModule.TabID - End If - Replacers.Add(New BlogTokenReplace(Me, bci)) - Next - - Case "authors", "allauthors" - - Dim blogToShow As Integer = BlogContext.BlogId - If DataSource.ToLower = "allauthors" Then blogToShow = -1 - Dim sort As String = "" - Parameters.ReadValue("sort", sort) - Select Case sort.ToLower - Case "username" - For Each u As PostAuthor In PostsController.GetAuthors(BlogContext.BlogModuleId, blogToShow).OrderBy(Function(t) t.Username) - Replacers.Add(New BlogTokenReplace(Me, New LazyLoadingUser(u))) - Next - Case "email" - For Each u As PostAuthor In PostsController.GetAuthors(BlogContext.BlogModuleId, blogToShow).OrderBy(Function(t) t.Email) - Replacers.Add(New BlogTokenReplace(Me, New LazyLoadingUser(u))) - Next - Case "firstname" - For Each u As PostAuthor In PostsController.GetAuthors(BlogContext.BlogModuleId, blogToShow).OrderBy(Function(t) t.FirstName) - Replacers.Add(New BlogTokenReplace(Me, New LazyLoadingUser(u))) - Next - Case "displayname" - For Each u As PostAuthor In PostsController.GetAuthors(BlogContext.BlogModuleId, blogToShow).OrderBy(Function(t) t.DisplayName) - Replacers.Add(New BlogTokenReplace(Me, New LazyLoadingUser(u))) - Next - Case Else ' last name - For Each u As PostAuthor In PostsController.GetAuthors(BlogContext.BlogModuleId, blogToShow) - If BlogContext.ParentModule IsNot Nothing Then - u.ParentTabID = BlogContext.ParentModule.TabID - End If - Replacers.Add(New BlogTokenReplace(Me, New LazyLoadingUser(u))) - Next - End Select + Case "keywords", "tags" - End Select + If callingObject IsNot Nothing AndAlso TypeOf callingObject Is PostInfo Then + For Each t As TermInfo In CType(callingObject, PostInfo).PostTags + If BlogContext.ParentModule IsNot Nothing Then + t.ParentTabID = BlogContext.ParentModule.TabID + End If + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, BlogContext.Post, t)) + Next + ElseIf BlogContext.Post IsNot Nothing Then + For Each t As TermInfo In BlogContext.Post.PostTags + If BlogContext.ParentModule IsNot Nothing Then + t.ParentTabID = BlogContext.ParentModule.TabID + End If + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, BlogContext.Post, t)) + Next + Else + For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale).Where(Function(x) x.VocabularyId = 1).ToList + If BlogContext.ParentModule IsNot Nothing Then + t.ParentTabID = BlogContext.ParentModule.TabID + End If + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, Nothing, t)) + Next + End If + _usePaging = False + + Case "allkeywords", "alltags" + + For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale).Where(Function(x) x.VocabularyId = 1).ToList + If BlogContext.ParentModule IsNot Nothing Then + t.ParentTabID = BlogContext.ParentModule.TabID + End If + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, Nothing, t)) + Next + _usePaging = False + + Case "categories" + + If callingObject IsNot Nothing AndAlso TypeOf callingObject Is PostInfo Then + For Each t As TermInfo In CType(callingObject, PostInfo).PostCategories + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, BlogContext.Post, t)) + Next + ElseIf BlogContext.Post IsNot Nothing Then + For Each t As TermInfo In BlogContext.Post.PostCategories + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, BlogContext.Post, t)) + Next + ElseIf ViewSettings.Categories = "" Then + For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale).Where(Function(x) x.VocabularyId <> 1).ToList + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, Nothing, t)) + Next + Else + For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale).Where(Function(x) ViewSettings.CategoryList.Contains(x.VocabularyId)).ToList + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, Nothing, t)) + Next + End If + _usePaging = False + + Case "allcategories" + + For Each t As TermInfo In TermsController.GetTermsByVocabulary(BlogContext.BlogModuleId, Settings.VocabularyId, BlogContext.Locale).Values + If BlogContext.ParentModule IsNot Nothing Then + t.ParentTabID = BlogContext.ParentModule.TabID + End If + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, Nothing, t)) + Next + _usePaging = False + + Case "selectcategories" + + For Each t As TermInfo In TermsController.GetTermsByModule(BlogContext.BlogModuleId, BlogContext.Locale).Where(Function(x) ViewSettings.CategoryList.Contains(x.TermId)).ToList + If BlogContext.ParentModule IsNot Nothing Then + t.ParentTabID = BlogContext.ParentModule.TabID + End If + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, Nothing, t)) + Next + _usePaging = False + + Case "comments" + + If callingObject IsNot Nothing AndAlso TypeOf callingObject Is PostInfo Then + For Each c As CommentInfo In CommentsController.GetCommentsByContentItem(CType(callingObject, PostInfo).ContentItemId, False, UserId) + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, BlogContext.Post, c)) + Next + _usePaging = False + ElseIf BlogContext.Post IsNot Nothing Then + For Each c As CommentInfo In CommentsController.GetCommentsByContentItem(BlogContext.Post.ContentItemId, False, UserId) + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, BlogContext.Post, c)) + Next + _usePaging = False + Else + _pageSize = Parameters.ReadValue("pagesize", _pageSize) + If _pageSize < 1 Then _pageSize = 10 ' we will not list "all Posts" + For Each c As CommentInfo In CommentsController.GetCommentsByModule(BlogContext.BlogModuleId, UserId, _reqPage - 1, _pageSize, "CREATEDONDATE DESC", _totalRecords).Values + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, BlogContext.Post, c)) + Next + End If + + Case "allcomments" + + _pageSize = Parameters.ReadValue("pagesize", _pageSize) + Dim loadPosts As Boolean = False + loadPosts = Parameters.ReadValue("loadposts", loadPosts) + If _pageSize < 1 Then _pageSize = 10 ' we will not list "all Posts" + For Each c As CommentInfo In CommentsController.GetCommentsByModule(BlogContext.BlogModuleId, UserId, _reqPage - 1, _pageSize, "CREATEDONDATE DESC", _totalRecords).Values + If loadPosts Then + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, PostsController.GetPost(c.ContentItemId, BlogContext.BlogModuleId, BlogContext.Locale), c)) + Else + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, Nothing, c)) + End If + Next + + Case "calendar", "blogcalendar" + + For Each bci As BlogCalendarInfo In BlogsController.GetBlogCalendar(BlogContext.BlogModuleId, BlogContext.BlogId, BlogContext.ShowLocale) + If BlogContext.ParentModule IsNot Nothing Then + bci.ParentTabID = BlogContext.ParentModule.TabID + End If + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, bci)) + Next + + Case "authors", "allauthors" + + Dim blogToShow As Integer = BlogContext.BlogId + If DataSource.ToLower = "allauthors" Then blogToShow = -1 + Dim sort As String = "" + sort = Parameters.ReadValue("sort", sort) + Select Case sort.ToLower + Case "username" + For Each u As PostAuthor In PostsController.GetAuthors(BlogContext.BlogModuleId, blogToShow).OrderBy(Function(t) t.Username) + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, New LazyLoadingUser(u))) + Next + Case "email" + For Each u As PostAuthor In PostsController.GetAuthors(BlogContext.BlogModuleId, blogToShow).OrderBy(Function(t) t.Email) + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, New LazyLoadingUser(u))) + Next + Case "firstname" + For Each u As PostAuthor In PostsController.GetAuthors(BlogContext.BlogModuleId, blogToShow).OrderBy(Function(t) t.FirstName) + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, New LazyLoadingUser(u))) + Next + Case "displayname" + For Each u As PostAuthor In PostsController.GetAuthors(BlogContext.BlogModuleId, blogToShow).OrderBy(Function(t) t.DisplayName) + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, New LazyLoadingUser(u))) + Next + Case Else ' last name + For Each u As PostAuthor In PostsController.GetAuthors(BlogContext.BlogModuleId, blogToShow) + If BlogContext.ParentModule IsNot Nothing Then + u.ParentTabID = BlogContext.ParentModule.TabID + End If + Replacers.Add(New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings, New LazyLoadingUser(u))) + Next + End Select - End Sub + End Select + + End Sub #End Region #Region " Post List Stuff " - Private Property PostList As IEnumerable(Of PostInfo) = Nothing - Private Sub EnsurePostList(pageSize As Integer) - - If PostList Is Nothing Then - If pageSize < 1 Then pageSize = 10 ' we will not list "all Posts" - Dim publishValue As Integer = 1 - If Not String.IsNullOrEmpty(BlogContext.SearchString) Then - If BlogContext.SearchUnpublished Then publishValue = -1 - If String.IsNullOrEmpty(BlogContext.Categories) Then - If BlogContext.Term Is Nothing Then - PostList = PostsController.SearchPosts(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, BlogContext.SearchString, BlogContext.SearchTitle, BlogContext.SearchContents, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, -1, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values - Else - PostList = PostsController.SearchPostsByTerm(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, BlogContext.TermId, BlogContext.SearchString, BlogContext.SearchTitle, BlogContext.SearchContents, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, -1, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values - End If - Else - PostList = PostsController.SearchPostsByCategory(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, BlogContext.Categories, BlogContext.SearchString, BlogContext.SearchTitle, BlogContext.SearchContents, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, -1, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values - End If - ElseIf String.IsNullOrEmpty(BlogContext.Categories) Then - publishValue = -1 - If ViewSettings.HideUnpublishedBlogsViewMode AndAlso PortalSettings.UserMode = PortalSettings.Mode.View Then publishValue = 1 - If ViewSettings.HideUnpublishedBlogsEditMode AndAlso PortalSettings.UserMode = PortalSettings.Mode.Edit Then publishValue = 1 - If BlogContext.Term Is Nothing Then - PostList = PostsController.GetPosts(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, BlogContext.AuthorId, False, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values - Else - PostList = PostsController.GetPostsByTerm(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, BlogContext.TermId, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, BlogContext.AuthorId, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values + Private Property PostList As IEnumerable(Of PostInfo) = Nothing + Private Sub EnsurePostList(pageSize As Integer) + + If PostList Is Nothing Then + If pageSize < 1 Then pageSize = 10 ' we will not list "all Posts" + Dim publishValue As Integer = 1 + If Not String.IsNullOrEmpty(BlogContext.SearchString) Then + If BlogContext.SearchUnpublished Then publishValue = -1 + If String.IsNullOrEmpty(BlogContext.Categories) Then + If BlogContext.Term Is Nothing Then + PostList = PostsController.SearchPosts(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, BlogContext.SearchString, BlogContext.SearchTitle, BlogContext.SearchContents, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, -1, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values + Else + PostList = PostsController.SearchPostsByTerm(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, BlogContext.TermId, BlogContext.SearchString, BlogContext.SearchTitle, BlogContext.SearchContents, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, -1, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values + End If + Else + PostList = PostsController.SearchPostsByCategory(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, BlogContext.Categories, BlogContext.SearchString, BlogContext.SearchTitle, BlogContext.SearchContents, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, -1, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values + End If + ElseIf String.IsNullOrEmpty(BlogContext.Categories) Then + publishValue = -1 + If ViewSettings.HideUnpublishedBlogsViewMode AndAlso PortalSettings.UserMode = PortalSettings.Mode.View Then publishValue = 1 + If ViewSettings.HideUnpublishedBlogsEditMode AndAlso PortalSettings.UserMode = PortalSettings.Mode.Edit Then publishValue = 1 + If BlogContext.Term Is Nothing Then + PostList = PostsController.GetPosts(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, BlogContext.AuthorId, False, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values + Else + PostList = PostsController.GetPostsByTerm(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, BlogContext.TermId, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, BlogContext.AuthorId, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values + End If + Else + publishValue = -1 + If ViewSettings.HideUnpublishedBlogsViewMode AndAlso PortalSettings.UserMode = PortalSettings.Mode.View Then publishValue = 1 + If ViewSettings.HideUnpublishedBlogsEditMode AndAlso PortalSettings.UserMode = PortalSettings.Mode.Edit Then publishValue = 1 + PostList = PostsController.GetPostsByCategory(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, BlogContext.Categories, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, BlogContext.AuthorId, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values + End If + _usePaging = True End If - Else - publishValue = -1 - If ViewSettings.HideUnpublishedBlogsViewMode AndAlso PortalSettings.UserMode = PortalSettings.Mode.View Then publishValue = 1 - If ViewSettings.HideUnpublishedBlogsEditMode AndAlso PortalSettings.UserMode = PortalSettings.Mode.Edit Then publishValue = 1 - PostList = PostsController.GetPostsByCategory(Settings.ModuleId, BlogContext.BlogId, BlogContext.Locale, BlogContext.Categories, publishValue, BlogContext.ShowLocale, BlogContext.EndDate, BlogContext.AuthorId, _reqPage - 1, pageSize, "PUBLISHEDONDATE DESC", _totalRecords, UserId, BlogContext.Security.UserIsAdmin).Values - End If - _usePaging = True - End If - End Sub + End Sub #End Region #Region " Overrides " - Public Overrides Sub DataBind() - - Dim tmgr As New TemplateManager(PortalSettings, ViewSettings.Template) - With vtContents - .TemplatePath = tmgr.TemplatePath - .TemplateRelPath = tmgr.TemplateRelPath - .TemplateMapPath = tmgr.TemplateMapPath - .DefaultReplacer = New BlogTokenReplace(Me) - End With - vtContents.DataBind() - - ctlComments.Visible = ViewSettings.AllowComments AndAlso BlogContext.Security.CanViewComments - ctlManagement.Visible = CBool(ViewSettings.BlogModuleId = -1) OrElse ViewSettings.ShowManagementPanel - - If PortalSettings.UserMode = PortalSettings.Mode.View AndAlso ViewSettings.ShowManagementPanelViewMode = False Then - ctlManagement.Visible = False - End If + Public Overrides Sub DataBind() + + Dim tmgr As New TemplateManager(PortalSettings, ViewSettings.Template) + With vtContents + .TemplatePath = tmgr.TemplatePath + .TemplateRelPath = tmgr.TemplateRelPath + .TemplateMapPath = tmgr.TemplateMapPath + .DefaultReplacer = New BlogTokenReplace(Me.ModuleConfiguration, Me.BlogContext, Me.Settings, Me.ViewSettings) + End With + vtContents.DataBind() + + ctlComments.Visible = ViewSettings.AllowComments AndAlso BlogContext.Security.CanViewComments + ctlManagement.Visible = CBool(ViewSettings.BlogModuleId = -1) OrElse ViewSettings.ShowManagementPanel + + If PortalSettings.UserMode = PortalSettings.Mode.View AndAlso ViewSettings.ShowManagementPanelViewMode = False Then + ctlManagement.Visible = False + End If - End Sub + End Sub #End Region #Region " IActionable " - Public ReadOnly Property ModuleActions As Actions.ModuleActionCollection Implements IActionable.ModuleActions - Get - Dim MyActions As New Actions.ModuleActionCollection - If IsEditable Or BlogContext.Security.IsBlogger Then - MyActions.Add(GetNextActionID, Localization.GetString(ModuleActionType.EditContent, LocalResourceFile), ModuleActionType.EditContent, "", "", EditUrl("Manage"), False, DotNetNuke.Security.SecurityAccessLevel.View, True, False) - End If - If IsEditable Then - MyActions.Add(GetNextActionID, LocalizeString("TemplateSettings"), ModuleActionType.EditContent, "", "", EditUrl("TemplateSettings"), False, DotNetNuke.Security.SecurityAccessLevel.Edit, True, False) - End If - Return MyActions - End Get - End Property + Public ReadOnly Property ModuleActions As Actions.ModuleActionCollection Implements IActionable.ModuleActions + Get + Dim MyActions As New Actions.ModuleActionCollection + If IsEditable Or BlogContext.Security.IsBlogger Then + MyActions.Add(GetNextActionID, Localization.GetString(ModuleActionType.EditContent, LocalResourceFile), ModuleActionType.EditContent, "", "", EditUrl("Manage"), False, DotNetNuke.Security.SecurityAccessLevel.View, True, False) + End If + If IsEditable Then + MyActions.Add(GetNextActionID, LocalizeString("TemplateSettings"), ModuleActionType.EditContent, "", "", EditUrl("TemplateSettings"), False, DotNetNuke.Security.SecurityAccessLevel.Edit, True, False) + End If + Return MyActions + End Get + End Property #End Region End Class diff --git a/Server/Blog/BlogEdit.ascx b/Server/Blog/BlogEdit.ascx index 6b5fe7eb..cc5ac693 100644 --- a/Server/Blog/BlogEdit.ascx +++ b/Server/Blog/BlogEdit.ascx @@ -1,7 +1,8 @@ <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="BlogEdit.ascx.vb" Inherits="DotNetNuke.Modules.Blog.BlogEdit" %> <%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> -<%@ Register TagPrefix="blog" Namespace="DotNetNuke.Modules.Blog.Security.Controls" Assembly="DotNetNuke.Modules.Blog" %> +<%@ Register TagPrefix="blog" Namespace="DotNetNuke.Modules.Blog.Core.Security.Controls" Assembly="DotNetNuke.Modules.Blog.Core" %> <%@ Register TagPrefix="blog" Namespace="DotNetNuke.Modules.Blog.Controls" Assembly="DotNetNuke.Modules.Blog" %> +

diff --git a/Server/Blog/BlogEdit.ascx.designer.vb b/Server/Blog/BlogEdit.ascx.designer.vb index 3754cab2..619abaa8 100644 --- a/Server/Blog/BlogEdit.ascx.designer.vb +++ b/Server/Blog/BlogEdit.ascx.designer.vb @@ -13,390 +13,390 @@ Option Explicit On Partial Public Class BlogEdit - ''' - '''lblTitle control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblTitle As Global.System.Web.UI.UserControl - - ''' - '''txtTitle control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents txtTitle As Global.DotNetNuke.Modules.Blog.Controls.ShortTextEdit - - ''' - '''lblDescription control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblDescription As Global.System.Web.UI.UserControl - - ''' - '''txtDescription control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents txtDescription As Global.DotNetNuke.Modules.Blog.Controls.LongTextEdit - - ''' - '''rowLocale control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents rowLocale As Global.System.Web.UI.HtmlControls.HtmlGenericControl - - ''' - '''lblLocale control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblLocale As Global.System.Web.UI.UserControl - - ''' - '''ddLocale control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents ddLocale As Global.System.Web.UI.WebControls.DropDownList - - ''' - '''rowFullLocalization control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents rowFullLocalization As Global.System.Web.UI.HtmlControls.HtmlGenericControl - - ''' - '''lblFullLocalization control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblFullLocalization As Global.System.Web.UI.UserControl - - ''' - '''chkFullLocalization control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkFullLocalization As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''lblImage control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblImage As Global.System.Web.UI.UserControl - - ''' - '''imgBlogImage control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents imgBlogImage As Global.System.Web.UI.WebControls.Image - - ''' - '''fileImage control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents fileImage As Global.System.Web.UI.WebControls.FileUpload - - ''' - '''cmdImageRemove control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents cmdImageRemove As Global.System.Web.UI.WebControls.LinkButton - - ''' - '''lblPublic control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblPublic As Global.System.Web.UI.UserControl - - ''' - '''chkPublic control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkPublic As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''lblSyndicate control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblSyndicate As Global.System.Web.UI.UserControl - - ''' - '''chkSyndicate control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkSyndicate As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''lblSyndicationEmail control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblSyndicationEmail As Global.System.Web.UI.UserControl - - ''' - '''txtSyndicationEmail control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents txtSyndicationEmail As Global.System.Web.UI.WebControls.TextBox - - ''' - '''lblCopyright control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblCopyright As Global.System.Web.UI.UserControl - - ''' - '''txtCopyright control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents txtCopyright As Global.System.Web.UI.WebControls.TextBox - - ''' - '''lblIncludeImagesInFeed control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblIncludeImagesInFeed As Global.System.Web.UI.UserControl - - ''' - '''chkIncludeImagesInFeed control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkIncludeImagesInFeed As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''lblIncludeAuthorInFeed control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblIncludeAuthorInFeed As Global.System.Web.UI.UserControl - - ''' - '''chkIncludeAuthorInFeed control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkIncludeAuthorInFeed As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''lblPingbacks control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblPingbacks As Global.System.Web.UI.UserControl - - ''' - '''chkEnablePingBackSend control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkEnablePingBackSend As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''chkEnablePingBackReceive control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkEnablePingBackReceive As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''chkAutoApprovePingBack control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkAutoApprovePingBack As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''lblTrackbacks control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblTrackbacks As Global.System.Web.UI.UserControl - - ''' - '''chkEnableTrackBackSend control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkEnableTrackBackSend As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''chkEnableTrackBackReceive control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkEnableTrackBackReceive As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''chkAutoApproveTrackBack control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkAutoApproveTrackBack As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''lblMustApproveGhostPosts control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblMustApproveGhostPosts As Global.System.Web.UI.UserControl - - ''' - '''chkMustApproveGhostPosts control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkMustApproveGhostPosts As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''lblPublishAsOwner control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblPublishAsOwner As Global.System.Web.UI.UserControl - - ''' - '''chkPublishAsOwner control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents chkPublishAsOwner As Global.System.Web.UI.WebControls.CheckBox - - ''' - '''lblPermissions control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblPermissions As Global.System.Web.UI.UserControl - - ''' - '''ctlPermissions control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents ctlPermissions As Global.DotNetNuke.Modules.Blog.Security.Controls.BlogPermissionsGrid - - ''' - '''cmdUpdate control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents cmdUpdate As Global.System.Web.UI.WebControls.LinkButton - - ''' - '''hlCancel control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents hlCancel As Global.System.Web.UI.WebControls.HyperLink - - ''' - '''cmdDelete control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents cmdDelete As Global.System.Web.UI.WebControls.LinkButton + ''' + '''lblTitle control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblTitle As Global.System.Web.UI.UserControl + + ''' + '''txtTitle control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents txtTitle As Global.DotNetNuke.Modules.Blog.Controls.ShortTextEdit + + ''' + '''lblDescription control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblDescription As Global.System.Web.UI.UserControl + + ''' + '''txtDescription control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents txtDescription As Global.DotNetNuke.Modules.Blog.Controls.LongTextEdit + + ''' + '''rowLocale control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents rowLocale As Global.System.Web.UI.HtmlControls.HtmlGenericControl + + ''' + '''lblLocale control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblLocale As Global.System.Web.UI.UserControl + + ''' + '''ddLocale control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents ddLocale As Global.System.Web.UI.WebControls.DropDownList + + ''' + '''rowFullLocalization control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents rowFullLocalization As Global.System.Web.UI.HtmlControls.HtmlGenericControl + + ''' + '''lblFullLocalization control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblFullLocalization As Global.System.Web.UI.UserControl + + ''' + '''chkFullLocalization control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkFullLocalization As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''lblImage control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblImage As Global.System.Web.UI.UserControl + + ''' + '''imgBlogImage control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents imgBlogImage As Global.System.Web.UI.WebControls.Image + + ''' + '''fileImage control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents fileImage As Global.System.Web.UI.WebControls.FileUpload + + ''' + '''cmdImageRemove control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents cmdImageRemove As Global.System.Web.UI.WebControls.LinkButton + + ''' + '''lblPublic control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblPublic As Global.System.Web.UI.UserControl + + ''' + '''chkPublic control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkPublic As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''lblSyndicate control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblSyndicate As Global.System.Web.UI.UserControl + + ''' + '''chkSyndicate control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkSyndicate As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''lblSyndicationEmail control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblSyndicationEmail As Global.System.Web.UI.UserControl + + ''' + '''txtSyndicationEmail control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents txtSyndicationEmail As Global.System.Web.UI.WebControls.TextBox + + ''' + '''lblCopyright control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblCopyright As Global.System.Web.UI.UserControl + + ''' + '''txtCopyright control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents txtCopyright As Global.System.Web.UI.WebControls.TextBox + + ''' + '''lblIncludeImagesInFeed control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblIncludeImagesInFeed As Global.System.Web.UI.UserControl + + ''' + '''chkIncludeImagesInFeed control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkIncludeImagesInFeed As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''lblIncludeAuthorInFeed control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblIncludeAuthorInFeed As Global.System.Web.UI.UserControl + + ''' + '''chkIncludeAuthorInFeed control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkIncludeAuthorInFeed As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''lblPingbacks control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblPingbacks As Global.System.Web.UI.UserControl + + ''' + '''chkEnablePingBackSend control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkEnablePingBackSend As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''chkEnablePingBackReceive control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkEnablePingBackReceive As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''chkAutoApprovePingBack control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkAutoApprovePingBack As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''lblTrackbacks control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblTrackbacks As Global.System.Web.UI.UserControl + + ''' + '''chkEnableTrackBackSend control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkEnableTrackBackSend As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''chkEnableTrackBackReceive control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkEnableTrackBackReceive As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''chkAutoApproveTrackBack control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkAutoApproveTrackBack As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''lblMustApproveGhostPosts control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblMustApproveGhostPosts As Global.System.Web.UI.UserControl + + ''' + '''chkMustApproveGhostPosts control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkMustApproveGhostPosts As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''lblPublishAsOwner control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblPublishAsOwner As Global.System.Web.UI.UserControl + + ''' + '''chkPublishAsOwner control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents chkPublishAsOwner As Global.System.Web.UI.WebControls.CheckBox + + ''' + '''lblPermissions control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents lblPermissions As Global.System.Web.UI.UserControl + + ''' + '''ctlPermissions control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents ctlPermissions As Global.DotNetNuke.Modules.Blog.Core.Security.Controls.BlogPermissionsGrid + + ''' + '''cmdUpdate control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents cmdUpdate As Global.System.Web.UI.WebControls.LinkButton + + ''' + '''hlCancel control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents hlCancel As Global.System.Web.UI.WebControls.HyperLink + + ''' + '''cmdDelete control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents cmdDelete As Global.System.Web.UI.WebControls.LinkButton End Class diff --git a/Server/Blog/BlogEdit.ascx.vb b/Server/Blog/BlogEdit.ascx.vb index e6eb2278..649b9401 100644 --- a/Server/Blog/BlogEdit.ascx.vb +++ b/Server/Blog/BlogEdit.ascx.vb @@ -20,215 +20,215 @@ Imports System.Linq Imports DotNetNuke.Common -Imports DotNetNuke.Services.Exceptions -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Common.Globals Imports DotNetNuke.Framework +Imports DotNetNuke.Modules.Blog.Core.Common +Imports DotNetNuke.Modules.Blog.Core.Entities.Blogs +Imports DotNetNuke.Services.Exceptions Public Class BlogEdit - Inherits BlogModuleBase - - Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init - - JavaScriptLibraries.JavaScript.RequestRegistration(JavaScriptLibraries.CommonJs.DnnPlugins) - If Not BlogContext.Security.IsEditor Then - If Not BlogContext.Security.IsBlogger Then - Response.Redirect(NavigateURL("Access Denied"), True) - End If - If BlogContext.Blog IsNot Nothing AndAlso BlogContext.Blog.OwnerUserId <> UserId Then - Response.Redirect(NavigateURL("Access Denied"), True) - End If - End If - txtTitle.DefaultLanguage = PortalSettings.DefaultLanguage - txtDescription.DefaultLanguage = PortalSettings.DefaultLanguage - - End Sub - - Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load - - If Not BlogContext.Security.IsBlogger Then - Throw New Exception("You do not have access to this resource. Please check your login status.") - End If - - If Not Page.IsPostBack Then - If BlogContext.Blog Is Nothing Then BlogContext.Blog = New BlogInfo ' initialize fields - - txtTitle.DefaultText = BlogContext.Blog.Title - txtTitle.LocalizedTexts = BlogContext.Blog.TitleLocalizations - txtTitle.InitialBind() - txtDescription.DefaultText = BlogContext.Blog.Description - txtDescription.LocalizedTexts = BlogContext.Blog.DescriptionLocalizations - txtDescription.InitialBind() - - If BlogContext.IsMultiLingualSite Then - ddLocale.DataSource = DotNetNuke.Services.Localization.LocaleController.Instance.GetLocales(PortalId).Values.OrderBy(Function(t) t.NativeName) - ddLocale.DataValueField = "Code" - ddLocale.DataBind() - Try - ddLocale.Items.FindByValue(BlogContext.Blog.Locale).Selected = True - Catch ex As Exception - End Try - chkFullLocalization.Checked = BlogContext.Blog.FullLocalization - Else - rowLocale.Visible = False - rowFullLocalization.Visible = False - End If - chkPublic.Checked = BlogContext.Blog.Published - chkSyndicate.Checked = BlogContext.Blog.Syndicated - If BlogContext.Blog.SyndicationEmail Is Nothing Then - txtSyndicationEmail.Text = ModuleContext.PortalSettings.UserInfo.Email - Else - txtSyndicationEmail.Text = BlogContext.Blog.SyndicationEmail - End If - chkIncludeImagesInFeed.Checked = BlogContext.Blog.IncludeImagesInFeed - chkIncludeAuthorInFeed.Checked = BlogContext.Blog.IncludeAuthorInFeed - chkEnablePingBackReceive.Checked = BlogContext.Blog.EnablePingBackReceive - chkEnablePingBackSend.Checked = BlogContext.Blog.EnablePingBackSend - chkAutoApprovePingBack.Checked = BlogContext.Blog.AutoApprovePingBack - chkEnableTrackBackReceive.Checked = BlogContext.Blog.EnableTrackBackReceive - chkEnableTrackBackSend.Checked = BlogContext.Blog.EnableTrackBackSend - chkAutoApproveTrackBack.Checked = BlogContext.Blog.AutoApproveTrackBack - txtCopyright.Text = BlogContext.Blog.Copyright - cmdDelete.Visible = CBool(BlogContext.BlogId <> -1) - If Not String.IsNullOrEmpty(BlogContext.Blog.Image) Then - imgBlogImage.ImageUrl = ResolveUrl(glbImageHandlerPath) & String.Format("?TabId={0}&ModuleId={1}&Blog={2}&w=100&h=100&c=1&key={3}", TabId, Settings.ModuleId, BlogContext.BlogId, BlogContext.Blog.Image) - imgBlogImage.Visible = True - cmdImageRemove.Visible = True - Else - imgBlogImage.Visible = False - cmdImageRemove.Visible = False - End If - ' ghost writing - chkMustApproveGhostPosts.Checked = BlogContext.Blog.MustApproveGhostPosts - chkPublishAsOwner.Checked = BlogContext.Blog.PublishAsOwner - ctlPermissions.Permissions = BlogContext.Blog.Permissions - ctlPermissions.TabId = TabId - ctlPermissions.CurrentUserId = UserId - ctlPermissions.UserIsAdmin = BlogContext.Security.UserIsAdmin - - hlCancel.NavigateUrl = EditUrl("Manage") - End If - - End Sub - - Protected Sub cmdDelete_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdDelete.Click - Try - If Not BlogContext.Blog Is Nothing Then - BlogsController.DeleteBlog(BlogContext.Blog.BlogID) - End If - Response.Redirect(EditUrl("Manage"), False) - Catch exc As Exception - ProcessModuleLoadException(Me, exc) - End Try - End Sub - - Private Sub cmdUpdate_Click(sender As Object, e As EventArgs) Handles cmdUpdate.Click - Try - If Page.IsValid = True Then - If BlogContext.Blog Is Nothing Then - BlogContext.Blog = New BlogInfo - With BlogContext.Blog - .ModuleID = Settings.ModuleId - .OwnerUserId = UserId - End With + Inherits BlogModuleBase + + Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init + + JavaScriptLibraries.JavaScript.RequestRegistration(JavaScriptLibraries.CommonJs.DnnPlugins) + If Not BlogContext.Security.IsEditor Then + If Not BlogContext.Security.IsBlogger Then + Response.Redirect(NavigateURL("Access Denied"), True) + End If + If BlogContext.Blog IsNot Nothing AndAlso BlogContext.Blog.OwnerUserId <> UserId Then + Response.Redirect(NavigateURL("Access Denied"), True) + End If End If - With BlogContext.Blog - .Title = txtTitle.DefaultText - .TitleLocalizations = txtTitle.GetLocalizedTexts - .Description = txtDescription.DefaultText - .DescriptionLocalizations = txtDescription.GetLocalizedTexts - If BlogContext.IsMultiLingualSite Then - .Locale = ddLocale.SelectedValue - .FullLocalization = chkFullLocalization.Checked - Else - .Locale = PortalSettings.DefaultLanguage - End If - .Published = chkPublic.Checked - .Syndicated = chkSyndicate.Checked - .SyndicationEmail = txtSyndicationEmail.Text - .IncludeImagesInFeed = chkIncludeImagesInFeed.Checked - .IncludeAuthorInFeed = chkIncludeAuthorInFeed.Checked - .EnablePingBackReceive = chkEnablePingBackReceive.Checked - .EnablePingBackSend = chkEnablePingBackSend.Checked - .AutoApprovePingBack = chkAutoApprovePingBack.Checked - .EnableTrackBackReceive = chkEnableTrackBackReceive.Checked - .EnableTrackBackSend = chkEnableTrackBackSend.Checked - .AutoApproveTrackBack = chkAutoApproveTrackBack.Checked - .Copyright = txtCopyright.Text.Trim - .MustApproveGhostPosts = chkMustApproveGhostPosts.Checked - .PublishAsOwner = chkPublishAsOwner.Checked - .Permissions = ctlPermissions.Permissions - If BlogContext.BlogId = -1 Then - .BlogID = BlogsController.AddBlog(BlogContext.Blog, UserId) - BlogContext.BlogId = .BlogID - Else - BlogsController.UpdateBlog(BlogContext.Blog, UserId) - End If - Modules.Blog.Security.Permissions.BlogPermissionsController.UpdateBlogPermissions(BlogContext.Blog) - End With - - If fileImage.HasFile Then - Dim extension As String = IO.Path.GetExtension(fileImage.FileName).ToLower - If glbPermittedFileExtensions.IndexOf(extension & ",") > -1 Then - Dim saveDir As String = GetBlogDirectoryMapPath(BlogContext.BlogId) - If Not IO.Directory.Exists(saveDir) Then IO.Directory.CreateDirectory(saveDir) - If BlogContext.Blog.Image <> "" Then - ' remove old images - Dim imagesToDelete As New List(Of String) - Dim d As New IO.DirectoryInfo(saveDir) - For Each f As IO.FileInfo In d.GetFiles - If f.Name.StartsWith(BlogContext.Blog.Image) Then - imagesToDelete.Add(f.FullName) - End If - Next - For Each f As String In imagesToDelete + txtTitle.DefaultLanguage = PortalSettings.DefaultLanguage + txtDescription.DefaultLanguage = PortalSettings.DefaultLanguage + + End Sub + + Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load + + If Not BlogContext.Security.IsBlogger Then + Throw New Exception("You do not have access to this resource. Please check your login status.") + End If + + If Not Page.IsPostBack Then + If BlogContext.Blog Is Nothing Then BlogContext.Blog = New BlogInfo ' initialize fields + + txtTitle.DefaultText = BlogContext.Blog.Title + txtTitle.LocalizedTexts = BlogContext.Blog.TitleLocalizations + txtTitle.InitialBind() + txtDescription.DefaultText = BlogContext.Blog.Description + txtDescription.LocalizedTexts = BlogContext.Blog.DescriptionLocalizations + txtDescription.InitialBind() + + If BlogContext.IsMultiLingualSite Then + ddLocale.DataSource = DotNetNuke.Services.Localization.LocaleController.Instance.GetLocales(PortalId).Values.OrderBy(Function(t) t.NativeName) + ddLocale.DataValueField = "Code" + ddLocale.DataBind() Try - IO.File.Delete(f) + ddLocale.Items.FindByValue(BlogContext.Blog.Locale).Selected = True Catch ex As Exception End Try - Next + chkFullLocalization.Checked = BlogContext.Blog.FullLocalization + Else + rowLocale.Visible = False + rowFullLocalization.Visible = False + End If + chkPublic.Checked = BlogContext.Blog.Published + chkSyndicate.Checked = BlogContext.Blog.Syndicated + If BlogContext.Blog.SyndicationEmail Is Nothing Then + txtSyndicationEmail.Text = ModuleContext.PortalSettings.UserInfo.Email + Else + txtSyndicationEmail.Text = BlogContext.Blog.SyndicationEmail End If - Dim newFileName As String = Guid.NewGuid.ToString("D") - fileImage.SaveAs(saveDir & newFileName & IO.Path.GetExtension(fileImage.FileName).ToLower) - BlogContext.Blog.Image = newFileName + chkIncludeImagesInFeed.Checked = BlogContext.Blog.IncludeImagesInFeed + chkIncludeAuthorInFeed.Checked = BlogContext.Blog.IncludeAuthorInFeed + chkEnablePingBackReceive.Checked = BlogContext.Blog.EnablePingBackReceive + chkEnablePingBackSend.Checked = BlogContext.Blog.EnablePingBackSend + chkAutoApprovePingBack.Checked = BlogContext.Blog.AutoApprovePingBack + chkEnableTrackBackReceive.Checked = BlogContext.Blog.EnableTrackBackReceive + chkEnableTrackBackSend.Checked = BlogContext.Blog.EnableTrackBackSend + chkAutoApproveTrackBack.Checked = BlogContext.Blog.AutoApproveTrackBack + txtCopyright.Text = BlogContext.Blog.Copyright + cmdDelete.Visible = CBool(BlogContext.BlogId <> -1) + If Not String.IsNullOrEmpty(BlogContext.Blog.Image) Then + imgBlogImage.ImageUrl = ResolveUrl(Core.Common.Globals.glbImageHandlerPath) & String.Format("?TabId={0}&ModuleId={1}&Blog={2}&w=100&h=100&c=1&key={3}", TabId, Settings.ModuleId, BlogContext.BlogId, BlogContext.Blog.Image) + imgBlogImage.Visible = True + cmdImageRemove.Visible = True + Else + imgBlogImage.Visible = False + cmdImageRemove.Visible = False + End If + ' ghost writing + chkMustApproveGhostPosts.Checked = BlogContext.Blog.MustApproveGhostPosts + chkPublishAsOwner.Checked = BlogContext.Blog.PublishAsOwner + ctlPermissions.Permissions = BlogContext.Blog.Permissions + ctlPermissions.TabId = TabId + ctlPermissions.CurrentUserId = UserId + ctlPermissions.UserIsAdmin = BlogContext.Security.UserIsAdmin + + hlCancel.NavigateUrl = EditUrl("Manage") + End If + + End Sub + + Protected Sub cmdDelete_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdDelete.Click + Try + If Not BlogContext.Blog Is Nothing Then + BlogsController.DeleteBlog(BlogContext.Blog.BlogID) + End If + Response.Redirect(EditUrl("Manage"), False) + Catch exc As Exception + ProcessModuleLoadException(Me, exc) + End Try + End Sub + + Private Sub cmdUpdate_Click(sender As Object, e As EventArgs) Handles cmdUpdate.Click + Try + If Page.IsValid = True Then + If BlogContext.Blog Is Nothing Then + BlogContext.Blog = New BlogInfo + With BlogContext.Blog + .ModuleID = Settings.ModuleId + .OwnerUserId = UserId + End With + End If + With BlogContext.Blog + .Title = txtTitle.DefaultText + .TitleLocalizations = txtTitle.GetLocalizedTexts + .Description = txtDescription.DefaultText + .DescriptionLocalizations = txtDescription.GetLocalizedTexts + If BlogContext.IsMultiLingualSite Then + .Locale = ddLocale.SelectedValue + .FullLocalization = chkFullLocalization.Checked + Else + .Locale = PortalSettings.DefaultLanguage + End If + .Published = chkPublic.Checked + .Syndicated = chkSyndicate.Checked + .SyndicationEmail = txtSyndicationEmail.Text + .IncludeImagesInFeed = chkIncludeImagesInFeed.Checked + .IncludeAuthorInFeed = chkIncludeAuthorInFeed.Checked + .EnablePingBackReceive = chkEnablePingBackReceive.Checked + .EnablePingBackSend = chkEnablePingBackSend.Checked + .AutoApprovePingBack = chkAutoApprovePingBack.Checked + .EnableTrackBackReceive = chkEnableTrackBackReceive.Checked + .EnableTrackBackSend = chkEnableTrackBackSend.Checked + .AutoApproveTrackBack = chkAutoApproveTrackBack.Checked + .Copyright = txtCopyright.Text.Trim + .MustApproveGhostPosts = chkMustApproveGhostPosts.Checked + .PublishAsOwner = chkPublishAsOwner.Checked + .Permissions = ctlPermissions.Permissions + If BlogContext.BlogId = -1 Then + .BlogID = BlogsController.AddBlog(BlogContext.Blog, UserId) + BlogContext.BlogId = .BlogID + Else + BlogsController.UpdateBlog(BlogContext.Blog, UserId) + End If + Modules.Blog.Core.Security.Permissions.BlogPermissionsController.UpdateBlogPermissions(BlogContext.Blog) + End With + + If fileImage.HasFile Then + Dim extension As String = IO.Path.GetExtension(fileImage.FileName).ToLower + If Core.Common.Globals.glbPermittedFileExtensions.IndexOf(extension & ",") > -1 Then + Dim saveDir As String = Core.Common.Globals.GetBlogDirectoryMapPath(BlogContext.BlogId) + If Not IO.Directory.Exists(saveDir) Then IO.Directory.CreateDirectory(saveDir) + If BlogContext.Blog.Image <> "" Then + ' remove old images + Dim imagesToDelete As New List(Of String) + Dim d As New IO.DirectoryInfo(saveDir) + For Each f As IO.FileInfo In d.GetFiles + If f.Name.StartsWith(BlogContext.Blog.Image) Then + imagesToDelete.Add(f.FullName) + End If + Next + For Each f As String In imagesToDelete + Try + IO.File.Delete(f) + Catch ex As Exception + End Try + Next + End If + Dim newFileName As String = Guid.NewGuid.ToString("D") + fileImage.SaveAs(saveDir & newFileName & IO.Path.GetExtension(fileImage.FileName).ToLower) + BlogContext.Blog.Image = newFileName + BlogsController.UpdateBlog(BlogContext.Blog, UserId) + End If + End If + + End If + Response.Redirect(EditUrl("Manage"), False) + Catch exc As Exception + ProcessModuleLoadException(Me, exc) + End Try + End Sub + + Private Sub cmdImageRemove_Click(sender As Object, e As EventArgs) Handles cmdImageRemove.Click + + If BlogContext.Blog IsNot Nothing Then + If BlogContext.Blog.Image <> "" Then + ' remove old images + Dim saveDir As String = Core.Common.Globals.GetBlogDirectoryMapPath(BlogContext.BlogId) + Dim imagesToDelete As New List(Of String) + Dim d As New IO.DirectoryInfo(saveDir) + For Each f As IO.FileInfo In d.GetFiles + If f.Name.StartsWith(BlogContext.Blog.Image) Then + imagesToDelete.Add(f.FullName) + End If + Next + For Each f As String In imagesToDelete + Try + IO.File.Delete(f) + Catch ex As Exception + End Try + Next + End If + BlogContext.Blog.Image = "" BlogsController.UpdateBlog(BlogContext.Blog, UserId) - End If End If + imgBlogImage.Visible = False + cmdImageRemove.Visible = False - End If - Response.Redirect(EditUrl("Manage"), False) - Catch exc As Exception - ProcessModuleLoadException(Me, exc) - End Try - End Sub - - Private Sub cmdImageRemove_Click(sender As Object, e As EventArgs) Handles cmdImageRemove.Click - - If BlogContext.Blog IsNot Nothing Then - If BlogContext.Blog.Image <> "" Then - ' remove old images - Dim saveDir As String = GetBlogDirectoryMapPath(BlogContext.BlogId) - Dim imagesToDelete As New List(Of String) - Dim d As New IO.DirectoryInfo(saveDir) - For Each f As IO.FileInfo In d.GetFiles - If f.Name.StartsWith(BlogContext.Blog.Image) Then - imagesToDelete.Add(f.FullName) - End If - Next - For Each f As String In imagesToDelete - Try - IO.File.Delete(f) - Catch ex As Exception - End Try - Next - End If - BlogContext.Blog.Image = "" - BlogsController.UpdateBlog(BlogContext.Blog, UserId) - End If - imgBlogImage.Visible = False - cmdImageRemove.Visible = False - - End Sub + End Sub End Class \ No newline at end of file diff --git a/Server/Blog/BlogImage.ashx.vb b/Server/Blog/BlogImage.ashx.vb index 55c5d437..3de162e7 100644 --- a/Server/Blog/BlogImage.ashx.vb +++ b/Server/Blog/BlogImage.ashx.vb @@ -18,79 +18,79 @@ ' DEALINGS IN THE SOFTWARE. ' -Imports DotNetNuke.Modules.Blog.Common.Globals Imports DotNetNuke.Entities.Portals +Imports DotNetNuke.Modules.Blog.Core.Common Public Class BlogImage - Implements System.Web.IHttpHandler + Implements System.Web.IHttpHandler - Private Property BlogId As Integer = -1 - Private Property PostId As Integer = -1 - Private Property ModuleId As Integer = -1 - Private Property TabId As Integer = -1 - Private Property Key As String = "" - Private Property Width As Integer = -1 - Private Property Height As Integer = -1 - Private Property Crop As Boolean = False - Private Property PortalSettings As PortalSettings = Nothing + Private Property BlogId As Integer = -1 + Private Property PostId As Integer = -1 + Private Property ModuleId As Integer = -1 + Private Property TabId As Integer = -1 + Private Property Key As String = "" + Private Property Width As Integer = -1 + Private Property Height As Integer = -1 + Private Property Crop As Boolean = False + Private Property PortalSettings As PortalSettings = Nothing - Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest + Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest - PortalSettings = PortalController.Instance.GetCurrentPortalSettings - context.Request.Params.ReadValue("Blog", BlogId) - context.Request.Params.ReadValue("Post", PostId) - context.Request.Params.ReadValue("Key", Key) - context.Request.Params.ReadValue("ModuleId", ModuleId) - context.Request.Params.ReadValue("TabId", TabId) - context.Request.Params.ReadValue("w", Width) - context.Request.Params.ReadValue("h", Height) - context.Request.Params.ReadValue("c", Crop) + PortalSettings = PortalController.Instance.GetCurrentPortalSettings + BlogId = context.Request.Params.ReadValue("Blog", BlogId) + PostId = context.Request.Params.ReadValue("Post", PostId) + Key = context.Request.Params.ReadValue("Key", Key) + ModuleId = context.Request.Params.ReadValue("ModuleId", ModuleId) + TabId = context.Request.Params.ReadValue("TabId", TabId) + Width = context.Request.Params.ReadValue("w", Width) + Height = context.Request.Params.ReadValue("h", Height) + Crop = context.Request.Params.ReadValue("c", Crop) - Try - Dim path As String = "" - If PostId > -1 Then ' we're looking for an Post's image - path = GetPostDirectoryMapPath(BlogId, PostId) - ElseIf BlogId > -1 Then ' we're looking for a blog's image - path = GetBlogDirectoryMapPath(BlogId) - End If - Dim files() As String = IO.Directory.GetFiles(path, String.Format("{0}-{1}-{2}-{3}.*", Key, Width, Height, Crop)) - If files.Length > 0 Then - Select Case IO.Path.GetExtension(files(0)).ToLower - Case ".jpg" - context.Response.ContentType = "image/jpeg" - Case ".png" - context.Response.ContentType = "image/png" - Case ".gif" - context.Response.ContentType = "image/gif" - Case ".bmp" - context.Response.ContentType = "image/bmp" - Case ".tif", ".tiff" - context.Response.ContentType = "image/tiff" - Case Else - Exit Sub - End Select - context.Response.WriteFile(files(0)) - Else - files = IO.Directory.GetFiles(path, String.Format("{0}.*", Key)) - If files.Length > 0 Then - Dim img As New Common.Image(files(0)) - If img.IsValidExtension Then - context.Response.ContentType = img.MimeType - Dim newImg As String = img.ResizeImage(Width, Height, Crop) - context.Response.WriteFile(newImg) - img.Dispose() - End If - End If - End If - Catch ex As Exception - End Try + Try + Dim path As String = "" + If PostId > -1 Then ' we're looking for an Post's image + path = Globals.GetPostDirectoryMapPath(BlogId, PostId) + ElseIf BlogId > -1 Then ' we're looking for a blog's image + path = Globals.GetBlogDirectoryMapPath(BlogId) + End If + Dim files() As String = IO.Directory.GetFiles(path, String.Format("{0}-{1}-{2}-{3}.*", Key, Width, Height, Crop)) + If files.Length > 0 Then + Select Case IO.Path.GetExtension(files(0)).ToLower + Case ".jpg" + context.Response.ContentType = "image/jpeg" + Case ".png" + context.Response.ContentType = "image/png" + Case ".gif" + context.Response.ContentType = "image/gif" + Case ".bmp" + context.Response.ContentType = "image/bmp" + Case ".tif", ".tiff" + context.Response.ContentType = "image/tiff" + Case Else + Exit Sub + End Select + context.Response.WriteFile(files(0)) + Else + files = IO.Directory.GetFiles(path, String.Format("{0}.*", Key)) + If files.Length > 0 Then + Dim img As New Core.Common.Image(files(0)) + If img.IsValidExtension Then + context.Response.ContentType = img.MimeType + Dim newImg As String = img.ResizeImage(Width, Height, Crop) + context.Response.WriteFile(newImg) + img.Dispose() + End If + End If + End If + Catch ex As Exception + End Try - End Sub + End Sub - ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable - Get - Return False - End Get - End Property + ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable + Get + Return False + End Get + End Property End Class \ No newline at end of file diff --git a/Server/Blog/BlogImport.ascx.vb b/Server/Blog/BlogImport.ascx.vb index aea9f9c4..50a3c024 100644 --- a/Server/Blog/BlogImport.ascx.vb +++ b/Server/Blog/BlogImport.ascx.vb @@ -20,10 +20,10 @@ Imports DotNetNuke.Common.Utilities Imports DotNetNuke.Services.Localization -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.BlogML.Xml -Imports DotNetNuke.Modules.Blog.Entities.Posts +Imports DotNetNuke.Modules.Blog.Core.Common +Imports DotNetNuke.Modules.Blog.Core.BlogML.Xml Imports System.IO.Compression +Imports DotNetNuke.Modules.Blog.Core.Entities.Posts Public Class BlogImport Inherits BlogModuleBase @@ -135,12 +135,12 @@ Public Class BlogImport .Locale = post.Locale End With If newPost.Title <> "" And newPost.Content <> "" Then - newPost.ContentItemId = PostsController.AddPost(newPost, UserId) + newPost = Core.Entities.Posts.PostsController.AddPost(newPost, UserId) strReport.AppendFormat("Added {0}" & vbCrLf, post.Title) ' import resources If post.Attachments.Count > 0 Then - Dim postDir As String = GetPostDirectoryMapPath(newPost) - Dim postPath As String = GetPostDirectoryPath(newPost) + Dim postDir As String = Core.Common.Globals.GetPostDirectoryMapPath(newPost) + Dim postPath As String = Core.Common.Globals.GetPostDirectoryPath(newPost) IO.Directory.CreateDirectory(postDir) For Each att As BlogMLAttachment In post.Attachments If att.Embedded And att.Data IsNot Nothing Then @@ -154,7 +154,7 @@ Public Class BlogImport End If Next End If - PostsController.UpdatePost(newPost, UserId) + Core.Entities.Posts.PostsController.UpdatePost(newPost, UserId) End If Next txtReport.Text = strReport.ToString diff --git a/Server/Blog/Components/Api/BlogRouteMapper.vb b/Server/Blog/Components/Api/BlogRouteMapper.vb new file mode 100644 index 00000000..a3b2c936 --- /dev/null +++ b/Server/Blog/Components/Api/BlogRouteMapper.vb @@ -0,0 +1,38 @@ +Imports DotNetNuke.Web.Api + +Namespace Api + Public Class BlogRouteMapper + Implements IServiceRouteMapper + + Public Enum ServiceControllers + Blogs + Comments + Posts + Terms + End Enum + + Public Const ServicePath As String = "~/DesktopModules/Blog/API/" + + Public Sub RegisterRoutes(mapRouteManager As IMapRoute) Implements IServiceRouteMapper.RegisterRoutes + mapRouteManager.MapHttpRoute("Blog", "BlogApiControllers", "{controller}/{action}", New String() {"DotNetNuke.Modules.Blog.Api"}) + End Sub + + Public Shared Function GetRoute(controller As ServiceControllers, method As String) As String + Select Case controller + Case ServiceControllers.Blogs + Return GetRoute("Blogs", method) + Case ServiceControllers.Comments + Return GetRoute("Comments", method) + Case ServiceControllers.Posts + Return GetRoute("Posts", method) + Case Else + Return GetRoute("Terms", method) + End Select + End Function + + Public Shared Function GetRoute(controller As String, method As String) As String + Return HttpContext.Current.Request.Url.Scheme & "://" & HttpContext.Current.Request.Url.Host & DotNetNuke.Common.ResolveUrl(ServicePath & controller & "/" & method) + End Function + + End Class +End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Entities/Blogs/BlogsController_Service.vb b/Server/Blog/Components/Api/BlogsController.vb similarity index 80% rename from Server/Blog/Components/Entities/Blogs/BlogsController_Service.vb rename to Server/Blog/Components/Api/BlogsController.vb index f0c21f11..3c912d67 100644 --- a/Server/Blog/Components/Entities/Blogs/BlogsController_Service.vb +++ b/Server/Blog/Components/Api/BlogsController.vb @@ -22,16 +22,18 @@ Imports System.Net Imports System.Net.Http Imports System.Web.Http Imports DotNetNuke.Web.Api -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Modules.Blog.Entities.Comments -Imports DotNetNuke.Modules.Blog.BlogML.Xml -Imports DotNetNuke.Modules.Blog.Entities.Terms +Imports DotNetNuke.Modules.Blog.Core.Common +Imports DotNetNuke.Modules.Blog.Core.BlogML.Xml +Imports DotNetNuke.Modules.Blog.Core.Entities.Terms Imports System.Xml -Imports DotNetNuke.Modules.Blog.Services Imports System.IO.Compression +Imports DotNetNuke.Modules.Blog.Core.Entities.Blogs +Imports DotNetNuke.Modules.Blog.Core.Entities.Posts +Imports DotNetNuke.Modules.Blog.Core +Imports DotNetNuke.Modules.Blog.Core.Entities.Comments +Imports DotNetNuke.Modules.Blog.Core.Services -Namespace Entities.Blogs +Namespace Api Partial Public Class BlogsController Inherits DnnApiController @@ -46,15 +48,15 @@ Namespace Entities.Blogs #Region " Service Methods " - + Public Function ExportBlog(postData As BlogDTO) As HttpResponseMessage SetContext(postData) - Dim saveDir As New IO.DirectoryInfo(GetBlogDirectoryMapPath(Blog.BlogID)) + Dim saveDir As New IO.DirectoryInfo(Globals.GetBlogDirectoryMapPath(Blog.BlogID)) If Not saveDir.Exists Then saveDir.Create() - RemoveOldTimeStampedFiles(saveDir) + Globals.RemoveOldTimeStampedFiles(saveDir) Dim newBlogML As New BlogMLBlog newBlogML.Title = Blog.Title @@ -65,7 +67,7 @@ Namespace Entities.Blogs AddPosts(newBlogML) Dim blogMLFile As String = Date.Now.ToString("yyyy-MM-dd") & "-" & Guid.NewGuid.ToString("D") - Using objZipOutputStream As New ZipArchive(IO.File.Create(GetBlogDirectoryMapPath(Blog.BlogID) & blogMLFile & ".zip"), ZipArchiveMode.Create) + Using objZipOutputStream As New ZipArchive(IO.File.Create(Globals.GetBlogDirectoryMapPath(Blog.BlogID) & blogMLFile & ".zip"), ZipArchiveMode.Create) Dim objZipEntry As ZipArchiveEntry = objZipOutputStream.CreateEntry(blogMLFile & ".xml") Using stream As XmlWriter = XmlWriter.Create(objZipEntry.Open) BlogMLSerializer.Serialize(stream, newBlogML) @@ -73,19 +75,19 @@ Namespace Entities.Blogs End Using End Using - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = GetBlogDirectoryPath(Blog.BlogID) & blogMLFile & ".zip"}) + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = Globals.GetBlogDirectoryPath(Blog.BlogID) & blogMLFile & ".zip"}) End Function #End Region #Region " Private Methods " Private Sub SetContext(data As BlogDTO) - Blog = BlogsController.GetBlog(data.BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) + Blog = Core.Entities.Blogs.BlogsController.GetBlog(data.BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) Settings = ModuleSettings.GetModuleSettings(ActiveModule.ModuleID) End Sub Private Sub AddCategories(ByRef TargetBlogML As BlogMLBlog) If Settings.VocabularyId > -1 Then - For Each c As TermInfo In Entities.Terms.TermsController.GetTermsByVocabulary(ActiveModule.ModuleID, Settings.VocabularyId, Threading.Thread.CurrentThread.CurrentCulture.Name).Values + For Each c As TermInfo In Core.Entities.Terms.TermsController.GetTermsByVocabulary(ActiveModule.ModuleID, Settings.VocabularyId, Threading.Thread.CurrentThread.CurrentCulture.Name).Values Dim categoryML As New BlogMLCategory categoryML.Approved = True categoryML.DateCreated = c.CreatedOnDate @@ -103,7 +105,7 @@ Namespace Entities.Blogs Dim handledRecs As Integer = 0 Dim page As Integer = 0 Do - For Each post As PostInfo In PostsController.GetPostsByBlog(ActiveModule.ModuleID, Blog.BlogID, Threading.Thread.CurrentThread.CurrentCulture.Name, -1, page, 10, "PUBLISHEDONDATE", totalRecs).Values + For Each post As PostInfo In Core.Entities.Posts.PostsController.GetPostsByBlog(ActiveModule.ModuleID, Blog.BlogID, Threading.Thread.CurrentThread.CurrentCulture.Name, -1, page, 10, "PUBLISHEDONDATE", totalRecs).Values handledRecs += 1 TargetBlogML.Posts.Add(ConvertPost(post)) Next @@ -142,7 +144,7 @@ Namespace Entities.Blogs newPostML.Locale = post.Locale ' pack files - Dim postDir As String = GetPostDirectoryMapPath(post.BlogID, post.ContentItemId) + Dim postDir As String = Globals.GetPostDirectoryMapPath(post.BlogID, post.ContentItemId) If IO.Directory.Exists(postDir) Then For Each f As String In IO.Directory.GetFiles(postDir) Dim fileName As String = IO.Path.GetFileName(f) @@ -167,7 +169,7 @@ Namespace Entities.Blogs Next End If - For Each comment As CommentInfo In CommentsController.GetCommentsByContentItem(post.ContentItemId, False, UserInfo.UserID) + For Each comment As CommentInfo In Core.Entities.Comments.CommentsController.GetCommentsByContentItem(post.ContentItemId, False, UserInfo.UserID) Dim newComment As New BlogMLComment newComment.Approved = comment.Approved newComment.Content = New BlogMLContent() diff --git a/Server/Blog/Components/Api/CommentsController.vb b/Server/Blog/Components/Api/CommentsController.vb new file mode 100644 index 00000000..ae92fb41 --- /dev/null +++ b/Server/Blog/Components/Api/CommentsController.vb @@ -0,0 +1,428 @@ +' +' DNN Connect - http://dnn-connect.org +' Copyright (c) 2015 +' by DNN Connect +' +' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +' documentation files (the "Software"), to deal in the Software without restriction, including without limitation +' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +' to permit persons to whom the Software is furnished to do so, subject to the following conditions: +' +' The above copyright notice and this permission notice shall be included in all copies or substantial portions +' of the Software. +' +' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +' DEALINGS IN THE SOFTWARE. +' + +Imports System.Linq +Imports System.Net +Imports System.Net.Http +Imports System.Web.Http +Imports DotNetNuke.Web.Api +Imports DotNetNuke.Modules.Blog.Core.Common +Imports System.Xml +Imports DotNetNuke.Modules.Blog.Core.Entities.Blogs +Imports DotNetNuke.Modules.Blog.Core.Entities.Posts +Imports DotNetNuke.Modules.Blog.Core.Entities.Comments +Imports DotNetNuke.Modules.Blog.Core.Security +Imports DotNetNuke.Modules.Blog.Core.Services +Imports DotNetNuke.Modules.Blog.Core.Templating + +Namespace Api + Partial Public Class CommentsController + Inherits DnnApiController + + Public Class CommentDTO + Public Property BlogId As Integer + Public Property CommentId As Integer + Public Property Karma As Integer + End Class + + Public Class FullCommentDTO + Public Property BlogId As Integer + Public Property PostId As Integer + Public Property ParentId As Integer + Public Property Comment As String + Public Property Author As String + Public Property Website As String + Public Property Email As String + End Class + +#Region " Private Members " + Private Property Blog As BlogInfo = Nothing + Private Property Post As PostInfo = Nothing + Private Property Comment As CommentInfo = Nothing + Private Property AllComments As New List(Of CommentInfo) + + Private _Settings As ModuleSettings + Private Property Settings() As ModuleSettings + Get + If _Settings Is Nothing Then + _Settings = ModuleSettings.GetModuleSettings(ActiveModule.ModuleID) + End If + Return _Settings + End Get + Set(ByVal value As ModuleSettings) + _Settings = value + End Set + End Property + + Private _viewSettings As ViewSettings + Private Property ViewSettings() As ViewSettings + Get + If _viewSettings Is Nothing Then + _viewSettings = ViewSettings.GetViewSettings(ActiveModule.TabModuleID) + End If + Return _viewSettings + End Get + Set(ByVal value As ViewSettings) + _viewSettings = value + End Set + End Property + + Private _Security As ContextSecurity + Private Property Security() As ContextSecurity + Get + If _Security Is Nothing Then + _Security = New ContextSecurity(ActiveModule.ModuleID, ActiveModule.TabID, Blog, UserInfo) + End If + Return _Security + End Get + Set(ByVal value As ContextSecurity) + _Security = value + End Set + End Property +#End Region + +#Region " Service Methods " + + + + + Public Function ApproveComment(postData As CommentDTO) As HttpResponseMessage + SetContext(postData) + If Blog Is Nothing Or Comment Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + Core.Entities.Comments.CommentsController.ApproveComment(ActiveModule.ModuleID, Blog.BlogID, Comment) + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) + End Function + + + + + + Public Function DeleteComment(postData As CommentDTO) As HttpResponseMessage + SetContext(postData) + If Blog Is Nothing Or Comment Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + Core.Entities.Comments.CommentsController.DeleteComment(ActiveModule.ModuleID, Blog.BlogID, Comment) + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) + End Function + + + + + + Public Function ReportComment(postData As CommentDTO) As HttpResponseMessage + SetContext(postData) + If Blog Is Nothing Or Comment Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + If UserInfo.UserID < 0 Then Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + Dim ret As Integer = Core.Data.DataProvider.Instance.AddCommentKarma(postData.CommentId, UserInfo.UserID, postData.Karma) + If ret = -1 Then Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "exists"}) + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) + End Function + + + + + + Public Function AddComment(postData As FullCommentDTO) As HttpResponseMessage + SetContext(postData) + Post = Core.Entities.Posts.PostsController.GetPost(postData.PostId, ActiveModule.ModuleID, "") + If Blog Is Nothing Or Post Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + Dim objComment As New CommentInfo + objComment.ContentItemId = Post.ContentItemId + objComment.CreatedByUserID = UserInfo.UserID + objComment.ParentId = postData.ParentId + objComment.Comment = HttpUtility.HtmlEncode(Globals.SafeStringSimpleHtml(postData.Comment).Replace(vbCrLf, "
")) + objComment.Approved = Security.CanAutoApproveComment Or Security.CanApproveComment Or Post.CreatedByUserID = UserInfo.UserID + objComment.Author = Globals.SafeString(postData.Author) + objComment.Email = Globals.SafeString(postData.Email) + objComment.Website = Globals.SafeString(postData.Website) + objComment.CommentID = Core.Entities.Comments.CommentsController.AddComment(Blog, Post, objComment) + If Not objComment.Approved Then + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "successnotapproved"}) + End If + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) + End Function + + + + + + Public Function ListComments() As HttpResponseMessage + Dim BlogId As Integer = -1 + Dim PostId As Integer = -1 + BlogId = HttpContext.Current.Request.Params.ReadValue("blogId", BlogId) + PostId = HttpContext.Current.Request.Params.ReadValue("postId", PostId) + Blog = Core.Entities.Blogs.BlogsController.GetBlog(BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) + Post = Core.Entities.Posts.PostsController.GetPost(PostId, ActiveModule.ModuleID, "") + If Blog Is Nothing Or Post Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + If Not Security.CanViewComments Then Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = ""}) + Dim ViewSettings As ViewSettings = ViewSettings.GetViewSettings(ActiveModule.TabModuleID) + AllComments = Core.Entities.Comments.CommentsController.GetCommentsByContentItem(Post.ContentItemId, Security.CanApproveComment, UserInfo.UserID) + Dim vt As New ViewTemplate + Dim tmgr As New TemplateManager(PortalSettings, ViewSettings.Template) + With vt + .TemplatePath = tmgr.TemplatePath + .TemplateRelPath = tmgr.TemplateRelPath + .TemplateMapPath = tmgr.TemplateMapPath + .DefaultReplacer = New BlogTokenReplace(ActiveModule, Security, Blog, Post, Settings, ViewSettings) + .StartTemplate = "CommentsTemplate.html" + End With + AddHandler vt.GetData, AddressOf TemplateGetData + vt.DataBind() + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = vt.GetContentsAsString}) + End Function + + + + + Public Function Pingback() As HttpResponseMessage + + Dim BlogId As Integer = -1 + Dim PostId As Integer = -1 + BlogId = HttpContext.Current.Request.Params.ReadValue("blogId", BlogId) + PostId = HttpContext.Current.Request.Params.ReadValue("postId", PostId) + Blog = Core.Entities.Blogs.BlogsController.GetBlog(BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) + If Not Blog.EnablePingBackReceive Then + Return Request.CreateResponse(HttpStatusCode.NotFound, New With {.Result = "This blog does not accept pingbacks"}) + End If + Post = Core.Entities.Posts.PostsController.GetPost(PostId, ActiveModule.ModuleID, "") + If Post Is Nothing Then + Return PingBackError(32, "The specified target URI does not exist.") + End If + + Dim doc As XmlDocument = RetrieveXmlDocument(HttpContext.Current) + Dim list As XmlNodeList = If(doc.SelectNodes("methodCall/params/param/value/string"), doc.SelectNodes("methodCall/params/param/value")) + + If list Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "Cannot parse the request"}) + End If + + Dim sourceUrl As String = Globals.SafeString(list(0).InnerText.Trim()) + Dim targetUrl As String = Globals.SafeString(list(1).InnerText.Trim()) + + Dim containsHtml As Boolean = False + Dim sourceHasLink As Boolean = False + Dim title As String = sourceUrl + + Try + CheckSourcePage(sourceUrl, targetUrl, sourceHasLink, title) + Catch ex As Exception + End Try + + If Not IsFirstPingBack(Post, sourceUrl) Then + Return PingBackError(48, "The pingback has already been registered.") + End If + + If Not sourceHasLink Then + Return PingBackError(17, "The source URI does not contain a link to the target URI, and so cannot be used as a source.") + End If + + If containsHtml Then + ' spam + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "Cannot parse the request"}) + Else + Dim objComment As New CommentInfo With {.ContentItemId = Post.ContentItemId, .Author = GetDomain(sourceUrl), .Website = sourceUrl} + Dim comment As String = String.Format(DotNetNuke.Services.Localization.Localization.GetString("PingbackComment", Globals.SharedResourceFileName), objComment.Author, sourceUrl, title) + objComment.Comment = HttpUtility.HtmlEncode(comment) + objComment.Approved = Blog.AutoApprovePingBack + objComment.CommentID = Core.Entities.Comments.CommentsController.AddComment(Blog, Post, objComment) + Return PingBackSuccess() + End If + + End Function + + + + + Public Function Trackback() As HttpResponseMessage + + Dim BlogId As Integer = -1 + Dim PostId As Integer = -1 + BlogId = HttpContext.Current.Request.Params.ReadValue("blogId", BlogId) + PostId = HttpContext.Current.Request.Params.ReadValue("postId", PostId) + Blog = Core.Entities.Blogs.BlogsController.GetBlog(BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) + If Not Blog.EnableTrackBackReceive Then + Return Request.CreateResponse(HttpStatusCode.NotFound, New With {.Result = "This blog does not accept trackbacks"}) + End If + Post = Core.Entities.Posts.PostsController.GetPost(PostId, ActiveModule.ModuleID, "") + If Post Is Nothing Then + Return TrackBackResponse("The source page does not link") + End If + + Dim title As String = Globals.SafeString(HttpContext.Current.Request.Params("title")) + Dim excerpt As String = Globals.SafeString(HttpContext.Current.Request.Params("excerpt")) + Dim blogName As String = Globals.SafeString(HttpContext.Current.Request.Params("blog_name")) + Dim sourceUrl As String = String.Empty + If HttpContext.Current.Request.Params("url") IsNot Nothing Then + sourceUrl = Globals.SafeString(HttpContext.Current.Request.Params("url").Split(","c)(0), DotNetNuke.Security.PortalSecurity.FilterFlag.NoSQL And DotNetNuke.Security.PortalSecurity.FilterFlag.NoScripting) + End If + + Dim sourceHasLink As Boolean = False + + Try + CheckSourcePage(sourceUrl, Post.PermaLink(PortalSettings), sourceHasLink, title) + Catch ex As Exception + End Try + + If Not IsFirstPingBack(Post, sourceUrl) Then + Return TrackBackResponse("Trackback already registered") + End If + + If Not sourceHasLink Then + Return TrackBackResponse("The source page does not link") + End If + + Dim objComment As New CommentInfo With {.ContentItemId = Post.ContentItemId, .Author = blogName, .Website = sourceUrl} + Dim comment As String = String.Format(DotNetNuke.Services.Localization.Localization.GetString("TrackbackComment", Globals.SharedResourceFileName), blogName, sourceUrl, title) + objComment.Comment = HttpUtility.HtmlEncode(comment) + objComment.Approved = Blog.AutoApproveTrackBack + objComment.CommentID = Core.Entities.Comments.CommentsController.AddComment(Blog, Post, objComment) + Return TrackBackResponse() + + End Function +#End Region + +#Region " Private Methods " + Private Sub SetContext(data As CommentDTO) + Blog = Core.Entities.Blogs.BlogsController.GetBlog(data.BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) + Comment = Core.Entities.Comments.CommentsController.GetComment(data.CommentId, UserInfo.UserID) + End Sub + + Private Sub SetContext(data As FullCommentDTO) + Blog = Core.Entities.Blogs.BlogsController.GetBlog(data.BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) + End Sub + + Private Sub TemplateGetData(ByVal DataSource As String, ByVal Parameters As Dictionary(Of String, String), ByRef Replacers As System.Collections.Generic.List(Of GenericTokenReplace), ByRef Arguments As System.Collections.Generic.List(Of String()), callingObject As Object) + + Select Case DataSource.ToLower + + Case "comments" + + If callingObject IsNot Nothing AndAlso TypeOf callingObject Is CommentInfo Then + Dim parent As Integer = CType(callingObject, CommentInfo).CommentID + For Each c As CommentInfo In AllComments.Where(Function(cmt) cmt.ParentId = parent).OrderBy(Function(cmt) cmt.CreatedOnDate) + Replacers.Add(New BlogTokenReplace(ActiveModule, Security, Blog, Post, Settings, ViewSettings, c)) + Next + Else + For Each c As CommentInfo In AllComments.Where(Function(cmt) cmt.ParentId = -1).OrderBy(Function(cmt) cmt.CreatedOnDate) + Replacers.Add(New BlogTokenReplace(ActiveModule, Security, Blog, Post, Settings, ViewSettings, c)) + Next + End If + + End Select + + End Sub + + Private Shared Function RetrieveXmlDocument(context As HttpContext) As XmlDocument + Dim xml As String = ParseRequest(context) + If Not xml.Contains("pingback.ping") Then + context.Response.StatusCode = 404 + context.Response.[End]() + End If + Dim doc As New XmlDocument() + doc.LoadXml(xml) + Return doc + End Function + + Private Shared Function ParseRequest(context As HttpContext) As String + Dim buffer(CInt(context.Request.InputStream.Length - 1)) As Byte + context.Request.InputStream.Read(buffer, 0, buffer.Length) + Return Encoding.[Default].GetString(buffer) + End Function + + Private Shared Function IsFirstPingBack(post As PostInfo, sourceUrl As String) As Boolean + For Each c As CommentInfo In Core.Entities.Comments.CommentsController.GetCommentsByContentItem(post.ContentItemId, True, -1) + If c.Website.ToString.Equals(sourceUrl, StringComparison.OrdinalIgnoreCase) Then Return False + Next + Return True + End Function + + Private Shared Function TrackBackResponse() As HttpResponseMessage + Return TrackBackResponse("0") + End Function + Private Shared Function TrackBackResponse(status As String) As HttpResponseMessage + Dim reply As String = String.Format("{0}", status) + Dim res As New HttpResponseMessage(HttpStatusCode.OK) + res.Content = New StringContent(reply, System.Text.Encoding.UTF8, "application/xml") + Return res + End Function + + Private Shared Function PingBackSuccess() As HttpResponseMessage + Dim Success As String = "Thanks!" + Dim res As New HttpResponseMessage(HttpStatusCode.OK) + res.Content = New StringContent(Success, System.Text.Encoding.UTF8, "application/xml") + Return res + End Function + + Private Shared Function PingBackError(code As Integer, message As String) As HttpResponseMessage + Dim sb As New StringBuilder() + sb.Append("") + sb.Append("") + sb.Append("") + sb.Append("") + sb.Append("") + sb.Append("") + sb.Append("faultCode") + sb.AppendFormat("{0}", code) + sb.Append("") + sb.Append("") + sb.Append("faultString") + sb.AppendFormat("{0}", message) + sb.Append("") + sb.Append("") + sb.Append("") + sb.Append("") + sb.Append("") + Dim res As New HttpResponseMessage(HttpStatusCode.OK) + res.Content = New StringContent(sb.ToString, System.Text.Encoding.UTF8, "application/xml") + Return res + End Function + + Private Shared Function GetDomain(sourceUrl As String) As String + Dim start As Integer = sourceUrl.IndexOf("://") + 3 + Dim [stop] As Integer = sourceUrl.IndexOf("/", start) + Return sourceUrl.Substring(start, [stop] - start).Replace("www.", String.Empty) + End Function + + Private Shared Sub CheckSourcePage(sourceUrl As String, targetUrl As String, ByRef sourceContainsLink As Boolean, ByRef title As String) + + Dim remoteFile As New WebPage(New Uri(sourceUrl)) + Dim html As String = remoteFile.GetFileAsString() + Dim RegexTitle As New Regex("(?<=)([\s\S]*)(?=)", RegexOptions.IgnoreCase Or RegexOptions.Compiled) + Dim titleMatch As Match = RegexTitle.Match(html) + If titleMatch.Success Then title = Globals.SafeString(titleMatch.Value.Trim(CChar(vbCrLf)).Trim()) + html = html.ToUpperInvariant + targetUrl = targetUrl.ToUpperInvariant + sourceContainsLink = html.Contains("HREF=""" & targetUrl & """") OrElse html.Contains("HREF='" & targetUrl & "'") + + End Sub +#End Region + + End Class +End Namespace + diff --git a/Server/Blog/Components/Api/NotificationServiceController.vb b/Server/Blog/Components/Api/NotificationServiceController.vb new file mode 100644 index 00000000..1f0824f1 --- /dev/null +++ b/Server/Blog/Components/Api/NotificationServiceController.vb @@ -0,0 +1,137 @@ +' +' DotNetNuke® - http://www.dotnetnuke.com +' Copyright (c) 2002-2011 +' by DotNetNuke Corporation +' +' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +' documentation files (the "Software"), to deal in the Software without restriction, including without limitation +' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +' to permit persons to whom the Software is furnished to do so, subject to the following conditions: +' +' The above copyright notice and this permission notice shall be included in all copies or substantial portions +' of the Software. +' +' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +' DEALINGS IN THE SOFTWARE. +' +Option Strict On +Option Explicit On +Imports System.Net +Imports System.Net.Http +Imports System.Web.Http +Imports DotNetNuke.Modules.Blog.Core.Entities.Blogs +Imports DotNetNuke.Modules.Blog.Core.Entities.Comments +Imports DotNetNuke.Modules.Blog.Core.Entities.Posts +Imports DotNetNuke.Modules.Blog.Core.Integration +Imports DotNetNuke.Modules.Blog.Core.Services +Imports DotNetNuke.Services.Social.Notifications +Imports DotNetNuke.Web.Api + +Namespace Api + + Public Class NotificationServiceController + Inherits DnnApiController + + Public Class NotificationDTO + Public Property NotificationId As Integer + End Class + +#Region " Private Members " + + Private Property BlogModuleId As Integer = -1 + Private Property BlogId As Integer = -1 + Private Property Blog As BlogInfo = Nothing + Private Property ContentItemId As Integer = -1 + Private Property Post As PostInfo = Nothing + Private Property CommentId As Integer = -1 + Private Property Comment As CommentInfo = Nothing + +#End Region + +#Region " Service Methods " + + + + Public Function ApprovePost(postData As NotificationDTO) As HttpResponseMessage + Dim notify As Notification = NotificationsController.Instance.GetNotification(postData.NotificationId) + ParsePublishKey(notify.Context) + If Blog Is Nothing Or Post Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + Post.Published = True + Core.Entities.Posts.PostsController.UpdatePost(Post, UserInfo.UserID) + NotificationsController.Instance().DeleteNotification(postData.NotificationId) + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) + End Function + + + + + Public Function DeletePost(postData As NotificationDTO) As HttpResponseMessage + Dim notify As Notification = NotificationsController.Instance.GetNotification(postData.NotificationId) + ParsePublishKey(notify.Context) + If Blog Is Nothing Or Post Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + Core.Entities.Posts.PostsController.DeletePost(ContentItemId) + NotificationsController.Instance().DeleteNotification(postData.NotificationId) + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) + End Function + + + + + Public Function ApproveComment(postData As NotificationDTO) As HttpResponseMessage + Dim notify As Notification = NotificationsController.Instance.GetNotification(postData.NotificationId) + ParseCommentKey(notify.Context) + If Blog Is Nothing Or Post Is Nothing Or Comment Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + Core.Entities.Comments.CommentsController.ApproveComment(BlogModuleId, BlogId, Comment) + NotificationsController.Instance().DeleteNotification(postData.NotificationId) + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) + End Function + + + + + Public Function DeleteComment(postData As NotificationDTO) As HttpResponseMessage + Dim notify As Notification = NotificationsController.Instance.GetNotification(postData.NotificationId) + ParseCommentKey(notify.Context) + If Blog Is Nothing Or Post Is Nothing Or Comment Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + Core.Entities.Comments.CommentsController.DeleteComment(BlogModuleId, BlogId, Comment) + NotificationsController.Instance().DeleteNotification(postData.NotificationId) + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) + End Function +#End Region + +#Region " Private Methods " + Private Sub ParsePublishKey(key As String) + Dim nKey As New NotificationKey(key) + BlogModuleId = nKey.ModuleId + BlogId = nKey.BlogId + ContentItemId = nKey.ContentItemId + Blog = Core.Entities.Blogs.BlogsController.GetBlog(BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) + Post = Core.Entities.Posts.PostsController.GetPost(ContentItemId, BlogModuleId, Threading.Thread.CurrentThread.CurrentCulture.Name) + End Sub + + Private Sub ParseCommentKey(key As String) + Dim nKey As New NotificationKey(key) + BlogModuleId = nKey.ModuleId + BlogId = nKey.BlogId + ContentItemId = nKey.ContentItemId + CommentId = nKey.CommentId + Blog = Core.Entities.Blogs.BlogsController.GetBlog(BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) + Post = Core.Entities.Posts.PostsController.GetPost(ContentItemId, BlogModuleId, Threading.Thread.CurrentThread.CurrentCulture.Name) + Comment = Core.Entities.Comments.CommentsController.GetComment(CommentId, UserInfo.UserID) + End Sub +#End Region + + End Class + +End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Api/PostsController.vb b/Server/Blog/Components/Api/PostsController.vb new file mode 100644 index 00000000..6076f513 --- /dev/null +++ b/Server/Blog/Components/Api/PostsController.vb @@ -0,0 +1,92 @@ +' +' DNN Connect - http://dnn-connect.org +' Copyright (c) 2015 +' by DNN Connect +' +' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +' documentation files (the "Software"), to deal in the Software without restriction, including without limitation +' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +' to permit persons to whom the Software is furnished to do so, subject to the following conditions: +' +' The above copyright notice and this permission notice shall be included in all copies or substantial portions +' of the Software. +' +' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +' DEALINGS IN THE SOFTWARE. +' + +Imports System.Net +Imports System.Net.Http +Imports System.Web.Http +Imports DotNetNuke.Modules.Blog.Core.Entities.Blogs +Imports DotNetNuke.Modules.Blog.Core.Entities.Posts +Imports DotNetNuke.Modules.Blog.Core.Services +Imports DotNetNuke.Web.Api + +Namespace Api + Partial Public Class PostsController + Inherits DnnApiController + + Public Class PostDTO + Public Property BlogId As Integer + Public Property PostId As Integer + End Class + +#Region " Private Members " + Private Property Blog As BlogInfo = Nothing + Private Property Post As PostInfo = Nothing +#End Region + +#Region " Service Methods " + + + + + Public Function ApprovePost(postData As PostDTO) As HttpResponseMessage + SetContext(postData) + If Blog Is Nothing Or Post Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + Core.Entities.Posts.PostsController.PublishPost(Post, True, UserInfo.UserID) + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) + End Function + + + + + + Public Function DeletePost(postData As PostDTO) As HttpResponseMessage + SetContext(postData) + If Blog Is Nothing Or Post Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + Core.Entities.Posts.PostsController.DeletePost(Post) + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) + End Function + + + + + + Public Function ViewPost(postData As PostDTO) As HttpResponseMessage + SetContext(postData) + If Blog Is Nothing Or Post Is Nothing Then + Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) + End If + Core.Data.DataProvider.Instance.AddPostView(postData.PostId) + Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) + End Function +#End Region + +#Region " Private Methods " + Private Sub SetContext(data As PostDTO) + Blog = Core.Entities.Blogs.BlogsController.GetBlog(data.BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) + Post = Core.Entities.Posts.PostsController.GetPost(data.PostId, ActiveModule.ModuleID, Threading.Thread.CurrentThread.CurrentCulture.Name) + End Sub +#End Region + + End Class +End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Api/TermsController.vb b/Server/Blog/Components/Api/TermsController.vb new file mode 100644 index 00000000..5037da6c --- /dev/null +++ b/Server/Blog/Components/Api/TermsController.vb @@ -0,0 +1,64 @@ +' +' DNN Connect - http://dnn-connect.org +' Copyright (c) 2015 +' by DNN Connect +' +' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +' documentation files (the "Software"), to deal in the Software without restriction, including without limitation +' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +' to permit persons to whom the Software is furnished to do so, subject to the following conditions: +' +' The above copyright notice and this permission notice shall be included in all copies or substantial portions +' of the Software. +' +' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +' DEALINGS IN THE SOFTWARE. +' + +Imports System.Linq +Imports System.Net +Imports System.Net.Http +Imports System.Web.Http +Imports DotNetNuke.Web.Api + +Namespace Api + Partial Public Class TermsController + Inherits DnnApiController + + Private Const DisallowedCharacters As String = "%?*&;:'\\" + +#Region " Service Methods " + + + + Public Function Search() As HttpResponseMessage + Dim queryString As NameValueCollection = HttpUtility.ParseQueryString(Request.RequestUri.Query) + Dim searchString As String = queryString("term") + Dim vocab As Integer = Integer.Parse(queryString("vocab")) + Dim colTerms As IEnumerable(Of String) = Core.Entities.Terms.TermsController.GetTermsByVocabulary(ActiveModule.ModuleID, vocab, Threading.Thread.CurrentThread.CurrentCulture.Name).Values.Where(Function(t) t.LocalizedName.IndexOfAny(DisallowedCharacters.ToCharArray()) = -1 And t.LocalizedName.ToLower().Contains(searchString.ToLower())).Select(Function(t) t.LocalizedName) + Return Request.CreateResponse(HttpStatusCode.OK, colTerms) + End Function + + + + + Public Function GetVocabularyML(vocabularyId As Integer) As HttpResponseMessage + Dim res As New List(Of TermML) + For Each t As Core.Entities.Terms.TermInfo In Core.Entities.Terms.TermsController.GetTermsByVocabulary(ActiveModule.ModuleID, vocabularyId, "").Values + res.Add(New TermML With {.TermID = t.TermId, .DefaultName = t.Name, .LocNames = t.NameLocalizations.GetDictionary}) + Next + Return Request.CreateResponse(HttpStatusCode.OK, res) + End Function +#End Region + + Public Structure TermML + Public TermID As Integer + Public DefaultName As String + Public LocNames As Dictionary(Of String, String) + End Structure + + End Class +End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/BlogML/BlogMLBlogExtendedProperties.vb b/Server/Blog/Components/BlogML/BlogMLBlogExtendedProperties.vb deleted file mode 100644 index 0ff58ba8..00000000 --- a/Server/Blog/Components/BlogML/BlogMLBlogExtendedProperties.vb +++ /dev/null @@ -1,6 +0,0 @@ -Namespace BlogML - Public Class BlogMLBlogExtendedProperties - Public Shared ReadOnly CommentModeration As String = "CommentModeration" - Public Shared ReadOnly EnableSendingTrackbacks As String = "SendTrackback" - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/BlogML/BlogMLResource.vb b/Server/Blog/Components/BlogML/BlogMLResource.vb deleted file mode 100644 index 0f2daec0..00000000 --- a/Server/Blog/Components/BlogML/BlogMLResource.vb +++ /dev/null @@ -1,85 +0,0 @@ -Imports System.IO -Imports System.Xml -Imports System.Xml.Schema - -Namespace BlogML - - Public Class BlogMLResource - ' TODO: Update to .NET 2.0 - Public Shared Function GetSchemaStream() As Stream - Dim stream As Stream = GetType(BlogMLResource).Assembly.GetManifestResourceStream("BlogML.BlogML.xsd") - If stream Is Nothing Then - Throw New InvalidOperationException("Schema not found") - End If - Return stream - End Function - - Public Shared Function GetSchema() As XmlSchema - - Dim schema As XmlSchema = XmlSchema.Read(GetSchemaStream(), New ValidationEventHandler(AddressOf ValidationEvent)) - Return schema - - End Function - - Private Shared Sub ValidationEvent(sender As [Object], e As ValidationEventArgs) - Dim message As String = String.Format("Validation {0}: {1}", e.Severity, e.Message) - Throw New InvalidOperationException(message) - End Sub - - - Public Shared Sub Validate(inputUri As String) - Validate(inputUri, Nothing) - End Sub - - - Public Shared Sub Validate(inputUri As String, validationHandler As ValidationEventHandler) - Dim reader As XmlTextReader = Nothing - Try - reader = New XmlTextReader(inputUri) - Validate(reader, validationHandler) - Finally - If reader IsNot Nothing Then - reader.Close() - - End If - End Try - End Sub - - Public Shared Sub Validate(reader As XmlTextReader) - Validate(reader, Nothing) - End Sub - - - Public Shared Sub Validate(treader As XmlTextReader, validationHandler As ValidationEventHandler) - Dim validator As XmlReaderSettings = Nothing - Try - validator = New XmlReaderSettings() - Dim schema As XmlSchema = GetSchema() - validator.Schemas.Add(schema) - validator.ValidationType = ValidationType.Schema - - - If validationHandler IsNot Nothing Then - AddHandler validator.ValidationEventHandler, validationHandler - Else - AddHandler validator.ValidationEventHandler, New ValidationEventHandler(AddressOf ValidationEvent) - End If - - Dim objXmlReader As XmlReader = XmlReader.Create(treader, validator) - - - While objXmlReader.Read() - End While - Catch ex As Exception - 'Console.WriteLine(ex.ToString()) - Throw - Finally - If validationHandler IsNot Nothing Then - RemoveHandler validator.ValidationEventHandler, validationHandler - Else - RemoveHandler validator.ValidationEventHandler, New ValidationEventHandler(AddressOf ValidationEvent) - End If - End Try - End Sub - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/BlogML/BlogMLWriterBase.vb b/Server/Blog/Components/BlogML/BlogMLWriterBase.vb deleted file mode 100644 index 09152e82..00000000 --- a/Server/Blog/Components/BlogML/BlogMLWriterBase.vb +++ /dev/null @@ -1,424 +0,0 @@ -Imports System.Xml -Imports System.IO -Imports DotNetNuke.Modules.Blog.BlogML.Xml - -Namespace BlogML - - Public MustInherit Class BlogMLWriterBase - Private Const BlogMLNamespace As String = "http://www.blogml.com/2006/09/BlogML" - - Protected Property Writer() As XmlWriter - Get - Return m_Writer - End Get - Private Set(value As XmlWriter) - m_Writer = Value - End Set - End Property - Private m_Writer As XmlWriter - - Public Sub Write(writer__1 As XmlWriter) - Writer = writer__1 - - 'Write the XML delcaration. - writer__1.WriteStartDocument() - - Try - InternalWriteBlog() - Finally - Writer = Nothing - End Try - End Sub - - Protected MustOverride Sub InternalWriteBlog() - -#Region "WriteStartBlog" - - - Protected Sub WriteStartBlog(title As String, subTitle As String, rootUrl As String) - WriteStartBlog(title, ContentTypes.Text, subTitle, ContentTypes.Text, rootUrl, DateTime.Now) - End Sub - - Protected Sub WriteStartBlog(title As String, subTitle As String, rootUrl As String, dateCreated As DateTime) - WriteStartBlog(title, ContentTypes.Text, subTitle, ContentTypes.Text, rootUrl, dateCreated) - End Sub - - Protected Sub WriteStartBlog(title As String, titleContentType As ContentTypes, subTitle As String, subTitleContentType As ContentTypes, rootUrl As String, dateCreated As DateTime) - 'WriteStartElement("blog"); - Writer.WriteStartElement("blog", BlogMLNamespace) - ' fixes bug in Work Item 2004 - WriteAttributeStringRequired("root-url", rootUrl) - WriteAttributeString("date-created", FormatDateTime(dateCreated)) - - ' Write the default namespace, identified as xmlns with no prefix - Writer.WriteAttributeString("xmlns", Nothing, Nothing, "http://www.blogml.com/2006/09/BlogML") - Writer.WriteAttributeString("xmlns", "xs", Nothing, "http://www.w3.org/2001/XMLSchema") - - WriteContent("title", BlogMLContent.Create(title, titleContentType)) - WriteContent("sub-title", BlogMLContent.Create(subTitle, subTitleContentType)) - End Sub - -#End Region - - Protected Sub WriteStartElement(tag As String) - Writer.WriteStartElement(tag) - End Sub - - - Protected Sub WriteEndElement() - Writer.WriteEndElement() - End Sub - - -#Region "Extended Properties" - - Protected Sub WriteStartExtendedProperties() - WriteStartElement("extended-properties") - End Sub - - Protected Sub WriteExtendedProperty(name As String, value As String) - WriteStartElement("property") - WriteAttributeString("name", name) - WriteAttributeString("value", value) - WriteEndElement() - End Sub - -#End Region - - - Protected Sub WriteAuthor(id As String, name As String, email As String, dateCreated As DateTime, dateModified As DateTime, approved As Boolean) - WriteStartElement("author") - WriteNodeAttributes(id, dateCreated, dateModified, approved) - WriteAttributeString("email", email) - WriteContent("title", BlogMLContent.Create(name, ContentTypes.Text)) - WriteEndElement() - End Sub - - - Protected Sub WriteCategory(id As String, title As String, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, description As String, _ - parentRef As String) - WriteCategory(id, title, ContentTypes.Text, dateCreated, dateModified, approved, _ - description, parentRef) - End Sub - - - Protected Sub WriteCategory(id As String, title As String, titleContentType As ContentTypes, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, _ - description As String, parentRef As String) - WriteStartElement("category") - WriteNodeAttributes(id, dateCreated, dateModified, approved) - WriteAttributeString("description", description) - WriteAttributeString("parentref", parentRef) - WriteContent("title", BlogMLContent.Create(title, titleContentType)) - WriteEndElement() - End Sub - - Protected Sub WriteAuthorReference(refId As String) - WriteStartElement("author") - WriteAttributeStringRequired("ref", refId) - WriteEndElement() - End Sub - - Protected Sub WriteCategoryReference(refId As String) - WriteStartElement("category") - WriteAttributeStringRequired("ref", refId) - WriteEndElement() - End Sub - - Protected Sub WriteStartAuthors() - WriteStartElement("authors") - End Sub - - Protected Sub WriteStartCategories() - WriteStartElement("categories") - End Sub - - - Protected Sub WriteStartPosts() - WriteStartElement("posts") - End Sub - - - Protected Sub WriteStartTrackbacks() - WriteStartElement("trackbacks") - End Sub - - - Protected Sub WriteStartAttachments() - WriteStartElement("attachments") - End Sub - - - Protected Sub WriteNodeAttributes(id As String, dateCreated As DateTime, dateModified As DateTime, approved As Boolean) - WriteAttributeString("id", id) - WriteAttributeString("date-created", FormatDateTime(dateCreated)) - WriteAttributeString("date-modified", FormatDateTime(dateModified)) - WriteAttributeString("approved", If(approved, "true", "false")) - End Sub - - - Protected Function FormatDateTime([date] As DateTime) As String - Return [date].ToUniversalTime().ToString("s") - End Function - - Protected Sub WriteStartPost(id As String, title As String, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, content As String, _ - postUrl As String) - WriteStartPost(id, title, ContentTypes.Text, dateCreated, dateModified, approved, _ - content, ContentTypes.Text, postUrl, 0, False, Nothing, _ - ContentTypes.Text, BlogPostTypes.Normal, String.Empty) - End Sub - - Protected Sub WriteStartPost(id As String, title As String, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, content As String, _ - postUrl As String, views As UInt32, blogpostType As BlogPostTypes, postName As String) - WriteStartPost(id, title, ContentTypes.Text, dateCreated, dateModified, approved, _ - content, ContentTypes.Text, postUrl, views, False, Nothing, _ - ContentTypes.Text, blogpostType, postName) - End Sub - - Protected Sub WriteStartPost(id As String, title As String, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, content As String, _ - postUrl As String, views As UInt32, excerpt As String, blogpostType As BlogPostTypes, postName As String) - WriteStartPost(id, title, ContentTypes.Text, dateCreated, dateModified, approved, _ - content, ContentTypes.Text, postUrl, views, True, excerpt, _ - ContentTypes.Text, blogpostType, postName) - End Sub - - Protected Sub WriteStartPost(id As String, title As BlogMLContent, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, content As BlogMLContent, _ - postUrl As String, views As UInt32, hasexcerpt As Boolean, excerpt As BlogMLContent, blogpostType As BlogPostTypes, postName As String) - WriteStartElement("post") - WriteNodeAttributes(id, dateCreated, dateModified, approved) - WriteAttributeString("post-url", postUrl) - WriteAttributeStringRequired("type", blogpostType.ToString().ToLower()) - WriteAttributeStringRequired("hasexcerpt", hasexcerpt.ToString().ToLower()) - WriteAttributeStringRequired("views", views.ToString()) - WriteContent("title", title) - WriteContent("content", content) - If postName IsNot Nothing Then - WriteContent("post-name", BlogMLContent.Create(postName, ContentTypes.Text)) - End If - If hasexcerpt Then - WriteContent("excerpt", excerpt) - End If - End Sub - - Protected Sub WriteStartPost(id As String, title As String, titleContentType As ContentTypes, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, _ - content As String, postContentType As ContentTypes, postUrl As String, views As UInt32, hasexcerpt As Boolean, excerpt As String, _ - excerptContentType As ContentTypes, blogpostType As BlogPostTypes, postName As String) - WriteStartElement("post") - WriteNodeAttributes(id, dateCreated, dateModified, approved) - WriteAttributeString("post-url", postUrl) - WriteAttributeStringRequired("type", blogpostType.ToString().ToLower()) - WriteAttributeStringRequired("hasexcerpt", hasexcerpt.ToString().ToLower()) - WriteAttributeStringRequired("views", views.ToString()) - WriteContent("title", BlogMLContent.Create(title, titleContentType)) - WriteContent("content", BlogMLContent.Create(content, postContentType)) - If postName IsNot Nothing Then - WriteContent("post-name", BlogMLContent.Create(postName, ContentTypes.Text)) - End If - If hasexcerpt Then - WriteContent("excerpt", BlogMLContent.Create(excerpt, excerptContentType)) - End If - End Sub - - Protected Sub WriteStartComments() - WriteStartElement("comments") - End Sub - - - Protected Sub WriteComment(id As String, title As String, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, userName As String, _ - userEmail As String, userUrl As String, content As String) - WriteComment(id, title, ContentTypes.Text, dateCreated, dateModified, approved, _ - userName, userEmail, userUrl, content, ContentTypes.Text) - End Sub - - Protected Sub WriteComment(id As String, title As BlogMLContent, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, userName As String, _ - userEmail As String, userUrl As String, content As BlogMLContent) - WriteStartElement("comment") - WriteNodeAttributes(id, dateCreated, dateModified, approved) - WriteAttributeStringRequired("user-name", If(userName, "")) - WriteAttributeString("user-url", If(userUrl, "")) - WriteAttributeString("user-email", If(userEmail, "")) - WriteContent("title", title) - WriteContent("content", content) - WriteEndElement() - End Sub - - - Protected Sub WriteComment(id As String, title As String, titleContentType As ContentTypes, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, _ - userName As String, userEmail As String, userUrl As String, content As String, commentContentType As ContentTypes) - WriteStartElement("comment") - WriteNodeAttributes(id, dateCreated, dateModified, approved) - WriteAttributeStringRequired("user-name", If(userName, "")) - WriteAttributeString("user-url", If(userUrl, "")) - WriteAttributeString("user-email", If(userEmail, "")) - WriteContent("title", BlogMLContent.Create(title, titleContentType)) - WriteContent("content", BlogMLContent.Create(content, commentContentType)) - WriteEndElement() - End Sub - - - Protected Sub WriteTrackback(id As String, title As String, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, url As String) - WriteTrackback(id, title, ContentTypes.Text, dateCreated, dateModified, approved, _ - url) - End Sub - - - Protected Sub WriteTrackback(id As String, title As String, titleContentType As ContentTypes, dateCreated As DateTime, dateModified As DateTime, approved As Boolean, _ - url As String) - WriteStartElement("trackback") - WriteNodeAttributes(id, dateCreated, dateModified, approved) - WriteAttributeStringRequired("url", url) - WriteContent("title", BlogMLContent.Create(title, titleContentType)) - WriteEndElement() - End Sub - - - Protected Sub WriteAttributeStringRequired(name As String, value As String) - If String.IsNullOrEmpty(value) Then - Throw New ArgumentNullException("value", name) - End If - Writer.WriteAttributeString(name, value) - End Sub - - - Protected Sub WriteAttributeString(name As String, value As String) - If Not String.IsNullOrEmpty(value) Then - Writer.WriteAttributeString(name, value) - End If - End Sub - - Protected Sub WriteContent(elementName As String, content As BlogMLContent) - WriteStartElement(elementName) - Dim contentType As String = (If([Enum].GetName(GetType(ContentTypes), content.ContentType), "text")).ToLowerInvariant() - WriteAttributeString("type", contentType) - Writer.WriteCData(If(content.Text, String.Empty)) - WriteEndElement() - End Sub - - Protected Sub WriteAttachment(externalUri As String, mimeType As String, fullUrl As String) - WriteAttachment(fullUrl, 0, mimeType, externalUri, False, Nothing) - End Sub - - Protected Sub WriteAttachment(embeddedUrl As String, mimeType As String, inputStream As Stream) - Using reader As New BinaryReader(inputStream) - reader.BaseStream.Position = 0 - Dim data As Byte() = reader.ReadBytes(CInt(inputStream.Length)) - WriteAttachment(embeddedUrl, data.Length, mimeType, Nothing, True, data) - End Using - End Sub - - Protected Sub WriteAttachment(embeddedUrl As String, size As Double, mimeType As String, externalUri As String, embedded As Boolean, data As Byte()) - WriteStartElement("attachment") - - Try - - WriteAttributeStringRequired("url", embeddedUrl) - - If size > 0 Then - WriteAttributeStringRequired("size", size.ToString()) - End If - - If mimeType IsNot Nothing Then - WriteAttributeStringRequired("mime-type", mimeType) - End If - - If Not String.IsNullOrEmpty(externalUri) Then - WriteAttributeStringRequired("external-uri", externalUri) - End If - - WriteAttributeString("embedded", If(embedded, "true", "false")) - - If embedded Then - Writer.WriteBase64(data, 0, data.Length) - End If - Finally - WriteEndElement() - End Try - - End Sub - - - Friend Sub CopyStream(src As Stream, dst As Stream) - Dim buf(4095) As Byte - While True - Dim bytesRead As Integer = src.Read(buf, 0, buf.Length) - - 'Read returns 0 when reached end of stream. - If bytesRead = 0 Then - Exit While - End If - - dst.Write(buf, 0, bytesRead) - End While - End Sub - - - Public NotInheritable Class SgmlUtil - Public Shared Function IsRootUrlOf(rootUrl As String, url As String) As Boolean - - If rootUrl Is Nothing Then - Throw New ArgumentNullException("rootUrl") - End If - - If url Is Nothing Then - Throw New ArgumentNullException("url") - End If - - rootUrl = rootUrl.Trim().ToLower() - url = url.Trim().ToLower() - ' is it a full path - If url.StartsWith("http://") Then - Return url.StartsWith(rootUrl) - End If - - ' it's local - Return True - End Function - - Public Shared Function StripRootUrlPath(rootUrl As String, url As String) As String - If url.StartsWith(rootUrl) Then - url = url.Remove(0, rootUrl.Length) - End If - - If url.StartsWith("/") Then - url.TrimStart("/"c) - End If - - Return url - End Function - - Public Shared Function CleanAttachmentUrls(content As String, oldPath As String, newPath As String) As String - oldPath = Regex.Escape(oldPath) - - content = Regex.Replace(content, oldPath, newPath, RegexOptions.CultureInvariant Or RegexOptions.IgnoreCase Or RegexOptions.Multiline Or RegexOptions.ExplicitCapture) - Return content - End Function - - Public Shared Function GetAttributeValues(content As String, tag As String, attribute As String) As String() - Dim srcrx As Regex = CreateAttributeRegex(attribute) - Dim matches As MatchCollection = CreateTagRegex(tag).Matches(content) - Dim sources(matches.Count - 1) As String - For i As Integer = 0 To sources.Length - 1 - Dim m As Match = srcrx.Match(matches(i).Value) - sources(i) = m.Groups("Value").Value - Next - Return sources - End Function - - Public Shared Function CreateTagRegex(name As String) As Regex - - Dim pattern As String = "<\s*{0}[^>]+>" - - pattern = String.Format(pattern, name) - Return New Regex(pattern, RegexOptions.CultureInvariant Or RegexOptions.IgnoreCase Or RegexOptions.Multiline Or RegexOptions.ExplicitCapture) - End Function - - Public Shared Function CreateAttributeRegex(name As String) As Regex - Dim pattern As String = "{0}\s*=\s*['""]?\s*(?[^'"" ]+)" - pattern = String.Format(pattern, name) - Return New Regex(pattern, RegexOptions.CultureInvariant Or RegexOptions.IgnoreCase Or RegexOptions.Multiline Or RegexOptions.ExplicitCapture) - End Function - - End Class - - End Class - -End Namespace diff --git a/Server/Blog/Components/BlogML/Enumerators/BlogPostTypes.vb b/Server/Blog/Components/BlogML/Enumerators/BlogPostTypes.vb deleted file mode 100644 index 5c54fbe4..00000000 --- a/Server/Blog/Components/BlogML/Enumerators/BlogPostTypes.vb +++ /dev/null @@ -1,8 +0,0 @@ -Namespace BlogML - Public Enum BlogPostTypes As Short - _ - Normal = 1 - _ - Article = 2 - End Enum -End Namespace diff --git a/Server/Blog/Components/BlogML/Enumerators/CommentModerationTypes.vb b/Server/Blog/Components/BlogML/Enumerators/CommentModerationTypes.vb deleted file mode 100644 index c44a06c5..00000000 --- a/Server/Blog/Components/BlogML/Enumerators/CommentModerationTypes.vb +++ /dev/null @@ -1,7 +0,0 @@ -Namespace BlogML - Public Enum CommentModerationTypes As Short - Anonymous = 1 - Enabled = 2 - Disabled = 3 - End Enum -End Namespace diff --git a/Server/Blog/Components/BlogML/Enumerators/ContentTypes.vb b/Server/Blog/Components/BlogML/Enumerators/ContentTypes.vb deleted file mode 100644 index 7eabe110..00000000 --- a/Server/Blog/Components/BlogML/Enumerators/ContentTypes.vb +++ /dev/null @@ -1,14 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML - Public Enum ContentTypes As Short - _ - Html = 1 - _ - Xhtml = 2 - _ - Text = 3 - _ - Base64 = 4 - End Enum -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/BlogML/Enumerators/SendTrackbackTypes.vb b/Server/Blog/Components/BlogML/Enumerators/SendTrackbackTypes.vb deleted file mode 100644 index 88b3f2db..00000000 --- a/Server/Blog/Components/BlogML/Enumerators/SendTrackbackTypes.vb +++ /dev/null @@ -1,7 +0,0 @@ - -Namespace BlogML - Public Enum SendTrackbackTypes As Short - Yes = 1 - No = 2 - End Enum -End Namespace diff --git a/Server/Blog/Components/BlogML/Pair.vb b/Server/Blog/Components/BlogML/Pair.vb deleted file mode 100644 index ecf12fa3..00000000 --- a/Server/Blog/Components/BlogML/Pair.vb +++ /dev/null @@ -1,15 +0,0 @@ -Namespace BlogML - - ''' - ''' A serializable keyvalue pair class - ''' - Public Structure Pair(Of K, V) - Public Key As K - Public Value As V - Public Sub New(key As K, value As V) - Me.Key = key - Me.Value = value - End Sub - End Structure - -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLAttachment.vb b/Server/Blog/Components/BlogML/Xml/BlogMLAttachment.vb deleted file mode 100644 index 02484a60..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLAttachment.vb +++ /dev/null @@ -1,23 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - - Public NotInheritable Class BlogMLAttachment - - - Public Property Embedded As Boolean = False - - - Public Property Url As String - - - Public Property Path As String - - - Public Property MimeType As String - - - Public Property Data As Byte() - - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLAuthor.vb b/Server/Blog/Components/BlogML/Xml/BlogMLAuthor.vb deleted file mode 100644 index a0a0d28a..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLAuthor.vb +++ /dev/null @@ -1,12 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - - Public NotInheritable Class BlogMLAuthor - Inherits BlogMLNode - - - Public Property Email As String - - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLAuthorReference.vb b/Server/Blog/Components/BlogML/Xml/BlogMLAuthorReference.vb deleted file mode 100644 index 8486fa3a..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLAuthorReference.vb +++ /dev/null @@ -1,11 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - - Public NotInheritable Class BlogMLAuthorReference - - - Public Property Ref As String - - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLBlog.vb b/Server/Blog/Components/BlogML/Xml/BlogMLBlog.vb deleted file mode 100644 index 09c4fbd1..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLBlog.vb +++ /dev/null @@ -1,56 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - - - Public NotInheritable Class BlogMLBlog - - - Public Property RootUrl As String - - - Public Property Title As String - - - Public Property SubTitle As String - - - Public Property DateCreated As DateTime = DateTime.Now - - - - Public Property ExtendedProperties As New ExtendedPropertiesCollection - - - - Public Property Authors As New AuthorCollection - - - - Public Property Posts As New PostCollection - - - - Public Property Categories As New CategoryCollection - - - Public NotInheritable Class AuthorCollection - Inherits List(Of BlogMLAuthor) - End Class - - - Public NotInheritable Class PostCollection - Inherits List(Of BlogMLPost) - End Class - - - Public NotInheritable Class CategoryCollection - Inherits List(Of BlogMLCategory) - End Class - - - Public NotInheritable Class ExtendedPropertiesCollection - Inherits List(Of Pair(Of String, String)) - End Class - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLCategory.vb b/Server/Blog/Components/BlogML/Xml/BlogMLCategory.vb deleted file mode 100644 index 97042a01..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLCategory.vb +++ /dev/null @@ -1,15 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - - Public NotInheritable Class BlogMLCategory - Inherits BlogMLNode - - - Public Property Description As String - - - Public Property ParentRef As String - - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLCategoryReference.vb b/Server/Blog/Components/BlogML/Xml/BlogMLCategoryReference.vb deleted file mode 100644 index a2522914..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLCategoryReference.vb +++ /dev/null @@ -1,11 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - - Public NotInheritable Class BlogMLCategoryReference - - - Public Property Ref As String - - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLComment.vb b/Server/Blog/Components/BlogML/Xml/BlogMLComment.vb deleted file mode 100644 index a6b3f732..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLComment.vb +++ /dev/null @@ -1,25 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - - Public NotInheritable Class BlogMLComment - Inherits BlogMLNode - Private m_userName As String - Private m_userEmail As String - Private m_userUrl As String - Private m_content As New BlogMLContent - - - Public Property UserName As String - - - Public Property UserUrl As String - - - Public Property UserEMail As String - - - Public Property Content As BlogMLContent - - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLContent.vb b/Server/Blog/Components/BlogML/Xml/BlogMLContent.vb deleted file mode 100644 index 5560c8f2..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLContent.vb +++ /dev/null @@ -1,68 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - - Public NotInheritable Class BlogMLContent - Private ReadOnly Property Base64Encoded As Boolean - Get - Return ContentType = ContentTypes.Base64 - End Get - End Property - - Private ReadOnly Property HtmlEncoded As Boolean - Get - Return ContentType = ContentTypes.Html OrElse ContentType = ContentTypes.Xhtml - End Get - End Property - - - Public Property ContentType As ContentTypes - Get - Return m_ContentType - End Get - Set(value As ContentTypes) - m_ContentType = value - End Set - End Property - Private m_ContentType As ContentTypes = ContentTypes.Text - - ' Encoded Text - - Public Property Text As String - Get - Return m_Text - End Get - Set(value As String) - m_Text = value - End Set - End Property - Private m_Text As String - - - Public ReadOnly Property UncodedText As String - Get - If Base64Encoded Then - Dim byteArray As Byte() = Convert.FromBase64String(Text) - Return Encoding.UTF8.GetString(byteArray) - End If - If HtmlEncoded Then - Return HttpUtility.HtmlDecode(Text) - End If - Return Text - End Get - End Property - - Public Shared Function Create(unencodedText As String, contentType As ContentTypes) As BlogMLContent - Dim content As New BlogMLContent With {.ContentType = contentType} - If content.Base64Encoded Then - Dim byteArray As Byte() = Encoding.UTF8.GetBytes(unencodedText) - content.Text = Convert.ToBase64String(byteArray) - ElseIf content.HtmlEncoded Then - content.Text = HttpUtility.HtmlEncode(unencodedText) - Else - content.Text = unencodedText - End If - Return content - End Function - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLMeta.vb b/Server/Blog/Components/BlogML/Xml/BlogMLMeta.vb deleted file mode 100644 index f5baf4e0..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLMeta.vb +++ /dev/null @@ -1,14 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - ")> - Public NotInheritable Class Meta - - - Public Property Type As String - - - Public Property Value As String - - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLNode.vb b/Server/Blog/Components/BlogML/Xml/BlogMLNode.vb deleted file mode 100644 index fce3baa9..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLNode.vb +++ /dev/null @@ -1,23 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - - Public MustInherit Class BlogMLNode - - - Public Property ID As String - - - Public Property Title As String - - - Public Property DateCreated As DateTime = Now - - - Public Property DateModified As DateTime = Now - - - Public Property Approved As Boolean = True - - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLPost.vb b/Server/Blog/Components/BlogML/Xml/BlogMLPost.vb deleted file mode 100644 index 921dc352..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLPost.vb +++ /dev/null @@ -1,148 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - - Public NotInheritable Class BlogMLPost - Inherits BlogMLNode - - - Public Property PostUrl As String - - - Public Property HasExcerpt As Boolean = False - - - Public Property PostType As New BlogPostTypes - - - Public Property Views As UInt32 = 0 - - - Public Property Image As String - - - Public Property AllowComments As Boolean = True - - - Public Property DisplayCopyright As Boolean = False - - - Public Property Copyright As String - - - Public Property Locale As String - - - Public Property PostName As String - - - Public Property Content As New BlogMLContent - - - Public Property Excerpt As New BlogMLContent - - - - Public Property Authors As New AuthorReferenceCollection - - - - Public Property Categories As New CategoryReferenceCollection - - - - Public Property Comments As New CommentCollection - - - - Public Property Trackbacks As New TrackbackCollection - - - - Public Property Attachments As New AttachmentCollection - - - Public NotInheritable Class AuthorReferenceCollection - Inherits ArrayList - Default Public Shadows ReadOnly Property Item(index As Integer) As BlogMLAuthorReference - Get - Return TryCast(MyBase.Item(index), BlogMLAuthorReference) - End Get - End Property - - Public Overloads Sub Add(value As BlogMLAuthorReference) - MyBase.Add(value) - End Sub - - Public Overloads Function Add(authorID As String) As BlogMLAuthorReference - Dim item As New BlogMLAuthorReference - item.Ref = authorID - MyBase.Add(item) - Return item - End Function - End Class - - - Public NotInheritable Class CommentCollection - Inherits ArrayList - Default Public Shadows ReadOnly Property Item(index As Integer) As BlogMLComment - Get - Return TryCast(MyBase.Item(index), BlogMLComment) - End Get - End Property - - Public Overloads Sub Add(value As BlogMLComment) - MyBase.Add(value) - End Sub - End Class - - - Public NotInheritable Class TrackbackCollection - Inherits ArrayList - Default Public Shadows ReadOnly Property Item(index As Integer) As BlogMLTrackback - Get - Return TryCast(MyBase.Item(index), BlogMLTrackback) - End Get - End Property - - Public Overloads Sub Add(value As BlogMLTrackback) - MyBase.Add(value) - End Sub - End Class - - - Public NotInheritable Class CategoryReferenceCollection - Inherits ArrayList - Default Public Shadows ReadOnly Property Item(index As Integer) As BlogMLCategoryReference - Get - Return TryCast(MyBase.Item(index), BlogMLCategoryReference) - End Get - End Property - - Public Overloads Sub Add(value As BlogMLCategoryReference) - MyBase.Add(value) - End Sub - - Public Overloads Function Add(categoryID As String) As BlogMLCategoryReference - Dim item As New BlogMLCategoryReference - item.Ref = categoryID - MyBase.Add(item) - Return item - End Function - End Class - - - Public NotInheritable Class AttachmentCollection - Inherits ArrayList - Default Public Shadows ReadOnly Property Item(index As Integer) As BlogMLAttachment - Get - Return TryCast(MyBase.Item(index), BlogMLAttachment) - End Get - End Property - - Public Overloads Sub Add(value As BlogMLAttachment) - MyBase.Add(value) - End Sub - End Class - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLSerializer.vb b/Server/Blog/Components/BlogML/Xml/BlogMLSerializer.vb deleted file mode 100644 index b5ab7eb2..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLSerializer.vb +++ /dev/null @@ -1,53 +0,0 @@ -Imports System.IO -Imports System.Xml.Serialization -Imports System.Xml - -Namespace BlogML.Xml - Public Class BlogMLSerializer - Private Shared ReadOnly syncRoot As New Object - Private Shared m_serializer As XmlSerializer - - Public Shared ReadOnly Property Serializer As XmlSerializer - Get - SyncLock syncRoot - If m_serializer Is Nothing Then - m_serializer = New XmlSerializer(GetType(BlogMLBlog)) - End If - Return m_serializer - End SyncLock - End Get - End Property - - Public Shared ReadOnly Property Namespaces As XmlSerializerNamespaces - Get - Dim ns As New XmlSerializerNamespaces() - ns.Add("dnn", "http://dnn-connect.org/blog/") - Return ns - End Get - End Property - - Public Shared Function Deserialize(stream As Stream) As BlogMLBlog - Return TryCast(Serializer.Deserialize(stream), BlogMLBlog) - End Function - - Public Shared Function Deserialize(reader As TextReader) As BlogMLBlog - Return TryCast(Serializer.Deserialize(reader), BlogMLBlog) - End Function - - Public Shared Function Deserialize(reader As XmlReader) As BlogMLBlog - Return TryCast(Serializer.Deserialize(reader), BlogMLBlog) - End Function - - Public Shared Sub Serialize(stream As Stream, blog As BlogMLBlog) - Serializer.Serialize(stream, blog, Namespaces) - End Sub - - Public Shared Sub Serialize(writer As TextWriter, blog As BlogMLBlog) - Serializer.Serialize(writer, blog, Namespaces) - End Sub - - Public Shared Sub Serialize(writer As XmlWriter, blog As BlogMLBlog) - Serializer.Serialize(writer, blog, Namespaces) - End Sub - End Class -End Namespace diff --git a/Server/Blog/Components/BlogML/Xml/BlogMLTrackback.vb b/Server/Blog/Components/BlogML/Xml/BlogMLTrackback.vb deleted file mode 100644 index 40b67bf6..00000000 --- a/Server/Blog/Components/BlogML/Xml/BlogMLTrackback.vb +++ /dev/null @@ -1,12 +0,0 @@ -Imports System.Xml.Serialization - -Namespace BlogML.Xml - - Public NotInheritable Class BlogMLTrackback - Inherits BlogMLNode - - - Public Property Url As String - - End Class -End Namespace diff --git a/Server/Blog/Components/Common/BlogContextInfo.vb b/Server/Blog/Components/Common/BlogContextInfo.vb deleted file mode 100644 index b75d98b6..00000000 --- a/Server/Blog/Components/Common/BlogContextInfo.vb +++ /dev/null @@ -1,250 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Modules.Blog.Security -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Services.Tokens - -Namespace Common - - Public Class BlogContextInfo - Implements IPropertyAccess - -#Region " Private Members " - Private Property RequestParams As NameValueCollection -#End Region - -#Region " Public Methods " - Public Sub New(context As HttpContext, blogModule As BlogModuleBase) - - BlogModuleId = blogModule.ModuleId - - ' Initialize values from View Settings - If blogModule.ViewSettings.BlogModuleId <> -1 Then - BlogModuleId = blogModule.ViewSettings.BlogModuleId - parentModule = (New DotNetNuke.Entities.Modules.ModuleController).GetModule(BlogModuleId) - End If - BlogId = blogModule.ViewSettings.BlogId - Categories = blogModule.ViewSettings.Categories - AuthorId = blogModule.ViewSettings.AuthorId - - Locale = Threading.Thread.CurrentThread.CurrentCulture.Name - If context.Request.UrlReferrer IsNot Nothing Then Referrer = context.Request.UrlReferrer.PathAndQuery - RequestParams = context.Request.Params - - context.Request.Params.ReadValue("Blog", BlogId) - context.Request.Params.ReadValue("Post", ContentItemId) - context.Request.Params.ReadValue("Term", TermId) - context.Request.Params.ReadValue("Categories", Categories) - context.Request.Params.ReadValue("User", AuthorId) - context.Request.Params.ReadValue("uid", AuthorId) - context.Request.Params.ReadValue("UserId", AuthorId) - context.Request.Params.ReadValue("Author", AuthorId) - context.Request.Params.ReadValue("end", EndDate) - context.Request.Params.ReadValue("search", SearchString) - context.Request.Params.ReadValue("t", SearchTitle) - context.Request.Params.ReadValue("c", SearchContents) - context.Request.Params.ReadValue("u", SearchUnpublished) - context.Request.Params.ReadValue("EntryId", LegacyEntryId) - If ContentItemId > -1 Then Post = Entities.Posts.PostsController.GetPost(ContentItemId, BlogModuleId, Locale) - If BlogId > -1 And Post IsNot Nothing AndAlso Post.BlogID <> BlogId Then Post = Nothing ' double check in case someone is hacking to retrieve an Post from another blog - If BlogId = -1 And Post IsNot Nothing Then BlogId = Post.BlogID - If BlogId > -1 Then Blog = Entities.Blogs.BlogsController.GetBlog(BlogId, blogModule.UserInfo.UserID, Locale) - If BlogId > -1 Then BlogMapPath = GetBlogDirectoryMapPath(BlogId) - If BlogMapPath <> "" AndAlso Not IO.Directory.Exists(BlogMapPath) Then IO.Directory.CreateDirectory(BlogMapPath) - If ContentItemId > -1 Then PostMapPath = GetPostDirectoryMapPath(BlogId, ContentItemId) - If PostMapPath <> "" AndAlso Not IO.Directory.Exists(PostMapPath) Then IO.Directory.CreateDirectory(PostMapPath) - If TermId > -1 Then Term = Entities.Terms.TermsController.GetTerm(TermId, BlogModuleId, Locale) - If AuthorId > -1 Then Author = DotNetNuke.Entities.Users.UserController.GetUserById(blogModule.PortalId, AuthorId) - If context.Request.UserAgent IsNot Nothing Then - WLWRequest = CBool(context.Request.UserAgent.IndexOf("Windows Live Writer") > -1) - End If - Security = New ContextSecurity(BlogModuleId, blogModule.TabId, Blog, blogModule.UserInfo) - If EndDate < Now.AddDays(-1) Then - EndDate = EndDate.Date.AddDays(1).AddMinutes(-1) - EndDateOrNow = EndDate - ElseIf Security.CanAddPost Then - EndDate = Nothing - Else - EndDate = DateTime.Now.ToUniversalTime ' security measure to stop people prying into future posts - EndDateOrNow = EndDate - End If - - ' security - Dim isStylePostRequest As Boolean = False - If Post IsNot Nothing AndAlso Not (Post.Published Or Security.CanEditThisPost(Post)) AndAlso Not Security.IsEditor Then - If Post.Title.Contains("3bfe001a-32de-4114-a6b4-4005b770f6d7") And WLWRequest Then - isStylePostRequest = True - Else - Post = Nothing - ContentItemId = -1 - End If - End If - If Blog IsNot Nothing AndAlso Not Blog.Published AndAlso Not Security.IsOwner AndAlso Not Security.UserIsAdmin AndAlso Not isStylePostRequest Then - Blog = Nothing - BlogId = -1 - End If - - ' set urls for use in module - If ParentModule Is Nothing Then - ModuleUrls = New ModuleUrls(blogModule.TabId, BlogId, ContentItemId, TermId, AuthorId) - Else - ModuleUrls = New ModuleUrls(blogModule.TabId, ParentModule.TabID, BlogId, ContentItemId, TermId, AuthorId) - End If - IsMultiLingualSite = CBool(DotNetNuke.Services.Localization.LocaleController.Instance.GetLocales(blogModule.PortalId).Count > 1) - If Not blogModule.ViewSettings.ShowAllLocales Then - ShowLocale = Locale - End If - If Referrer.Contains("/ctl/") Or Referrer.Contains("&ctl=") Then - Referrer = DotNetNuke.Common.NavigateURL(blogModule.TabId) ' just catch 99% of bad referrals to edit pages - End If - - UiTimeZone = blogModule.ModuleContext.PortalSettings.TimeZone - If blogModule.UserInfo.Profile.PreferredTimeZone IsNot Nothing Then - UiTimeZone = blogModule.UserInfo.Profile.PreferredTimeZone - End If - - End Sub - - Public Shared Function GetBlogContext(ByRef context As HttpContext, blogModule As BlogModuleBase) As BlogContextInfo - Dim res As BlogContextInfo - If context.Items("BlogContext" & blogModule.TabModuleId.ToString) Is Nothing Then - res = New BlogContextInfo(context, blogModule) - context.Items("BlogContext" & blogModule.TabModuleId.ToString) = res - Else - res = CType(context.Items("BlogContext" & blogModule.TabModuleId.ToString), BlogContextInfo) - End If - Return res - End Function -#End Region - -#Region " Public Properties " - Public Property BlogModuleId As Integer = -1 - Public Property ParentModule As DotNetNuke.Entities.Modules.ModuleInfo = Nothing - Public Property BlogId As Integer = -1 - Public Property ContentItemId As Integer = -1 - Public Property TermId As Integer = -1 - Public Property Categories As String = "" - Public Property AuthorId As Integer = -1 - Public Property EndDate As Date = DateTime.Now.ToUniversalTime - Public Property EndDateOrNow As Date = DateTime.Now - Public Property Blog As Entities.Blogs.BlogInfo = Nothing - Public Property Post As Entities.Posts.PostInfo = Nothing - Public Property Term As Entities.Terms.TermInfo = Nothing - Public Property Author As DotNetNuke.Entities.Users.UserInfo = Nothing - Public Property BlogMapPath As String = "" - Public Property PostMapPath As String = "" - Public Property OutputAdditionalFiles As Boolean - Public Property ModuleUrls As ModuleUrls = Nothing - Public Property SearchString As String = "" - Public Property SearchTitle As Boolean = True - Public Property SearchContents As Boolean = False - Public Property SearchUnpublished As Boolean = False - Public Property IsMultiLingualSite As Boolean = False - Public Property ShowLocale As String = Nothing - Public Property Locale As String = "" - Public Property Referrer As String = "" - Public Property WLWRequest As Boolean = False - Public Property UiTimeZone As TimeZoneInfo - Public Property Security As ContextSecurity - Public Property LegacyEntryId As Integer = -1 -#End Region - -#Region " IPropertyAccess Implementation " - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As System.Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Select Case strPropertyName.ToLower - Case "blogmoduleid" - Return (BlogModuleId.ToString(OutputFormat, formatProvider)) - Case "blogid" - Return (BlogId.ToString(OutputFormat, formatProvider)) - Case "Postid", "contentitemid", "postid", "post" - Return (ContentItemId.ToString(OutputFormat, formatProvider)) - Case "termid", "term" - Return (TermId.ToString(OutputFormat, formatProvider)) - Case "categories" - Return Categories - Case "authorid", "author" - Return (AuthorId.ToString(OutputFormat, formatProvider)) - Case "enddate" - Return (EndDate.ToString(OutputFormat, formatProvider)) - Case "enddateornow" - Return (EndDateOrNow.ToString(OutputFormat, formatProvider)) - Case "blogselected" - Return CBool(BlogId > -1).ToString() - Case "postselected" - Return CBool(ContentItemId > -1).ToString() - Case "termselected" - Return CBool(TermId > -1).ToString() - Case "authorselected" - Return CBool(AuthorId > -1).ToString() - Case "ismultilingualsite" - Return IsMultiLingualSite.ToString() - Case "showlocale" - Return ShowLocale - Case "locale" - Select Case strFormat.ToLower - Case "3" - Return Threading.Thread.CurrentThread.CurrentCulture.ThreeLetterISOLanguageName - Case "ietf" - Return Threading.Thread.CurrentThread.CurrentCulture.IetfLanguageTag - Case "displayname", "display" - Return Threading.Thread.CurrentThread.CurrentCulture.DisplayName - Case "englishname", "english" - Return Threading.Thread.CurrentThread.CurrentCulture.EnglishName - Case "nativename", "native" - Return Threading.Thread.CurrentThread.CurrentCulture.NativeName - Case "generic", "2" - Return Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName - Case Else - Return Locale - End Select - Case "searchstring" - Return SearchString - Case "issearch" - Return CBool(SearchString <> "").ToString() - Case "referrer" - Return Referrer - Case Else - If RequestParams(strPropertyName) IsNot Nothing Then - Return RequestParams(strPropertyName) - Else - PropertyNotFound = True - End If - End Select - Return DotNetNuke.Common.Utilities.Null.NullString - End Function - - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Common/BlogModuleBase.vb b/Server/Blog/Components/Common/BlogModuleBase.vb deleted file mode 100644 index bd6ef901..00000000 --- a/Server/Blog/Components/Common/BlogModuleBase.vb +++ /dev/null @@ -1,184 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Web.Client.ClientResourceManagement -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Framework -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.Entities.Terms -Imports DotNetNuke.Modules.Blog.Templating -Imports DotNetNuke.Services.Localization -Imports DotNetNuke.UI.Utilities -Imports DotNetNuke.Web.Client -Imports DotNetNuke.Framework.JavaScriptLibraries - -Namespace Common - - Public Class BlogModuleBase - Inherits PortalModuleBase - -#Region " Private Members " -#End Region - -#Region " Properties " - Private _blogContext As BlogContextInfo - Public Property BlogContext() As BlogContextInfo - Get - If _blogContext Is Nothing Then - _blogContext = BlogContextInfo.GetBlogContext(Context, Me) - End If - Return _blogContext - End Get - Set(ByVal value As BlogContextInfo) - _blogContext = value - End Set - End Property - - Private _settings As ModuleSettings - Public Shadows Property Settings() As ModuleSettings - Get - If _settings Is Nothing Then - If ViewSettings.BlogModuleId = -1 Then - _settings = ModuleSettings.GetModuleSettings(ModuleConfiguration.ModuleID) - Else - _settings = ModuleSettings.GetModuleSettings(ViewSettings.BlogModuleId) - End If - End If - Return _settings - End Get - Set(ByVal value As ModuleSettings) - _settings = value - End Set - End Property - - Private _categories As Dictionary(Of String, TermInfo) - Public Property Categories() As Dictionary(Of String, TermInfo) - Get - If _categories Is Nothing Then - _categories = TermsController.GetTermsByVocabulary(ModuleId, Settings.VocabularyId, BlogContext.Locale) - End If - Return _categories - End Get - Set(ByVal value As Dictionary(Of String, TermInfo)) - _categories = value - End Set - End Property - - Private _viewSettings As ViewSettings - Public Property ViewSettings() As ViewSettings - Get - If _viewSettings Is Nothing Then _viewSettings = ViewSettings.GetViewSettings(TabModuleId) - Return _viewSettings - End Get - Set(ByVal value As ViewSettings) - _viewSettings = value - End Set - End Property - - Public Shadows ReadOnly Property Page As CDefault - Get - Return CType(MyBase.Page, CDefault) - End Get - End Property - - Private _BlogModuleMapPath As String = "" - Public ReadOnly Property BlogModuleMapPath As String - Get - If String.IsNullOrEmpty(_BlogModuleMapPath) Then - _BlogModuleMapPath = Server.MapPath("~/DesktopModules/Blog") & "\" - End If - Return _BlogModuleMapPath - End Get - End Property -#End Region - -#Region " Event Handlers " - Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load - - If Context.Items("BlogModuleBaseInitialized") Is Nothing Then - - JavaScript.RequestRegistration(CommonJs.jQuery) - JavaScript.RequestRegistration(CommonJs.jQueryUI) - Dim script As New StringBuilder - script.AppendLine("") - ClientAPI.RegisterClientScriptBlock(Page, "blogAppPath", script.ToString) - AddBlogService() - - Context.Items("BlogModuleBaseInitialized") = True - End If - - End Sub -#End Region - -#Region " Public Methods " - Public Sub AddBlogService() - - If Context.Items("BlogServiceAdded") Is Nothing Then - - JavaScript.RequestRegistration(CommonJs.DnnPlugins) - ServicesFramework.Instance.RequestAjaxScriptSupport() - ServicesFramework.Instance.RequestAjaxAntiForgerySupport() - AddJavascriptFile("dotnetnuke.blog.js", 70) - - ' Load initialization snippet - Dim scriptBlock As String = ReadFile(DotNetNuke.Common.ApplicationMapPath & "\DesktopModules\Blog\js\dotnetnuke.blog.pagescript.js") - Dim tr As New BlogTokenReplace(BlogContext.BlogModuleId) - tr.AddResources("~/DesktopModules/Blog/App_LocalResources/SharedResources.resx") - scriptBlock = tr.ReplaceTokens(scriptBlock) - scriptBlock = "" - Page.ClientScript.RegisterClientScriptBlock([GetType], "BlogServiceScript", scriptBlock) - - Context.Items("BlogServiceAdded") = True - End If - - End Sub - - Public Sub AddJavascriptFile(jsFilename As String, priority As Integer) - Page.AddJavascriptFile(Settings.Version, jsFilename, priority) - End Sub - - Public Sub AddJavascriptFile(jsFilename As String, name As String, version As String, priority As Integer) - Page.AddJavascriptFile(Settings.Version, jsFilename, name, version, priority) - End Sub - - Public Sub AddCssFile(cssFilename As String) - Page.AddCssFile(Settings.Version, cssFilename) - End Sub - - Public Sub AddCssFile(cssFilename As String, name As String, version As String) - Page.AddCssFile(Settings.Version, cssFilename, name, version) - End Sub - - Public Function LocalizeJSString(resourceKey As String) As String - Return ClientAPI.GetSafeJSString(LocalizeString(resourceKey)) - End Function - - Public Function LocalizeJSString(resourceKey As String, resourceFile As String) As String - Return ClientAPI.GetSafeJSString(Localization.GetString(resourceKey, resourceFile)) - End Function -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Common/DynatreeItem.vb b/Server/Blog/Components/Common/DynatreeItem.vb deleted file mode 100644 index 2cee91ab..00000000 --- a/Server/Blog/Components/Common/DynatreeItem.vb +++ /dev/null @@ -1,31 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Namespace Common - Public Class DynatreeItem - Public Property title As String = "" - Public Property key As String = "" - Public Property icon As Boolean = False - Public Property expand As Boolean = True - Public Property isFolder As Boolean = True - Public Property [select] As Boolean = False - Public Property children As New List(Of DynatreeItem) - End Class -End Namespace diff --git a/Server/Blog/Components/Common/Extensions.vb b/Server/Blog/Components/Common/Extensions.vb index 3abd096c..fb8cae79 100644 --- a/Server/Blog/Components/Common/Extensions.vb +++ b/Server/Blog/Components/Common/Extensions.vb @@ -18,434 +18,11 @@ ' DEALINGS IN THE SOFTWARE. ' -Imports System.Linq -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.Entities.Terms -Imports System.Xml Imports System.Runtime.CompilerServices -Imports DotNetNuke.Web.Client.ClientResourceManagement -Imports DotNetNuke.Web.Client -Imports System.Globalization Namespace Common Module Extensions -#Region " Collection Read Extensions " - - Public Sub ReadValue(ByRef ValueTable As Hashtable, ValueName As String, ByRef Variable As Integer) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Integer) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As Hashtable, ValueName As String, ByRef Variable As Long) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Long) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As Hashtable, ValueName As String, ByRef Variable As String) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), String) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As Hashtable, ValueName As String, ByRef Variable As Boolean) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Boolean) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As Hashtable, ValueName As String, ByRef Variable As Date) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Date) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As Hashtable, ValueName As String, ByRef Variable As SummaryType) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(CType(ValueTable.Item(ValueName), Integer), SummaryType) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As Hashtable, ValueName As String, ByRef Variable As LocalizationType) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(CType(ValueTable.Item(ValueName), Integer), LocalizationType) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As Hashtable, ValueName As String, ByRef Variable As TimeSpan) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = TimeSpan.Parse(CType(ValueTable.Item(ValueName), String)) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As NameValueCollection, ValueName As String, ByRef Variable As Integer) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Integer) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As NameValueCollection, ValueName As String, ByRef Variable As Long) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Long) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As NameValueCollection, ValueName As String, ByRef Variable As String) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), String) - Variable = (New DotNetNuke.Security.PortalSecurity).InputFilter(Variable, DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup Or DotNetNuke.Security.PortalSecurity.FilterFlag.NoScripting) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As NameValueCollection, ValueName As String, ByRef Variable As Boolean) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Boolean) - Catch ex As Exception - Select Case ValueTable.Item(ValueName).ToLower - Case "on", "yes" - Variable = True - Case Else - Variable = False - End Select - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As NameValueCollection, ValueName As String, ByRef Variable As Date) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Date) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As NameValueCollection, ValueName As String, ByRef Variable As TimeSpan) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = TimeSpan.Parse(CType(ValueTable.Item(ValueName), String)) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ValueTable As Dictionary(Of String, String), ValueName As String, ByRef Variable As Integer) - If ValueTable.ContainsKey(ValueName) Then - Try - Variable = CType(ValueTable.Item(ValueName), Integer) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ValueTable As Dictionary(Of String, String), ValueName As String, ByRef Variable As String) - If ValueTable.ContainsKey(ValueName) Then - Try - Variable = CType(ValueTable.Item(ValueName), String) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ValueTable As Dictionary(Of String, String), ValueName As String, ByRef Variable As Boolean) - If ValueTable.ContainsKey(ValueName) Then - Try - Variable = CType(ValueTable.Item(ValueName), Boolean) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ValueTable As Dictionary(Of String, String), ValueName As String, ByRef Variable As Date) - If ValueTable.ContainsKey(ValueName) Then - Try - Variable = CType(ValueTable.Item(ValueName), Date) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ValueTable As Dictionary(Of String, String), ValueName As String, ByRef Variable As TimeSpan) - If ValueTable.ContainsKey(ValueName) Then - Try - Variable = TimeSpan.Parse(CType(ValueTable.Item(ValueName), String)) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As StateBag, ValueName As String, ByRef Variable As Integer) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Integer) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As StateBag, ValueName As String, ByRef Variable As Long) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Long) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As StateBag, ValueName As String, ByRef Variable As String) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), String) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As StateBag, ValueName As String, ByRef Variable As Boolean) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Boolean) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As StateBag, ValueName As String, ByRef Variable As Date) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.Item(ValueName), Date) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As StateBag, ValueName As String, ByRef Variable As TimeSpan) - If Not ValueTable.Item(ValueName) Is Nothing Then - Try - Variable = TimeSpan.Parse(CType(ValueTable.Item(ValueName), String)) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As XmlNode, ValueName As String, ByRef Variable As Integer) - If Not ValueTable.SelectSingleNode(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.SelectSingleNode(ValueName).InnerText, Integer) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As XmlNode, ValueName As String, ByRef Variable As Long) - If Not ValueTable.SelectSingleNode(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.SelectSingleNode(ValueName).InnerText, Long) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As XmlNode, ValueName As String, ByRef Variable As String) - If Not ValueTable.SelectSingleNode(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.SelectSingleNode(ValueName).InnerText, String) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As XmlNode, ValueName As String, ByRef Variable As Boolean) - If Not ValueTable.SelectSingleNode(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.SelectSingleNode(ValueName).InnerText, Boolean) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As XmlNode, ValueName As String, ByRef Variable As Date) - If Not ValueTable.SelectSingleNode(ValueName) Is Nothing Then - Try - Variable = CType(ValueTable.SelectSingleNode(ValueName).InnerText, Date) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As XmlNode, ValueName As String, ByRef Variable As SummaryType) - If Not ValueTable.SelectSingleNode(ValueName) Is Nothing Then - Try - Variable = CType(CType(ValueTable.SelectSingleNode(ValueName).InnerText, Integer), SummaryType) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As XmlNode, ValueName As String, ByRef Variable As LocalizationType) - If Not ValueTable.SelectSingleNode(ValueName) Is Nothing Then - Try - Variable = CType(CType(ValueTable.SelectSingleNode(ValueName).InnerText, Integer), LocalizationType) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As XmlNode, ValueName As String, ByRef Variable As TimeSpan) - If Not ValueTable.SelectSingleNode(ValueName) Is Nothing Then - Try - Variable = TimeSpan.Parse(CType(ValueTable.SelectSingleNode(ValueName).InnerText, String)) - Catch ex As Exception - End Try - End If - End Sub - - - Public Sub ReadValue(ByRef ValueTable As XmlNode, ValueName As String, ByRef Variable As LocalizedText) - If Not ValueTable.SelectSingleNode(ValueName) Is Nothing Then - If Not ValueTable.SelectSingleNode(ValueName).SelectSingleNode("MLText") Is Nothing Then - If Variable Is Nothing Then Variable = New LocalizedText - For Each t As XmlNode In ValueTable.SelectSingleNode(ValueName).SelectSingleNode("MLText").SelectNodes("Text") - Variable.Add(t.Attributes("Locale").InnerText, t.InnerText) - Next - End If - End If - End Sub -#End Region - -#Region " Conversion Extensions " - - Public Function ToInt(var As Boolean) As Integer - If var Then - Return 1 - Else - Return 0 - End If - End Function - - - Public Function ToYesNo(var As Boolean) As String - If var Then - Return "Yes" - Else - Return "No" - End If - End Function - - - Public Function ToInt(var As String) As Integer - If IsNumeric(var) Then - Return Integer.Parse(var) - Else - Return -1 - End If - End Function - - - Public Function ToBool(var As Integer) As Boolean - Return CBool(var > 0) - End Function - - - Public Function ToStringArray(terms As List(Of TermInfo)) As String() - Return terms.Select(Function(x) - Return x.Name - End Function).ToArray - End Function - - - Public Function ToTermIDString(terms As List(Of TermInfo)) As String - Return ToTermIDString(terms, ";") - End Function - - - Public Function ToTermIDString(terms As List(Of TermInfo), separator As String) As String - Dim res As New List(Of String) - For Each t As TermInfo In terms - res.Add(t.TermId.ToString) - Next - Return String.Join(separator, res.ToArray) - End Function - - - Public Function ToStringOrZero(value As Integer?) As String - If value Is Nothing Then - Return "0" - Else - Return value.ToString - End If - End Function -#End Region - -#Region " Other " Public Function FindControlByID(Control As Control, id As String) As Control Dim found As Control = Nothing @@ -475,109 +52,87 @@ Namespace Common Return found End Function - - Public Function OutputHtml(encodedHtml As String, strFormat As String) As String - Select Case strFormat.ToLower - Case "" - Return HttpUtility.HtmlDecode(encodedHtml) - Case "js" - Return HttpUtility.HtmlDecode(encodedHtml).Replace("""", "\""").Replace("'", "\'").Replace(vbCrLf, "\r\n") - Case Else - If IsNumeric(strFormat) Then - Return RemoveHtmlTags(HttpUtility.HtmlDecode(encodedHtml)).SubstringWithoutException(0, Integer.Parse(strFormat)) - Else - Return HttpUtility.HtmlDecode(encodedHtml) - End If - End Select - End Function - - - Public Function SubstringWithoutException(input As String, startIndex As Integer, length As Integer) As String - If String.IsNullOrEmpty(input) Then Return "" - If startIndex > 0 Then - If startIndex >= input.Length Then - Return "" - End If - If startIndex + length > input.Length Then - Return input.Substring(startIndex, input.Length - startIndex) - Else - Return input.Substring(startIndex, length) - End If - Else - If length > input.Length Then - Return input.Substring(0, input.Length - startIndex) - Else - Return input.Substring(0, length) - End If - End If - End Function - - - Public Sub WriteAttachmentToXml(attachment As BlogML.Xml.BlogMLAttachment, writer As System.Xml.XmlWriter) - writer.WriteStartElement("File") - writer.WriteElementString("Path", attachment.Path) - writer.WriteStartElement("Data") - writer.WriteBase64(attachment.Data, 0, attachment.Data.Length - 1) - writer.WriteEndElement() ' Data - writer.WriteEndElement() ' File - End Sub - - - Public Sub AddJavascriptFile(page As Page, moduleVersion As String, jsFilename As String, priority As Integer) - If DotNetNuke.Entities.Host.Host.CrmEnableCompositeFiles Then - ClientResourceManager.RegisterScript(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/js/" & jsFilename), priority) - Else - ClientResourceManager.RegisterScript(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/js/" & jsFilename) + "?_=" + moduleVersion, priority) - End If - End Sub - - - Public Sub AddJavascriptFile(page As Page, moduleVersion As String, jsFilename As String, name As String, version As String, priority As Integer) - If DotNetNuke.Entities.Host.Host.CrmEnableCompositeFiles Then - ClientResourceManager.RegisterScript(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/js/" & jsFilename), priority, "DnnBodyProvider", name, version) - Else - ClientResourceManager.RegisterScript(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/js/" & jsFilename) + "?_=" + moduleVersion, priority, "DnnBodyProvider", name, version) - End If - End Sub - - - Public Sub AddCssFile(page As Page, moduleVersion As String, cssFilename As String) - If DotNetNuke.Entities.Host.Host.CrmEnableCompositeFiles Then - ClientResourceManager.RegisterStyleSheet(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/css/" & cssFilename), FileOrder.Css.ModuleCss) - Else - ClientResourceManager.RegisterStyleSheet(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/css/" & cssFilename) + "?_=" + moduleVersion, FileOrder.Css.ModuleCss) - End If - End Sub - - - Public Sub AddCssFile(page As Page, moduleVersion As String, cssFilename As String, name As String, version As String) - If DotNetNuke.Entities.Host.Host.CrmEnableCompositeFiles Then - ClientResourceManager.RegisterStyleSheet(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/css/" & cssFilename), FileOrder.Css.ModuleCss, "DnnPageHeaderProvider", name, version) - Else - ClientResourceManager.RegisterStyleSheet(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/css/" & cssFilename) + "?_=" + moduleVersion, FileOrder.Css.ModuleCss, "DnnPageHeaderProvider", name, version) - End If - End Sub - - - Public Function RemoveDiacritics(ByVal text As String) As String - If String.IsNullOrEmpty(text) Then - Return text - End If - - Dim normalizedString As String = text.Normalize(NormalizationForm.FormD) - Dim stringBuilder As StringBuilder = New StringBuilder() - - For Each c As Char In normalizedString - Dim unicodeCategory As UnicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c) - - If unicodeCategory <> UnicodeCategory.NonSpacingMark Then - stringBuilder.Append(c) - End If - Next - - Return stringBuilder.ToString().Normalize(NormalizationForm.FormC) - End Function -#End Region - + ' + 'Public Function OutputHtml(encodedHtml As String, strFormat As String) As String + ' Select Case strFormat.ToLower + ' Case "" + ' Return HttpUtility.HtmlDecode(encodedHtml) + ' Case "js" + ' Return HttpUtility.HtmlDecode(encodedHtml).Replace("""", "\""").Replace("'", "\'").Replace(vbCrLf, "\r\n") + ' Case Else + ' If IsNumeric(strFormat) Then + ' Return RemoveHtmlTags(HttpUtility.HtmlDecode(encodedHtml)).SubstringWithoutException(0, Integer.Parse(strFormat)) + ' Else + ' Return HttpUtility.HtmlDecode(encodedHtml) + ' End If + ' End Select + 'End Function + + ' + 'Public Function SubstringWithoutException(input As String, startIndex As Integer, length As Integer) As String + ' If String.IsNullOrEmpty(input) Then Return "" + ' If startIndex > 0 Then + ' If startIndex >= input.Length Then + ' Return "" + ' End If + ' If startIndex + length > input.Length Then + ' Return input.Substring(startIndex, input.Length - startIndex) + ' Else + ' Return input.Substring(startIndex, length) + ' End If + ' Else + ' If length > input.Length Then + ' Return input.Substring(0, input.Length - startIndex) + ' Else + ' Return input.Substring(0, length) + ' End If + ' End If + 'End Function + + ' + 'Public Sub WriteAttachmentToXml(attachment As BlogML.Xml.BlogMLAttachment, writer As System.Xml.XmlWriter) + ' writer.WriteStartElement("File") + ' writer.WriteElementString("Path", attachment.Path) + ' writer.WriteStartElement("Data") + ' writer.WriteBase64(attachment.Data, 0, attachment.Data.Length - 1) + ' writer.WriteEndElement() ' Data + ' writer.WriteEndElement() ' File + 'End Sub + + ' + 'Public Sub AddJavascriptFile(page As Page, moduleVersion As String, jsFilename As String, priority As Integer) + ' If DotNetNuke.Entities.Host.Host.CrmEnableCompositeFiles Then + ' ClientResourceManager.RegisterScript(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/js/" & jsFilename), priority) + ' Else + ' ClientResourceManager.RegisterScript(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/js/" & jsFilename) + "?_=" + moduleVersion, priority) + ' End If + 'End Sub + + ' + 'Public Sub AddJavascriptFile(page As Page, moduleVersion As String, jsFilename As String, name As String, version As String, priority As Integer) + ' If DotNetNuke.Entities.Host.Host.CrmEnableCompositeFiles Then + ' ClientResourceManager.RegisterScript(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/js/" & jsFilename), priority, "DnnBodyProvider", name, version) + ' Else + ' ClientResourceManager.RegisterScript(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/js/" & jsFilename) + "?_=" + moduleVersion, priority, "DnnBodyProvider", name, version) + ' End If + 'End Sub + + ' + 'Public Sub AddCssFile(page As Page, moduleVersion As String, cssFilename As String) + ' If DotNetNuke.Entities.Host.Host.CrmEnableCompositeFiles Then + ' ClientResourceManager.RegisterStyleSheet(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/css/" & cssFilename), FileOrder.Css.ModuleCss) + ' Else + ' ClientResourceManager.RegisterStyleSheet(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/css/" & cssFilename) + "?_=" + moduleVersion, FileOrder.Css.ModuleCss) + ' End If + 'End Sub + + ' + 'Public Sub AddCssFile(page As Page, moduleVersion As String, cssFilename As String, name As String, version As String) + ' If DotNetNuke.Entities.Host.Host.CrmEnableCompositeFiles Then + ' ClientResourceManager.RegisterStyleSheet(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/css/" & cssFilename), FileOrder.Css.ModuleCss, "DnnPageHeaderProvider", name, version) + ' Else + ' ClientResourceManager.RegisterStyleSheet(page, DotNetNuke.Common.ResolveUrl("~/DesktopModules/Blog/css/" & cssFilename) + "?_=" + moduleVersion, FileOrder.Css.ModuleCss, "DnnPageHeaderProvider", name, version) + ' End If + 'End Sub End Module End Namespace diff --git a/Server/Blog/Components/Common/Globals.vb b/Server/Blog/Components/Common/Globals.vb index c30fe26f..3fc64394 100644 --- a/Server/Blog/Components/Common/Globals.vb +++ b/Server/Blog/Components/Common/Globals.vb @@ -18,123 +18,9 @@ ' DEALINGS IN THE SOFTWARE. ' -Imports System.Linq -Imports DotNetNuke.Entities.Content.Taxonomy - Namespace Common Public Class Globals - -#Region " Constants " - Public Const SharedResourceFileName As String = "~/DesktopModules/Blog/App_LocalResources/SharedResources.resx" - Public Const glbAppName As String = "Blog" - Public Const glbImageHandlerPath As String = "~/DesktopModules/Blog/BlogImage.ashx" - Public Const glbPermittedFileExtensions As String = ".jpg,.png,.gif,.bmp," - Public Const glbTemplatesPath As String = "~/DesktopModules/Blog/Templates/" - Public Const glbServicesPath As String = "~/DesktopModules/Blog/API/" - Public Const BloggerPermission As String = "BLOGGER" - - Public Enum SummaryType - PlainTextIndependent = 0 - HtmlIndependent = 1 - HtmlPrecedesPost = 2 - End Enum - - Public Enum LocalizationType - None = 0 - Loose = 1 - Strict = 2 - End Enum -#End Region - -#Region " Dates " - Public Shared Function UtcToLocalTime(utcTime As Date, TimeZone As TimeZoneInfo) As Date - Return TimeZoneInfo.ConvertTimeFromUtc(utcTime, TimeZone) - End Function - - Public Shared Function ParseDate(DateString As String, Culture As String) As DateTime - Dim dtf As System.Globalization.DateTimeFormatInfo = New System.Globalization.CultureInfo(Culture, False).DateTimeFormat - Try - Return Date.Parse(DateString, dtf) - Catch ex As Exception - Return Nothing - End Try - End Function - - Public Shared Function IsValidDate(DateString As String, Culture As String) As Boolean - Dim dtf As System.Globalization.DateTimeFormatInfo = New System.Globalization.CultureInfo(Culture, False).DateTimeFormat - Try - Dim oDate As Date = Date.Parse(DateString, dtf) - Return True - Catch ex As Exception - Return False - End Try - End Function - - Public Shared Function GetLocalAddedTime(AddedDate As DateTime, PortalId As Integer, user As DotNetNuke.Entities.Users.UserInfo) As DateTime - Return TimeZoneInfo.ConvertTimeToUtc(AddedDate, user.Profile.PreferredTimeZone) - End Function -#End Region - -#Region " Other " - Public Shared Function GetBlogDirectoryMapPath(blogId As Integer) As String - Return String.Format("{0}Blog\Files\{1}\", DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectoryMapPath, blogId) - End Function - Public Shared Function GetBlogDirectoryPath(blogId As Integer) As String - Return String.Format("{0}Blog/Files/{1}/", DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectory, blogId) - End Function - Public Shared Function GetPostDirectoryMapPath(blogId As Integer, postId As Integer) As String - Return String.Format("{0}Blog\Files\{1}\{2}\", DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectoryMapPath, blogId, postId) - End Function - Public Shared Function GetPostDirectoryPath(blogId As Integer, postId As Integer) As String - Return String.Format("{0}Blog/Files/{1}/{2}/", DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectory, blogId, postId) - End Function - Public Shared Function GetPostDirectoryMapPath(post As Entities.Posts.PostInfo) As String - Return GetPostDirectoryMapPath(post.BlogID, post.ContentItemId) - End Function - Public Shared Function GetPostDirectoryPath(post As Entities.Posts.PostInfo) As String - Return GetPostDirectoryPath(post.BlogID, post.ContentItemId) - End Function - Public Shared Function GetTempPostDirectoryMapPath(blogId As Integer) As String - Return String.Format("{0}Blog\Files\{1}\_temp_images\", DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectoryMapPath, blogId) - End Function - Public Shared Function GetTempPostDirectoryPath(blogId As Integer) As String - Return String.Format("{0}Blog/Files/{1}/_temp_images/", DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectory, blogId) - End Function - - Public Shared Function ManifestFilePath(tabId As Integer, moduleId As Integer) As String - Return String.Format("~/DesktopModules/Blog/API/Modules/Manifest?TabId={0}&ModuleId={1}", tabId, moduleId) - End Function - - Public Shared Function GetAString(Value As Object) As String - If Value Is Nothing Then - Return "" - Else - If Value Is DBNull.Value Then - Return "" - Else - Return CType(Value, String) - End If - End If - End Function - - Public Shared Function ReadFile(fileName As String) As String - If Not IO.File.Exists(fileName) Then Return "" - Using sr As New IO.StreamReader(fileName) - Return sr.ReadToEnd - End Using - End Function - - Public Shared Sub WriteToFile(filePath As String, text As String) - WriteToFile(filePath, text, False) - End Sub - Public Shared Sub WriteToFile(filePath As String, text As String, append As Boolean) - Using sw As New IO.StreamWriter(filePath, append) - sw.Write(text) - sw.Flush() - End Using - End Sub - Public Shared Function GetResource(resourceName As String) As String Dim res As String = "" Using stream As IO.Stream = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(resourceName) @@ -144,143 +30,5 @@ Namespace Common End Using Return res End Function - - Public Shared Function FormatBoolean(value As Boolean, format As String) As String - If String.IsNullOrEmpty(format) Then - Return value.ToString - End If - If format.Contains(";") Then - If value Then - Return Left(format, format.IndexOf(";")) - Else - Return Mid(format, format.IndexOf(";") + 2) - End If - End If - Return value.ToString - End Function - - Public Shared Function GetSummary(body As String, autoGenerateLength As Integer, summaryModel As SummaryType, encoded As Boolean) As String - If String.IsNullOrEmpty(body) Then Return "" - Dim res As String = body - If encoded Then - res = HttpUtility.HtmlDecode(res) - End If - res = TryToGetFirstParagraph(res) - res = RemoveHtmlTags(res).SubstringWithoutException(0, autoGenerateLength) - If res.Length >= autoGenerateLength Then res &= " ..." - If Not summaryModel = SummaryType.PlainTextIndependent Then - res = String.Format("

{0}

", res) - End If - If encoded Then - Return HttpUtility.HtmlEncode(res) - Else - Return res - End If - End Function - - Public Shared Function TryToGetFirstParagraph(inputString As String) As String - Dim m As Match = Regex.Match(inputString, "(?s)(?i)]*>((?:(?!

).)*)(?-i)(?-s)") - If m.Success Then - Return m.Groups(1).Value - End If - Return inputString - End Function - - Public Shared Function RemoveHtmlTags(inputString As String) As String - inputString = Regex.Replace(inputString, "<[^>]+>", "") - Return (New DotNetNuke.Security.PortalSecurity).InputFilter(inputString, DotNetNuke.Security.PortalSecurity.FilterFlag.NoScripting Or DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup) - End Function - - Friend Shared Function GetPortalVocabularies(portalId As Integer) As List(Of Vocabulary) - Dim cntVocab As IVocabularyController = DotNetNuke.Entities.Content.Common.Util.GetVocabularyController() - Dim colVocabularies As IQueryable(Of Vocabulary) = cntVocab.GetVocabularies() - Dim portalVocabularies As IQueryable(Of Vocabulary) = From v In colVocabularies Where v.ScopeTypeId = 2 And v.ScopeId = portalId - Return portalVocabularies.ToList() - End Function - - Public Shared Function GetSafePageName(pageName As String) As String - Return Regex.Replace(Regex.Replace(pageName, "[^\w^\d]", "-").Trim("-"c), "-+", "-").RemoveDiacritics() - End Function - - Public Shared Sub RemoveOldTimeStampedFiles(dir As IO.DirectoryInfo) - Dim today As String = Date.Now.ToString("yyyy-MM-dd") - Dim deleteList As New List(Of String) - For Each f As IO.FileInfo In dir.GetFiles - Dim m As Match = Regex.Match(f.Name, "^(\d\d\d\d-\d\d-\d\d)-") - If m.Success Then - If m.Groups(1).Value < today Then - deleteList.Add(f.FullName) - End If - End If - Next - For Each f As String In deleteList - Try - IO.File.Delete(f) - Catch ex As Exception - End Try - Next - End Sub - - Public Shared Function GetRolesByGroup(portalId As Integer, roleGroupId As Integer) As List(Of DotNetNuke.Security.Roles.RoleInfo) - Return DotNetNuke.Security.Roles.RoleProvider.Instance.GetRoles(portalId).Cast(Of DotNetNuke.Security.Roles.RoleInfo).Where(Function(r) r.RoleGroupID = roleGroupId).ToList - End Function - - Public Shared Function GetRolesByPortal(portalId As Integer) As List(Of DotNetNuke.Security.Roles.RoleInfo) - Return DotNetNuke.Security.Roles.RoleProvider.Instance.GetRoles(portalId).Cast(Of DotNetNuke.Security.Roles.RoleInfo).ToList - End Function - - Public Shared Function SafeString(input As String, filter As DotNetNuke.Security.PortalSecurity.FilterFlag) As String - Dim ps As New DotNetNuke.Security.PortalSecurity - Return ps.InputFilter(input, filter) - End Function - - Public Shared Function SafeString(input As String) As String - Return SafeString(input, DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup And DotNetNuke.Security.PortalSecurity.FilterFlag.NoProfanity And DotNetNuke.Security.PortalSecurity.FilterFlag.NoScripting And DotNetNuke.Security.PortalSecurity.FilterFlag.NoSQL) - End Function - - Public Shared Function SafeHtml(input As String) As String - Return SafeString(input, DotNetNuke.Security.PortalSecurity.FilterFlag.NoProfanity And DotNetNuke.Security.PortalSecurity.FilterFlag.NoScripting And DotNetNuke.Security.PortalSecurity.FilterFlag.NoSQL) - End Function - - Public Shared Function SafeStringSimpleHtml(input As String) As String - input = SafeString(input) - input = Regex.Replace(input, "(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?", AddressOf ReplaceLink) - input = input.Replace(vbCrLf, "
") - Return input - End Function - - Public Shared Function CleanStringForXmlAttribute(input As String) As String - Return input.Replace("&", "and").Replace("""", """) - End Function - - Public Shared Function ReplaceLink(m As Match) As String - Dim link As String = m.Value - Return String.Format("{0}", link) - End Function - - Public Shared Function readElement(reader As System.Xml.XmlReader, ElementName As String) As String - If (Not reader.NodeType = System.Xml.XmlNodeType.Element) OrElse reader.Name <> ElementName Then - reader.ReadToFollowing(ElementName) - End If - If reader.NodeType = System.Xml.XmlNodeType.Element Then - Return reader.ReadElementContentAsString - Else - Return "" - End If - End Function - - Public Shared Function readAttribute(reader As System.Xml.XmlReader, attributeName As String) As String - If (Not reader.NodeType = System.Xml.XmlNodeType.Attribute) OrElse reader.Name <> attributeName Then - reader.ReadToFollowing(attributeName) - End If - If reader.NodeType = System.Xml.XmlNodeType.Attribute Then - Return reader.ReadContentAsString - Else - Return "" - End If - End Function -#End Region - End Class - End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Common/Image.vb b/Server/Blog/Components/Common/Image.vb deleted file mode 100644 index 5fbd7f12..00000000 --- a/Server/Blog/Components/Common/Image.vb +++ /dev/null @@ -1,175 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Drawing.Imaging -Imports System.Drawing - -Namespace Common - Public Class Image - - Public Const glbJpegFileType As String = ".jpg" - Public Const glbPngFileType As String = ".png" - Public Const glbGifFileType As String = ".gif" - - Private _thisImage As Bitmap - Private _imgFormat As ImageFormat - Private _imgRatio As Single - Private _extension As String = "" - Private _newExtension As String = "" - Private _originalFile As String = "" - - Public Property IsValidExtension As Boolean = True - Public Property MimeType As String = "image/jpeg" - Public Property OriginalWidth As Integer - Public Property OriginalHeight As Integer - Public Property Scale As Double - Public Property NewHeight As Integer - Public Property NewWidth As Integer - - Public Sub New(originalFilePath As String) - _originalFile = originalFilePath - _extension = IO.Path.GetExtension(originalFilePath).ToLower - If _extension = glbGifFileType Or _extension = glbJpegFileType Or _extension = glbPngFileType Then - _thisImage = New Bitmap(originalFilePath) - _imgFormat = _thisImage.RawFormat - OriginalWidth = _thisImage.Width - OriginalHeight = _thisImage.Height - _imgRatio = Convert.ToSingle(OriginalHeight / OriginalWidth) - Select Case _extension - Case glbGifFileType - MimeType = "image/gif" - Case glbPngFileType - MimeType = "image/png" - End Select - Else - IsValidExtension = False - End If - End Sub - - Public Function ResizeImage(maxWidth As Integer, maxHeight As Integer, crop As Boolean) As String - - Select Case _extension - Case glbGifFileType.ToLower - _newExtension = glbGifFileType - Return ResizeImage(maxWidth, maxHeight, crop, ImageFormat.Gif) - Case glbPngFileType.ToLower - _newExtension = glbPngFileType - Return ResizeImage(maxWidth, maxHeight, crop, ImageFormat.Png) - Case Else ' jpg - _newExtension = glbJpegFileType - Return ResizeImage(maxWidth, maxHeight, crop, ImageFormat.Jpeg) - End Select - - End Function - - Public Function ResizeImage(maxWidth As Integer, maxHeight As Integer, crop As Boolean, format As ImageFormat) As String - - Try - - Dim backBuffer As Bitmap = Nothing - Dim backBufferGraphics As Graphics = Nothing - - If maxHeight = -1 Then - - NewHeight = CInt(Math.Floor(_imgRatio * maxWidth)) - Scale = maxWidth / OriginalWidth - backBuffer = New Bitmap(maxWidth, NewHeight, Drawing.Imaging.PixelFormat.Format32bppRgb) - backBufferGraphics = Graphics.FromImage(backBuffer) - backBufferGraphics.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic - backBufferGraphics.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias - backBufferGraphics.DrawImage(_thisImage, 0, 0, maxWidth, NewHeight) - - ElseIf maxWidth = -1 Then - - NewWidth = CInt(Math.Floor(maxHeight / _imgRatio)) - Scale = maxHeight / OriginalHeight - backBuffer = New Bitmap(NewWidth, maxHeight, Drawing.Imaging.PixelFormat.Format32bppRgb) - backBufferGraphics = Graphics.FromImage(backBuffer) - backBufferGraphics.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic - backBufferGraphics.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias - backBufferGraphics.DrawImage(_thisImage, 0, 0, NewWidth, maxHeight) - - ElseIf crop Then - - Dim WidthOverflow As Boolean = False - Scale = maxWidth / OriginalWidth - If (maxHeight / OriginalHeight) > Scale Then - Scale = (maxHeight / OriginalHeight) - WidthOverflow = True - End If - NewHeight = maxHeight - NewWidth = maxWidth - backBuffer = New Bitmap(NewWidth, NewHeight, Drawing.Imaging.PixelFormat.Format32bppRgb) - backBufferGraphics = Graphics.FromImage(backBuffer) - backBufferGraphics.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic - backBufferGraphics.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias - If WidthOverflow Then - Dim Overflow As Integer = Convert.ToInt32(((Scale * OriginalWidth) - maxWidth) / 2) - backBufferGraphics.DrawImage(_thisImage, -1 * Overflow, 0, Convert.ToInt32(OriginalWidth * Scale), NewHeight) - Else - Dim Overflow As Integer = Convert.ToInt32(((Scale * OriginalHeight) - maxHeight) / 2) - backBufferGraphics.DrawImage(_thisImage, 0, -1 * Overflow, NewWidth, Convert.ToInt32(OriginalHeight * Scale)) - End If - - Else - - Scale = maxWidth / OriginalWidth - If (maxHeight / OriginalHeight) < Scale Then - Scale = (maxHeight / OriginalHeight) - End If - If Scale > 1 Then - Scale = 1 - NewHeight = OriginalHeight - NewWidth = OriginalWidth - Else - NewHeight = Convert.ToInt32(OriginalHeight * Scale) - NewWidth = Convert.ToInt32(OriginalWidth * Scale) - End If - backBuffer = New Bitmap(NewWidth, NewHeight, Drawing.Imaging.PixelFormat.Format32bppRgb) - backBufferGraphics = Graphics.FromImage(backBuffer) - backBufferGraphics.InterpolationMode = Drawing.Drawing2D.InterpolationMode.HighQualityBicubic - backBufferGraphics.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias - backBufferGraphics.DrawImage(_thisImage, 0, 0, NewWidth, NewHeight) - - End If - - Dim newFilePath As String = _originalFile.Substring(0, _originalFile.LastIndexOf(".")) & String.Format("-{0}-{1}-{2}", maxWidth, maxHeight, crop) & _newExtension - backBuffer.Save(newFilePath, _imgFormat) - Return newFilePath - - Catch ex As Exception - - Throw New Exception(ex.Message) - - End Try - - End Function - - Public Sub Dispose() - Try - _thisImage.Dispose() - _thisImage = Nothing - Catch - End Try - End Sub - - - End Class -End Namespace diff --git a/Server/Blog/Components/Common/LocalizedText.vb b/Server/Blog/Components/Common/LocalizedText.vb deleted file mode 100644 index 8b465a8c..00000000 --- a/Server/Blog/Components/Common/LocalizedText.vb +++ /dev/null @@ -1,221 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Xml -Imports System.Xml.Schema -Imports System.Xml.Serialization - -Namespace Common - _ - Public Class LocalizedText - Implements IXmlSerializable - -#Region " Properties " - Private _texts As New Dictionary(Of String, String) - Public ReadOnly Property Locales As List(Of String) - Get - Dim res As New List(Of String) - For Each k As String In _texts.Keys - res.Add(k) - Next - Return res - End Get - End Property - Default Public Property Item(ByVal key As String) As String - Get - If ContainsKey(key) Then - Return _texts.Item(key) - Else - Return "" - End If - End Get - Set(ByVal value As String) - _texts.Item(key) = value - End Set - End Property -#End Region - -#Region " Public Methods " - Public Function GetDictionary() As Dictionary(Of String, String) - Return _texts - End Function - Public Function ContainsKey(ByVal key As String) As Boolean - Return _texts.ContainsKey(key) - End Function - Public Sub Add(ByVal key As String, ByVal value As String) - _texts.Add(key, value) - End Sub - Public Function Remove(ByVal key As String) As Boolean - Return _texts.Remove(key) - End Function -#End Region - -#Region " Constructors " - Public Sub New() - MyBase.New() - End Sub - - Public Sub New(ByVal ir As IDataReader, ByVal FieldName As String) - MyBase.New() - Do While ir.Read - If ir.Item(FieldName) IsNot DBNull.Value Then - _texts.Add(CStr(ir.Item("Locale")), CStr(ir.Item(FieldName))) - End If - Loop - ir.Close() - ir.Dispose() - End Sub -#End Region - -#Region " (De)Serialization " - Public Function ToJSONArray(ByVal DefaultLocale As String, ByVal DefaultText As String) As String - Dim res As String = "" - For Each localeCode As String In _texts.Keys - res &= ", """ & localeCode.Replace("-", "_") & """: """ - res &= CStr(_texts.Item(localeCode)) - res &= """" - Next - res &= ", """ & DefaultLocale.Replace("-", "_") & """: """ - res &= DefaultText - res &= """" - Return res - End Function - - Public Overrides Function ToString() As String - Dim res As New StringBuilder - Dim xw As XmlWriter = XmlTextWriter.Create(res) - xw.WriteStartElement("MLText") - For Each l As String In _texts.Keys - xw.WriteStartElement("Text") - xw.WriteAttributeString("Locale", l) - xw.WriteString(_texts.Item(l)) - xw.WriteEndElement() - Next - xw.WriteEndElement() - xw.Flush() - Return res.ToString - End Function - - Public Sub Deserialize(ByVal xml As String) - Dim str As New IO.StringReader(xml) - Dim xr As XmlReader = XmlTextReader.Create(str) - xr.MoveToContent() - Do While xr.ReadToFollowing("Text") - If xr.MoveToAttribute("Locale") Then - Dim l As String = xr.ReadContentAsString - xr.MoveToContent() - Dim s As String = xr.ReadElementContentAsString - _texts.Add(l, s) - End If - Loop - End Sub - - Public Sub FromXml(xml As XmlNode) - If xml Is Nothing Then Exit Sub - - End Sub - - Public Function ToConcatenatedString() As String - Dim res As New StringBuilder - For Each l As String In _texts.Keys - res.Append(_texts.Item(l)) - res.Append(" ") - Next - Return res.ToString - End Function -#End Region - -#Region " IXmlSerializable Implementation " - Public Function GetSchema() As XmlSchema Implements IXmlSerializable.GetSchema - Return Nothing - End Function - - Private Function readElement(ByVal reader As XmlReader, ByVal ElementName As String) As String - If (Not reader.NodeType = XmlNodeType.Element) OrElse reader.Name <> ElementName Then - reader.ReadToFollowing(ElementName) - End If - If reader.NodeType = XmlNodeType.Element Then - Return reader.ReadElementContentAsString - Else - Return "" - End If - End Function - - Private Function readAttribute(ByVal reader As XmlReader, ByVal AttributeName As String) As String - If reader.HasAttributes Then - reader.MoveToAttribute(AttributeName) - Return reader.Value - Else - Return "" - End If - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' ReadXml fills the object (de-serializes it) from the XmlReader passed - ''' - ''' - ''' The XmlReader that contains the xml for the object - ''' - ''' [pdonker] 05/21/2008 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub ReadXml(ByVal reader As XmlReader) Implements IXmlSerializable.ReadXml - Do While reader.Name = "Text" - reader.ReadStartElement("Text") - Dim loc As String = readAttribute(reader, "Locale") - If loc <> "" Then - Dim txt As String = reader.ReadElementContentAsString - Add(loc, txt) - End If - reader.ReadEndElement() ' Text - Loop - End Sub - - Public Sub ReadXml(ByVal xMLText As XmlNode) - If xMLText Is Nothing Then Exit Sub - For Each xText As XmlNode In xMLText.ChildNodes - Dim locale As String = xText.Attributes("Locale").InnerText - _texts.Add(locale, xText.InnerText) - Next - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' WriteXml converts the object to Xml (serializes it) and writes it using the XmlWriter passed - ''' - ''' - ''' The XmlWriter that contains the xml for the object - ''' - ''' [pdonker] 05/21/2008 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub WriteXml(ByVal writer As XmlWriter) Implements IXmlSerializable.WriteXml - For Each locale As String In _texts.Keys - writer.WriteStartElement("Text") - writer.WriteAttributeString("Locale", locale) - writer.WriteCData(_texts.Item(locale)) - writer.WriteEndElement() - Next - End Sub -#End Region - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Common/ModuleSettings.vb b/Server/Blog/Components/Common/ModuleSettings.vb deleted file mode 100644 index 00f18729..00000000 --- a/Server/Blog/Components/Common/ModuleSettings.vb +++ /dev/null @@ -1,280 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Xml -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Services.Tokens -Imports DotNetNuke.Modules.Blog.Common.Globals - -Namespace Common - - Public Class ModuleSettings - Implements IPropertyAccess - -#Region " Private Members " - Private _allSettings As Hashtable = Nothing - Private _moduleId As Integer = -1 - Private _importedModuleId As Integer = -1 -#End Region - -#Region " Properties " - Public Property Version As String = "0.0.0" - Public Property AllowWLW As Boolean = False - Public Property AllowMultipleCategories As Boolean = True - Public Property VocabularyId As Integer = -1 - Public Property AllowAttachments As Boolean = True - Public Property SummaryModel As SummaryType = SummaryType.HtmlIndependent - Public Property StyleDetectionUrl As String = "" - Public Property WLWRecentPostsMax As Integer = 10 - Public Property AutoGenerateMissingSummary As Boolean = True - Public Property AutoGeneratedSummaryLength As Integer = 1000 - Public Property FacebookAppId As String = "" - Public Property FacebookProfileIdProperty As Integer = -1 - - Public Property ModifyPageDetails As Boolean = False - - Public Property RssEmail As String = "" - Public Property RssDefaultNrItems As Integer = 20 - Public Property RssMaxNrItems As Integer = 50 - Public Property RssTtl As Integer = 30 - Public Property RssImageWidth As Integer = 144 - Public Property RssImageHeight As Integer = 96 - Public Property RssImageSizeAllowOverride As Boolean = True - Public Property RssAllowContentInFeed As Boolean = True - Public Property RssDefaultCopyright As String = "" - - Public Property PortalTemplatesPath As String = "" - Public Property IncrementViewCount As Integer = 60 'seconds - Private Property PortalModulePath As String = "" - Private Property PortalModuleMapPath As String = "" - Private _portalTemplatesMapPath As String = "" - Public Property UseFriendlyURLs As Boolean = True - - Public ReadOnly Property PortalTemplatesMapPath As String - Get - Return _portalTemplatesMapPath - End Get - End Property - Public ReadOnly Property ModuleId As Integer - Get - Return _moduleId - End Get - End Property -#End Region - -#Region " Constructors " - Public Sub New(moduleId As Integer) - - _moduleId = moduleId - Version = [GetType]().Assembly.GetName().Version.ToString() - _allSettings = (New DotNetNuke.Entities.Modules.ModuleController).GetModule(moduleId).ModuleSettings - _allSettings.ReadValue("AllowWLW", AllowWLW) - _allSettings.ReadValue("AllowMultipleCategories", AllowMultipleCategories) - _allSettings.ReadValue("VocabularyId", VocabularyId) - _allSettings.ReadValue("AllowAttachments", AllowAttachments) - _allSettings.ReadValue("SummaryModel", SummaryModel) - _allSettings.ReadValue("StyleDetectionUrl", StyleDetectionUrl) - _allSettings.ReadValue("WLWRecentPostsMax", WLWRecentPostsMax) - _allSettings.ReadValue("ModifyPageDetails", ModifyPageDetails) - _allSettings.ReadValue("AutoGenerateMissingSummary", AutoGenerateMissingSummary) - _allSettings.ReadValue("AutoGeneratedSummaryLength", AutoGeneratedSummaryLength) - _allSettings.ReadValue("FacebookAppId", FacebookAppId) - _allSettings.ReadValue("FacebookProfileIdProperty", FacebookProfileIdProperty) - - _allSettings.ReadValue("RssEmail", RssEmail) - _allSettings.ReadValue("RssDefaultNrItems", RssDefaultNrItems) - _allSettings.ReadValue("RssMaxNrItems", RssMaxNrItems) - _allSettings.ReadValue("RssTtl", RssTtl) - _allSettings.ReadValue("RssImageWidth", RssImageWidth) - _allSettings.ReadValue("RssImageHeight", RssImageHeight) - _allSettings.ReadValue("RssImageSizeAllowOverride", RssImageSizeAllowOverride) - _allSettings.ReadValue("RssAllowContentInFeed", RssAllowContentInFeed) - _allSettings.ReadValue("RssDefaultCopyright", RssDefaultCopyright) - _allSettings.ReadValue("IncrementViewCount", IncrementViewCount) - - _PortalModulePath = DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectory - If Not _PortalModulePath.EndsWith("/") Then - _PortalModulePath &= "/" - End If - _PortalModulePath &= String.Format("Blog/", moduleId) - - _PortalModuleMapPath = DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectoryMapPath - If Not _PortalModuleMapPath.EndsWith("\") Then - _PortalModuleMapPath &= "\" - End If - _PortalModuleMapPath &= String.Format("Blog\", moduleId) - - _portalTemplatesMapPath = String.Format("{0}Templates\", _PortalModuleMapPath) - If Not IO.Directory.Exists(_portalTemplatesMapPath) Then - IO.Directory.CreateDirectory(_portalTemplatesMapPath) - End If - _PortalTemplatesPath = String.Format("{0}Templates/", _PortalModulePath) - - End Sub - - Public Shared Function GetModuleSettings(moduleId As Integer) As ModuleSettings - Dim CacheKey As String = "Blog_ModuleSettings" & moduleId.ToString - Dim settings As ModuleSettings = CType(DotNetNuke.Common.Utilities.DataCache.GetCache(CacheKey), ModuleSettings) - If settings Is Nothing Then - settings = New ModuleSettings(moduleId) - DotNetNuke.Common.Utilities.DataCache.SetCache(CacheKey, settings) - End If - Return settings - End Function -#End Region - -#Region " Public Members " - Public Overridable Sub UpdateSettings() - - Dim objModules As New DotNetNuke.Entities.Modules.ModuleController - objModules.UpdateModuleSetting(_moduleId, "AllowWLW", AllowWLW.ToString) - objModules.UpdateModuleSetting(_moduleId, "AllowMultipleCategories", AllowMultipleCategories.ToString) - objModules.UpdateModuleSetting(_moduleId, "VocabularyId", VocabularyId.ToString) - objModules.UpdateModuleSetting(_moduleId, "AllowAttachments", AllowAttachments.ToString) - objModules.UpdateModuleSetting(_moduleId, "SummaryModel", CInt(SummaryModel).ToString) - objModules.UpdateModuleSetting(_moduleId, "StyleDetectionUrl", StyleDetectionUrl) - objModules.UpdateModuleSetting(_moduleId, "WLWRecentPostsMax", WLWRecentPostsMax.ToString) - objModules.UpdateModuleSetting(_moduleId, "ModifyPageDetails", ModifyPageDetails.ToString) - objModules.UpdateModuleSetting(_moduleId, "AutoGenerateMissingSummary", AutoGenerateMissingSummary.ToString) - objModules.UpdateModuleSetting(_moduleId, "AutoGeneratedSummaryLength", AutoGeneratedSummaryLength.ToString) - objModules.UpdateModuleSetting(_moduleId, "FacebookAppId", FacebookAppId) - objModules.UpdateModuleSetting(_moduleId, "FacebookProfileIdProperty", FacebookProfileIdProperty.ToString) - - objModules.UpdateModuleSetting(_moduleId, "RssEmail", RssEmail) - objModules.UpdateModuleSetting(_moduleId, "RssDefaultNrItems", RssDefaultNrItems.ToString) - objModules.UpdateModuleSetting(_moduleId, "RssMaxNrItems", RssMaxNrItems.ToString) - objModules.UpdateModuleSetting(_moduleId, "RssTtl", RssTtl.ToString) - objModules.UpdateModuleSetting(_moduleId, "RssImageWidth", RssImageWidth.ToString) - objModules.UpdateModuleSetting(_moduleId, "RssImageHeight", RssImageHeight.ToString) - objModules.UpdateModuleSetting(_moduleId, "RssImageSizeAllowOverride", RssImageSizeAllowOverride.ToString) - objModules.UpdateModuleSetting(_moduleId, "RssAllowContentInFeed", RssAllowContentInFeed.ToString) - objModules.UpdateModuleSetting(_moduleId, "RssDefaultCopyright", RssDefaultCopyright) - objModules.UpdateModuleSetting(_moduleId, "IncrementViewCount", IncrementViewCount.ToString) - If _importedModuleId > -1 Then objModules.UpdateModuleSetting(_moduleId, "ImportedModuleID", _importedModuleId.ToString) - - Dim CacheKey As String = "Blog_ModuleSettings" & _moduleId.ToString - DotNetNuke.Common.Utilities.DataCache.SetCache(CacheKey, Me) - End Sub -#End Region - -#Region " IPropertyAccess Implementation " - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As System.Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Select Case strPropertyName.ToLower - Case "email" - Return PropertyAccess.FormatString(RssEmail, strFormat) - Case "allowmultiplecategories" - Return AllowMultipleCategories.ToString(formatProvider) - Case "allowattachments" - Return AllowAttachments.ToString(formatProvider) - Case "summarymodel" - Return CInt(SummaryModel).ToString - - Case "portaltemplatespath" - Return PropertyAccess.FormatString(PortalTemplatesPath, strFormat) - Case "portalmodulepath" - Return PropertyAccess.FormatString(_PortalModulePath, strFormat) - Case "apppath" - Return DotNetNuke.Common.ApplicationPath - Case "imagehandlerpath" - Return DotNetNuke.Common.ResolveUrl(glbImageHandlerPath) - Case "facebookappid" - Return FacebookAppId - Case Else - PropertyNotFound = True - End Select - - Return Null.NullString - End Function - - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - -#Region " Serialization " - Public Sub Serialize(writer As XmlWriter) - writer.WriteStartElement("Settings") - writer.WriteElementString("ModuleID", ModuleId.ToString) - writer.WriteElementString("AllowWLW", AllowWLW.ToString) - writer.WriteElementString("AllowMultipleCategories", AllowMultipleCategories.ToString) - writer.WriteElementString("VocabularyId", VocabularyId.ToString) - writer.WriteElementString("AllowAttachments", AllowAttachments.ToString) - writer.WriteElementString("SummaryModel", SummaryModel.ToString) - writer.WriteElementString("StyleDetectionUrl", StyleDetectionUrl) - writer.WriteElementString("WLWRecentPostsMax", WLWRecentPostsMax.ToString) - writer.WriteElementString("ModifyPageDetails", ModifyPageDetails.ToString) - writer.WriteElementString("AutoGenerateMissingSummary", AutoGenerateMissingSummary.ToString) - writer.WriteElementString("AutoGeneratedSummaryLength", AutoGeneratedSummaryLength.ToString) - writer.WriteElementString("FacebookAppId", FacebookAppId) - writer.WriteElementString("FacebookProfileIdProperty", FacebookProfileIdProperty.ToString) - - writer.WriteElementString("RssEmail", RssEmail) - writer.WriteElementString("RssDefaultNrItems", RssDefaultNrItems.ToString) - writer.WriteElementString("RssMaxNrItems", RssMaxNrItems.ToString) - writer.WriteElementString("RssTtl", RssTtl.ToString) - writer.WriteElementString("RssImageWidth", RssImageWidth.ToString) - writer.WriteElementString("RssImageHeight", RssImageHeight.ToString) - writer.WriteElementString("RssImageSizeAllowOverride", RssImageSizeAllowOverride.ToString) - writer.WriteElementString("RssAllowContentInFeed", RssAllowContentInFeed.ToString) - writer.WriteElementString("RssDefaultCopyright", RssDefaultCopyright) - writer.WriteElementString("IncrementViewCount", IncrementViewCount.ToString) - writer.WriteEndElement() ' settings - End Sub - - Public Sub FromXml(xml As XmlNode) - If xml Is Nothing Then Exit Sub - xml.ReadValue("ModuleID", _importedModuleId) - xml.ReadValue("AllowWLW", AllowWLW) - xml.ReadValue("AllowMultipleCategories", AllowMultipleCategories) - xml.ReadValue("VocabularyId", VocabularyId) - xml.ReadValue("AllowAttachments", AllowAttachments) - xml.ReadValue("SummaryModel", SummaryModel) - xml.ReadValue("StyleDetectionUrl", StyleDetectionUrl) - xml.ReadValue("WLWRecentPostsMax", WLWRecentPostsMax) - xml.ReadValue("ModifyPageDetails", ModifyPageDetails) - xml.ReadValue("AutoGenerateMissingSummary", AutoGenerateMissingSummary) - xml.ReadValue("AutoGeneratedSummaryLength", AutoGeneratedSummaryLength) - xml.ReadValue("FacebookAppId", FacebookAppId) - xml.ReadValue("FacebookProfileIdProperty", FacebookProfileIdProperty) - - xml.ReadValue("RssEmail", RssEmail) - xml.ReadValue("RssDefaultNrItems", RssDefaultNrItems) - xml.ReadValue("RssMaxNrItems", RssMaxNrItems) - xml.ReadValue("RssTtl", RssTtl) - xml.ReadValue("RssImageWidth", RssImageWidth) - xml.ReadValue("RssImageHeight", RssImageHeight) - xml.ReadValue("RssImageSizeAllowOverride", RssImageSizeAllowOverride) - xml.ReadValue("RssAllowContentInFeed", RssAllowContentInFeed) - xml.ReadValue("RssDefaultCopyright", RssDefaultCopyright) - xml.ReadValue("IncrementViewCount", IncrementViewCount) - End Sub -#End Region - - End Class -End Namespace diff --git a/Server/Blog/Components/Common/ModuleUrls.vb b/Server/Blog/Components/Common/ModuleUrls.vb deleted file mode 100644 index 65a4aa86..00000000 --- a/Server/Blog/Components/Common/ModuleUrls.vb +++ /dev/null @@ -1,162 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Services.Tokens - -Namespace Common - Public Class ModuleUrls - Implements IPropertyAccess - -#Region " Properties " - Public Property TabId As Integer = -1 - Public Property ParentTabId As Integer = -1 - Public Property BlogId As Integer = -1 - Public Property ContentItemId As Integer = -1 - Public Property TermId As Integer = -1 - Public Property AuthorId As Integer = -1 - Private Property Cache As New Dictionary(Of String, String) -#End Region - -#Region " Constructors " - Public Sub New(tabId As Integer, blogId As Integer, contentItemId As Integer, termId As Integer, authorId As Integer) - Me.TabId = tabId - Me.BlogId = blogId - Me.ContentItemId = contentItemId - Me.TermId = termId - Me.AuthorId = authorId - End Sub - - Public Sub New(tabId As Integer, parenttabId As Integer, blogId As Integer, contentItemId As Integer, termId As Integer, authorId As Integer) - Me.TabId = tabId - Me.ParentTabId = parenttabId - Me.BlogId = blogId - Me.ContentItemId = contentItemId - Me.TermId = termId - Me.AuthorId = authorId - End Sub -#End Region - -#Region " Public Methods " - Public Function GetUrl(includeBlog As Boolean, includePost As Boolean, includeTerm As Boolean, includeAuthor As Boolean, includeEnding As Boolean) As String - Dim urlType As String = "" - If includeBlog Then urlType = "blog" - If includePost Then urlType &= "post" - If includeTerm Then urlType &= "term" - If includeAuthor Then urlType &= "author" - Dim cacheKey As String = String.Format("{0}:{1}", urlType, includeEnding.ToString.ToLower) - If Cache.ContainsKey(cacheKey) Then Return Cache(cacheKey) - BuildUrl(urlType) - Return Cache(cacheKey) - End Function -#End Region - -#Region " Private Methods " - Private Sub BuildUrl(urlType As String) - Dim params As New List(Of String) - Select Case urlType - Case "blog" - If BlogId > -1 Then params.Add("Blog=" & BlogId.ToString) - Case "post" - If ContentItemId > -1 Then params.Add("Post=" & ContentItemId.ToString) - Case "term" - If TermId > -1 Then params.Add("Term=" & TermId.ToString) - Case "author" - If AuthorId > -1 Then params.Add("Author=" & AuthorId.ToString) - Case "blogpost" - If BlogId > -1 Then params.Add("Blog=" & BlogId.ToString) - If ContentItemId > -1 Then params.Add("Post=" & ContentItemId.ToString) - Case "blogterm" - If BlogId > -1 Then params.Add("Blog=" & BlogId.ToString) - If TermId > -1 Then params.Add("Term=" & TermId.ToString) - Case "blogauthor" - If BlogId > -1 Then params.Add("Blog=" & BlogId.ToString) - If AuthorId > -1 Then params.Add("Author=" & AuthorId.ToString) - Case "postterm" - If ContentItemId > -1 Then params.Add("Post=" & ContentItemId.ToString) - If TermId > -1 Then params.Add("Term=" & TermId.ToString) - Case "postauthor" - If ContentItemId > -1 Then params.Add("Post=" & ContentItemId.ToString) - If AuthorId > -1 Then params.Add("Author=" & AuthorId.ToString) - Case "termauthor" - If TermId > -1 Then params.Add("Term=" & TermId.ToString) - If AuthorId > -1 Then params.Add("Author=" & AuthorId.ToString) - Case "blogpostterm" - If BlogId > -1 Then params.Add("Blog=" & BlogId.ToString) - If ContentItemId > -1 Then params.Add("Post=" & ContentItemId.ToString) - If TermId > -1 Then params.Add("Term=" & TermId.ToString) - Case "blogpostauthor" - If BlogId > -1 Then params.Add("Blog=" & BlogId.ToString) - If ContentItemId > -1 Then params.Add("Post=" & ContentItemId.ToString) - If AuthorId > -1 Then params.Add("Author=" & AuthorId.ToString) - Case "blogtermauthor" - If BlogId > -1 Then params.Add("Blog=" & BlogId.ToString) - If TermId > -1 Then params.Add("Term=" & TermId.ToString) - If AuthorId > -1 Then params.Add("Author=" & AuthorId.ToString) - Case "posttermauthor" - If ContentItemId > -1 Then params.Add("Post=" & ContentItemId.ToString) - If TermId > -1 Then params.Add("Term=" & TermId.ToString) - If AuthorId > -1 Then params.Add("Author=" & AuthorId.ToString) - Case "blogposttermauthor", "all" - If BlogId > -1 Then params.Add("Blog=" & BlogId.ToString) - If ContentItemId > -1 Then params.Add("Post=" & ContentItemId.ToString) - If TermId > -1 Then params.Add("Term=" & TermId.ToString) - If AuthorId > -1 Then params.Add("Author=" & AuthorId.ToString) - Case "parenturl" - TabId = ParentTabId - End Select - Dim BaseUrl As String = DotNetNuke.Common.NavigateURL(TabId, "", params.ToArray) - Dim BaseUrlPlusEnding As String - If BaseUrl.Contains("?") Then - BaseUrlPlusEnding = BaseUrl & "&" - Else - BaseUrlPlusEnding = BaseUrl & "?" - End If - Cache.Add(String.Format("{0}:false", urlType), BaseUrl) - Cache.Add(String.Format("{0}:true", urlType), BaseUrlPlusEnding) - End Sub -#End Region - -#Region " IPropertyAccess Implementation " - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As System.Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - strFormat = strFormat.ToLower - If strFormat <> "true" AndAlso strFormat <> "false" Then strFormat = "false" - strPropertyName = strPropertyName.ToLower - Dim cacheKey As String = String.Format("{0}:{1}", strPropertyName, strFormat) - If Cache.ContainsKey(cacheKey) Then Return Cache(cacheKey) - BuildUrl(strPropertyName) - Return Cache(cacheKey) - End Function - - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - - End Class -End Namespace diff --git a/Server/Blog/Components/Common/PostBodyAndSummary.vb b/Server/Blog/Components/Common/PostBodyAndSummary.vb index be3b70d4..7e59749e 100644 --- a/Server/Blog/Components/Common/PostBodyAndSummary.vb +++ b/Server/Blog/Components/Common/PostBodyAndSummary.vb @@ -18,135 +18,136 @@ ' DEALINGS IN THE SOFTWARE. ' -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Modules.Blog.Common.Globals +Imports DotNetNuke.Modules.Blog.Core.Entities.Posts +Imports DotNetNuke.Modules.Blog.Core.Common.Globals +Imports DotNetNuke.Modules.Blog.Core.Common Namespace Common - Public Class PostBodyAndSummary + Public Class PostBodyAndSummary - Public Property Body As String = "" - Public Property BodyLocalizations As New LocalizedText - Public Property Summary As String = "" - Public Property SummaryLocalizations As New LocalizedText + Public Property Body As String = "" + Public Property BodyLocalizations As New LocalizedText + Public Property Summary As String = "" + Public Property SummaryLocalizations As New LocalizedText #Region " Constructors " - Public Sub New(contentEditor As Controls.LongTextEdit, summaryEditor As Controls.LongTextEdit, summaryModel As SummaryType, includeLocalizations As Boolean, autoGenerateSummaryIfEmpty As Boolean, autoGenerateLength As Integer) - Body = contentEditor.DefaultText - Summary = Trim(summaryEditor.DefaultText) - If Summary = "<p>&#160;</p>" Then Summary = "" ' an empty editor in DNN returns this - If includeLocalizations Then - BodyLocalizations = contentEditor.LocalizedTexts - SummaryLocalizations = summaryEditor.LocalizedTexts - End If - Select Case summaryModel - Case SummaryType.HtmlIndependent - Case SummaryType.HtmlPrecedesPost - Body = Summary & Body - For Each l As String In SummaryLocalizations.Locales - BodyLocalizations(l) = SummaryLocalizations(l) & BodyLocalizations(l) - Next - Case SummaryType.PlainTextIndependent - Summary = RemoveHtmlTags(Summary) - For Each l As String In SummaryLocalizations.Locales - SummaryLocalizations(l) = RemoveHtmlTags(SummaryLocalizations(l)) - Next - End Select - If autoGenerateSummaryIfEmpty And autoGenerateLength > 0 Then - If Summary = "" Then Summary = GetSummary(Body, autoGenerateLength, summaryModel, True) - For Each l As String In SummaryLocalizations.Locales - If SummaryLocalizations(l) = "" Then SummaryLocalizations(l) = GetSummary(BodyLocalizations(l), autoGenerateLength, summaryModel, True) - Next - End If - End Sub + Public Sub New(contentEditor As Controls.LongTextEdit, summaryEditor As Controls.LongTextEdit, summaryModel As SummaryType, includeLocalizations As Boolean, autoGenerateSummaryIfEmpty As Boolean, autoGenerateLength As Integer) + Body = contentEditor.DefaultText + Summary = Trim(summaryEditor.DefaultText) + If Summary = "<p>&#160;</p>" Then Summary = "" ' an empty editor in DNN returns this + If includeLocalizations Then + BodyLocalizations = contentEditor.LocalizedTexts + SummaryLocalizations = summaryEditor.LocalizedTexts + End If + Select Case summaryModel + Case SummaryType.HtmlIndependent + Case SummaryType.HtmlPrecedesPost + Body = Summary & Body + For Each l As String In SummaryLocalizations.Locales + BodyLocalizations(l) = SummaryLocalizations(l) & BodyLocalizations(l) + Next + Case SummaryType.PlainTextIndependent + Summary = RemoveHtmlTags(Summary) + For Each l As String In SummaryLocalizations.Locales + SummaryLocalizations(l) = RemoveHtmlTags(SummaryLocalizations(l)) + Next + End Select + If autoGenerateSummaryIfEmpty And autoGenerateLength > 0 Then + If Summary = "" Then Summary = GetSummary(Body, autoGenerateLength, summaryModel, True) + For Each l As String In SummaryLocalizations.Locales + If SummaryLocalizations(l) = "" Then SummaryLocalizations(l) = GetSummary(BodyLocalizations(l), autoGenerateLength, summaryModel, True) + Next + End If + End Sub - Public Sub New(Post As PostInfo, summaryModel As SummaryType, includeLocalizations As Boolean, autoGenerateSummaryIfEmpty As Boolean, autoGenerateLength As Integer) - Body = HttpUtility.HtmlDecode(Post.Content) - If Body Is Nothing Then Body = "" - If summaryModel = SummaryType.PlainTextIndependent Then - Summary = Post.Summary - Else - Summary = HttpUtility.HtmlDecode(Post.Summary) - End If - If summaryModel = SummaryType.HtmlPrecedesPost Then - Body = Body.Substring(Summary.Length) - End If - If includeLocalizations Then - For Each l As String In Post.TitleLocalizations.Locales - Dim lBody As String = "" - If Post.ContentLocalizations.ContainsKey(l) Then lBody = Post.ContentLocalizations(l) - Dim lSummary As String = "" - If Post.SummaryLocalizations.ContainsKey(l) Then lSummary = Post.SummaryLocalizations(l) - BodyLocalizations.Add(l, lBody) - If summaryModel = SummaryType.PlainTextIndependent Then - SummaryLocalizations.Add(l, lSummary) - Else - SummaryLocalizations.Add(l, HttpUtility.HtmlDecode(lSummary)) - End If - If summaryModel = SummaryType.HtmlPrecedesPost Then - BodyLocalizations(l) = BodyLocalizations(l).Substring(SummaryLocalizations(l).Length) - End If - Next - End If - If autoGenerateSummaryIfEmpty And autoGenerateLength > 0 Then - If Summary = "" Then Summary = GetSummary(Body, autoGenerateLength, summaryModel, False) - For Each l As String In SummaryLocalizations.Locales - If SummaryLocalizations(l) = "" Then SummaryLocalizations(l) = GetSummary(BodyLocalizations(l), autoGenerateLength, summaryModel, False) - Next - End If - End Sub + Public Sub New(Post As PostInfo, summaryModel As SummaryType, includeLocalizations As Boolean, autoGenerateSummaryIfEmpty As Boolean, autoGenerateLength As Integer) + Body = HttpUtility.HtmlDecode(Post.Content) + If Body Is Nothing Then Body = "" + If summaryModel = SummaryType.PlainTextIndependent Then + Summary = Post.Summary + Else + Summary = HttpUtility.HtmlDecode(Post.Summary) + End If + If summaryModel = SummaryType.HtmlPrecedesPost Then + Body = Body.Substring(Summary.Length) + End If + If includeLocalizations Then + For Each l As String In Post.TitleLocalizations.Locales + Dim lBody As String = "" + If Post.ContentLocalizations.ContainsKey(l) Then lBody = Post.ContentLocalizations(l) + Dim lSummary As String = "" + If Post.SummaryLocalizations.ContainsKey(l) Then lSummary = Post.SummaryLocalizations(l) + BodyLocalizations.Add(l, lBody) + If summaryModel = SummaryType.PlainTextIndependent Then + SummaryLocalizations.Add(l, lSummary) + Else + SummaryLocalizations.Add(l, HttpUtility.HtmlDecode(lSummary)) + End If + If summaryModel = SummaryType.HtmlPrecedesPost Then + BodyLocalizations(l) = BodyLocalizations(l).Substring(SummaryLocalizations(l).Length) + End If + Next + End If + If autoGenerateSummaryIfEmpty And autoGenerateLength > 0 Then + If Summary = "" Then Summary = GetSummary(Body, autoGenerateLength, summaryModel, False) + For Each l As String In SummaryLocalizations.Locales + If SummaryLocalizations(l) = "" Then SummaryLocalizations(l) = GetSummary(BodyLocalizations(l), autoGenerateLength, summaryModel, False) + Next + End If + End Sub - Public Sub New(post As Services.WLW.MetaWeblog.Post, summaryModel As SummaryType, autoGenerateSummaryIfEmpty As Boolean, autoGenerateLength As Integer) - Select Case summaryModel - Case SummaryType.HtmlIndependent - Body = post.description - Case SummaryType.HtmlPrecedesPost - Body = post.mt_text_more - Summary = post.description - Case Else ' plain text - Body = post.description - Summary = post.mt_excerpt - End Select - If autoGenerateSummaryIfEmpty And autoGenerateLength > 0 Then - If Summary = "" Then Summary = GetSummary(Body, autoGenerateLength, summaryModel, False) - End If - End Sub + Public Sub New(post As Core.Services.WLW.MetaWeblog.Post, summaryModel As SummaryType, autoGenerateSummaryIfEmpty As Boolean, autoGenerateLength As Integer) + Select Case summaryModel + Case SummaryType.HtmlIndependent + Body = post.description + Case SummaryType.HtmlPrecedesPost + Body = post.mt_text_more + Summary = post.description + Case Else ' plain text + Body = post.description + Summary = post.mt_excerpt + End Select + If autoGenerateSummaryIfEmpty And autoGenerateLength > 0 Then + If Summary = "" Then Summary = GetSummary(Body, autoGenerateLength, summaryModel, False) + End If + End Sub #End Region #Region " Writing " - Public Sub WriteToPost(ByRef Post As PostInfo, summaryModel As SummaryType, htmlEncode As Boolean, includeLocalizations As Boolean) - If htmlEncode Then - Body = HttpUtility.HtmlEncode(Body) - If Not summaryModel = SummaryType.PlainTextIndependent Then - Summary = HttpUtility.HtmlEncode(Summary) - End If - If includeLocalizations Then - For Each l As String In SummaryLocalizations.Locales - BodyLocalizations(l) = HttpUtility.HtmlEncode(BodyLocalizations(l)) - SummaryLocalizations(l) = HttpUtility.HtmlEncode(SummaryLocalizations(l)) - Next - End If - End If - Post.Content = Body - Post.Summary = Summary - If includeLocalizations Then - Post.ContentLocalizations = BodyLocalizations - Post.SummaryLocalizations = SummaryLocalizations - End If - End Sub + Public Sub WriteToPost(ByRef Post As PostInfo, summaryModel As SummaryType, htmlEncode As Boolean, includeLocalizations As Boolean) + If htmlEncode Then + Body = HttpUtility.HtmlEncode(Body) + If Not summaryModel = SummaryType.PlainTextIndependent Then + Summary = HttpUtility.HtmlEncode(Summary) + End If + If includeLocalizations Then + For Each l As String In SummaryLocalizations.Locales + BodyLocalizations(l) = HttpUtility.HtmlEncode(BodyLocalizations(l)) + SummaryLocalizations(l) = HttpUtility.HtmlEncode(SummaryLocalizations(l)) + Next + End If + End If + Post.Content = Body + Post.Summary = Summary + If includeLocalizations Then + Post.ContentLocalizations = BodyLocalizations + Post.SummaryLocalizations = SummaryLocalizations + End If + End Sub - Public Sub WriteToPost(ByRef post As Services.WLW.MetaWeblog.Post, summaryModel As SummaryType) - Select Case summaryModel - Case SummaryType.HtmlIndependent - post.description = Body - Case SummaryType.HtmlPrecedesPost - post.mt_text_more = Body - post.description = Summary - Case Else ' plain text - post.description = Body - post.mt_excerpt = Summary - End Select - End Sub + Public Sub WriteToPost(ByRef post As Core.Services.WLW.MetaWeblog.Post, summaryModel As SummaryType) + Select Case summaryModel + Case SummaryType.HtmlIndependent + post.description = Body + Case SummaryType.HtmlPrecedesPost + post.mt_text_more = Body + post.description = Summary + Case Else ' plain text + post.description = Body + post.mt_excerpt = Summary + End Select + End Sub #End Region - End Class + End Class End Namespace diff --git a/Server/Blog/Components/Common/ViewSettings.vb b/Server/Blog/Components/Common/ViewSettings.vb deleted file mode 100644 index b131e91e..00000000 --- a/Server/Blog/Components/Common/ViewSettings.vb +++ /dev/null @@ -1,261 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Xml -Imports DotNetNuke.Services.Tokens - -Namespace Common - - Public Class ViewSettings - Implements IPropertyAccess - -#Region " Private Members " - Private _allSettings As Hashtable = Nothing - Private _tabModuleId As Integer = -1 -#End Region - -#Region " Properties " - Public Property Template As String = "[G]_default" - Public Property BlogModuleId As Integer = -1 - Public Property ShowAllLocales As Boolean = True - Public Property ModifyPageDetails As Boolean = False - Public Property AddCanonicalTag As Boolean = False - Public Property ShowManagementPanel As Boolean = False - Public Property ShowManagementPanelViewMode As Boolean = True - Public Property HideUnpublishedBlogsViewMode As Boolean = False - Public Property HideUnpublishedBlogsEditMode As Boolean = False - Public Property AllowComments As Boolean = True - Public Property BlogId As Integer = -1 - Public Property Categories As String = "" - Public Property AuthorId As Integer = -1 - Public Property TemplateSettings As New Dictionary(Of String, String) - Private Property TemplateManager As Templating.TemplateManager - Friend Property CanCache As Boolean = True -#End Region - -#Region " ReadOnly Properties " - Private _categoryList As List(Of Integer) - Public ReadOnly Property CategoryList As List(Of Integer) - Get - If _categoryList Is Nothing Then - _categoryList = New List(Of Integer) - For Each c As String In Categories.Split(","c) - If IsNumeric(c) Then - _categoryList.Add(Integer.Parse(c)) - End If - Next - End If - Return _categoryList - End Get - End Property -#End Region - -#Region " Constructors " - Public Sub New(tabModuleId As Integer) - Me.New(tabModuleId, False) - End Sub - - Public Sub New(tabModuleId As Integer, justLoadSettings As Boolean) - - _tabModuleId = tabModuleId - _allSettings = (New DotNetNuke.Entities.Modules.ModuleController).GetTabModule(tabModuleId).TabModuleSettings - _allSettings.ReadValue("Template", Template) - _allSettings.ReadValue("BlogModuleId", BlogModuleId) - _allSettings.ReadValue("ShowAllLocales", ShowAllLocales) - _allSettings.ReadValue("ModifyPageDetails", ModifyPageDetails) - _allSettings.ReadValue("AddCanonicalTag", AddCanonicalTag) - _allSettings.ReadValue("ShowManagementPanel", ShowManagementPanel) - _allSettings.ReadValue("ShowManagementPanelViewMode", ShowManagementPanelViewMode) - _allSettings.ReadValue("HideUnpublishedBlogsViewMode", HideUnpublishedBlogsViewMode) - _allSettings.ReadValue("HideUnpublishedBlogsEditMode", HideUnpublishedBlogsEditMode) - _allSettings.ReadValue("AllowComments", AllowComments) - _allSettings.ReadValue("BlogId", BlogId) - _allSettings.ReadValue("Categories", Categories) - _allSettings.ReadValue("AuthorId", AuthorId) - If BlogModuleId > -1 And tabModuleId > -1 Then ' security check - Dim parentModule As DotNetNuke.Entities.Modules.ModuleInfo = (New DotNetNuke.Entities.Modules.ModuleController).GetModule(BlogModuleId) - Dim thisTabModule As DotNetNuke.Entities.Modules.ModuleInfo = (New DotNetNuke.Entities.Modules.ModuleController).GetTabModule(tabModuleId) - If parentModule Is Nothing OrElse parentModule.PortalID <> thisTabModule.PortalID Then - BlogModuleId = -1 - CanCache = False - End If - End If - If justLoadSettings Then Exit Sub - - ' Template Settings - first load defaults - SetTemplate(Template) - - End Sub - - Public Shared Function GetViewSettings(tabModuleId As Integer) As ViewSettings - Dim CacheKey As String = "Blog_TabModuleSettings" & tabModuleId.ToString - Dim settings As ViewSettings = CType(DotNetNuke.Common.Utilities.DataCache.GetCache(CacheKey), ViewSettings) - If settings Is Nothing Then - settings = New ViewSettings(tabModuleId) - If settings.CanCache Then DotNetNuke.Common.Utilities.DataCache.SetCache(CacheKey, settings) - End If - Return settings - End Function -#End Region - -#Region " Public Members " - Public Overridable Sub UpdateSettings() - UpdateSettings(_tabModuleId) - End Sub - - Public Overridable Sub UpdateSettings(tabModuleId As Integer) - - Dim objModules As New DotNetNuke.Entities.Modules.ModuleController - objModules.UpdateTabModuleSetting(tabModuleId, "Template", Template) - objModules.UpdateTabModuleSetting(tabModuleId, "BlogModuleId", BlogModuleId.ToString) - objModules.UpdateTabModuleSetting(tabModuleId, "ShowAllLocales", ShowAllLocales.ToString) - objModules.UpdateTabModuleSetting(tabModuleId, "ModifyPageDetails", ModifyPageDetails.ToString) - objModules.UpdateTabModuleSetting(tabModuleId, "AddCanonicalTag", AddCanonicalTag.ToString) - objModules.UpdateTabModuleSetting(tabModuleId, "ShowManagementPanel", ShowManagementPanel.ToString) - objModules.UpdateTabModuleSetting(tabModuleId, "ShowManagementPanelViewMode", ShowManagementPanelViewMode.ToString) - objModules.UpdateTabModuleSetting(tabModuleId, "HideUnpublishedBlogsViewMode", HideUnpublishedBlogsViewMode.ToString) - objModules.UpdateTabModuleSetting(tabModuleId, "HideUnpublishedBlogsEditMode", HideUnpublishedBlogsEditMode.ToString) - objModules.UpdateTabModuleSetting(tabModuleId, "AllowComments", AllowComments.ToString) - objModules.UpdateTabModuleSetting(tabModuleId, "BlogId", BlogId.ToString) - objModules.UpdateTabModuleSetting(tabModuleId, "Categories", Categories.ToString) - objModules.UpdateTabModuleSetting(tabModuleId, "AuthorId", AuthorId.ToString) - _categoryList = Nothing - - Dim CacheKey As String = "Blog_TabModuleSettings" & tabModuleId.ToString - DotNetNuke.Common.Utilities.DataCache.SetCache(CacheKey, Me) - - End Sub - - Public Sub SaveTemplateSettings() - Dim objModules As New DotNetNuke.Entities.Modules.ModuleController - For Each key As String In TemplateSettings.Keys - objModules.UpdateTabModuleSetting(_tabModuleId, "t_" & key, TemplateSettings(key)) - Next - Dim CacheKey As String = "Blog_TabModuleSettings" & _tabModuleId.ToString - DotNetNuke.Common.Utilities.DataCache.SetCache(CacheKey, Me) - End Sub - - Public Sub SetTemplateSetting(key As String, value As String) - If Not TemplateSettings.ContainsKey(key) Then - TemplateSettings.Add(key, value) - Else - TemplateSettings(key) = value - End If - End Sub -#End Region - -#Region " Private Methods " - Private Sub SetTemplate(template As String) - TemplateManager = New Templating.TemplateManager(DotNetNuke.Entities.Portals.PortalSettings.Current, template) - TemplateSettings.Clear() - For Each st As Templating.TemplateSetting In _TemplateManager.TemplateSettings.Settings - TemplateSettings.Add(st.Key, st.DefaultValue) - Next - For Each key As String In _allSettings.Keys - If key.StartsWith("t_") Then - SetTemplateSetting(Mid(key, 3), CStr(_allSettings(key))) - End If - Next - End Sub -#End Region - -#Region " IPropertyAccess " - Public ReadOnly Property Cacheability As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property - - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As System.Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Select Case strPropertyName.ToLower - Case "tabmoduleid" - Return (_tabModuleId.ToString(OutputFormat, formatProvider)) - Case "templatepath" - Return PropertyAccess.FormatString(_TemplateManager.TemplatePath, strFormat) - Case "templatemappath" - Return PropertyAccess.FormatString(_TemplateManager.TemplateMapPath, strFormat) - Case Else - If TemplateSettings.ContainsKey(strPropertyName) Then - Return PropertyAccess.FormatString(CStr(TemplateSettings(strPropertyName)), strFormat) - End If - If strPropertyName.StartsWith("t_") Then strPropertyName = Mid(strPropertyName, 3) - If TemplateSettings.ContainsKey(strPropertyName) Then - Return PropertyAccess.FormatString(CStr(TemplateSettings(strPropertyName)), strFormat) - End If - Select Case strPropertyName.ToLower - Case "termid", "categories" ' termid is for legacy purposes - Return Categories - Case "authorid" - Return (AuthorId.ToString(OutputFormat, formatProvider)) - Case "blogid" - Return (BlogId.ToString(OutputFormat, formatProvider)) - Case "blogmoduleid" - Return (BlogModuleId.ToString(OutputFormat, formatProvider)) - Case Else - Return "" - End Select - End Select - End Function -#End Region - -#Region " Serialization " - Public Sub Serialize(writer As XmlWriter) - writer.WriteStartElement("ViewSettings") - writer.WriteElementString("Template", Template) - writer.WriteElementString("BlogModuleId", BlogModuleId.ToString) - writer.WriteElementString("ShowAllLocales", ShowAllLocales.ToString) - writer.WriteElementString("ModifyPageDetails", ModifyPageDetails.ToString) - writer.WriteElementString("AddCanonicalTag", AddCanonicalTag.ToString) - writer.WriteElementString("ShowManagementPanel", ShowManagementPanel.ToString) - writer.WriteElementString("ShowManagementPanelViewMode", ShowManagementPanelViewMode.ToString) - writer.WriteElementString("HideUnpublishedBlogsViewMode", HideUnpublishedBlogsViewMode.ToString) - writer.WriteElementString("HideUnpublishedBlogsEditMode", HideUnpublishedBlogsEditMode.ToString) - writer.WriteElementString("AllowComments", AllowComments.ToString) - writer.WriteElementString("BlogId", BlogId.ToString) - writer.WriteElementString("AuthorId", AuthorId.ToString) - writer.WriteEndElement() ' viewsettings - End Sub - - Public Sub FromXml(xml As XmlNode) - If xml Is Nothing Then Exit Sub - xml.ReadValue("Template", Template) - xml.ReadValue("BlogModuleId", BlogModuleId) - xml.ReadValue("ShowAllLocales", ShowAllLocales) - xml.ReadValue("ModifyPageDetails", ModifyPageDetails) - xml.ReadValue("AddCanonicalTag", AddCanonicalTag) - xml.ReadValue("ShowManagementPanel", ShowManagementPanel) - xml.ReadValue("ShowManagementPanelViewMode", ShowManagementPanelViewMode) - xml.ReadValue("HideUnpublishedBlogsViewMode", HideUnpublishedBlogsViewMode) - xml.ReadValue("HideUnpublishedBlogsEditMode", HideUnpublishedBlogsEditMode) - xml.ReadValue("AllowComments", AllowComments) - xml.ReadValue("BlogId", BlogId) - xml.ReadValue("AuthorId", AuthorId) - _categoryList = Nothing - End Sub -#End Region - - End Class -End Namespace diff --git a/Server/Blog/Components/Common/WebPage.vb b/Server/Blog/Components/Common/WebPage.vb deleted file mode 100644 index 32cac0b9..00000000 --- a/Server/Blog/Components/Common/WebPage.vb +++ /dev/null @@ -1,99 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Net -Imports System.IO - -Namespace Common - Public Class WebPage - -#Region " Properties " - Private ReadOnly url As Uri - Public ReadOnly Property Uri() As Uri - Get - Return url - End Get - End Property -#End Region - -#Region " Constructors " - Friend Sub New(filePath As Uri) - If filePath Is Nothing Then - Throw New ArgumentNullException("filePath") - End If - url = filePath - End Sub -#End Region - -#Region " Public Methods " - Public Function GetWebResponse() As WebResponse - Dim response As WebResponse = GetWebRequest().GetResponse() - Dim contentLength As Long = response.ContentLength - If contentLength = -1 Then - Dim headerContentLength As String = response.Headers("Content-Length") - If Not [String].IsNullOrEmpty(headerContentLength) Then - contentLength = Long.Parse(headerContentLength) - End If - End If - If contentLength <= -1 Then - response.Close() - Return Nothing - End If - Return response - End Function - - Private _webRequest As WebRequest - - Public Function GetFileAsString() As String - Try - Using response As WebResponse = GetWebResponse() - If response Is Nothing Then - Return String.Empty - End If - Using reader As New StreamReader(response.GetResponseStream()) - Return reader.ReadToEnd() - End Using - End Using - Catch ex As Exception - DotNetNuke.Services.Exceptions.LogException(New Exception(String.Format("Track/Pingback Verification Request To '{0}' Failed", Uri.PathAndQuery), ex)) - Return "" - End Try - End Function -#End Region - -#Region " Private Methods " - Private Function GetWebRequest() As WebRequest - - If _webRequest Is Nothing Then - Dim request As HttpWebRequest = DirectCast(WebRequest.Create(Uri), HttpWebRequest) - request.Headers("Accept-Encoding") = "gzip" - request.Headers("Accept-Language") = "en-us" - request.Credentials = CredentialCache.DefaultNetworkCredentials - request.AutomaticDecompression = DecompressionMethods.GZip - request.Timeout = 1000 * 30 ' 30 secs timeout - _webRequest = request - End If - Return _webRequest - - End Function -#End Region - - End Class -End Namespace diff --git a/Server/Blog/Components/Data/DataProvider.vb b/Server/Blog/Components/Data/DataProvider.vb deleted file mode 100644 index beef26f9..00000000 --- a/Server/Blog/Components/Data/DataProvider.vb +++ /dev/null @@ -1,27 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - -Namespace Data - - Partial Public MustInherit Class DataProvider - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Data/DataProvider_CMD.vb b/Server/Blog/Components/Data/DataProvider_CMD.vb deleted file mode 100644 index 0dac0da9..00000000 --- a/Server/Blog/Components/Data/DataProvider_CMD.vb +++ /dev/null @@ -1,64 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - -Namespace Data - - Partial Public MustInherit Class DataProvider - - Public MustOverride Sub AddPostView(contentItemId As Int32) - Public MustOverride Sub ApproveComment(commentId As Int32) - Public MustOverride Function AddCommentKarma(commentId As Int32, userId As Int32, karma As Int32) As Integer - Public MustOverride Sub DeleteBlogPermissions(blogId As Int32) - Public MustOverride Function GetAuthors(moduleId As Int32, blogID As Int32) As IDataReader - Public MustOverride Function GetBlog(blogId As Int32, userId As Int32, locale As String) As IDataReader - Public MustOverride Function GetBlogCalendar(moduleId As Int32, blogId As Int32, locale As String) As IDataReader - Public MustOverride Function GetBlogLocalizations(blogId As Int32) As IDataReader - Public MustOverride Function GetBlogPermissionsByBlog(blogId As Int32) As IDataReader - Public MustOverride Function GetBlogsByModule(moduleId As Int32, userId As Int32, locale As String) As IDataReader - Public MustOverride Function GetBlogsByPortal(portalId As Int32, userId As Int32, locale As String) As IDataReader - Public MustOverride Function GetComment(commentID As Int32, userID As Int32) As IDataReader - Public MustOverride Function GetCommentsByContentItem(contentItemId As Int32, includeNonApproved As Boolean, userID As Int32) As IDataReader - Public MustOverride Function GetCommentsByModuleId(moduleId As Int32, userID As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Public MustOverride Function GetPostByLegacyEntryId(entryId As Int32, portalId As Int32, locale As String) As IDataReader - Public MustOverride Function GetPostByLegacyUrl(url As String, portalId As Int32, locale As String) As IDataReader - Public MustOverride Function GetPostLocalizations(contentItemId As Int32) As IDataReader - Public MustOverride Function GetPosts(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, onlyActionable As Boolean, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Public MustOverride Function GetPostsByTerm(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, termID As Int32, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Public MustOverride Function GetPostsByCategory(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, categories As String, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Public MustOverride Function GetTerm(termId As Int32, moduleId As Int32, locale As String) As IDataReader - Public MustOverride Function GetTermLocalizations(termId As Int32) As IDataReader - Public MustOverride Function GetTermsByModule(moduleId As Int32, locale As String) As IDataReader - Public MustOverride Function GetTermsByPost(contentItemId As Int32, moduleId As Int32, locale As String) As IDataReader - Public MustOverride Function GetTermsByVocabulary(moduleId As Int32, vocabularyId As Int32, locale As String) As IDataReader - Public MustOverride Function GetUserPermissionsByModule(moduleID As Int32, userId As Int32) As IDataReader - Public MustOverride Function GetUsersByBlogPermission(portalId As Int32, blogId As Int32, permissionId As Int32) As IDataReader - Public MustOverride Function SearchPosts(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, searchText As String, searchTitle As Boolean, searchContents As Boolean, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Public MustOverride Function SearchPostsByTerm(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, termID As Int32, searchText As String, searchTitle As Boolean, searchContents As Boolean, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Public MustOverride Function SearchPostsByCategory(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, categories As String, searchText As String, searchTitle As Boolean, searchContents As Boolean, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Public MustOverride Sub SetBlogLocalization(blogID As Int32, locale As String, title As String, description As String) - Public MustOverride Sub SetPostLocalization(postID As Int32, locale As String, title As String, summary As String, content As String, updatedByUser As Int32) - Public MustOverride Function SetTerm(termID As Int32, vocabularyID As Int32, parentTermID As Int32, viewOrder As Int32, name As String, description As String, createdByUserID As Int32) As Integer - Public MustOverride Sub SetTermLocalization(termID As Int32, locale As String, name As String, description As String) - Public MustOverride Sub UpdateModuleWiring(portalId As Int32, oldModuleId As Int32, newModuleId As Int32) - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Data/DataProvider_CRUD.vb b/Server/Blog/Components/Data/DataProvider_CRUD.vb deleted file mode 100644 index d16bda55..00000000 --- a/Server/Blog/Components/Data/DataProvider_CRUD.vb +++ /dev/null @@ -1,84 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - -Namespace Data - - Partial Public MustInherit Class DataProvider - -#Region " Shared/Static Methods " - - ' singleton reference to the instantiated object - Private Shared objProvider As DataProvider = Nothing - - ' constructor - Shared Sub New() - CreateProvider() - End Sub - - ' dynamically create provider - Private Shared Sub CreateProvider() - objProvider = CType(DotNetNuke.Framework.Reflection.CreateObject("data", "DotNetNuke.Modules.Blog.Data", ""), DataProvider) - End Sub - - ' return the provider - Public Shared Shadows Function Instance() As DataProvider - Return objProvider - End Function - -#End Region - -#Region " General Methods " - Public MustOverride Function GetNull(Field As Object) As Object -#End Region - -#Region " BlogPermission Methods " - Public MustOverride Function GetBlogPermission(blogId As Int32, permissionId As Int32, roleId As Int32, userId As Int32) As IDataReader - Public MustOverride Sub AddBlogPermission(allowAccess As Boolean, blogId As Int32, expires As Date, permissionId As Int32, roleId As Int32, userId As Int32) - Public MustOverride Sub UpdateBlogPermission(allowAccess As Boolean, blogId As Int32, expires As Date, permissionId As Int32, roleId As Int32, userId As Int32) - Public MustOverride Sub DeleteBlogPermission(blogId As Int32, permissionId As Int32, roleId As Int32, userId As Int32) -#End Region - -#Region " Blog Methods " - Public MustOverride Function AddBlog(autoApprovePingBack As Boolean, moduleID As Int32, autoApproveTrackBack As Boolean, copyright As String, description As String, enablePingBackReceive As Boolean, enablePingBackSend As Boolean, enableTrackBackReceive As Boolean, enableTrackBackSend As Boolean, fullLocalization As Boolean, image As String, includeAuthorInFeed As Boolean, includeImagesInFeed As Boolean, locale As String, mustApproveGhostPosts As Boolean, ownerUserId As Int32, publishAsOwner As Boolean, published As Boolean, syndicated As Boolean, syndicationEmail As String, title As String, createdByUser As Int32) As Integer - Public MustOverride Sub UpdateBlog(autoApprovePingBack As Boolean, moduleID As Int32, autoApproveTrackBack As Boolean, blogID As Int32, copyright As String, description As String, enablePingBackReceive As Boolean, enablePingBackSend As Boolean, enableTrackBackReceive As Boolean, enableTrackBackSend As Boolean, fullLocalization As Boolean, image As String, includeAuthorInFeed As Boolean, includeImagesInFeed As Boolean, locale As String, mustApproveGhostPosts As Boolean, ownerUserId As Int32, publishAsOwner As Boolean, published As Boolean, syndicated As Boolean, syndicationEmail As String, title As String, updatedByUser As Int32) - Public MustOverride Sub DeleteBlog(blogID As Int32) -#End Region - -#Region " Comment Methods " - Public MustOverride Function AddComment(approved As Boolean, author As String, comment As String, contentItemId As Int32, email As String, parentId As Int32, website As String, createdByUser As Int32) As Integer - Public MustOverride Sub UpdateComment(approved As Boolean, author As String, comment As String, commentID As Int32, contentItemId As Int32, email As String, parentId As Int32, website As String, updatedByUser As Int32) - Public MustOverride Sub DeleteComment(commentID As Int32) -#End Region - -#Region " LegacyUrl Methods " - Public MustOverride Sub AddLegacyUrl(contentItemId As Int32, entryId As Int32, url As String) -#End Region - -#Region " Post Methods " - Public MustOverride Function GetPost(contentItemId As Int32, moduleId As Int32, locale As String) As IDataReader - Public MustOverride Function AddPost(allowComments As Boolean, blogID As Int32, content As String, copyright As String, displayCopyright As Boolean, image As String, locale As String, published As Boolean, publishedOnDate As Date, summary As String, termIds As String, title As String, viewCount As Int32, createdByUser As Int32) As Integer - Public MustOverride Sub UpdatePost(allowComments As Boolean, blogID As Int32, content As String, contentItemId As Int32, copyright As String, displayCopyright As Boolean, image As String, locale As String, published As Boolean, publishedOnDate As Date, summary As String, termIds As String, title As String, viewCount As Int32, updatedByUser As Int32) - Public MustOverride Sub DeletePost(contentItemId As Int32) -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Data/DataProvider_FK.vb b/Server/Blog/Components/Data/DataProvider_FK.vb deleted file mode 100644 index b0bc745c..00000000 --- a/Server/Blog/Components/Data/DataProvider_FK.vb +++ /dev/null @@ -1,44 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - -Namespace Data - - Partial Public MustInherit Class DataProvider - -#Region " BlogPermission Methods " - Public MustOverride Function GetBlogPermissionsByBlog(blogID As Int32, StartRowIndex As Integer, MaximumRows As Integer, OrderBy As String) As IDataReader -#End Region - -#Region " Blog Methods " - Public MustOverride Function GetBlogsByCreatedByUser(userID As Int32, StartRowIndex As Integer, MaximumRows As Integer, OrderBy As String) As IDataReader -#End Region - -#Region " Comment Methods " -#End Region - -#Region " Post Methods " - Public MustOverride Function GetPostsByBlog(blogID As Int32, displayLocale As String, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader -#End Region - - End Class - -End Namespace - diff --git a/Server/Blog/Components/Data/SqlDataProvider.vb b/Server/Blog/Components/Data/SqlDataProvider.vb deleted file mode 100644 index 5e18beca..00000000 --- a/Server/Blog/Components/Data/SqlDataProvider.vb +++ /dev/null @@ -1,28 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - -Namespace Data - - Partial Public Class SqlDataProvider - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Data/SqlDataProvider_CMD.vb b/Server/Blog/Components/Data/SqlDataProvider_CMD.vb deleted file mode 100644 index d876a177..00000000 --- a/Server/Blog/Components/Data/SqlDataProvider_CMD.vb +++ /dev/null @@ -1,171 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports Microsoft.ApplicationBlocks.Data - -Namespace Data - - Partial Public Class SqlDataProvider - - Public Overrides Function AddCommentKarma(commentId As Int32, userId As Int32, karma As Int32) As Integer - Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "AddCommentKarma", commentId, userId, karma), Integer) - End Function - - Public Overrides Sub AddPostView(contentItemId As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "AddPostView", contentItemId) - End Sub - - Public Overrides Sub ApproveComment(commentId As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "ApproveComment", commentId) - End Sub - - Public Overrides Sub DeleteBlogPermissions(blogId As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "DeleteBlogPermissions", blogId) - End Sub - - Public Overrides Function GetAuthors(moduleId As Int32, blogID As Int32) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetAuthors", moduleId, blogID), IDataReader) - End Function - - Public Overrides Function GetBlog(blogId As Int32, userId As Int32, locale As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetBlog", blogId, userId, locale), IDataReader) - End Function - - Public Overrides Function GetBlogCalendar(moduleId As Int32, blogId As Int32, locale As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetBlogCalendar", moduleId, blogId, GetNull(locale)), IDataReader) - End Function - - Public Overrides Function GetBlogLocalizations(blogId As Int32) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetBlogLocalizations", blogId), IDataReader) - End Function - - Public Overrides Function GetBlogPermissionsByBlog(blogId As Int32) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetBlogPermissionsByBlog", blogId), IDataReader) - End Function - - Public Overrides Function GetBlogsByModule(moduleId As Int32, userId As Int32, locale As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetBlogsByModule", moduleId, userId, locale), IDataReader) - End Function - - Public Overrides Function GetBlogsByPortal(portalId As Int32, userId As Int32, locale As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetBlogsByPortal", portalId, userId, locale), IDataReader) - End Function - - Public Overrides Function GetComment(commentID As Int32, userID As Int32) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetComment", commentID, userID), IDataReader) - End Function - - Public Overrides Function GetCommentsByContentItem(contentItemId As Int32, includeNonApproved As Boolean, userID As Int32) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetCommentsByContentItem", contentItemId, includeNonApproved, userID), IDataReader) - End Function - - Public Overrides Function GetCommentsByModuleId(moduleId As Int32, userID As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetCommentsByModuleId", moduleId, userID, pageIndex, pageSize, orderBy), IDataReader) - End Function - - Public Overrides Function GetPostByLegacyEntryId(entryId As Int32, portalId As Int32, locale As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetPostByLegacyEntryId", entryId, portalId, locale), IDataReader) - End Function - - Public Overrides Function GetPostByLegacyUrl(url As String, portalId As Int32, locale As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetPostByLegacyUrl", url, portalId, locale), IDataReader) - End Function - - Public Overrides Function GetPostLocalizations(contentItemId As Int32) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetPostLocalizations", contentItemId), IDataReader) - End Function - - Public Overrides Function GetPosts(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, onlyActionable As Boolean, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetPosts", moduleId, blogID, displayLocale, userId, userIsAdmin, published, GetNull(limitToLocale), GetNull(endDate), authorUserId, onlyActionable, pageIndex, pageSize, orderBy), IDataReader) - End Function - - Public Overrides Function GetPostsByTerm(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, termID As Int32, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetPostsByTerm", moduleId, blogID, displayLocale, userId, userIsAdmin, termID, published, GetNull(limitToLocale), GetNull(endDate), authorUserId, pageIndex, pageSize, orderBy), IDataReader) - End Function - - Public Overrides Function GetPostsByCategory(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, categories As String, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetPostsByCategory", moduleId, blogID, displayLocale, userId, userIsAdmin, categories, published, GetNull(limitToLocale), GetNull(endDate), authorUserId, pageIndex, pageSize, orderBy), IDataReader) - End Function - - Public Overrides Function GetTerm(termId As Int32, moduleId As Int32, locale As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetTerm", termId, moduleId, locale), IDataReader) - End Function - - Public Overrides Function GetTermLocalizations(termId As Int32) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetTermLocalizations", termId), IDataReader) - End Function - - Public Overrides Function GetTermsByModule(moduleId As Int32, locale As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetTermsByModule", moduleId, locale), IDataReader) - End Function - - Public Overrides Function GetTermsByPost(contentItemId As Int32, moduleId As Int32, locale As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetTermsByPost", contentItemId, moduleId, locale), IDataReader) - End Function - - Public Overrides Function GetTermsByVocabulary(moduleId As Int32, vocabularyId As Int32, locale As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetTermsByVocabulary", moduleId, vocabularyId, locale), IDataReader) - End Function - - Public Overrides Function GetUserPermissionsByModule(moduleID As Int32, userId As Int32) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetUserPermissionsByModule", moduleID, userId), IDataReader) - End Function - - Public Overrides Function GetUsersByBlogPermission(portalId As Int32, blogId As Int32, permissionId As Int32) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetUsersByBlogPermission", portalId, blogId, permissionId), IDataReader) - End Function - - Public Overrides Function SearchPosts(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, searchText As String, searchTitle As Boolean, searchContents As Boolean, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "SearchPosts", moduleId, blogID, displayLocale, userId, userIsAdmin, searchText, searchTitle, searchContents, published, GetNull(limitToLocale), GetNull(endDate), authorUserId, pageIndex, pageSize, orderBy), IDataReader) - End Function - - Public Overrides Function SearchPostsByTerm(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, termID As Int32, searchText As String, searchTitle As Boolean, searchContents As Boolean, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "SearchPostsByTerm", moduleId, blogID, displayLocale, userId, userIsAdmin, termID, searchText, searchTitle, searchContents, published, GetNull(limitToLocale), GetNull(endDate), authorUserId, pageIndex, pageSize, orderBy), IDataReader) - End Function - - Public Overrides Function SearchPostsByCategory(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, userIsAdmin As Boolean, categories As String, searchText As String, searchTitle As Boolean, searchContents As Boolean, published As Int32, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "SearchPostsByCategory", moduleId, blogID, displayLocale, userId, userIsAdmin, categories, searchText, searchTitle, searchContents, published, GetNull(limitToLocale), GetNull(endDate), authorUserId, pageIndex, pageSize, orderBy), IDataReader) - End Function - - - Public Overrides Sub SetBlogLocalization(blogID As Int32, locale As String, title As String, description As String) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "SetBlogLocalization", blogID, locale, title, description) - End Sub - - Public Overrides Sub SetPostLocalization(postID As Int32, locale As String, title As String, summary As String, content As String, updatedByUser As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "SetPostLocalization", postID, locale, title, summary, content, updatedByUser) - End Sub - - Public Overrides Function SetTerm(termID As Int32, vocabularyID As Int32, parentTermID As Int32, viewOrder As Int32, name As String, description As String, createdByUserID As Int32) As Integer - Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "SetTerm", termID, vocabularyID, parentTermID, viewOrder, name, description, createdByUserID), Integer) - End Function - - Public Overrides Sub SetTermLocalization(termID As Int32, locale As String, name As String, description As String) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "SetTermLocalization", termID, locale, name, description) - End Sub - - Public Overrides Sub UpdateModuleWiring(portalId As Int32, oldModuleId As Int32, newModuleId As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "UpdateModuleWiring", portalId, oldModuleId, newModuleId) - End Sub - - End Class - -End Namespace - diff --git a/Server/Blog/Components/Data/SqlDataProvider_CRUD.vb b/Server/Blog/Components/Data/SqlDataProvider_CRUD.vb deleted file mode 100644 index 6d95668a..00000000 --- a/Server/Blog/Components/Data/SqlDataProvider_CRUD.vb +++ /dev/null @@ -1,189 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports Microsoft.ApplicationBlocks.Data -Imports DotNetNuke.Framework.Providers - -Namespace Data - - Partial Public Class SqlDataProvider - Inherits DataProvider - -#Region " Private Members " - - Private Const ProviderType As String = "data" - Private Const ModuleQualifier As String = "Blog_" - - Private _providerConfiguration As DotNetNuke.Framework.Providers.ProviderConfiguration = DotNetNuke.Framework.Providers.ProviderConfiguration.GetProviderConfiguration(ProviderType) - Private _connectionString As String - Private _providerPath As String - Private _objectQualifier As String - Private _databaseOwner As String - -#End Region - -#Region " Constructors " - - Public Sub New() - - ' Read the configuration specific information for this provider - Dim objProvider As DotNetNuke.Framework.Providers.Provider = CType(_providerConfiguration.Providers(_providerConfiguration.DefaultProvider), Provider) - - 'Get Connection string from web.config - _connectionString = DotNetNuke.Common.Utilities.Config.GetConnectionString() - - If _connectionString = "" Then - ' Use connection string specified in provider - _connectionString = objProvider.Attributes("connectionString") - End If - - _providerPath = objProvider.Attributes("providerPath") - - _objectQualifier = objProvider.Attributes("objectQualifier") - If _objectQualifier <> "" And _objectQualifier.EndsWith("_") = False Then - _objectQualifier += "_" - End If - - _databaseOwner = objProvider.Attributes("databaseOwner") - If _databaseOwner <> "" And _databaseOwner.EndsWith(".") = False Then - _databaseOwner += "." - End If - - End Sub - -#End Region - -#Region " Properties " - - Public ReadOnly Property ConnectionString() As String - Get - Return _connectionString - End Get - End Property - - Public ReadOnly Property ProviderPath() As String - Get - Return _providerPath - End Get - End Property - - Public ReadOnly Property ObjectQualifier() As String - Get - Return _objectQualifier - End Get - End Property - - Public ReadOnly Property DatabaseOwner() As String - Get - Return _databaseOwner - End Get - End Property - -#End Region - -#Region " General Methods " - Public Overrides Function GetNull(Field As Object) As Object - Return DotNetNuke.Common.Utilities.Null.GetNull(Field, DBNull.Value) - End Function -#End Region - - -#Region " BlogPermission Methods " - - Public Overrides Function GetBlogPermission(blogId As Int32, permissionId As Int32, roleId As Int32, userId As Int32) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetBlogPermission", blogId, permissionId, roleId, userId), IDataReader) - End Function - - Public Overrides Sub AddBlogPermission(allowAccess As Boolean, blogId As Int32, expires As Date, permissionId As Int32, roleId As Int32, userId As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "AddBlogPermission", allowAccess, blogId, GetNull(expires), permissionId, roleId, userId) - End Sub - - Public Overrides Sub UpdateBlogPermission(allowAccess As Boolean, blogId As Int32, expires As Date, permissionId As Int32, roleId As Int32, userId As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "UpdateBlogPermission", allowAccess, blogId, GetNull(expires), permissionId, roleId, userId) - End Sub - - Public Overrides Sub DeleteBlogPermission(blogId As Int32, permissionId As Int32, roleId As Int32, userId As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "DeleteBlogPermission", blogId, permissionId, roleId, userId) - End Sub - -#End Region - -#Region " Blog Methods " - - Public Overrides Function AddBlog(autoApprovePingBack As Boolean, moduleID As Int32, autoApproveTrackBack As Boolean, copyright As String, description As String, enablePingBackReceive As Boolean, enablePingBackSend As Boolean, enableTrackBackReceive As Boolean, enableTrackBackSend As Boolean, fullLocalization As Boolean, image As String, includeAuthorInFeed As Boolean, includeImagesInFeed As Boolean, locale As String, mustApproveGhostPosts As Boolean, ownerUserId As Int32, publishAsOwner As Boolean, published As Boolean, syndicated As Boolean, syndicationEmail As String, title As String, createdByUser As Int32) As Integer - Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "AddBlog", autoApprovePingBack, moduleID, autoApproveTrackBack, GetNull(copyright), GetNull(description), enablePingBackReceive, enablePingBackSend, enableTrackBackReceive, enableTrackBackSend, fullLocalization, GetNull(image), includeAuthorInFeed, includeImagesInFeed, locale, mustApproveGhostPosts, ownerUserId, publishAsOwner, published, syndicated, GetNull(syndicationEmail), title, createdByUser), Integer) - End Function - - Public Overrides Sub UpdateBlog(autoApprovePingBack As Boolean, moduleID As Int32, autoApproveTrackBack As Boolean, blogID As Int32, copyright As String, description As String, enablePingBackReceive As Boolean, enablePingBackSend As Boolean, enableTrackBackReceive As Boolean, enableTrackBackSend As Boolean, fullLocalization As Boolean, image As String, includeAuthorInFeed As Boolean, includeImagesInFeed As Boolean, locale As String, mustApproveGhostPosts As Boolean, ownerUserId As Int32, publishAsOwner As Boolean, published As Boolean, syndicated As Boolean, syndicationEmail As String, title As String, updatedByUser As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "UpdateBlog", autoApprovePingBack, moduleID, autoApproveTrackBack, blogID, GetNull(copyright), GetNull(description), enablePingBackReceive, enablePingBackSend, enableTrackBackReceive, enableTrackBackSend, fullLocalization, GetNull(image), includeAuthorInFeed, includeImagesInFeed, locale, mustApproveGhostPosts, ownerUserId, publishAsOwner, published, syndicated, GetNull(syndicationEmail), title, updatedByUser) - End Sub - - Public Overrides Sub DeleteBlog(blogID As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "DeleteBlog", blogID) - End Sub - -#End Region - -#Region " Comment Methods " - - Public Overrides Function AddComment(approved As Boolean, author As String, comment As String, contentItemId As Int32, email As String, parentId As Int32, website As String, createdByUser As Int32) As Integer - Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "AddComment", approved, GetNull(author), comment, contentItemId, GetNull(email), GetNull(parentId), GetNull(website), createdByUser), Integer) - End Function - - Public Overrides Sub UpdateComment(approved As Boolean, author As String, comment As String, commentID As Int32, contentItemId As Int32, email As String, parentId As Int32, website As String, updatedByUser As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "UpdateComment", approved, GetNull(author), comment, commentID, contentItemId, GetNull(email), GetNull(parentId), GetNull(website), updatedByUser) - End Sub - - Public Overrides Sub DeleteComment(commentID As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "DeleteComment", commentID) - End Sub - -#End Region - -#Region " LegacyUrl Methods " - Public Overrides Sub AddLegacyUrl(contentItemId As Int32, entryId As Int32, url As String) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "AddLegacyUrl", contentItemId, GetNull(entryId), url) - End Sub -#End Region - -#Region " Post Methods " - - Public Overrides Function GetPost(contentItemId As Int32, moduleId As Int32, locale As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetPost", contentItemId, moduleId, locale), IDataReader) - End Function - - Public Overrides Function AddPost(allowComments As Boolean, blogID As Int32, content As String, copyright As String, displayCopyright As Boolean, image As String, locale As String, published As Boolean, publishedOnDate As Date, summary As String, termIds As String, title As String, viewCount As Int32, createdByUser As Int32) As Integer - Return CType(SqlHelper.ExecuteScalar(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "AddPost", allowComments, blogID, content, copyright, displayCopyright, image, GetNull(locale), published, publishedOnDate, summary, termIds, title, viewCount, createdByUser), Integer) - End Function - - Public Overrides Sub UpdatePost(allowComments As Boolean, blogID As Int32, content As String, contentItemId As Int32, copyright As String, displayCopyright As Boolean, image As String, locale As String, published As Boolean, publishedOnDate As Date, summary As String, termIds As String, title As String, viewCount As Int32, updatedByUser As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "UpdatePost", allowComments, blogID, content, contentItemId, copyright, displayCopyright, image, GetNull(locale), published, publishedOnDate, summary, termIds, title, viewCount, updatedByUser) - End Sub - - Public Overrides Sub DeletePost(contentItemId As Int32) - SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "DeletePost", contentItemId) - End Sub - -#End Region - - - End Class - -End Namespace diff --git a/Server/Blog/Components/Data/SqlDataProvider_FK.vb b/Server/Blog/Components/Data/SqlDataProvider_FK.vb deleted file mode 100644 index 1a56baaf..00000000 --- a/Server/Blog/Components/Data/SqlDataProvider_FK.vb +++ /dev/null @@ -1,53 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports Microsoft.ApplicationBlocks.Data - -Namespace Data - - Partial Public Class SqlDataProvider - -#Region " BlogPermission Methods " - Public Overrides Function GetBlogPermissionsByBlog(blogID As Int32, StartRowIndex As Integer, MaximumRows As Integer, OrderBy As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetBlogPermissionsByBlog", blogID, StartRowIndex, MaximumRows, OrderBy.ToUpper), IDataReader) - End Function - -#End Region - -#Region " Blog Methods " - - Public Overrides Function GetBlogsByCreatedByUser(userID As Int32, StartRowIndex As Integer, MaximumRows As Integer, OrderBy As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetBlogsByCreatedByUser", userID, StartRowIndex, MaximumRows, OrderBy.ToUpper), IDataReader) - End Function - -#End Region - -#Region " Comment Methods " -#End Region - -#Region " Post Methods " - Public Overrides Function GetPostsByBlog(blogID As Int32, displayLocale As String, pageIndex As Int32, pageSize As Int32, orderBy As String) As IDataReader - Return CType(SqlHelper.ExecuteReader(ConnectionString, DatabaseOwner & ObjectQualifier & ModuleQualifier & "GetPostsByBlog", blogID, displayLocale, pageIndex, pageSize, orderBy), IDataReader) - End Function -#End Region - - End Class - -End Namespace diff --git a/Server/Blog/Components/Entities/Blogs/BlogCalendarInfo.vb b/Server/Blog/Components/Entities/Blogs/BlogCalendarInfo.vb deleted file mode 100644 index e4e1bcfd..00000000 --- a/Server/Blog/Components/Entities/Blogs/BlogCalendarInfo.vb +++ /dev/null @@ -1,172 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Runtime.Serialization -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Services.Tokens - -Namespace Entities.Blogs - Public Class BlogCalendarInfo - Implements IHydratable - Implements IPropertyAccess - -#Region " ML Properties " - Public Property ParentTabID As Integer = -1 -#End Region - -#Region " Public Properties " - - Public Property PostYear As Int32 = -1 - - Public Property PostMonth As Int32 = -1 - - Public Property PostCount As Int32 = -1 - - Public Property ViewCount As Int32 = -1 - - Private _FirstDay As Date = Date.MinValue - Public ReadOnly Property FirstDay As Date - Get - If _FirstDay = Date.MinValue Then - _FirstDay = DateSerial(PostYear, PostMonth, 1) - End If - Return _FirstDay - End Get - End Property - - Private _FirstDayNextMonth As Date = Date.MinValue - Public ReadOnly Property FirstDayNextMonth As Date - Get - If _FirstDayNextMonth = Date.MinValue Then - _FirstDayNextMonth = DateSerial(PostYear, PostMonth, 1).AddMonths(1) - End If - Return _FirstDayNextMonth - End Get - End Property - - Private _LastDay As Date = Date.MinValue - Public ReadOnly Property LastDay As Date - Get - If _LastDay = Date.MinValue Then - _LastDay = DateSerial(PostYear, PostMonth, 1).AddMonths(1).AddDays(-1) - End If - Return _LastDay - End Get - End Property -#End Region - -#Region " IHydratable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' Fill hydrates the object from a Datareader - ''' - ''' The Fill method is used by the CBO method to hydrtae the object - ''' rather than using the more expensive Refection methods. - ''' - ''' [pdonker] 02/16/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub Fill(dr As IDataReader) Implements IHydratable.Fill - PostYear = Convert.ToInt32(Null.SetNull(dr.Item("PostYear"), PostYear)) - PostMonth = Convert.ToInt32(Null.SetNull(dr.Item("PostMonth"), PostMonth)) - PostCount = Convert.ToInt32(Null.SetNull(dr.Item("PostCount"), PostCount)) - ViewCount = Convert.ToInt32(Null.SetNull(dr.Item("ViewCount"), ViewCount)) - End Sub - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and sets the Key ID - ''' - ''' The KeyID property is part of the IHydratble interface. It is used - ''' as the key property when creating a Dictionary - ''' - ''' [pdonker] 02/16/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Property KeyID() As Integer Implements IHydratable.KeyID - Get - Return Nothing - End Get - Set(value As Integer) - End Set - End Property -#End Region - -#Region " IPropertyAccess Implementation " - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As System.Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Select Case strPropertyName.ToLower - Case "postyear" - Return (PostYear.ToString(OutputFormat, formatProvider)) - Case "postmonth" - Return (PostMonth.ToString(OutputFormat, formatProvider)) - Case "postcount" - Return (PostCount.ToString(OutputFormat, formatProvider)) - Case "viewcount" - Return (ViewCount.ToString(OutputFormat, formatProvider)) - Case "firstday" - Return (FirstDay.ToString(OutputFormat, formatProvider)) - Case "lastday" - Return (LastDay.ToString(OutputFormat, formatProvider)) - Case "firstdaynextmonth" - Return (FirstDayNextMonth.ToString(OutputFormat, formatProvider)) - Case "parenturl" - Return PermaLink(ParentTabID) - Case Else - PropertyNotFound = True - End Select - Return Null.NullString - End Function - - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - - Public Function PermaLink(strParentTabID As Integer) As String - Dim oTabController As DotNetNuke.Entities.Tabs.TabController = New DotNetNuke.Entities.Tabs.TabController - Dim oParentTab As DotNetNuke.Entities.Tabs.TabInfo = oTabController.GetTab(strParentTabID, DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, False) - _permaLink = String.Empty - Return PermaLink(oParentTab) - End Function - - Public Function PermaLink(portalSettings As DotNetNuke.Entities.Portals.PortalSettings) As String - Return PermaLink(portalSettings.ActiveTab) - End Function - - Private _permaLink As String = "" - Public Function PermaLink(tab As DotNetNuke.Entities.Tabs.TabInfo) As String - If String.IsNullOrEmpty(_permaLink) Then - _permaLink = DotNetNuke.Common.Globals.ApplicationURL(tab.TabID) & "&end=" & FirstDayNextMonth.ToString - _permaLink = DotNetNuke.Common.Globals.FriendlyUrl(tab, _permaLink) - End If - Return _permaLink - End Function - - End Class -End Namespace diff --git a/Server/Blog/Components/Entities/Blogs/BlogInfo.vb b/Server/Blog/Components/Entities/Blogs/BlogInfo.vb deleted file mode 100644 index 494c66ad..00000000 --- a/Server/Blog/Components/Entities/Blogs/BlogInfo.vb +++ /dev/null @@ -1,77 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Runtime.Serialization -Imports DotNetNuke.Common.Globals -Imports DotNetNuke.Modules.Blog.Common.Globals - -Namespace Entities.Blogs - - Partial Public Class BlogInfo - - Private _permissions As Security.Permissions.BlogPermissionCollection - Public Property Permissions() As Security.Permissions.BlogPermissionCollection - Get - If _permissions Is Nothing Then - _permissions = Security.Permissions.BlogPermissionsController.GetBlogPermissionsCollection(BlogID) - End If - Return _permissions - End Get - Set(value As Security.Permissions.BlogPermissionCollection) - _permissions = value - End Set - End Property - - - Public Property CanEdit As Boolean = False - - Public Property CanAdd As Boolean = False - - Public Property CanApprove As Boolean = False - - Public Property IsOwner As Boolean = False - - Public Function PermaLink(strParentTabID As Integer) As String - Dim oTabController As DotNetNuke.Entities.Tabs.TabController = New DotNetNuke.Entities.Tabs.TabController - Dim oParentTab As DotNetNuke.Entities.Tabs.TabInfo = oTabController.GetTab(strParentTabID, DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, False) - _permaLink = String.Empty - Return PermaLink(oParentTab) - End Function - - Public Function PermaLink(portalSettings As DotNetNuke.Entities.Portals.PortalSettings) As String - Return PermaLink(portalSettings.ActiveTab) - End Function - - Private _permaLink As String = "" - Public Function PermaLink(tab As DotNetNuke.Entities.Tabs.TabInfo) As String - If String.IsNullOrEmpty(_permaLink) Then - _permaLink = ApplicationURL(tab.TabID) & "&Blog=" & BlogID.ToString - If DotNetNuke.Entities.Host.Host.UseFriendlyUrls Then - _permaLink = FriendlyUrl(tab, _permaLink, GetSafePageName(LocalizedTitle)) - Else - _permaLink = ResolveUrl(_permaLink) - End If - End If - Return _permaLink - End Function - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Entities/Blogs/BlogInfo_Interfaces.vb b/Server/Blog/Components/Entities/Blogs/BlogInfo_Interfaces.vb deleted file mode 100644 index 32b5047b..00000000 --- a/Server/Blog/Components/Entities/Blogs/BlogInfo_Interfaces.vb +++ /dev/null @@ -1,397 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Runtime.Serialization -Imports System.Xml -Imports System.Xml.Schema -Imports System.Xml.Serialization - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Services.Tokens - -Imports DotNetNuke.Modules.Blog.Common.Globals - -Namespace Entities.Blogs - - - Partial Public Class BlogInfo - Implements IHydratable - Implements IPropertyAccess - Implements IXmlSerializable - -#Region " ML Properties " - Public Property ParentTabID As Integer = -1 -#End Region - -#Region " IHydratable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' Fill hydrates the object from a Datareader - ''' - ''' The Fill method is used by the CBO method to hydrtae the object - ''' rather than using the more expensive Refection methods. - ''' - ''' [pdonker] 02/16/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub Fill(dr As IDataReader) Implements IHydratable.Fill - BlogID = Convert.ToInt32(Null.SetNull(dr.Item("BlogID"), BlogID)) - ModuleID = Convert.ToInt32(Null.SetNull(dr.Item("ModuleID"), ModuleID)) - Title = Convert.ToString(Null.SetNull(dr.Item("Title"), Title)) - Description = Convert.ToString(Null.SetNull(dr.Item("Description"), Description)) - Image = Convert.ToString(Null.SetNull(dr.Item("Image"), Image)) - Locale = Convert.ToString(Null.SetNull(dr.Item("Locale"), Locale)) - FullLocalization = Convert.ToBoolean(Null.SetNull(dr.Item("FullLocalization"), FullLocalization)) - Published = Convert.ToBoolean(Null.SetNull(dr.Item("Published"), Published)) - IncludeImagesInFeed = Convert.ToBoolean(Null.SetNull(dr.Item("IncludeImagesInFeed"), IncludeImagesInFeed)) - IncludeAuthorInFeed = Convert.ToBoolean(Null.SetNull(dr.Item("IncludeAuthorInFeed"), IncludeAuthorInFeed)) - Syndicated = Convert.ToBoolean(Null.SetNull(dr.Item("Syndicated"), Syndicated)) - SyndicationEmail = Convert.ToString(Null.SetNull(dr.Item("SyndicationEmail"), SyndicationEmail)) - Copyright = Convert.ToString(Null.SetNull(dr.Item("Copyright"), Copyright)) - MustApproveGhostPosts = Convert.ToBoolean(Null.SetNull(dr.Item("MustApproveGhostPosts"), MustApproveGhostPosts)) - PublishAsOwner = Convert.ToBoolean(Null.SetNull(dr.Item("PublishAsOwner"), PublishAsOwner)) - EnablePingBackSend = Convert.ToBoolean(Null.SetNull(dr.Item("EnablePingBackSend"), EnablePingBackSend)) - EnablePingBackReceive = Convert.ToBoolean(Null.SetNull(dr.Item("EnablePingBackReceive"), EnablePingBackReceive)) - AutoApprovePingBack = Convert.ToBoolean(Null.SetNull(dr.Item("AutoApprovePingBack"), AutoApprovePingBack)) - EnableTrackBackSend = Convert.ToBoolean(Null.SetNull(dr.Item("EnableTrackBackSend"), EnableTrackBackSend)) - EnableTrackBackReceive = Convert.ToBoolean(Null.SetNull(dr.Item("EnableTrackBackReceive"), EnableTrackBackReceive)) - AutoApproveTrackBack = Convert.ToBoolean(Null.SetNull(dr.Item("AutoApproveTrackBack"), AutoApproveTrackBack)) - OwnerUserId = Convert.ToInt32(Null.SetNull(dr.Item("OwnerUserId"), OwnerUserId)) - CreatedByUserID = Convert.ToInt32(Null.SetNull(dr.Item("CreatedByUserID"), CreatedByUserID)) - CreatedOnDate = CDate(Null.SetNull(dr.Item("CreatedOnDate"), CreatedOnDate)) - LastModifiedByUserID = Convert.ToInt32(Null.SetNull(dr.Item("LastModifiedByUserID"), LastModifiedByUserID)) - LastModifiedOnDate = CDate(Null.SetNull(dr.Item("LastModifiedOnDate"), LastModifiedOnDate)) - DisplayName = Convert.ToString(Null.SetNull(dr.Item("DisplayName"), DisplayName)) - Email = Convert.ToString(Null.SetNull(dr.Item("Email"), Email)) - Username = Convert.ToString(Null.SetNull(dr.Item("Username"), Username)) - NrPosts = Convert.ToInt32(Null.SetNull(dr.Item("NrPosts"), NrPosts)) - LastPublishDate = CDate(Null.SetNull(dr.Item("LastPublishDate"), LastPublishDate)) - NrViews = Convert.ToInt32(Null.SetNull(dr.Item("NrViews"), NrViews)) - FirstPublishDate = CDate(Null.SetNull(dr.Item("FirstPublishDate"), FirstPublishDate)) - AltLocale = Convert.ToString(Null.SetNull(dr.Item("AltLocale"), AltLocale)) - AltTitle = Convert.ToString(Null.SetNull(dr.Item("AltTitle"), AltTitle)) - AltDescription = Convert.ToString(Null.SetNull(dr.Item("AltDescription"), AltDescription)) - CanEdit = Convert.ToBoolean(Null.SetNull(dr.Item("CanEdit"), CanEdit)) - CanAdd = Convert.ToBoolean(Null.SetNull(dr.Item("CanAdd"), CanAdd)) - CanApprove = Convert.ToBoolean(Null.SetNull(dr.Item("CanApprove"), CanApprove)) - - End Sub - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and sets the Key ID - ''' - ''' The KeyID property is part of the IHydratble interface. It is used - ''' as the key property when creating a Dictionary - ''' - ''' [pdonker] 02/16/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Property KeyID() As Integer Implements IHydratable.KeyID - Get - Return BlogID - End Get - Set(value As Integer) - BlogID = value - End Set - End Property -#End Region - -#Region " IPropertyAccess Implementation " - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As System.Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Select Case strPropertyName.ToLower - Case "blogid" - Return (BlogID.ToString(OutputFormat, formatProvider)) - Case "moduleid" - Return (ModuleID.ToString(OutputFormat, formatProvider)) - Case "title" - Return PropertyAccess.FormatString(Title, strFormat) - Case "description" - Return PropertyAccess.FormatString(Description, strFormat) - Case "image" - Return PropertyAccess.FormatString(Image, strFormat) - Case "hasimage" - Return CBool(Image <> "").ToString(formatProvider) - Case "locale" - Return PropertyAccess.FormatString(Locale, strFormat) - Case "fulllocalization" - Return FullLocalization.ToString - Case "fulllocalizationyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(FullLocalization, formatProvider) - Case "published" - Return Published.ToString - Case "publishedyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(Published, formatProvider) - Case "includeimagesinfeed" - Return IncludeImagesInFeed.ToString - Case "includeimagesinfeedyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(IncludeImagesInFeed, formatProvider) - Case "includeauthorinfeed" - Return IncludeAuthorInFeed.ToString - Case "includeauthorinfeedyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(IncludeAuthorInFeed, formatProvider) - Case "syndicated" - Return Syndicated.ToString - Case "syndicatedyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(Syndicated, formatProvider) - Case "syndicationemail" - Return PropertyAccess.FormatString(SyndicationEmail, strFormat) - Case "copyright" - Return PropertyAccess.FormatString(Copyright, strFormat) - Case "mustapproveghostposts" - Return MustApproveGhostPosts.ToString - Case "mustapproveghostpostsyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(MustApproveGhostPosts, formatProvider) - Case "publishasowner" - Return PublishAsOwner.ToString - Case "publishasowneryesno" - Return PropertyAccess.Boolean2LocalizedYesNo(PublishAsOwner, formatProvider) - Case "enablepingbacksend" - Return EnablePingBackSend.ToString - Case "enablepingbacksendyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(EnablePingBackSend, formatProvider) - Case "enablepingbackreceive" - Return EnablePingBackReceive.ToString - Case "enablepingbackreceiveyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(EnablePingBackReceive, formatProvider) - Case "autoapprovepingback" - Return AutoApprovePingBack.ToString - Case "autoapprovepingbackyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(AutoApprovePingBack, formatProvider) - Case "enabletrackbacksend" - Return EnableTrackBackSend.ToString - Case "enabletrackbacksendyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(EnableTrackBackSend, formatProvider) - Case "enabletrackbackreceive" - Return EnableTrackBackReceive.ToString - Case "enabletrackbackreceiveyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(EnableTrackBackReceive, formatProvider) - Case "autoapprovetrackback" - Return AutoApproveTrackBack.ToString - Case "autoapprovetrackbackyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(AutoApproveTrackBack, formatProvider) - Case "owneruserid" - Return (OwnerUserId.ToString(OutputFormat, formatProvider)) - Case "createdbyuserid" - Return (CreatedByUserID.ToString(OutputFormat, formatProvider)) - Case "createdondate" - Return (CreatedOnDate.ToString(OutputFormat, formatProvider)) - Case "lastmodifiedbyuserid" - Return (LastModifiedByUserID.ToString(OutputFormat, formatProvider)) - Case "lastmodifiedondate" - Return (LastModifiedOnDate.ToString(OutputFormat, formatProvider)) - Case "displayname" - Return PropertyAccess.FormatString(DisplayName, strFormat) - Case "email" - Return PropertyAccess.FormatString(Email, strFormat) - Case "username" - Return PropertyAccess.FormatString(Username, strFormat) - Case "nrposts" - Return (NrPosts.ToString(OutputFormat, formatProvider)) - Case "lastpublishdate" - Return (LastPublishDate.ToString(OutputFormat, formatProvider)) - Case "nrviews" - Return (NrViews.ToString(OutputFormat, formatProvider)) - Case "firstpublishdate" - Return (FirstPublishDate.ToString(OutputFormat, formatProvider)) - Case "altlocale" - Return PropertyAccess.FormatString(AltLocale, strFormat) - Case "alttitle" - Return PropertyAccess.FormatString(AltTitle, strFormat) - Case "altdescription" - Return PropertyAccess.FormatString(AltDescription, strFormat) - Case "localizedtitle" - Return PropertyAccess.FormatString(LocalizedTitle, strFormat) - Case "localizeddescription" - Return PropertyAccess.FormatString(LocalizedDescription, strFormat) - Case "link", "permalink" - Return PermaLink(DotNetNuke.Entities.Portals.PortalSettings.Current) - Case "parenturl" - Return PermaLink(ParentTabID) - Case Else - PropertyNotFound = True - End Select - - Return Null.NullString - End Function - - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - -#Region " IXmlSerializable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' GetSchema returns the XmlSchema for this class - ''' - ''' GetSchema is implemented as a stub method as it is not required - ''' - ''' [pdonker] 02/16/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Function GetSchema() As XmlSchema Implements IXmlSerializable.GetSchema - Return Nothing - End Function - - Private Function readElement(reader As XmlReader, ElementName As String) As String - If (Not reader.NodeType = XmlNodeType.Element) OrElse reader.Name <> ElementName Then - reader.ReadToFollowing(ElementName) - End If - If reader.NodeType = XmlNodeType.Element Then - Return reader.ReadElementContentAsString - Else - Return "" - End If - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' ReadXml fills the object (de-serializes it) from the XmlReader passed - ''' - ''' - ''' The XmlReader that contains the xml for the object - ''' - ''' [pdonker] 02/16/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub ReadXml(reader As XmlReader) Implements IXmlSerializable.ReadXml - ' not implemented - End Sub - - Friend Property ImportedBlogId As Integer = -1 - Friend Property ImportedPosts As List(Of Posts.PostInfo) - Friend Property ImportedFiles As List(Of String) - - Public Sub FromXml(xml As XmlNode) - If xml Is Nothing Then Exit Sub - - xml.ReadValue("BlogId", ImportedBlogId) - xml.ReadValue("Title", Title) - xml.ReadValue("TitleLocalizations", TitleLocalizations) - xml.ReadValue("Description", Description) - xml.ReadValue("DescriptionLocalizations", DescriptionLocalizations) - xml.ReadValue("Image", Image) - xml.ReadValue("Locale", Locale) - xml.ReadValue("FullLocalization", FullLocalization) - xml.ReadValue("Published", Published) - xml.ReadValue("IncludeImagesInFeed", IncludeImagesInFeed) - xml.ReadValue("IncludeAuthorInFeed", IncludeAuthorInFeed) - xml.ReadValue("Syndicated", Syndicated) - xml.ReadValue("SyndicationEmail", SyndicationEmail) - xml.ReadValue("Copyright", Copyright) - xml.ReadValue("MustApproveGhostPosts", MustApproveGhostPosts) - xml.ReadValue("PublishAsOwner", PublishAsOwner) - xml.ReadValue("EnablePingBackSend", EnablePingBackSend) - xml.ReadValue("EnablePingBackReceive", EnablePingBackReceive) - xml.ReadValue("AutoApprovePingBack", AutoApprovePingBack) - xml.ReadValue("EnableTrackBackSend", EnableTrackBackSend) - xml.ReadValue("EnableTrackBackReceive", EnableTrackBackReceive) - xml.ReadValue("AutoApproveTrackBack", AutoApproveTrackBack) - xml.ReadValue("Username", Username) - xml.ReadValue("Email", Email) - - ImportedPosts = New List(Of Posts.PostInfo) - For Each xPost As XmlNode In xml.SelectNodes("Posts/Post") - Dim post As New Posts.PostInfo - post.fromXml(xPost) - ImportedPosts.Add(post) - Next - - ImportedFiles = New List(Of String) - For Each xFile As XmlNode In xml.SelectNodes("Files/File") - ImportedFiles.Add(xFile.InnerText) - Next - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' WriteXml converts the object to Xml (serializes it) and writes it using the XmlWriter passed - ''' - ''' - ''' The XmlWriter that contains the xml for the object - ''' - ''' [pdonker] 02/16/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub WriteXml(writer As XmlWriter) Implements IXmlSerializable.WriteXml - writer.WriteStartElement("Blog") - writer.WriteElementString("BlogId", BlogID.ToString) - writer.WriteElementString("Title", Title) - writer.WriteElementString("TitleLocalizations", TitleLocalizations.ToString) - writer.WriteElementString("Description", Description) - writer.WriteElementString("DescriptionLocalizations", DescriptionLocalizations.ToString) - writer.WriteElementString("Image", Image) - writer.WriteElementString("Locale", Locale) - writer.WriteElementString("FullLocalization", FullLocalization.ToString()) - writer.WriteElementString("Published", Published.ToString()) - writer.WriteElementString("IncludeImagesInFeed", IncludeImagesInFeed.ToString()) - writer.WriteElementString("IncludeAuthorInFeed", IncludeAuthorInFeed.ToString()) - writer.WriteElementString("Syndicated", Syndicated.ToString()) - writer.WriteElementString("SyndicationEmail", SyndicationEmail) - writer.WriteElementString("Copyright", Copyright) - writer.WriteElementString("MustApproveGhostPosts", MustApproveGhostPosts.ToString()) - writer.WriteElementString("PublishAsOwner", PublishAsOwner.ToString()) - writer.WriteElementString("EnablePingBackSend", EnablePingBackSend.ToString()) - writer.WriteElementString("EnablePingBackReceive", EnablePingBackReceive.ToString()) - writer.WriteElementString("AutoApprovePingBack", AutoApprovePingBack.ToString()) - writer.WriteElementString("EnableTrackBackSend", EnableTrackBackSend.ToString()) - writer.WriteElementString("EnableTrackBackReceive", EnableTrackBackReceive.ToString()) - writer.WriteElementString("AutoApproveTrackBack", AutoApproveTrackBack.ToString()) - writer.WriteElementString("Username", Username) - writer.WriteElementString("Email", Email) - writer.WriteStartElement("Posts") - Dim page As Integer = 0 - Dim totalRecords As Integer = 1 - Do While page * 10 < totalRecords - For Each p As Posts.PostInfo In Posts.PostsController.GetPostsByBlog(ModuleID, BlogID, "", -1, page, 20, "PUBLISHEDONDATE DESC", totalRecords).Values - p.WriteXml(writer) - Next - page += 1 - Loop - writer.WriteEndElement() ' Posts - writer.WriteStartElement("Files") - ' pack files - Dim postDir As String = GetBlogDirectoryMapPath(BlogID) - If IO.Directory.Exists(postDir) Then - For Each f As String In IO.Directory.GetFiles(postDir) - Dim fileName As String = IO.Path.GetFileName(f) - writer.WriteElementString("File", fileName) - Next - End If - writer.WriteEndElement() ' Files - writer.WriteEndElement() ' Blog - End Sub -#End Region - - End Class -End Namespace - - diff --git a/Server/Blog/Components/Entities/Blogs/BlogInfo_Properties.vb b/Server/Blog/Components/Entities/Blogs/BlogInfo_Properties.vb deleted file mode 100644 index 7adb228e..00000000 --- a/Server/Blog/Components/Entities/Blogs/BlogInfo_Properties.vb +++ /dev/null @@ -1,177 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Runtime.Serialization - -Namespace Entities.Blogs - Partial Public Class BlogInfo - -#Region " Private Members " -#End Region - -#Region " Constructors " - Public Sub New() - Try - Locale = DotNetNuke.Entities.Portals.PortalSettings.Current.DefaultLanguage - Catch ex As Exception - End Try - End Sub -#End Region - -#Region " Public Properties " - - Public Property BlogID As Int32 = -1 - - Public Property ModuleID As Int32 = -1 - - Public Property Title As String = "" - - Public Property Description As String = "" - - Public Property Image As String = "" - - Public Property Locale As String = "" - - Public Property FullLocalization As Boolean = False - - Public Property Published As Boolean = True - - Public Property IncludeImagesInFeed As Boolean = True - - Public Property IncludeAuthorInFeed As Boolean = False - - Public Property Syndicated As Boolean = True - - Public Property SyndicationEmail As String = "" - - Public Property Copyright As String = "" - - Public Property MustApproveGhostPosts As Boolean = False - - Public Property PublishAsOwner As Boolean = False - - Public Property EnablePingBackSend As Boolean = True - - Public Property EnablePingBackReceive As Boolean = True - - Public Property AutoApprovePingBack As Boolean = False - - Public Property EnableTrackBackSend As Boolean = True - - Public Property EnableTrackBackReceive As Boolean = False - - Public Property AutoApproveTrackBack As Boolean = False - - Public Property OwnerUserId As Int32 = -1 - - Public Property CreatedByUserID As Int32 = -1 - - Public Property CreatedOnDate As Date = Date.MinValue - - Public Property LastModifiedByUserID As Int32 = -1 - - Public Property LastModifiedOnDate As Date = Date.MinValue - - Public Property DisplayName As String = "" - - Public Property Email As String = "" - - Public Property Username As String = "" - - Public Property NrPosts As Int32 = -1 - - Public Property LastPublishDate As Date = Date.MinValue - - Public Property NrViews As Int32 = -1 - - Public Property FirstPublishDate As Date = Date.MinValue -#End Region - -#Region " ML Properties " - - Public Property AltLocale As String = "" - - Public Property AltTitle As String = "" - - Public Property AltDescription As String = "" - - Public ReadOnly Property LocalizedTitle As String - Get - Return CStr(IIf(String.IsNullOrEmpty(AltTitle), Title, AltTitle)) - End Get - End Property - - Public ReadOnly Property LocalizedDescription As String - Get - Return CStr(IIf(String.IsNullOrEmpty(AltDescription), Description, AltDescription)) - End Get - End Property - - ''' - ''' ML text type to handle the title of the blog - ''' - ''' - ''' - ''' - Public Property TitleLocalizations() As LocalizedText - Get - If _titleLocalizations Is Nothing Then - If BlogID = -1 Then - _titleLocalizations = New LocalizedText - Else - _titleLocalizations = New LocalizedText(Data.DataProvider.Instance().GetBlogLocalizations(BlogID), "Title") - End If - End If - Return _titleLocalizations - End Get - Set(ByVal value As LocalizedText) - _titleLocalizations = value - End Set - End Property - Private _titleLocalizations As LocalizedText - - ''' - ''' ML text type to handle the description of the blog - ''' - ''' - ''' - ''' - Public Property DescriptionLocalizations() As LocalizedText - Get - If _descriptionLocalizations Is Nothing Then - If BlogID = -1 Then - _descriptionLocalizations = New LocalizedText - Else - _descriptionLocalizations = New LocalizedText(Data.DataProvider.Instance().GetBlogLocalizations(BlogID), "Description") - End If - End If - Return _descriptionLocalizations - End Get - Set(ByVal value As LocalizedText) - _descriptionLocalizations = value - End Set - End Property - Private _descriptionLocalizations As LocalizedText -#End Region - - End Class -End Namespace - - diff --git a/Server/Blog/Components/Entities/Blogs/BlogsController.vb b/Server/Blog/Components/Entities/Blogs/BlogsController.vb deleted file mode 100644 index 3df27cc1..00000000 --- a/Server/Blog/Components/Entities/Blogs/BlogsController.vb +++ /dev/null @@ -1,80 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Modules.Blog.Data -Imports DotNetNuke.Common.Utilities - -Namespace Entities.Blogs - - Partial Public Class BlogsController - - Public Shared Function GetBlog(blogID As Int32, userId As Integer, locale As String) As BlogInfo - - Return CBO.FillObject(Of BlogInfo)(DataProvider.Instance().GetBlog(blogID, userId, locale)) - - End Function - - Public Shared Function GetBlogsByModule(moduleID As Int32, locale As String) As Dictionary(Of Integer, BlogInfo) - - Return GetBlogsByModule(moduleID, -1, locale) - - End Function - - Public Shared Function GetBlogsByModule(moduleID As Int32, userId As Integer, locale As String) As Dictionary(Of Integer, BlogInfo) - - Dim res As Dictionary(Of Integer, BlogInfo) = DotNetNuke.Common.Utilities.CBO.FillDictionary(Of Integer, BlogInfo)("BlogID", DataProvider.Instance().GetBlogsByModule(moduleID, userId, locale)) - If userId > -1 Then - For Each b As BlogInfo In res.Values - If b.OwnerUserId = userId Then - b.CanAdd = True - b.CanEdit = True - b.CanApprove = True - b.IsOwner = True - End If - Next - End If - Return res - - End Function - - Public Shared Function GetBlogsByPortal(portalId As Int32, userId As Integer, locale As String) As Dictionary(Of Integer, BlogInfo) - - Dim res As Dictionary(Of Integer, BlogInfo) = DotNetNuke.Common.Utilities.CBO.FillDictionary(Of Integer, BlogInfo)("BlogID", DataProvider.Instance().GetBlogsByPortal(portalId, userId, locale)) - If userId > -1 Then - For Each b As BlogInfo In res.Values - If b.OwnerUserId = userId Then - b.CanAdd = True - b.CanEdit = True - b.CanApprove = True - b.IsOwner = True - End If - Next - End If - Return res - - End Function - - Public Shared Function GetBlogCalendar(moduleId As Integer, blogId As Integer, locale As String) As List(Of BlogCalendarInfo) - Return DotNetNuke.Common.Utilities.CBO.FillCollection(Of BlogCalendarInfo)(DataProvider.Instance.GetBlogCalendar(moduleId, blogId, locale)) - End Function - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Entities/Blogs/BlogsController_CRUD.vb b/Server/Blog/Components/Entities/Blogs/BlogsController_CRUD.vb deleted file mode 100644 index 19ef3e99..00000000 --- a/Server/Blog/Components/Entities/Blogs/BlogsController_CRUD.vb +++ /dev/null @@ -1,61 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - - -Imports DotNetNuke.Modules.Blog.Data - -Namespace Entities.Blogs - - Partial Public Class BlogsController - - Public Shared Function AddBlog(ByRef objBlog As BlogInfo, createdByUser As Integer) As Integer - - objBlog.BlogID = CType(DataProvider.Instance().AddBlog(objBlog.AutoApprovePingBack, objBlog.ModuleID, objBlog.AutoApproveTrackBack, objBlog.Copyright, objBlog.Description, objBlog.EnablePingBackReceive, objBlog.EnablePingBackSend, objBlog.EnableTrackBackReceive, objBlog.EnableTrackBackSend, objBlog.FullLocalization, objBlog.Image, objBlog.IncludeAuthorInFeed, objBlog.IncludeImagesInFeed, objBlog.Locale, objBlog.MustApproveGhostPosts, objBlog.OwnerUserId, objBlog.PublishAsOwner, objBlog.Published, objBlog.Syndicated, objBlog.SyndicationEmail, objBlog.Title, createdByUser), Integer) - - ' localization - For Each l As String In objBlog.TitleLocalizations.Locales - DataProvider.Instance().SetBlogLocalization(objBlog.BlogID, l, objBlog.TitleLocalizations(l), objBlog.DescriptionLocalizations(l)) - Next - - Return objBlog.BlogID - - End Function - - Public Shared Sub UpdateBlog(objBlog As BlogInfo, updatedByUser As Integer) - - DataProvider.Instance().UpdateBlog(objBlog.AutoApprovePingBack, objBlog.ModuleID, objBlog.AutoApproveTrackBack, objBlog.BlogID, objBlog.Copyright, objBlog.Description, objBlog.EnablePingBackReceive, objBlog.EnablePingBackSend, objBlog.EnableTrackBackReceive, objBlog.EnableTrackBackSend, objBlog.FullLocalization, objBlog.Image, objBlog.IncludeAuthorInFeed, objBlog.IncludeImagesInFeed, objBlog.Locale, objBlog.MustApproveGhostPosts, objBlog.OwnerUserId, objBlog.PublishAsOwner, objBlog.Published, objBlog.Syndicated, objBlog.SyndicationEmail, objBlog.Title, updatedByUser) - - ' localization - For Each l As String In objBlog.TitleLocalizations.Locales - DataProvider.Instance().SetBlogLocalization(objBlog.BlogID, l, objBlog.TitleLocalizations(l), objBlog.DescriptionLocalizations(l)) - Next - - End Sub - - Public Shared Sub DeleteBlog(blogID As Int32) - - DataProvider.Instance().DeleteBlog(blogID) - - End Sub - - End Class -End Namespace - diff --git a/Server/Blog/Components/Entities/Blogs/BlogsController_FK.vb b/Server/Blog/Components/Entities/Blogs/BlogsController_FK.vb deleted file mode 100644 index 536b4c54..00000000 --- a/Server/Blog/Components/Entities/Blogs/BlogsController_FK.vb +++ /dev/null @@ -1,31 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - - - -Namespace Entities.Blogs - - Partial Public Class BlogsController - - - End Class -End Namespace - diff --git a/Server/Blog/Components/Entities/Comments/CommentInfo.vb b/Server/Blog/Components/Entities/Comments/CommentInfo.vb deleted file mode 100644 index 6b25186b..00000000 --- a/Server/Blog/Components/Entities/Comments/CommentInfo.vb +++ /dev/null @@ -1,27 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - -Namespace Entities.Comments - - Partial Public Class CommentInfo - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Entities/Comments/CommentInfo_Interfaces.vb b/Server/Blog/Components/Entities/Comments/CommentInfo_Interfaces.vb deleted file mode 100644 index 007e5e10..00000000 --- a/Server/Blog/Components/Entities/Comments/CommentInfo_Interfaces.vb +++ /dev/null @@ -1,335 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.IO -Imports System.Runtime.Serialization -Imports System.Runtime.Serialization.Json -Imports System.Xml -Imports System.Xml.Schema -Imports System.Xml.Serialization - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Services.Tokens - -Namespace Entities.Comments - - - Partial Public Class CommentInfo - Implements IHydratable - Implements IPropertyAccess - Implements IXmlSerializable - -#Region " IHydratable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' Fill hydrates the object from a Datareader - ''' - ''' The Fill method is used by the CBO method to hydrtae the object - ''' rather than using the more expensive Refection methods. - ''' - ''' [pdonker] 02/24/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub Fill(dr As IDataReader) Implements IHydratable.Fill - CommentID = Convert.ToInt32(Null.SetNull(dr.Item("CommentID"), CommentID)) - ContentItemId = Convert.ToInt32(Null.SetNull(dr.Item("ContentItemId"), ContentItemId)) - ParentId = Convert.ToInt32(Null.SetNull(dr.Item("ParentId"), ParentId)) - Comment = Convert.ToString(Null.SetNull(dr.Item("Comment"), Comment)) - Approved = Convert.ToBoolean(Null.SetNull(dr.Item("Approved"), Approved)) - Author = Convert.ToString(Null.SetNull(dr.Item("Author"), Author)) - Website = Convert.ToString(Null.SetNull(dr.Item("Website"), Website)) - Email = Convert.ToString(Null.SetNull(dr.Item("Email"), Email)) - CreatedByUserID = Convert.ToInt32(Null.SetNull(dr.Item("CreatedByUserID"), CreatedByUserID)) - CreatedOnDate = CDate(Null.SetNull(dr.Item("CreatedOnDate"), CreatedOnDate)) - LastModifiedByUserID = Convert.ToInt32(Null.SetNull(dr.Item("LastModifiedByUserID"), LastModifiedByUserID)) - LastModifiedOnDate = CDate(Null.SetNull(dr.Item("LastModifiedOnDate"), LastModifiedOnDate)) - Username = Convert.ToString(Null.SetNull(dr.Item("Username"), Username)) - DisplayName = Convert.ToString(Null.SetNull(dr.Item("DisplayName"), DisplayName)) - Likes = Convert.ToInt32(Null.SetNull(dr.Item("Likes"), Likes)) - Dislikes = Convert.ToInt32(Null.SetNull(dr.Item("Dislikes"), Dislikes)) - Reports = Convert.ToInt32(Null.SetNull(dr.Item("Reports"), Reports)) - Liked = Convert.ToInt32(Null.SetNull(dr.Item("Liked"), Likes)) - Disliked = Convert.ToInt32(Null.SetNull(dr.Item("Disliked"), Dislikes)) - Reported = Convert.ToInt32(Null.SetNull(dr.Item("Reported"), Reports)) - End Sub - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and sets the Key ID - ''' - ''' The KeyID property is part of the IHydratble interface. It is used - ''' as the key property when creating a Dictionary - ''' - ''' [pdonker] 02/24/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Property KeyID() As Integer Implements IHydratable.KeyID - Get - Return CommentID - End Get - Set(value As Integer) - CommentID = value - End Set - End Property -#End Region - -#Region " IPropertyAccess Implementation " - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As System.Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Select Case strPropertyName.ToLower - Case "commentid" - Return (CommentID.ToString(OutputFormat, formatProvider)) - Case "contentitemid" - Return (ContentItemId.ToString(OutputFormat, formatProvider)) - Case "parentid" - Return (ParentId.ToString(OutputFormat, formatProvider)) - Case "comment" - Return Comment.OutputHtml(strFormat) - Case "approved" - Return Approved.ToString - Case "approvedyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(Approved, formatProvider) - Case "author" - Return PropertyAccess.FormatString(Author, strFormat) - Case "website" - Return PropertyAccess.FormatString(Website, strFormat) - Case "email" - Return PropertyAccess.FormatString(Email, strFormat) - Case "createdbyuserid" - Return (CreatedByUserID.ToString(OutputFormat, formatProvider)) - Case "createdondate" - Return (CreatedOnDate.ToString(OutputFormat, formatProvider)) - Case "createdondateutc" - Return (CreatedOnDate.ToUniversalTime.ToString(OutputFormat, formatProvider)) - Case "lastmodifiedbyuserid" - Return (LastModifiedByUserID.ToString(OutputFormat, formatProvider)) - Case "lastmodifiedondate" - Return (LastModifiedOnDate.ToString(OutputFormat, formatProvider)) - Case "lastmodifiedondateutc" - Return (LastModifiedOnDate.ToUniversalTime.ToString(OutputFormat, formatProvider)) - Case "username" - Return PropertyAccess.FormatString(Username, strFormat) - Case "displayname" - Return PropertyAccess.FormatString(DisplayName, strFormat) - Case "likes" - Return (Likes.ToString(OutputFormat, formatProvider)) - Case "dislikes" - Return (Dislikes.ToString(OutputFormat, formatProvider)) - Case "reports" - Return (Reports.ToString(OutputFormat, formatProvider)) - Case "liked" - Return Liked.ToBool.ToString - Case "likedyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(Liked.ToBool, formatProvider) - Case "disliked" - Return Disliked.ToBool.ToString - Case "dislikedyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(Disliked.ToBool, formatProvider) - Case "reported" - Return Reported.ToBool.ToString - Case "reportedyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(Reported.ToBool, formatProvider) - Case "karmaed" - Return (Reported + Liked + Disliked).ToBool.ToString - Case "karmaedyesno" - Return PropertyAccess.Boolean2LocalizedYesNo((Reported + Liked + Disliked).ToBool, formatProvider) - Case "posturl" - Dim _Link As String = DotNetNuke.Common.ApplicationURL(DotNetNuke.Entities.Portals.PortalSettings.Current.ActiveTab.TabID) & "&Post=" & ContentItemId.ToString - Return DotNetNuke.Common.FriendlyUrl(DotNetNuke.Entities.Portals.PortalSettings.Current.ActiveTab, _Link) - Case Else - PropertyNotFound = True - End Select - - Return Null.NullString - End Function - - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - -#Region " IXmlSerializable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' GetSchema returns the XmlSchema for this class - ''' - ''' GetSchema is implemented as a stub method as it is not required - ''' - ''' [pdonker] 02/24/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Function GetSchema() As XmlSchema Implements IXmlSerializable.GetSchema - Return Nothing - End Function - - Private Function readElement(reader As XmlReader, ElementName As String) As String - If (Not reader.NodeType = XmlNodeType.Element) OrElse reader.Name <> ElementName Then - reader.ReadToFollowing(ElementName) - End If - If reader.NodeType = XmlNodeType.Element Then - Return reader.ReadElementContentAsString - Else - Return "" - End If - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' ReadXml fills the object (de-serializes it) from the XmlReader passed - ''' - ''' - ''' The XmlReader that contains the xml for the object - ''' - ''' [pdonker] 02/24/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub ReadXml(reader As XmlReader) Implements IXmlSerializable.ReadXml - Try - - If Not Int32.TryParse(readElement(reader, "CommentID"), CommentID) Then - CommentID = Null.NullInteger - End If - If Not Int32.TryParse(readElement(reader, "ContentItemId"), ContentItemId) Then - ContentItemId = Null.NullInteger - End If - If Not Int32.TryParse(readElement(reader, "ParentId"), ParentId) Then - ParentId = Null.NullInteger - End If - Comment = readElement(reader, "Comment") - Boolean.TryParse(readElement(reader, "Approved"), Approved) - Author = readElement(reader, "Author") - Website = readElement(reader, "Website") - Email = readElement(reader, "Email") - If Not Int32.TryParse(readElement(reader, "CreatedByUserID"), CreatedByUserID) Then - CreatedByUserID = Null.NullInteger - End If - Date.TryParse(readElement(reader, "CreatedOnDate"), CreatedOnDate) - If Not Int32.TryParse(readElement(reader, "LastModifiedByUserID"), LastModifiedByUserID) Then - LastModifiedByUserID = Null.NullInteger - End If - Date.TryParse(readElement(reader, "LastModifiedOnDate"), LastModifiedOnDate) - Username = readElement(reader, "Username") - DisplayName = readElement(reader, "DisplayName") - If Not Int32.TryParse(readElement(reader, "Likes"), Likes) Then - Likes = Null.NullInteger - End If - If Not Int32.TryParse(readElement(reader, "Dislikes"), Dislikes) Then - Dislikes = Null.NullInteger - End If - If Not Int32.TryParse(readElement(reader, "Reports"), Reports) Then - Reports = Null.NullInteger - End If - Catch ex As Exception - ' log exception as DNN import routine does not do that - DotNetNuke.Services.Exceptions.LogException(ex) - ' re-raise exception to make sure import routine displays a visible error to the user - Throw New Exception("An error occured during import of an Comment", ex) - End Try - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' WriteXml converts the object to Xml (serializes it) and writes it using the XmlWriter passed - ''' - ''' - ''' The XmlWriter that contains the xml for the object - ''' - ''' [pdonker] 02/24/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub WriteXml(writer As XmlWriter) Implements IXmlSerializable.WriteXml - writer.WriteStartElement("Comment") - writer.WriteElementString("CommentID", CommentID.ToString()) - writer.WriteElementString("ContentItemId", ContentItemId.ToString()) - writer.WriteElementString("ParentId", ParentId.ToString()) - writer.WriteElementString("Comment", Comment) - writer.WriteElementString("Approved", Approved.ToString()) - writer.WriteElementString("Author", Author) - writer.WriteElementString("Website", Website) - writer.WriteElementString("Email", Email) - writer.WriteElementString("CreatedByUserID", CreatedByUserID.ToString()) - writer.WriteElementString("CreatedOnDate", CreatedOnDate.ToString()) - writer.WriteElementString("LastModifiedByUserID", LastModifiedByUserID.ToString()) - writer.WriteElementString("LastModifiedOnDate", LastModifiedOnDate.ToString()) - writer.WriteElementString("Username", Username) - writer.WriteElementString("DisplayName", DisplayName) - writer.WriteElementString("Likes", Likes.ToString()) - writer.WriteElementString("Dislikes", Dislikes.ToString()) - writer.WriteElementString("Reports", Reports.ToString()) - writer.WriteEndElement() - End Sub -#End Region - -#Region " ToXml Methods " - Public Function ToXml() As String - Return ToXml("Comment") - End Function - - Public Function ToXml(elementName As String) As String - Dim xml As New StringBuilder - xml.Append("<") - xml.Append(elementName) - AddAttribute(xml, "CommentID", CommentID.ToString()) - AddAttribute(xml, "ContentItemId", ContentItemId.ToString()) - AddAttribute(xml, "ParentId", ParentId.ToString()) - AddAttribute(xml, "Comment", Comment) - AddAttribute(xml, "Approved", Approved.ToString()) - AddAttribute(xml, "Author", Author) - AddAttribute(xml, "Website", Website) - AddAttribute(xml, "Email", Email) - AddAttribute(xml, "CreatedByUserID", CreatedByUserID.ToString()) - AddAttribute(xml, "CreatedOnDate", CreatedOnDate.ToUniversalTime.ToString("u")) - AddAttribute(xml, "LastModifiedByUserID", LastModifiedByUserID.ToString()) - AddAttribute(xml, "LastModifiedOnDate", LastModifiedOnDate.ToUniversalTime.ToString("u")) - AddAttribute(xml, "Username", Username) - AddAttribute(xml, "DisplayName", DisplayName) - AddAttribute(xml, "Likes", Likes.ToString()) - AddAttribute(xml, "Dislikes", Dislikes.ToString()) - AddAttribute(xml, "Reports", Reports.ToString()) - xml.Append(" />") - Return xml.ToString - End Function - - Private Sub AddAttribute(ByRef xml As StringBuilder, attributeName As String, attributeValue As String) - xml.Append(" " & attributeName) - xml.Append("=""" & attributeValue & """") - End Sub -#End Region - -#Region " JSON Serialization " - Public Sub WriteJSON(ByRef s As Stream) - Dim ser As New DataContractJsonSerializer(GetType(CommentInfo)) - ser.WriteObject(s, Me) - End Sub -#End Region - - End Class -End Namespace - - diff --git a/Server/Blog/Components/Entities/Comments/CommentInfo_Properties.vb b/Server/Blog/Components/Entities/Comments/CommentInfo_Properties.vb deleted file mode 100644 index 63dfae96..00000000 --- a/Server/Blog/Components/Entities/Comments/CommentInfo_Properties.vb +++ /dev/null @@ -1,80 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Runtime.Serialization - -Namespace Entities.Comments - Partial Public Class CommentInfo - -#Region " Private Members " -#End Region - -#Region " Constructors " - Public Sub New() - End Sub -#End Region - -#Region " Public Properties " - - Public Property CommentID As Int32 = -1 - - Public Property ContentItemId As Int32 = -1 - - Public Property ParentId As Int32 = -1 - - Public Property Comment As String = "" - - Public Property Approved As Boolean = False - - Public Property Author As String = "" - - Public Property Website As String = "" - - Public Property Email As String = "" - - Public Property CreatedByUserID As Int32 = -1 - - Public Property CreatedOnDate As Date = Date.MinValue - - Public Property LastModifiedByUserID As Int32 = -1 - - Public Property LastModifiedOnDate As Date = Date.MinValue - - Public Property Username As String = "" - - Public Property DisplayName As String = "" - - Public Property Likes As Int32 = 0 - - Public Property Dislikes As Int32 = 0 - - Public Property Reports As Int32 = 0 - - Public Property Liked As Int32 = 0 - - Public Property Disliked As Int32 = 0 - - Public Property Reported As Int32 = 0 -#End Region - - End Class -End Namespace - - diff --git a/Server/Blog/Components/Entities/Comments/CommentsController.vb b/Server/Blog/Components/Entities/Comments/CommentsController.vb deleted file mode 100644 index 83cbaf2f..00000000 --- a/Server/Blog/Components/Entities/Comments/CommentsController.vb +++ /dev/null @@ -1,121 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Entities.Portals -Imports DotNetNuke.Services.Localization.Localization - -Imports DotNetNuke.Modules.Blog.Data -Imports DotNetNuke.Modules.Blog.Integration -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Modules.Blog.Common.Globals - -Namespace Entities.Comments - - Partial Public Class CommentsController - - Public Shared Function GetComment(commentID As Int32, userId As Integer) As CommentInfo - - Return CBO.FillObject(Of CommentInfo)(DataProvider.Instance().GetComment(commentID, userId)) - - End Function - - Public Shared Function GetCommentsByModule(moduleId As Int32, userID As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String, ByRef totalRecords As Integer) As Dictionary(Of Integer, CommentInfo) - - If pageIndex < 0 Then - pageIndex = 0 - pageSize = Integer.MaxValue - End If - - Dim res As New Dictionary(Of Integer, CommentInfo) - Using ir As IDataReader = DataProvider.Instance().GetCommentsByModuleId(moduleId, userID, pageIndex, pageSize, orderBy) - res = DotNetNuke.Common.Utilities.CBO.FillDictionary(Of Integer, CommentInfo)("CommentId", ir, False) - ir.NextResult() - totalRecords = DotNetNuke.Common.Globals.GetTotalRecords(ir) - End Using - Return res - - End Function - - Public Shared Function AddComment(blog As BlogInfo, Post As PostInfo, ByRef comment As CommentInfo) As Integer - - AddComment(comment, PortalSettings.Current.UserId) - If comment.Approved Then - JournalController.AddOrUpdateCommentInJournal(blog, Post, comment, PortalSettings.Current.PortalId, PortalSettings.Current.ActiveTab.TabID, PortalSettings.Current.UserId, Post.PermaLink(PortalSettings.Current)) - Else - Dim title As String = GetString("CommentPendingNotify.Subject", SharedResourceFileName) - Dim summary As String = String.Format(GetString("CommentPendingNotify.Body", SharedResourceFileName), Post.PermaLink(PortalSettings.Current), comment.CommentID, Post.Title, comment.Comment) - NotificationController.CommentPendingApproval(comment, blog, Post, PortalSettings.Current.PortalId, summary, title) - End If - Return comment.CommentID - - End Function - - Public Shared Sub UpdateComment(blog As BlogInfo, Post As PostInfo, comment As CommentInfo) - - UpdateComment(comment, PortalSettings.Current.UserId) - NotificationController.RemoveCommentPendingNotification(blog.ModuleID, blog.BlogID, comment.ContentItemId, comment.CommentID) - If comment.Approved Then - JournalController.AddOrUpdateCommentInJournal(blog, Post, comment, PortalSettings.Current.PortalId, PortalSettings.Current.ActiveTab.TabID, PortalSettings.Current.UserId, Post.PermaLink(PortalSettings.Current)) - Else - Dim title As String = GetString("CommentPendingNotify.Subject", SharedResourceFileName) - Dim summary As String = String.Format(GetString("CommentPendingNotify.Body", SharedResourceFileName), Post.PermaLink(PortalSettings.Current), comment.CommentID, Post.Title, comment.Comment) - NotificationController.CommentPendingApproval(comment, blog, Post, PortalSettings.Current.PortalId, summary, title) - End If - - End Sub - - Public Shared Sub ApproveComment(moduleId As Integer, blogId As Integer, comment As CommentInfo) - - Data.DataProvider.Instance.ApproveComment(comment.CommentID) - NotificationController.RemoveCommentPendingNotification(moduleId, blogId, comment.ContentItemId, comment.CommentID) - - End Sub - - Public Shared Sub DeleteComment(moduleId As Integer, blogId As Integer, comment As CommentInfo) - - DataProvider.Instance().DeleteComment(comment.CommentID) - NotificationController.RemoveCommentPendingNotification(moduleId, blogId, comment.ContentItemId, comment.CommentID) - - End Sub - - Public Shared Function CommentKarma(callingModule As ModuleInfo, comment As CommentInfo, user As DotNetNuke.Entities.Users.UserInfo, karma As Integer) As Integer - - If user.UserID < 0 Then Return -1 - Dim ret As Integer = Data.DataProvider.Instance.AddCommentKarma(comment.CommentID, user.UserID, karma) - If ret > -1 Then - If karma = 2 Then ' reporting comment as inappropriate - Dim title As String = String.Format(GetString("CommentReportedNotify", SharedResourceFileName), user.DisplayName) - Dim post As PostInfo = PostsController.GetPost(comment.ContentItemId, callingModule.ModuleID, "") - Dim summary As String = String.Format(GetString("CommentReportedNotify.Body", SharedResourceFileName), user.DisplayName, comment.DisplayName, comment.Comment, post.PermaLink(PortalSettings.Current), post.Title) - NotificationController.ReportComment(comment, post.Blog, post, callingModule.PortalID, summary, title) - End If - Return ret - End If - Return 0 - - End Function - - End Class -End Namespace - diff --git a/Server/Blog/Components/Entities/Comments/CommentsController_CRUD.vb b/Server/Blog/Components/Entities/Comments/CommentsController_CRUD.vb deleted file mode 100644 index d873cd93..00000000 --- a/Server/Blog/Components/Entities/Comments/CommentsController_CRUD.vb +++ /dev/null @@ -1,50 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - - -Imports DotNetNuke.Modules.Blog.Data - -Namespace Entities.Comments - - Partial Public Class CommentsController - - Public Shared Function AddComment(ByRef objComment As CommentInfo, createdByUser As Integer) As Integer - - objComment.CommentID = CType(DataProvider.Instance().AddComment(objComment.Approved, objComment.Author, objComment.Comment, objComment.ContentItemId, objComment.Email, objComment.ParentId, objComment.Website, createdByUser), Integer) - Return objComment.CommentID - - End Function - - Public Shared Sub UpdateComment(objComment As CommentInfo, updatedByUser As Integer) - - DataProvider.Instance().UpdateComment(objComment.Approved, objComment.Author, objComment.Comment, objComment.CommentID, objComment.ContentItemId, objComment.Email, objComment.ParentId, objComment.Website, updatedByUser) - - End Sub - - Public Shared Sub DeleteComment(commentID As Int32) - - DataProvider.Instance().DeleteComment(commentID) - - End Sub - - End Class -End Namespace - diff --git a/Server/Blog/Components/Entities/Comments/CommentsController_FK.vb b/Server/Blog/Components/Entities/Comments/CommentsController_FK.vb deleted file mode 100644 index 928a4f4c..00000000 --- a/Server/Blog/Components/Entities/Comments/CommentsController_FK.vb +++ /dev/null @@ -1,37 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - - -Imports DotNetNuke.Modules.Blog.Data - -Namespace Entities.Comments - - Partial Public Class CommentsController - - Public Shared Function GetCommentsByContentItem(contentItemId As Int32, IncludeNonApproved As Boolean, userId As Integer) As List(Of CommentInfo) - - Return DotNetNuke.Common.Utilities.CBO.FillCollection(Of CommentInfo)(DataProvider.Instance().GetCommentsByContentItem(contentItemId, IncludeNonApproved, userId)) - - End Function - - End Class -End Namespace - diff --git a/Server/Blog/Components/Entities/Comments/CommentsController_Service.vb b/Server/Blog/Components/Entities/Comments/CommentsController_Service.vb deleted file mode 100644 index 1246d672..00000000 --- a/Server/Blog/Components/Entities/Comments/CommentsController_Service.vb +++ /dev/null @@ -1,427 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Linq -Imports System.Net -Imports System.Net.Http -Imports System.Web.Http -Imports DotNetNuke.Web.Api -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Modules.Blog.Security -Imports DotNetNuke.Modules.Blog.Services -Imports DotNetNuke.Modules.Blog.Templating -Imports System.Xml - -Namespace Entities.Comments - Partial Public Class CommentsController - Inherits DnnApiController - - Public Class CommentDTO - Public Property BlogId As Integer - Public Property CommentId As Integer - Public Property Karma As Integer - End Class - - Public Class FullCommentDTO - Public Property BlogId As Integer - Public Property PostId As Integer - Public Property ParentId As Integer - Public Property Comment As String - Public Property Author As String - Public Property Website As String - Public Property Email As String - End Class - -#Region " Private Members " - Private Property Blog As BlogInfo = Nothing - Private Property Post As PostInfo = Nothing - Private Property Comment As CommentInfo = Nothing - Private Property AllComments As New List(Of CommentInfo) - - Private _Settings As ModuleSettings - Private Property Settings() As ModuleSettings - Get - If _Settings Is Nothing Then - _Settings = ModuleSettings.GetModuleSettings(ActiveModule.ModuleID) - End If - Return _Settings - End Get - Set(ByVal value As ModuleSettings) - _Settings = value - End Set - End Property - - Private _viewSettings As ViewSettings - Private Property ViewSettings() As ViewSettings - Get - If _viewSettings Is Nothing Then - _viewSettings = ViewSettings.GetViewSettings(ActiveModule.TabModuleID) - End If - Return _viewSettings - End Get - Set(ByVal value As ViewSettings) - _viewSettings = value - End Set - End Property - - Private _Security As ContextSecurity - Private Property Security() As ContextSecurity - Get - If _Security Is Nothing Then - _Security = New ContextSecurity(ActiveModule.ModuleID, ActiveModule.TabID, Blog, UserInfo) - End If - Return _Security - End Get - Set(ByVal value As ContextSecurity) - _Security = value - End Set - End Property -#End Region - -#Region " Service Methods " - - - - - Public Function ApproveComment(postData As CommentDTO) As HttpResponseMessage - SetContext(postData) - If Blog Is Nothing Or Comment Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - CommentsController.ApproveComment(ActiveModule.ModuleID, Blog.BlogID, Comment) - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - End Function - - - - - - Public Function DeleteComment(postData As CommentDTO) As HttpResponseMessage - SetContext(postData) - If Blog Is Nothing Or Comment Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - CommentsController.DeleteComment(ActiveModule.ModuleID, Blog.BlogID, Comment) - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - End Function - - - - - - Public Function ReportComment(postData As CommentDTO) As HttpResponseMessage - SetContext(postData) - If Blog Is Nothing Or Comment Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - If UserInfo.UserID < 0 Then Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - Dim ret As Integer = Data.DataProvider.Instance.AddCommentKarma(postData.CommentId, UserInfo.UserID, postData.Karma) - If ret = -1 Then Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "exists"}) - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - End Function - - - - - - Public Function AddComment(postData As FullCommentDTO) As HttpResponseMessage - SetContext(postData) - Post = PostsController.GetPost(postData.PostId, ActiveModule.ModuleID, "") - If Blog Is Nothing Or Post Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - Dim objComment As New CommentInfo - objComment.ContentItemId = Post.ContentItemId - objComment.CreatedByUserID = UserInfo.UserID - objComment.ParentId = postData.ParentId - objComment.Comment = HttpUtility.HtmlEncode(SafeStringSimpleHtml(postData.Comment).Replace(vbCrLf, "
")) - objComment.Approved = Security.CanAutoApproveComment Or Security.CanApproveComment Or Post.CreatedByUserID = UserInfo.UserID - objComment.Author = SafeString(postData.Author) - objComment.Email = SafeString(postData.Email) - objComment.Website = SafeString(postData.Website) - objComment.CommentID = CommentsController.AddComment(Blog, Post, objComment) - If Not objComment.Approved Then - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "successnotapproved"}) - End If - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - End Function - - - - - - Public Function ListComments() As HttpResponseMessage - Dim BlogId As Integer = -1 - Dim PostId As Integer = -1 - HttpContext.Current.Request.Params.ReadValue("blogId", BlogId) - HttpContext.Current.Request.Params.ReadValue("postId", PostId) - Blog = BlogsController.GetBlog(BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) - Post = PostsController.GetPost(PostId, ActiveModule.ModuleID, "") - If Blog Is Nothing Or Post Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - If Not Security.CanViewComments Then Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = ""}) - Dim ViewSettings As ViewSettings = ViewSettings.GetViewSettings(ActiveModule.TabModuleID) - AllComments = CommentsController.GetCommentsByContentItem(Post.ContentItemId, Security.CanApproveComment, UserInfo.UserID) - Dim vt As New ViewTemplate - Dim tmgr As New TemplateManager(PortalSettings, ViewSettings.Template) - With vt - .TemplatePath = tmgr.TemplatePath - .TemplateRelPath = tmgr.TemplateRelPath - .TemplateMapPath = tmgr.TemplateMapPath - .DefaultReplacer = New BlogTokenReplace(ActiveModule, Security, Blog, Post, Settings, ViewSettings) - .StartTemplate = "CommentsTemplate.html" - End With - AddHandler vt.GetData, AddressOf TemplateGetData - vt.DataBind() - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = vt.GetContentsAsString}) - End Function - - - - - Public Function Pingback() As HttpResponseMessage - - Dim BlogId As Integer = -1 - Dim PostId As Integer = -1 - HttpContext.Current.Request.Params.ReadValue("blogId", BlogId) - HttpContext.Current.Request.Params.ReadValue("postId", PostId) - Blog = BlogsController.GetBlog(BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) - If Not Blog.EnablePingBackReceive Then - Return Request.CreateResponse(HttpStatusCode.NotFound, New With {.Result = "This blog does not accept pingbacks"}) - End If - Post = PostsController.GetPost(PostId, ActiveModule.ModuleID, "") - If Post Is Nothing Then - Return PingBackError(32, "The specified target URI does not exist.") - End If - - Dim doc As XmlDocument = RetrieveXmlDocument(HttpContext.Current) - Dim list As XmlNodeList = If(doc.SelectNodes("methodCall/params/param/value/string"), doc.SelectNodes("methodCall/params/param/value")) - - If list Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "Cannot parse the request"}) - End If - - Dim sourceUrl As String = SafeString(list(0).InnerText.Trim()) - Dim targetUrl As String = SafeString(list(1).InnerText.Trim()) - - Dim containsHtml As Boolean = False - Dim sourceHasLink As Boolean = False - Dim title As String = sourceUrl - - Try - CheckSourcePage(sourceUrl, targetUrl, sourceHasLink, title) - Catch ex As Exception - End Try - - If Not IsFirstPingBack(Post, sourceUrl) Then - Return PingBackError(48, "The pingback has already been registered.") - End If - - If Not sourceHasLink Then - Return PingBackError(17, "The source URI does not contain a link to the target URI, and so cannot be used as a source.") - End If - - If containsHtml Then - ' spam - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "Cannot parse the request"}) - Else - Dim objComment As New CommentInfo With {.ContentItemId = Post.ContentItemId, .Author = GetDomain(sourceUrl), .Website = sourceUrl} - Dim comment As String = String.Format(DotNetNuke.Services.Localization.Localization.GetString("PingbackComment", SharedResourceFileName), objComment.Author, sourceUrl, title) - objComment.Comment = HttpUtility.HtmlEncode(comment) - objComment.Approved = Blog.AutoApprovePingBack - objComment.CommentID = CommentsController.AddComment(Blog, Post, objComment) - Return PingBackSuccess() - End If - - End Function - - - - - Public Function Trackback() As HttpResponseMessage - - Dim BlogId As Integer = -1 - Dim PostId As Integer = -1 - HttpContext.Current.Request.Params.ReadValue("blogId", BlogId) - HttpContext.Current.Request.Params.ReadValue("postId", PostId) - Blog = BlogsController.GetBlog(BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) - If Not Blog.EnableTrackBackReceive Then - Return Request.CreateResponse(HttpStatusCode.NotFound, New With {.Result = "This blog does not accept trackbacks"}) - End If - Post = PostsController.GetPost(PostId, ActiveModule.ModuleID, "") - If Post Is Nothing Then - Return TrackBackResponse("The source page does not link") - End If - - Dim title As String = SafeString(HttpContext.Current.Request.Params("title")) - Dim excerpt As String = SafeString(HttpContext.Current.Request.Params("excerpt")) - Dim blogName As String = SafeString(HttpContext.Current.Request.Params("blog_name")) - Dim sourceUrl As String = String.Empty - If HttpContext.Current.Request.Params("url") IsNot Nothing Then - sourceUrl = SafeString(HttpContext.Current.Request.Params("url").Split(","c)(0), DotNetNuke.Security.PortalSecurity.FilterFlag.NoSQL And DotNetNuke.Security.PortalSecurity.FilterFlag.NoScripting) - End If - - Dim sourceHasLink As Boolean = False - - Try - CheckSourcePage(sourceUrl, Post.PermaLink(PortalSettings), sourceHasLink, title) - Catch ex As Exception - End Try - - If Not IsFirstPingBack(Post, sourceUrl) Then - Return TrackBackResponse("Trackback already registered") - End If - - If Not sourceHasLink Then - Return TrackBackResponse("The source page does not link") - End If - - Dim objComment As New CommentInfo With {.ContentItemId = Post.ContentItemId, .Author = blogName, .Website = sourceUrl} - Dim comment As String = String.Format(DotNetNuke.Services.Localization.Localization.GetString("TrackbackComment", SharedResourceFileName), blogName, sourceUrl, title) - objComment.Comment = HttpUtility.HtmlEncode(comment) - objComment.Approved = Blog.AutoApproveTrackBack - objComment.CommentID = CommentsController.AddComment(Blog, Post, objComment) - Return TrackBackResponse() - - End Function -#End Region - -#Region " Private Methods " - Private Sub SetContext(data As CommentDTO) - Blog = BlogsController.GetBlog(data.BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) - Comment = CommentsController.GetComment(data.CommentId, UserInfo.UserID) - End Sub - - Private Sub SetContext(data As FullCommentDTO) - Blog = BlogsController.GetBlog(data.BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) - End Sub - - Private Sub TemplateGetData(ByVal DataSource As String, ByVal Parameters As Dictionary(Of String, String), ByRef Replacers As System.Collections.Generic.List(Of GenericTokenReplace), ByRef Arguments As System.Collections.Generic.List(Of String()), callingObject As Object) - - Select Case DataSource.ToLower - - Case "comments" - - If callingObject IsNot Nothing AndAlso TypeOf callingObject Is CommentInfo Then - Dim parent As Integer = CType(callingObject, CommentInfo).CommentID - For Each c As CommentInfo In AllComments.Where(Function(cmt) cmt.ParentId = parent).OrderBy(Function(cmt) cmt.CreatedOnDate) - Replacers.Add(New BlogTokenReplace(ActiveModule, Security, Blog, Post, Settings, ViewSettings, c)) - Next - Else - For Each c As CommentInfo In AllComments.Where(Function(cmt) cmt.ParentId = -1).OrderBy(Function(cmt) cmt.CreatedOnDate) - Replacers.Add(New BlogTokenReplace(ActiveModule, Security, Blog, Post, Settings, ViewSettings, c)) - Next - End If - - End Select - - End Sub - - Private Shared Function RetrieveXmlDocument(context As HttpContext) As XmlDocument - Dim xml As String = ParseRequest(context) - If Not xml.Contains("pingback.ping") Then - context.Response.StatusCode = 404 - context.Response.[End]() - End If - Dim doc As New XmlDocument() - doc.LoadXml(xml) - Return doc - End Function - - Private Shared Function ParseRequest(context As HttpContext) As String - Dim buffer(CInt(context.Request.InputStream.Length - 1)) As Byte - context.Request.InputStream.Read(buffer, 0, buffer.Length) - Return Encoding.[Default].GetString(buffer) - End Function - - Private Shared Function IsFirstPingBack(post As PostInfo, sourceUrl As String) As Boolean - For Each c As CommentInfo In CommentsController.GetCommentsByContentItem(post.ContentItemId, True, -1) - If c.Website.ToString.Equals(sourceUrl, StringComparison.OrdinalIgnoreCase) Then Return False - Next - Return True - End Function - - Private Shared Function TrackBackResponse() As HttpResponseMessage - Return TrackBackResponse("0") - End Function - Private Shared Function TrackBackResponse(status As String) As HttpResponseMessage - Dim reply As String = String.Format("{0}", status) - Dim res As New HttpResponseMessage(HttpStatusCode.OK) - res.Content = New StringContent(reply, System.Text.Encoding.UTF8, "application/xml") - Return res - End Function - - Private Shared Function PingBackSuccess() As HttpResponseMessage - Dim Success As String = "Thanks!" - Dim res As New HttpResponseMessage(HttpStatusCode.OK) - res.Content = New StringContent(Success, System.Text.Encoding.UTF8, "application/xml") - Return res - End Function - - Private Shared Function PingBackError(code As Integer, message As String) As HttpResponseMessage - Dim sb As New StringBuilder() - sb.Append("") - sb.Append("") - sb.Append("") - sb.Append("") - sb.Append("") - sb.Append("") - sb.Append("faultCode") - sb.AppendFormat("{0}", code) - sb.Append("") - sb.Append("") - sb.Append("faultString") - sb.AppendFormat("{0}", message) - sb.Append("") - sb.Append("") - sb.Append("") - sb.Append("") - sb.Append("") - Dim res As New HttpResponseMessage(HttpStatusCode.OK) - res.Content = New StringContent(sb.ToString, System.Text.Encoding.UTF8, "application/xml") - Return res - End Function - - Private Shared Function GetDomain(sourceUrl As String) As String - Dim start As Integer = sourceUrl.IndexOf("://") + 3 - Dim [stop] As Integer = sourceUrl.IndexOf("/", start) - Return sourceUrl.Substring(start, [stop] - start).Replace("www.", String.Empty) - End Function - - Private Shared Sub CheckSourcePage(sourceUrl As String, targetUrl As String, ByRef sourceContainsLink As Boolean, ByRef title As String) - - Dim remoteFile As New WebPage(New Uri(sourceUrl)) - Dim html As String = remoteFile.GetFileAsString() - Dim RegexTitle As New Regex("(?<=)([\s\S]*)(?=)", RegexOptions.IgnoreCase Or RegexOptions.Compiled) - Dim titleMatch As Match = RegexTitle.Match(html) - If titleMatch.Success Then title = SafeString(titleMatch.Value.Trim(CChar(vbCrLf)).Trim()) - html = html.ToUpperInvariant - targetUrl = targetUrl.ToUpperInvariant - sourceContainsLink = html.Contains("HREF=""" & targetUrl & """") OrElse html.Contains("HREF='" & targetUrl & "'") - - End Sub -#End Region - - End Class -End Namespace - diff --git a/Server/Blog/Components/Entities/LegacyUrls/LegacyUrlInfo_Interfaces.vb b/Server/Blog/Components/Entities/LegacyUrls/LegacyUrlInfo_Interfaces.vb deleted file mode 100644 index 817665ac..00000000 --- a/Server/Blog/Components/Entities/LegacyUrls/LegacyUrlInfo_Interfaces.vb +++ /dev/null @@ -1,68 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Modules - -Namespace Entities.LegacyUrls - Partial Public Class LegacyUrlInfo - Implements IHydratable - -#Region " IHydratable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' Fill hydrates the object from a Datareader - ''' - ''' The Fill method is used by the CBO method to hydrtae the object - ''' rather than using the more expensive Refection methods. - ''' - ''' [pdonker] 05/23/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub Fill(dr As IDataReader) Implements IHydratable.Fill - - ContentItemId = Convert.ToInt32(Null.SetNull(dr.Item("ContentItemId"), ContentItemId)) - EntryId = Convert.ToInt32(Null.SetNull(dr.Item("EntryId"), EntryId)) - Url = Convert.ToString(Null.SetNull(dr.Item("Url"), Url)) - - End Sub - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and sets the Key ID - ''' - ''' The KeyID property is part of the IHydratble interface. It is used - ''' as the key property when creating a Dictionary - ''' - ''' [pdonker] 05/23/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Property KeyID() As Integer Implements IHydratable.KeyID - Get - Return Nothing - End Get - Set(value As Integer) - End Set - End Property -#End Region - - End Class -End Namespace - diff --git a/Server/Blog/Components/Entities/LegacyUrls/LegacyUrlInfo_Properties.vb b/Server/Blog/Components/Entities/LegacyUrls/LegacyUrlInfo_Properties.vb deleted file mode 100644 index 22dc25c0..00000000 --- a/Server/Blog/Components/Entities/LegacyUrls/LegacyUrlInfo_Properties.vb +++ /dev/null @@ -1,50 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Runtime.Serialization - -Namespace Entities.LegacyUrls - Partial Public Class LegacyUrlInfo - -#Region " Private Members " -#End Region - -#Region " Constructors " - Public Sub New() - End Sub - - Public Sub New(url As String, contentItemId As Int32, entryId As Int32) - Me.ContentItemId = contentItemId - Me.EntryId = entryId - Me.Url = url - End Sub -#End Region - -#Region " Public Properties " - - Public Property ContentItemId As Int32 = -1 - - Public Property EntryId As Int32 = -1 - - Public Property Url As String = "" -#End Region - - End Class -End Namespace diff --git a/Server/Blog/Components/Entities/LegacyUrls/LegacyUrlsController_CRUD.vb b/Server/Blog/Components/Entities/LegacyUrls/LegacyUrlsController_CRUD.vb deleted file mode 100644 index aa61373e..00000000 --- a/Server/Blog/Components/Entities/LegacyUrls/LegacyUrlsController_CRUD.vb +++ /dev/null @@ -1,35 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - -Imports DotNetNuke.Modules.Blog.Data - -Namespace Entities.LegacyUrls - - Partial Public Class LegacyUrlsController - - Public Shared Sub AddLegacyUrl(objLegacyUrl As LegacyUrlInfo) - - DataProvider.Instance().AddLegacyUrl(objLegacyUrl.ContentItemId, objLegacyUrl.EntryId, objLegacyUrl.Url) - - End Sub - - End Class -End Namespace diff --git a/Server/Blog/Components/Entities/Posts/PostAuthor.vb b/Server/Blog/Components/Entities/Posts/PostAuthor.vb deleted file mode 100644 index 69ca6138..00000000 --- a/Server/Blog/Components/Entities/Posts/PostAuthor.vb +++ /dev/null @@ -1,150 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Common.Globals - -Imports System.Runtime.Serialization -Imports DotNetNuke.Entities.Users -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Services.Tokens - -Namespace Entities.Posts - Public Class PostAuthor - Inherits UserInfo - - Implements IHydratable - Implements IPropertyAccess - -#Region " Public Properties " - - Public Property ParentTabID As Integer = -1 - Public Property NrPosts As Int32 = 0 - - Public Property NrViews As Int32 = 0 - - Public Property LastPublishDate As Date = Date.MinValue - - Public Property FirstPublishDate As Date = Date.MinValue -#End Region - -#Region " IHydratable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' Fill hydrates the object from a Datareader - ''' - ''' The Fill method is used by the CBO method to hydrtae the object - ''' rather than using the more expensive Refection methods. - ''' - ''' [pdonker] 02/16/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub Fill(dr As IDataReader) Implements IHydratable.Fill - PortalID = Convert.ToInt32(Null.SetNull(dr.Item("PortalID"), PortalID)) - IsSuperUser = Convert.ToBoolean(Null.SetNull(dr.Item("IsSuperUser"), IsSuperUser)) - UserID = Convert.ToInt32(Null.SetNull(dr.Item("UserID"), UserID)) - FirstName = Convert.ToString(Null.SetNull(dr.Item("FirstName"), FirstName)) - LastName = Convert.ToString(Null.SetNull(dr.Item("LastName"), LastName)) - DisplayName = Convert.ToString(Null.SetNull(dr.Item("DisplayName"), DisplayName)) - Username = Convert.ToString(Null.SetNull(dr.Item("Username"), Username)) - Email = Convert.ToString(Null.SetNull(dr.Item("Email"), Email)) - NrPosts = Convert.ToInt32(Null.SetNull(dr.Item("NrPosts"), NrPosts)) - NrViews = Convert.ToInt32(Null.SetNull(dr.Item("NrViews"), NrViews)) - LastPublishDate = CDate(Null.SetNull(dr.Item("LastPublishDate"), LastPublishDate)) - FirstPublishDate = CDate(Null.SetNull(dr.Item("FirstPublishDate"), FirstPublishDate)) - End Sub - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and sets the Key ID - ''' - ''' The KeyID property is part of the IHydratble interface. It is used - ''' as the key property when creating a Dictionary - ''' - ''' [pdonker] 02/16/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Property KeyID() As Integer Implements IHydratable.KeyID - Get - Return Nothing - End Get - Set(value As Integer) - End Set - End Property -#End Region - -#Region " IPropertyAccess Implementation " - Public Shadows Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As System.Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Select Case strPropertyName.ToLower - Case "nrposts" - Return (NrPosts.ToString(OutputFormat, formatProvider)) - Case "nrviews" - Return (NrViews.ToString(OutputFormat, formatProvider)) - Case "lastpublishdate" - Return (LastPublishDate.ToString(OutputFormat, formatProvider)) - Case "firstpublishdate" - Return (FirstPublishDate.ToString(OutputFormat, formatProvider)) - Case "parenturl" - Return PermaLink(ParentTabID) - Case Else - Return MyBase.GetProperty(strPropertyName, strFormat, formatProvider, AccessingUser, AccessLevel, PropertyNotFound) - End Select - End Function - - Public Shadows ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - -#Region " Public Methods " - Public Function PermaLink(portalSettings As DotNetNuke.Entities.Portals.PortalSettings) As String - Return PermaLink(portalSettings.ActiveTab) - End Function - Public Function PermaLink(strParentTabID As Integer) As String - Dim oTabController As DotNetNuke.Entities.Tabs.TabController = New DotNetNuke.Entities.Tabs.TabController - Dim oParentTab As DotNetNuke.Entities.Tabs.TabInfo = oTabController.GetTab(strParentTabID, DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, False) - _permaLink = String.Empty - Return PermaLink(oParentTab) - End Function - - Private _permaLink As String = "" - Public Function PermaLink(tab As DotNetNuke.Entities.Tabs.TabInfo) As String - If String.IsNullOrEmpty(_permaLink) Then - _permaLink = ApplicationURL(tab.TabID) & "&author=" & UserID.ToString - If DotNetNuke.Entities.Host.Host.UseFriendlyUrls Then - _permaLink = FriendlyUrl(tab, _permaLink, "") - Else - _permaLink = ResolveUrl(_permaLink) - End If - End If - Return _permaLink - End Function - -#End Region - End Class -End Namespace diff --git a/Server/Blog/Components/Entities/Posts/PostInfo.vb b/Server/Blog/Components/Entities/Posts/PostInfo.vb deleted file mode 100644 index 61fa90e1..00000000 --- a/Server/Blog/Components/Entities/Posts/PostInfo.vb +++ /dev/null @@ -1,104 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Linq -Imports DotNetNuke.Common.Globals -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Entities.Terms - -Namespace Entities.Posts - - Partial Public Class PostInfo - - Public ReadOnly Property PostCategories As List(Of TermInfo) - Get - Return Terms.Where(Function(t) t.VocabularyId <> 1).ToList - End Get - End Property - - Public ReadOnly Property PostTags As List(Of TermInfo) - Get - Return Terms.Where(Function(t) t.VocabularyId = 1).ToList - End Get - End Property - - Public Function PermaLink(strParentTabID As Integer) As String - Dim oTabController As DotNetNuke.Entities.Tabs.TabController = New DotNetNuke.Entities.Tabs.TabController - Dim oParentTab As DotNetNuke.Entities.Tabs.TabInfo = oTabController.GetTab(strParentTabID, DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, False) - _permaLink = String.Empty - Return PermaLink(oParentTab) - End Function - - Public Function PermaLink() As String - Return PermaLink(DotNetNuke.Entities.Portals.PortalSettings.Current.ActiveTab) - End Function - - Public Function PermaLink(portalSettings As DotNetNuke.Entities.Portals.PortalSettings) As String - Return PermaLink(portalSettings.ActiveTab) - End Function - - Private _permaLink As String = "" - Public Function PermaLink(tab As DotNetNuke.Entities.Tabs.TabInfo) As String - If String.IsNullOrEmpty(_permaLink) Then - _permaLink = ApplicationURL(tab.TabID) - If Not String.IsNullOrEmpty(Locale) Then - _permaLink &= "&language=" & Locale - End If - _permaLink &= "&Post=" & ContentItemId.ToString - If DotNetNuke.Entities.Host.Host.UseFriendlyUrls Then - _permaLink = FriendlyUrl(tab, _permaLink, GetSafePageName(LocalizedTitle)) - Else - _permaLink = ResolveUrl(_permaLink) - End If - End If - Return _permaLink - End Function - - Private _terms As List(Of TermInfo) - Public Shadows Property Terms() As List(Of TermInfo) - Get - If _terms Is Nothing Then - _terms = TermsController.GetTermsByPost(ContentItemId, Blog.ModuleID, Threading.Thread.CurrentThread.CurrentCulture.Name) - End If - If _terms Is Nothing Then - _terms = New List(Of TermInfo) - End If - Return _terms - End Get - Set(ByVal value As List(Of TermInfo)) - _terms = value - End Set - End Property - - Private _blog As BlogInfo = Nothing - Public Property Blog() As BlogInfo - Get - If _blog Is Nothing Then - _blog = BlogsController.GetBlog(BlogID, -1, Threading.Thread.CurrentThread.CurrentCulture.Name) - End If - Return _blog - End Get - Set(ByVal value As BlogInfo) - _blog = value - End Set - End Property - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Entities/Posts/PostInfo_Interfaces.vb b/Server/Blog/Components/Entities/Posts/PostInfo_Interfaces.vb deleted file mode 100644 index 2862852c..00000000 --- a/Server/Blog/Components/Entities/Posts/PostInfo_Interfaces.vb +++ /dev/null @@ -1,362 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.IO -Imports System.Linq -Imports System.Runtime.Serialization -Imports System.Runtime.Serialization.Json -Imports System.Xml -Imports System.Xml.Schema -Imports System.Xml.Serialization - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Services.Tokens - -Imports DotNetNuke.Modules.Blog.Common.Globals - -Namespace Entities.Posts - - - Partial Public Class PostInfo - Implements IHydratable - Implements IPropertyAccess - Implements IXmlSerializable - -#Region " ML Properties " - Public Property ParentTabID As Integer = -1 -#End Region - -#Region " IHydratable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' Fill hydrates the object from a Datareader - ''' - ''' The Fill method is used by the CBO method to hydrtae the object - ''' rather than using the more expensive Refection methods. - ''' - ''' [pdonker] 02/19/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Overrides Sub Fill(dr As IDataReader) Implements IHydratable.Fill - FillInternal(dr) - BlogID = Convert.ToInt32(Null.SetNull(dr.Item("BlogID"), BlogID)) - Title = Convert.ToString(Null.SetNull(dr.Item("Title"), Title)) - Summary = Convert.ToString(Null.SetNull(dr.Item("Summary"), Summary)) - Image = Convert.ToString(Null.SetNull(dr.Item("Image"), Image)) - Published = Convert.ToBoolean(Null.SetNull(dr.Item("Published"), Published)) - PublishedOnDate = CDate(Null.SetNull(dr.Item("PublishedOnDate"), PublishedOnDate)) - AllowComments = Convert.ToBoolean(Null.SetNull(dr.Item("AllowComments"), AllowComments)) - DisplayCopyright = Convert.ToBoolean(Null.SetNull(dr.Item("DisplayCopyright"), DisplayCopyright)) - Copyright = Convert.ToString(Null.SetNull(dr.Item("Copyright"), Copyright)) - Locale = Convert.ToString(Null.SetNull(dr.Item("Locale"), Locale)) - ViewCount = Convert.ToInt32(Null.SetNull(dr.Item("ViewCount"), ViewCount)) - Username = Convert.ToString(Null.SetNull(dr.Item("Username"), Username)) - Email = Convert.ToString(Null.SetNull(dr.Item("Email"), Email)) - DisplayName = Convert.ToString(Null.SetNull(dr.Item("DisplayName"), DisplayName)) - AltLocale = Convert.ToString(Null.SetNull(dr.Item("AltLocale"), AltLocale)) - AltTitle = Convert.ToString(Null.SetNull(dr.Item("AltTitle"), AltTitle)) - AltSummary = Convert.ToString(Null.SetNull(dr.Item("AltSummary"), AltSummary)) - AltContent = Convert.ToString(Null.SetNull(dr.Item("AltContent"), AltContent)) - NrComments = Convert.ToInt32(Null.SetNull(dr.Item("NrComments"), NrComments)) - PublishedOnDate = Date.SpecifyKind(PublishedOnDate, DateTimeKind.Utc) - End Sub - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and sets the Key ID - ''' - ''' The KeyID property is part of the IHydratble interface. It is used - ''' as the key property when creating a Dictionary - ''' - ''' [pdonker] 02/19/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Overrides Property KeyID() As Integer Implements IHydratable.KeyID - Get - Return ContentItemId - End Get - Set(value As Integer) - ContentItemId = value - End Set - End Property -#End Region - -#Region " IPropertyAccess Implementation " - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Select Case strPropertyName.ToLower - Case "blogid" - Return BlogID.ToString(OutputFormat, formatProvider) - Case "title" - Return PropertyAccess.FormatString(Title, strFormat) - Case "summary" - Return Summary.OutputHtml(strFormat) - Case "image" - Return PropertyAccess.FormatString(Image, strFormat) - Case "isvisible" - Return Published.ToString - Case "published" - Return (Published AndAlso PublishedOnDate < DateTime.UtcNow).ToString() - Case "publishedyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(Published, formatProvider) - Case "publishedondate" - Dim userTimeZone As TimeZoneInfo = portalSettings.TimeZone - If AccessingUser.Profile.PreferredTimeZone IsNot Nothing Then - userTimeZone = AccessingUser.Profile.PreferredTimeZone - End If - Return UtcToLocalTime(PublishedOnDate, userTimeZone).ToString(OutputFormat, formatProvider) - Case "publishedondateutc" - Return PublishedOnDate.ToString(OutputFormat, formatProvider) - Case "allowcomments" - Return AllowComments.ToString - Case "allowcommentsyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(AllowComments, formatProvider) - Case "displaycopyright" - Return DisplayCopyright.ToString - Case "displaycopyrightyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(DisplayCopyright, formatProvider) - Case "copyright" - Return PropertyAccess.FormatString(Copyright, strFormat) - Case "locale" - Return PropertyAccess.FormatString(Locale, strFormat) - Case "nrcomments" - Return NrComments.ToString(OutputFormat, formatProvider) - Case "viewcount" - Return ViewCount.ToString(OutputFormat, formatProvider) - Case "username" - Return PropertyAccess.FormatString(Username, strFormat) - Case "email" - Return PropertyAccess.FormatString(Email, strFormat) - Case "displayname" - Return PropertyAccess.FormatString(DisplayName, strFormat) - Case "altlocale" - Return PropertyAccess.FormatString(AltLocale, strFormat) - Case "alttitle" - Return PropertyAccess.FormatString(AltTitle, strFormat) - Case "altsummary" - Return PropertyAccess.FormatString(AltSummary, strFormat) - Case "altcontent" - Return PropertyAccess.FormatString(AltContent, strFormat) - Case "localizedtitle" - Return PropertyAccess.FormatString(LocalizedTitle, strFormat) - Case "localizedsummary" - Return LocalizedSummary.OutputHtml(strFormat) - Case "localizedcontent" - Return LocalizedContent.OutputHtml(strFormat) - Case "contentitemid" - Return ContentItemId.ToString(OutputFormat, formatProvider) - Case "createdbyuserid" - Return CreatedByUserID.ToString(OutputFormat, formatProvider) - Case "createdondate" - Return CreatedOnDate.ToString(OutputFormat, formatProvider) - Case "lastmodifiedbyuserid" - Return LastModifiedByUserID.ToString(OutputFormat, formatProvider) - Case "lastmodifiedondate" - Return LastModifiedOnDate.ToString(OutputFormat, formatProvider) - Case "content", "contents" - Return Content.OutputHtml(strFormat) - Case "hasimage" - Return CBool(Image <> "").ToString(formatProvider) - Case "link", "permalink" - Return PermaLink(DotNetNuke.Entities.Portals.PortalSettings.Current) - Case "parenturl" - Return PermaLink(ParentTabID) - Case "currentmode" - Return DotNetNuke.Entities.Portals.PortalSettings.Current.UserMode.ToString() - Case Else - PropertyNotFound = True - End Select - - Return Null.NullString - End Function - - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - -#Region " IXmlSerializable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' GetSchema returns the XmlSchema for this class - ''' - ''' GetSchema is implemented as a stub method as it is not required - ''' - ''' [pdonker] 05/03/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Function GetSchema() As XmlSchema Implements IXmlSerializable.GetSchema - Return Nothing - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' ReadXml fills the object (de-serializes it) from the XmlReader passed - ''' - ''' - ''' The XmlReader that contains the xml for the object - ''' - ''' [pdonker] 05/03/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub ReadXml(reader As XmlReader) Implements IXmlSerializable.ReadXml - ' not implemented - End Sub - - Friend Property ImportedPostId As Integer = -1 - Friend Property ImportedFiles As List(Of String) - Friend Property ImportedTags As List(Of String) - Friend Property ImportedCategories As List(Of String) - - Public Sub FromXml(xml As XmlNode) - If xml Is Nothing Then Exit Sub - - xml.ReadValue("PostId", ImportedPostId) - xml.ReadValue("Title", Title) - xml.ReadValue("TitleLocalizations", TitleLocalizations) - xml.ReadValue("Summary", Summary) - xml.ReadValue("SummaryLocalizations", SummaryLocalizations) - xml.ReadValue("Content", Content) - xml.ReadValue("ContentLocalizations", ContentLocalizations) - xml.ReadValue("Image", Image) - xml.ReadValue("Published", Published) - xml.ReadValue("PublishedOnDate", PublishedOnDate) - xml.ReadValue("AllowComments", AllowComments) - xml.ReadValue("DisplayCopyright", DisplayCopyright) - xml.ReadValue("Copyright", Copyright) - xml.ReadValue("Locale", Locale) - xml.ReadValue("Username", Username) - xml.ReadValue("Email", Email) - - ImportedFiles = New List(Of String) - For Each xFile As XmlNode In xml.SelectNodes("Files/File") - ImportedFiles.Add(xFile.InnerText) - Next - ImportedTags = New List(Of String) - For Each xTag As XmlNode In xml.SelectNodes("Tag") - ImportedTags.Add(xTag.InnerText) - Next - ImportedCategories = New List(Of String) - For Each xCategory As XmlNode In xml.SelectNodes("Category") - ImportedCategories.Add(xCategory.InnerText) - Next - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' WriteXml converts the object to Xml (serializes it) and writes it using the XmlWriter passed - ''' - ''' - ''' The XmlWriter that contains the xml for the object - ''' - ''' [pdonker] 05/03/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub WriteXml(writer As XmlWriter) Implements IXmlSerializable.WriteXml - writer.WriteStartElement("Post") - writer.WriteElementString("PostId", ContentItemId.ToString) - writer.WriteElementString("Title", Title) - writer.WriteElementString("TitleLocalizations", TitleLocalizations.ToString) - writer.WriteElementString("Summary", Summary) - writer.WriteElementString("SummaryLocalizations", SummaryLocalizations.ToString) - writer.WriteElementString("Content", Content) - writer.WriteElementString("ContentLocalizations", ContentLocalizations.ToString) - writer.WriteElementString("Image", Image) - writer.WriteElementString("Published", Published.ToString()) - writer.WriteElementString("PublishedOnDate", PublishedOnDate.ToString()) - writer.WriteElementString("AllowComments", AllowComments.ToString()) - writer.WriteElementString("DisplayCopyright", DisplayCopyright.ToString()) - writer.WriteElementString("Copyright", Copyright) - writer.WriteElementString("Locale", Locale) - writer.WriteElementString("Username", Username) - writer.WriteElementString("Email", Email) - writer.WriteStartElement("Files") - ' pack files - Dim postDir As String = GetPostDirectoryMapPath(BlogID, ContentItemId) - - If Directory.Exists(postDir) Then - For Each fileName As String In From f In Directory.GetFiles(postDir) Select Path.GetFileName(f) - writer.WriteElementString("File", fileName) - Next - End If - writer.WriteEndElement() ' Files - For Each t As Terms.TermInfo In PostTags - writer.WriteElementString("Tag", t.Name) - Next - For Each t As Terms.TermInfo In PostCategories - writer.WriteElementString("Category", t.Name) - Next - writer.WriteEndElement() ' Post - End Sub -#End Region - -#Region " ToXml Methods " - Public Function ToXml() As String - Return ToXml("Post") - End Function - - Public Function ToXml(elementName As String) As String - Dim xml As New StringBuilder - xml.Append("<") - xml.Append(elementName) - AddAttribute(xml, "BlogID", BlogID.ToString()) - AddAttribute(xml, "Title", Title) - AddAttribute(xml, "Summary", Summary) - AddAttribute(xml, "Image", Image) - AddAttribute(xml, "Published", Published.ToString()) - AddAttribute(xml, "PublishedOnDate", PublishedOnDate.ToUniversalTime.ToString("u")) - AddAttribute(xml, "AllowComments", AllowComments.ToString()) - AddAttribute(xml, "DisplayCopyright", DisplayCopyright.ToString()) - AddAttribute(xml, "Copyright", Copyright) - AddAttribute(xml, "Locale", Locale) - AddAttribute(xml, "ViewCount", ViewCount.ToString()) - AddAttribute(xml, "Username", Username) - AddAttribute(xml, "Email", Email) - AddAttribute(xml, "DisplayName", DisplayName) - xml.Append(" />") - Return xml.ToString - End Function - - Private Sub AddAttribute(ByRef xml As StringBuilder, attributeName As String, attributeValue As String) - xml.Append(" " & attributeName) - xml.Append("=""" & attributeValue & """") - End Sub -#End Region - -#Region " JSON Serialization " - Public Sub WriteJSON(ByRef s As Stream) - Dim ser As New DataContractJsonSerializer(GetType(PostInfo)) - ser.WriteObject(s, Me) - End Sub -#End Region - - End Class -End Namespace - - diff --git a/Server/Blog/Components/Entities/Posts/PostInfo_Properties.vb b/Server/Blog/Components/Entities/Posts/PostInfo_Properties.vb deleted file mode 100644 index d60a6926..00000000 --- a/Server/Blog/Components/Entities/Posts/PostInfo_Properties.vb +++ /dev/null @@ -1,169 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Runtime.Serialization - -Namespace Entities.Posts - Partial Public Class PostInfo - Inherits DotNetNuke.Entities.Content.ContentItem - -#Region " Private Members " -#End Region - -#Region " Constructors " - Public Sub New() - End Sub -#End Region - -#Region " Public Properties " - - Public Property BlogID As Int32 = -1 - - Public Property Title As String = "" - - Public Property Summary As String = "" - - Public Property Image As String = "" - - Public Property Published As Boolean = False - - Public Property PublishedOnDate As Date = Date.Now.ToUniversalTime - - Public Property AllowComments As Boolean = True - - Public Property DisplayCopyright As Boolean = False - - Public Property Copyright As String = "" - - Public Property Locale As String = Nothing - - Public Property ViewCount As Int32 = 0 - - Public Property Username As String = "" - - Public Property Email As String = "" - - Public Property DisplayName As String = "" - - Public Property NrComments As Int32 = 0 -#End Region - -#Region " ML Properties " - - Public Property AltLocale As String = "" - - Public Property AltTitle As String = "" - - Public Property AltSummary As String = "" - - Public Property AltContent As String = "" - - Public ReadOnly Property LocalizedTitle As String - Get - Return CStr(IIf(String.IsNullOrEmpty(AltTitle), Title, AltTitle)) - End Get - End Property - - Public ReadOnly Property LocalizedSummary As String - Get - Return CStr(IIf(String.IsNullOrEmpty(AltSummary), Summary, AltSummary)) - End Get - End Property - - Public ReadOnly Property LocalizedContent As String - Get - Return CStr(IIf(String.IsNullOrEmpty(AltContent), Content, AltContent)) - End Get - End Property - - ''' - ''' ML text type to handle the title of the post - ''' - ''' - ''' - ''' - Public Property TitleLocalizations() As LocalizedText - Get - If _titleLocalizations Is Nothing Then - If ContentItemId = -1 Then - _titleLocalizations = New LocalizedText - Else - _titleLocalizations = New LocalizedText(Data.DataProvider.Instance().GetPostLocalizations(ContentItemId), "Title") - End If - End If - Return _titleLocalizations - End Get - Set(ByVal value As LocalizedText) - _titleLocalizations = value - End Set - End Property - Private _titleLocalizations As LocalizedText - - ''' - ''' ML text type to handle the summary of the post - ''' - ''' - ''' - ''' - Public Property SummaryLocalizations() As LocalizedText - Get - If _summaryLocalizations Is Nothing Then - If ContentItemId = -1 Then - _summaryLocalizations = New LocalizedText - Else - _summaryLocalizations = New LocalizedText(Data.DataProvider.Instance().GetPostLocalizations(ContentItemId), "Summary") - End If - End If - Return _summaryLocalizations - End Get - Set(ByVal value As LocalizedText) - _summaryLocalizations = value - End Set - End Property - Private _summaryLocalizations As LocalizedText - - ''' - ''' ML text type to handle the content of the post - ''' - ''' - ''' - ''' - Public Property ContentLocalizations() As LocalizedText - Get - If _contentLocalizations Is Nothing Then - If BlogID = -1 Then - _contentLocalizations = New LocalizedText - Else - _contentLocalizations = New LocalizedText(Data.DataProvider.Instance().GetPostLocalizations(ContentItemId), "Content") - End If - End If - Return _contentLocalizations - End Get - Set(ByVal value As LocalizedText) - _contentLocalizations = value - End Set - End Property - Private _contentLocalizations As LocalizedText -#End Region - - End Class -End Namespace - - diff --git a/Server/Blog/Components/Entities/Posts/PostsController.vb b/Server/Blog/Components/Entities/Posts/PostsController.vb deleted file mode 100644 index 8ab2c47d..00000000 --- a/Server/Blog/Components/Entities/Posts/PostsController.vb +++ /dev/null @@ -1,226 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Modules.Blog.Data -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Modules.Blog.Integration -Imports DotNetNuke.Modules.Blog.Entities.Blogs - -Namespace Entities.Posts - - Partial Public Class PostsController - - Public Shared Sub PublishPost(Post As PostInfo, publish As Boolean, publishedByUser As Integer) - - If Post.Published = publish Then Exit Sub - Post.Published = publish - UpdatePost(Post, publishedByUser) - PublishPost(Post, publishedByUser) - - End Sub - - Public Shared Sub PublishPost(Post As PostInfo, publishedByUser As Integer) - - Dim blog As BlogInfo = BlogsController.GetBlog(Post.BlogID, publishedByUser, Threading.Thread.CurrentThread.CurrentCulture.Name) - Dim journalUrl As String = Post.PermaLink(DotNetNuke.Entities.Portals.PortalSettings.Current) - Dim journalUserId As Integer = publishedByUser - If blog.PublishAsOwner Then journalUserId = blog.OwnerUserId - JournalController.AddBlogPostToJournal(Post, DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, DotNetNuke.Entities.Portals.PortalSettings.Current.ActiveTab.TabID, journalUserId, journalUrl) - NotificationController.RemovePostPendingNotification(blog.ModuleID, blog.BlogID, Post.ContentItemId) - - Dim trackAndPingbacks As New Services.TrackAndPingBackController(Post) - Dim trd As New Threading.Thread(AddressOf trackAndPingbacks.SendTrackAndPingBacks) - trd.IsBackground = True - trd.Start() - - End Sub - - Public Shared Sub DeletePost(Post As PostInfo) - DataProvider.Instance().DeletePost(Post.ContentItemId) - Dim blog As BlogInfo = BlogsController.GetBlog(Post.BlogID, -1, Threading.Thread.CurrentThread.CurrentCulture.Name) - NotificationController.RemovePostPendingNotification(blog.ModuleID, blog.BlogID, Post.ContentItemId) - End Sub - - Public Shared Sub DeletePost(contentItemId As Integer, blogId As Integer, portalId As Integer, vocabularyId As Integer) - DataProvider.Instance().DeletePost(contentItemId) - End Sub - - Public Shared Function GetPosts(moduleId As Int32, blogID As Int32, displayLocale As String, published As Integer, limitToLocale As String, endDate As Date, authorUserId As Int32, onlyActionable As Boolean, pageIndex As Int32, pageSize As Int32, orderBy As String, ByRef totalRecords As Integer, userId As Integer, userIsAdmin As Boolean) As Dictionary(Of Integer, PostInfo) - - If pageIndex < 0 Then - pageIndex = 0 - pageSize = Integer.MaxValue - End If - - Dim res As New Dictionary(Of Integer, PostInfo) - Using ir As IDataReader = DataProvider.Instance().GetPosts(moduleId, blogID, displayLocale, userId, userIsAdmin, published, limitToLocale, endDate, authorUserId, onlyActionable, pageIndex, pageSize, orderBy) - res = DotNetNuke.Common.Utilities.CBO.FillDictionary(Of Integer, PostInfo)("ContentItemID", ir, False) - ir.NextResult() - totalRecords = DotNetNuke.Common.Globals.GetTotalRecords(ir) - End Using - Return GetPostsWithBlog(res, blogID, moduleId, userId, displayLocale) - - End Function - - Public Shared Function GetPostsByTerm(moduleId As Int32, blogID As Int32, displayLocale As String, termId As Integer, published As Integer, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String, ByRef totalRecords As Integer, userId As Integer, userIsAdmin As Boolean) As Dictionary(Of Integer, PostInfo) - - If pageIndex < 0 Then - pageIndex = 0 - pageSize = Integer.MaxValue - End If - - Dim res As New Dictionary(Of Integer, PostInfo) - Using ir As IDataReader = DataProvider.Instance().GetPostsByTerm(moduleId, blogID, displayLocale, userId, userIsAdmin, termId, published, limitToLocale, endDate, authorUserId, pageIndex, pageSize, orderBy) - res = DotNetNuke.Common.Utilities.CBO.FillDictionary(Of Integer, PostInfo)("ContentItemID", ir, False) - ir.NextResult() - totalRecords = DotNetNuke.Common.Globals.GetTotalRecords(ir) - End Using - Return GetPostsWithBlog(res, blogID, moduleId, userId, displayLocale) - - End Function - - Public Shared Function GetPostsByCategory(moduleId As Int32, blogID As Int32, displayLocale As String, categories As String, published As Integer, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String, ByRef totalRecords As Integer, userId As Integer, userIsAdmin As Boolean) As Dictionary(Of Integer, PostInfo) - - If pageIndex < 0 Then - pageIndex = 0 - pageSize = Integer.MaxValue - End If - - Dim res As New Dictionary(Of Integer, PostInfo) - Using ir As IDataReader = DataProvider.Instance().GetPostsByCategory(moduleId, blogID, displayLocale, userId, userIsAdmin, categories, published, limitToLocale, endDate, authorUserId, pageIndex, pageSize, orderBy) - res = DotNetNuke.Common.Utilities.CBO.FillDictionary(Of Integer, PostInfo)("ContentItemID", ir, False) - ir.NextResult() - totalRecords = DotNetNuke.Common.Globals.GetTotalRecords(ir) - End Using - Return GetPostsWithBlog(res, blogID, moduleId, userId, displayLocale) - - End Function - - Public Shared Function GetPostsByBlog(moduleId As Int32, blogID As Int32, displayLocale As String, userId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String, ByRef totalRecords As Integer) As Dictionary(Of Integer, PostInfo) - - If pageIndex < 0 Then - pageIndex = 0 - pageSize = Integer.MaxValue - End If - - Dim res As New Dictionary(Of Integer, PostInfo) - Using ir As IDataReader = DataProvider.Instance().GetPostsByBlog(blogID, displayLocale, pageIndex, pageSize, orderBy) - res = DotNetNuke.Common.Utilities.CBO.FillDictionary(Of Integer, PostInfo)("ContentItemID", ir, False) - ir.NextResult() - totalRecords = DotNetNuke.Common.Globals.GetTotalRecords(ir) - End Using - Return GetPostsWithBlog(res, blogID, moduleId, userId, displayLocale) - - End Function - - Public Shared Function SearchPosts(moduleId As Int32, blogID As Int32, displayLocale As String, searchText As String, searchTitle As Boolean, searchContents As Boolean, published As Integer, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String, ByRef totalRecords As Integer, userId As Integer, userIsAdmin As Boolean) As Dictionary(Of Integer, PostInfo) - - If pageIndex < 0 Then - pageIndex = 0 - pageSize = Integer.MaxValue - End If - - Dim res As New Dictionary(Of Integer, PostInfo) - Using ir As IDataReader = DataProvider.Instance().SearchPosts(moduleId, blogID, displayLocale, userId, userIsAdmin, searchText, searchTitle, searchContents, published, limitToLocale, endDate, authorUserId, pageIndex, pageSize, orderBy) - res = DotNetNuke.Common.Utilities.CBO.FillDictionary(Of Integer, PostInfo)("ContentItemID", ir, False) - ir.NextResult() - totalRecords = DotNetNuke.Common.Globals.GetTotalRecords(ir) - End Using - Return GetPostsWithBlog(res, blogID, moduleId, userId, displayLocale) - - End Function - - Public Shared Function SearchPostsByTerm(moduleId As Int32, blogID As Int32, displayLocale As String, termId As Integer, searchText As String, searchTitle As Boolean, searchContents As Boolean, published As Integer, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String, ByRef totalRecords As Integer, userId As Integer, userIsAdmin As Boolean) As Dictionary(Of Integer, PostInfo) - - If pageIndex < 0 Then - pageIndex = 0 - pageSize = Integer.MaxValue - End If - - Dim res As New Dictionary(Of Integer, PostInfo) - Using ir As IDataReader = DataProvider.Instance().SearchPostsByTerm(moduleId, blogID, displayLocale, userId, userIsAdmin, termId, searchText, searchTitle, searchContents, published, limitToLocale, endDate, authorUserId, pageIndex, pageSize, orderBy) - res = DotNetNuke.Common.Utilities.CBO.FillDictionary(Of Integer, PostInfo)("ContentItemID", ir, False) - ir.NextResult() - totalRecords = DotNetNuke.Common.Globals.GetTotalRecords(ir) - End Using - Return GetPostsWithBlog(res, blogID, moduleId, userId, displayLocale) - - End Function - - Public Shared Function SearchPostsByCategory(moduleId As Int32, blogID As Int32, displayLocale As String, categories As String, searchText As String, searchTitle As Boolean, searchContents As Boolean, published As Integer, limitToLocale As String, endDate As Date, authorUserId As Int32, pageIndex As Int32, pageSize As Int32, orderBy As String, ByRef totalRecords As Integer, userId As Integer, userIsAdmin As Boolean) As Dictionary(Of Integer, PostInfo) - - If pageIndex < 0 Then - pageIndex = 0 - pageSize = Integer.MaxValue - End If - - Dim res As New Dictionary(Of Integer, PostInfo) - Using ir As IDataReader = DataProvider.Instance().SearchPostsByCategory(moduleId, blogID, displayLocale, userId, userIsAdmin, categories, searchText, searchTitle, searchContents, published, limitToLocale, endDate, authorUserId, pageIndex, pageSize, orderBy) - res = DotNetNuke.Common.Utilities.CBO.FillDictionary(Of Integer, PostInfo)("ContentItemID", ir, False) - ir.NextResult() - totalRecords = DotNetNuke.Common.Globals.GetTotalRecords(ir) - End Using - Return GetPostsWithBlog(res, blogID, moduleId, userId, displayLocale) - - End Function - - Public Shared Function GetAuthors(moduleId As Integer, blogId As Integer) As List(Of PostAuthor) - Return DotNetNuke.Common.Utilities.CBO.FillCollection(Of PostAuthor)(DataProvider.Instance.GetAuthors(moduleId, blogId)) - End Function - - Public Shared Function GetPostByLegacyEntryId(entryId As Int32, portalId As Int32, locale As String) As PostInfo - Return CBO.FillObject(Of PostInfo)(DataProvider.Instance().GetPostByLegacyEntryId(entryId, portalId, locale)) - End Function - - Public Shared Function GetPostByLegacyUrl(url As String, portalId As Int32, locale As String) As PostInfo - Return CBO.FillObject(Of PostInfo)(DataProvider.Instance().GetPostByLegacyUrl(url, portalId, locale)) - End Function - - Public Shared Function GetChangedPosts(moduleId As Integer, lastChange As DateTime) As List(Of PostInfo) - Return DotNetNuke.Common.Utilities.CBO.FillCollection(Of PostInfo)(DotNetNuke.Data.DataProvider.Instance().ExecuteReader("Blog_GetChangedPosts", moduleId, lastChange)) - End Function - -#Region " Private Methods " - Private Shared Function GetPostsWithBlog(selection As Dictionary(Of Integer, PostInfo), blogId As Integer, moduleId As Integer, userId As Integer, displayLocale As String) As Dictionary(Of Integer, PostInfo) - - Dim res As New Dictionary(Of Integer, PostInfo) - If blogId = -1 Then - Dim blogs As Dictionary(Of Integer, BlogInfo) = BlogsController.GetBlogsByModule(moduleId, userId, displayLocale) - For Each e As PostInfo In selection.Values - If blogs.ContainsKey(e.BlogID) Then - e.Blog = blogs(e.BlogID) - res.Add(e.ContentItemId, e) - End If - Next - Else - Dim blog As BlogInfo = BlogsController.GetBlog(blogId, userId, displayLocale) - For Each e As PostInfo In selection.Values - e.Blog = blog - res.Add(e.ContentItemId, e) - Next - End If - Return res - - End Function -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Entities/Posts/PostsController_CRUD.vb b/Server/Blog/Components/Entities/Posts/PostsController_CRUD.vb deleted file mode 100644 index d2b4bb93..00000000 --- a/Server/Blog/Components/Entities/Posts/PostsController_CRUD.vb +++ /dev/null @@ -1,65 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Modules.Blog.Data - -Namespace Entities.Posts - - Partial Public Class PostsController - - Public Shared Function GetPost(contentItemId As Int32, moduleId As Int32, locale As String) As PostInfo - - Return CBO.FillObject(Of PostInfo)(DataProvider.Instance().GetPost(contentItemId, moduleId, locale)) - - End Function - - Public Shared Function AddPost(ByRef objPost As PostInfo, createdByUser As Integer) As Integer - - objPost.ContentItemId = DataProvider.Instance().AddPost(objPost.AllowComments, objPost.BlogID, objPost.Content, objPost.Copyright, objPost.DisplayCopyright, objPost.Image, objPost.Locale, objPost.Published, objPost.PublishedOnDate, objPost.Summary, objPost.Terms.ToTermIDString, objPost.Title, objPost.ViewCount, createdByUser) - - ' localization - For Each l As String In objPost.TitleLocalizations.Locales - DataProvider.Instance().SetPostLocalization(objPost.ContentItemId, l, objPost.TitleLocalizations(l), objPost.SummaryLocalizations(l), objPost.ContentLocalizations(l), createdByUser) - Next - - Return objPost.ContentItemId - - End Function - - Public Shared Sub UpdatePost(objPost As PostInfo, updatedByUser As Integer) - - DataProvider.Instance().UpdatePost(objPost.AllowComments, objPost.BlogID, objPost.Content, objPost.ContentItemId, objPost.Copyright, objPost.DisplayCopyright, objPost.Image, objPost.Locale, objPost.Published, objPost.PublishedOnDate, objPost.Summary, objPost.Terms.ToTermIDString, objPost.Title, objPost.ViewCount, updatedByUser) - - ' localization - For Each l As String In objPost.TitleLocalizations.Locales - DataProvider.Instance().SetPostLocalization(objPost.ContentItemId, l, objPost.TitleLocalizations(l), objPost.SummaryLocalizations(l), objPost.ContentLocalizations(l), updatedByUser) - Next - - End Sub - - Public Shared Sub DeletePost(contentItemId As Int32) - - DataProvider.Instance().DeletePost(contentItemId) - - End Sub - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Entities/Posts/PostsController_Service.vb b/Server/Blog/Components/Entities/Posts/PostsController_Service.vb deleted file mode 100644 index c77d54fc..00000000 --- a/Server/Blog/Components/Entities/Posts/PostsController_Service.vb +++ /dev/null @@ -1,91 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Net -Imports System.Net.Http -Imports System.Web.Http -Imports DotNetNuke.Web.Api -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Services - -Namespace Entities.Posts - Partial Public Class PostsController - Inherits DnnApiController - - Public Class PostDTO - Public Property BlogId As Integer - Public Property PostId As Integer - End Class - -#Region " Private Members " - Private Property Blog As BlogInfo = Nothing - Private Property Post As PostInfo = Nothing -#End Region - -#Region " Service Methods " - - - - - Public Function ApprovePost(postData As PostDTO) As HttpResponseMessage - SetContext(postData) - If Blog Is Nothing Or Post Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - PostsController.PublishPost(Post, True, UserInfo.UserID) - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - End Function - - - - - - Public Function DeletePost(postData As PostDTO) As HttpResponseMessage - SetContext(postData) - If Blog Is Nothing Or Post Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - PostsController.DeletePost(Post) - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - End Function - - - - - - Public Function ViewPost(postData As PostDTO) As HttpResponseMessage - SetContext(postData) - If Blog Is Nothing Or Post Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - Data.DataProvider.Instance.AddPostView(postData.PostId) - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - End Function -#End Region - -#Region " Private Methods " - Private Sub SetContext(data As PostDTO) - Blog = BlogsController.GetBlog(data.BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) - Post = PostsController.GetPost(data.PostId, ActiveModule.ModuleID, Threading.Thread.CurrentThread.CurrentCulture.Name) - End Sub -#End Region - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Entities/Terms/TermInfo.vb b/Server/Blog/Components/Entities/Terms/TermInfo.vb deleted file mode 100644 index 82eaff90..00000000 --- a/Server/Blog/Components/Entities/Terms/TermInfo.vb +++ /dev/null @@ -1,267 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Common.Globals -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Content.Taxonomy -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Services.Tokens -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports System.Linq -Imports System.Xml - -Namespace Entities.Terms - - Public Class TermInfo - Inherits Term - Implements IHydratable - Implements IPropertyAccess - -#Region " Constructors " - Public Sub New() - End Sub - Public Sub New(name As String) - Description = "" - Me.Name = name - ParentTermId = 0 - TermId = -1 - End Sub -#End Region - -#Region " Public Properties " - Public Property TotalPosts() As Integer -#End Region - -#Region " ML Properties " - Public Property ParentTabID As Integer = -1 - Public Property AltLocale As String = "" - Public Property AltName As String = "" - Public Property AltDescription As String = "" - - Public ReadOnly Property LocalizedName As String - Get - Return CStr(IIf(String.IsNullOrEmpty(AltName), Name, AltName)) - End Get - End Property - - Public ReadOnly Property LocalizedDescription As String - Get - Return CStr(IIf(String.IsNullOrEmpty(AltDescription), Description, AltDescription)) - End Get - End Property - - ''' - ''' ML text type to handle the name of the term - ''' - ''' - ''' - ''' - Public Property NameLocalizations() As LocalizedText - Get - If _nameLocalizations Is Nothing Then - If TermId = -1 Then - _nameLocalizations = New LocalizedText - Else - _nameLocalizations = New LocalizedText(Data.DataProvider.Instance().GetTermLocalizations(TermId), "Name") - End If - End If - Return _nameLocalizations - End Get - Set(ByVal value As LocalizedText) - _nameLocalizations = value - End Set - End Property - Private _nameLocalizations As LocalizedText - - ''' - ''' ML text type to handle the description of the term - ''' - ''' - ''' - ''' - Public Property DescriptionLocalizations() As LocalizedText - Get - If _descriptionLocalizations Is Nothing Then - If TermId = -1 Then - _descriptionLocalizations = New LocalizedText - Else - _descriptionLocalizations = New LocalizedText(Data.DataProvider.Instance().GetTermLocalizations(TermId), "Description") - End If - End If - Return _descriptionLocalizations - End Get - Set(ByVal value As LocalizedText) - _descriptionLocalizations = value - End Set - End Property - Private _descriptionLocalizations As LocalizedText -#End Region - -#Region " IHydratable Implementation " - Public Overrides Sub Fill(dr As System.Data.IDataReader) - MyBase.Fill(dr) - MyBase.FillInternal(dr) - - TotalPosts = Null.SetNullInteger(dr("TotalPosts")) - AltLocale = Convert.ToString(Null.SetNull(dr.Item("AltLocale"), AltLocale)) - AltName = Convert.ToString(Null.SetNull(dr.Item("AltName"), AltName)) - AltDescription = Convert.ToString(Null.SetNull(dr.Item("AltDescription"), AltDescription)) - End Sub -#End Region - -#Region " IPropertyAccess Implementation " - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As System.Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings - - Dim ParentModule As New DotNetNuke.Entities.Modules.ModuleInfo - 'PropertySource(strObjectName.ToLower).GetProperty(strPropertyName, strFormat, formatProvider, AccessingUser, CurrentAccessLevel, PropertyNotFound) - - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Select Case strPropertyName.ToLower - Case "description" - Return PropertyAccess.FormatString(Description, strFormat) - Case "isheirarchical" - Return IsHeirarchical.ToString - Case "isheirarchicalyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(IsHeirarchical, formatProvider) - Case "left" - Return (Left.ToString(OutputFormat, formatProvider)) - Case "title", "name" - Return PropertyAccess.FormatString(Name, strFormat) - Case "parenttermid" - Return ParentTermId.ToStringOrZero - Case "right" - Return (Right.ToString(OutputFormat, formatProvider)) - Case "termid" - Return (TermId.ToString(OutputFormat, formatProvider)) - Case "vocabularyid" - Return (VocabularyId.ToString(OutputFormat, formatProvider)) - Case "weight" - Return (Weight.ToString(OutputFormat, formatProvider)) - Case "createdbyuserid" - Return (CreatedByUserID.ToString(OutputFormat, formatProvider)) - Case "createdondate" - Return (CreatedOnDate.ToString(OutputFormat, formatProvider)) - Case "lastmodifiedbyuserid" - Return (LastModifiedByUserID.ToString(OutputFormat, formatProvider)) - Case "lastmodifiedondate" - Return (LastModifiedOnDate.ToString(OutputFormat, formatProvider)) - Case "totalposts" - Return (TotalPosts.ToString(OutputFormat, formatProvider)) - Case "altlocale" - Return PropertyAccess.FormatString(AltLocale, strFormat) - Case "altname" - Return PropertyAccess.FormatString(AltName, strFormat) - Case "altdescription" - Return PropertyAccess.FormatString(AltDescription, strFormat) - Case "localizedname" - Return PropertyAccess.FormatString(LocalizedName, strFormat) - Case "localizeddescription" - Return PropertyAccess.FormatString(LocalizedDescription, strFormat) - Case "link", "permalink" - Return PermaLink(DotNetNuke.Entities.Portals.PortalSettings.Current) - Case "parenturl" - Return PermaLink(ParentTabID) - Case Else - PropertyNotFound = True - End Select - - Return Null.NullString - End Function - - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - -#Region " (De)serialization " - Friend Property ImportedChildTerms As List(Of TermInfo) - Public Sub FromXml(xml As XmlNode) - If xml Is Nothing Then Exit Sub - xml.ReadValue("Name", Name) - xml.ReadValue("NameLocalizations", NameLocalizations) - xml.ReadValue("Description", Description) - xml.ReadValue("DescriptionLocalizations", DescriptionLocalizations) - For Each xTerm As XmlNode In xml.SelectNodes("Term") - Dim t As New TermInfo - t.FromXml(xTerm) - ImportedChildTerms.Add(t) - Next - End Sub - - Public Sub WriteXml(writer As XmlWriter, vocabulary As List(Of TermInfo)) - writer.WriteStartElement("Term") - writer.WriteElementString("Name", Name) - writer.WriteElementString("NameLocalizations", NameLocalizations.ToString) - writer.WriteElementString("Description", Description) - writer.WriteElementString("DescriptionLocalizations", DescriptionLocalizations.ToString) - For Each t As TermInfo In vocabulary.Where(Function(x) CBool(x.ParentTermId IsNot Nothing AndAlso x.ParentTermId = TermId)) - t.WriteXml(writer, vocabulary) - Next - writer.WriteEndElement() ' Term - End Sub -#End Region - -#Region " Public Methods " - Public Function PermaLink(portalSettings As DotNetNuke.Entities.Portals.PortalSettings) As String - Return PermaLink(portalSettings.ActiveTab) - End Function - Public Function PermaLink(strParentTabID As Integer) As String - Dim oTabController As DotNetNuke.Entities.Tabs.TabController = New DotNetNuke.Entities.Tabs.TabController - Dim oParentTab As DotNetNuke.Entities.Tabs.TabInfo = oTabController.GetTab(strParentTabID, DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, False) - _permaLink = String.Empty - Return PermaLink(oParentTab) - End Function - - Private _permaLink As String = "" - Public Function PermaLink(tab As DotNetNuke.Entities.Tabs.TabInfo) As String - If String.IsNullOrEmpty(_permaLink) Then - _permaLink = ApplicationURL(tab.TabID) & "&Term=" & TermId.ToString - If DotNetNuke.Entities.Host.Host.UseFriendlyUrls Then - _permaLink = FriendlyUrl(tab, _permaLink, GetSafePageName(LocalizedName)) - Else - _permaLink = ResolveUrl(_permaLink) - End If - End If - Return _permaLink - End Function - - Public Function FlatClone() As TermInfo - Dim res As New TermInfo - With res - .Name = Name - .NameLocalizations = NameLocalizations - .Name = Description - .DescriptionLocalizations = DescriptionLocalizations - .Weight = Weight - End With - Return res - End Function -#End Region - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Entities/Terms/TermsController.vb b/Server/Blog/Components/Entities/Terms/TermsController.vb deleted file mode 100644 index 4408dc2a..00000000 --- a/Server/Blog/Components/Entities/Terms/TermsController.vb +++ /dev/null @@ -1,186 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Linq - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Content.Taxonomy -Imports System.Xml - -Namespace Entities.Terms - Partial Public Class TermsController - - Public Shared Function GetTerm(termId As Integer, moduleId As Integer, locale As String) As TermInfo - Return CBO.FillObject(Of TermInfo)(Data.DataProvider.Instance().GetTerm(termId, moduleId, locale)) - End Function - - Public Shared Function GetTermsByPost(contentItemId As Int32, moduleId As Int32, locale As String) As List(Of TermInfo) - Return DotNetNuke.Common.Utilities.CBO.FillCollection(Of TermInfo)(Data.DataProvider.Instance.GetTermsByPost(contentItemId, moduleId, locale)) - End Function - - Public Shared Function GetTermsByModule(moduleId As Int32, locale As String) As List(Of TermInfo) - Return DotNetNuke.Common.Utilities.CBO.FillCollection(Of TermInfo)(Data.DataProvider.Instance.GetTermsByModule(moduleId, locale)) - End Function - - Public Shared Function GetTermsByVocabulary(moduleId As Int32, vocabularyId As Int32, locale As String) As Dictionary(Of String, TermInfo) - Return GetTermsByVocabulary(moduleId, vocabularyId, locale, False) - End Function - - Public Shared Function GetTermsByVocabulary(moduleId As Int32, vocabularyId As Int32, locale As String, clearCache As Boolean) As Dictionary(Of String, TermInfo) - Dim CacheKey As String = String.Format("BlogVocab-{0}-{1}-{2}", moduleId, vocabularyId, locale) - Dim res As Dictionary(Of String, TermInfo) = CType(DotNetNuke.Common.Utilities.DataCache.GetCache(CacheKey), Dictionary(Of String, TermInfo)) - If res Is Nothing Or clearCache Then - res = New Dictionary(Of String, TermInfo)(StringComparer.CurrentCultureIgnoreCase) - DotNetNuke.Common.Utilities.CBO.FillDictionary(Of String, TermInfo)("Name", Data.DataProvider.Instance.GetTermsByVocabulary(moduleId, vocabularyId, locale), res) - DotNetNuke.Common.Utilities.DataCache.SetCache(CacheKey, res) - End If - Return res - End Function - - Public Shared Function GetTermsByVocabulary(moduleId As Int32, vocabularyId As Int32) As Dictionary(Of Integer, TermInfo) - Dim res As New Dictionary(Of Integer, TermInfo) - DotNetNuke.Common.Utilities.CBO.FillDictionary(Of Integer, TermInfo)("TermID", Data.DataProvider.Instance.GetTermsByVocabulary(moduleId, vocabularyId, ""), res) - Return res - End Function - - Public Shared Function GetTermList(moduleId As Integer, termList As String, vocabularyId As Integer, autoCreate As Boolean, locale As String) As List(Of TermInfo) - If termList Is Nothing Then termList = "" - Dim termNames As String() = termList.Replace(";", ",").Trim(","c).Split(","c) - Return GetTermList(moduleId, termNames.ToList, vocabularyId, autoCreate, locale) - End Function - - Public Shared Function GetTermList(moduleId As Integer, termList As List(Of String), vocabularyId As Integer, autoCreate As Boolean, locale As String) As List(Of TermInfo) - Dim vocab As Dictionary(Of String, TermInfo) = GetTermsByVocabulary(moduleId, vocabularyId, locale, True) - Dim res As New List(Of TermInfo) - For Each termName As String In termList - Dim name As String = termName.Trim - Dim existantTerm As TermInfo = Nothing - If vocab.ContainsKey(name) Then existantTerm = vocab(name) - If existantTerm IsNot Nothing Then - res.Add(existantTerm) - ElseIf autoCreate And name <> "" Then - Dim termId As Integer = DotNetNuke.Entities.Content.Common.Util.GetTermController().AddTerm(New Term(vocabularyId) With {.Name = name}) - res.Add(New TermInfo(name) With {.Description = "", .TermId = termId, .TotalPosts = 0, .Weight = 0}) - End If - Next - Return res - End Function - -#Region " (De)serialization " - Public Shared Function FromXml(xml As XmlNode) As List(Of TermInfo) - Dim res As New List(Of TermInfo) - If xml Is Nothing Then Return res - For Each xTerm As XmlNode In xml.SelectNodes("Term") - Dim t As New TermInfo - t.FromXml(xTerm) - res.Add(t) - Next - Return res - End Function - - Public Shared Sub WriteVocabulary(writer As XmlTextWriter, name As String, vocabulary As List(Of TermInfo)) - writer.WriteStartElement(name) - For Each t As TermInfo In vocabulary.Where(Function(x) CBool(x.ParentTermId Is Nothing)) - t.WriteXml(writer, vocabulary) - Next - writer.WriteEndElement() ' Vocabulary - End Sub - - Public Shared Sub AddTags(moduleId As Integer, tagList As List(Of TermInfo)) - Dim allTags As Dictionary(Of String, TermInfo) = GetTermsByVocabulary(moduleId, 1, "") - For Each t As TermInfo In tagList - If Not allTags.ContainsKey(t.Name) Then - Dim newTerm As New Term(1) With {.Name = t.Name.Trim, .Description = t.Description} - newTerm.TermId = DotNetNuke.Entities.Content.Common.Util.GetTermController().AddTerm(newTerm) - For Each l As String In t.NameLocalizations.Locales - Data.DataProvider.Instance.SetTermLocalization(newTerm.TermId, l, t.NameLocalizations(l), t.DescriptionLocalizations(l)) - Next - End If - Next - End Sub - - Public Shared Sub AddVocabulary(vocabularyId As Integer, vocabulary As List(Of TermInfo)) - For Each t As TermInfo In vocabulary.Where(Function(x) CBool(x.ParentTermId Is Nothing)) - AddTerm(vocabularyId, vocabulary, 0, t) - Next - End Sub - - Private Shared Sub AddTerm(vocabularyId As Integer, vocabulary As List(Of TermInfo), parentId As Integer, term As TermInfo) - Dim newTerm As New Term(vocabularyId) With {.Name = term.Name.Trim, .Description = term.Description, .ParentTermId = parentId} - newTerm.TermId = DotNetNuke.Entities.Content.Common.Util.GetTermController().AddTerm(newTerm) - For Each l As String In term.NameLocalizations.Locales - Data.DataProvider.Instance.SetTermLocalization(newTerm.TermId, l, term.NameLocalizations(l), term.DescriptionLocalizations(l)) - Next - For Each t As TermInfo In vocabulary.Where(Function(x) CBool(x.ParentTermId = term.TermId)) - AddTerm(vocabularyId, vocabulary, newTerm.TermId, t) - Next - End Sub -#End Region - -#Region " UI Functions " - Public Shared Function GetCategoryTreeAsJson(vocabulary As Dictionary(Of String, TermInfo)) As String - Return GetCategoryTreeAsJson(vocabulary, New List(Of Integer)) - End Function - - Public Shared Function GetCategoryTreeAsJson(vocabulary As Dictionary(Of String, TermInfo), selectedIds As List(Of Integer)) As String - Dim childTreeBuilder As New StringBuilder - GetCategoryTree(childTreeBuilder, vocabulary, -1, selectedIds) - Dim res As String = childTreeBuilder.ToString - If res.Length > 0 Then - res = res.Substring(14) ' cut off the first children declaration - End If - Return res - End Function - - Private Shared Sub GetCategoryTree(out As StringBuilder, vocabulary As Dictionary(Of String, TermInfo), parentId As Integer, selectedIds As List(Of Integer)) - Dim selection As IEnumerable(Of TermInfo) - If parentId = -1 Then - selection = vocabulary.Values.Where(Function(t) - Return CBool(t.ParentTermId Is Nothing) - End Function) - Else - selection = vocabulary.Values.Where(Function(t) - Return t.ParentTermId IsNot Nothing AndAlso CBool(t.ParentTermId = parentId) - End Function) - End If - - If selection.Count > 0 Then - out.Append(", ""children"": [") - Dim first As Boolean = True - For Each cat As TermInfo In selection - If Not first Then out.Append(",") - out.Append("{") - out.Append(String.Format("""title"": ""{0}"",", cat.LocalizedName)) - out.Append(String.Format("""key"": ""{0}"",", cat.TermId)) - out.Append("""icon"": false,") - out.Append("""expand"": true,") - out.Append("""isFolder"": true,") - out.Append(String.Format("""select"": {0}", IIf(selectedIds.Contains(cat.TermId), "true", "false"))) - GetCategoryTree(out, vocabulary, cat.TermId, selectedIds) - out.Append("}") - first = False - Next - out.Append("]") - End If - End Sub -#End Region - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Entities/Terms/TermsController_Service.vb b/Server/Blog/Components/Entities/Terms/TermsController_Service.vb deleted file mode 100644 index 923af131..00000000 --- a/Server/Blog/Components/Entities/Terms/TermsController_Service.vb +++ /dev/null @@ -1,64 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Web.Api -Imports System.Web.Http -Imports System.Net.Http -Imports System.Net -Imports System.Linq - -Namespace Entities.Terms - Partial Public Class TermsController - Inherits DnnApiController - - Private Const DisallowedCharacters As String = "%?*&;:'\\" - -#Region " Service Methods " - - - - Public Function Search() As HttpResponseMessage - Dim queryString As NameValueCollection = HttpUtility.ParseQueryString(Request.RequestUri.Query) - Dim searchString As String = queryString("term") - Dim vocab As Integer = Integer.Parse(queryString("vocab")) - Dim colTerms As IEnumerable(Of String) = Entities.Terms.TermsController.GetTermsByVocabulary(ActiveModule.ModuleID, vocab, Threading.Thread.CurrentThread.CurrentCulture.Name).Values.Where(Function(t) t.LocalizedName.IndexOfAny(DisallowedCharacters.ToCharArray()) = -1 And t.LocalizedName.ToLower().Contains(searchString.ToLower())).Select(Function(t) t.LocalizedName) - Return Request.CreateResponse(HttpStatusCode.OK, colTerms) - End Function - - - - - Public Function GetVocabularyML(vocabularyId As Integer) As HttpResponseMessage - Dim res As New List(Of TermML) - For Each t As Entities.Terms.TermInfo In Entities.Terms.TermsController.GetTermsByVocabulary(ActiveModule.ModuleID, vocabularyId, "").Values - res.Add(New TermML With {.TermID = t.TermId, .DefaultName = t.Name, .LocNames = t.NameLocalizations.GetDictionary}) - Next - Return Request.CreateResponse(HttpStatusCode.OK, res) - End Function -#End Region - - Public Structure TermML - Public TermID As Integer - Public DefaultName As String - Public LocNames As Dictionary(Of String, String) - End Structure - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Integration/BlogModuleController_Portable.vb b/Server/Blog/Components/Integration/BlogModuleController_Portable.vb deleted file mode 100644 index c67d90bd..00000000 --- a/Server/Blog/Components/Integration/BlogModuleController_Portable.vb +++ /dev/null @@ -1,197 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Services -Imports System.Linq -Imports System.Xml -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Modules.Blog.Entities.Terms - -Namespace Integration - Partial Public Class BlogModuleController - Implements IPortable - - Private Const LogFilePattern As String = "{0}BlogImport_{1}.resources" - -#Region " Post Import Logic " - Public Shared Sub CheckupOnImportedFiles(moduleId As Integer) - Dim CacheKey As String = "Blog_CheckupOnImportedFiles" & moduleId.ToString - If DotNetNuke.Common.Utilities.DataCache.GetCache(CacheKey) Is Nothing Then - Dim logFile As String = String.Format(LogFilePattern, DotNetNuke.Common.HostMapPath, moduleId) - If IO.File.Exists(logFile) Then - Using sr As New IO.StreamReader(logFile) - Dim line As String - Dim currentBlog As Integer = -1 - Do - line = sr.ReadLine() - If Not String.IsNullOrEmpty(line) Then - Dim t As String = line.Substring(0, 1) - Dim oldId As Integer = Integer.Parse(line.Substring(1, line.IndexOf("-") - 1)) - Dim newId As Integer = Integer.Parse(line.Substring(line.IndexOf("-") + 1)) - If t = "M" Then - Data.DataProvider.Instance.UpdateModuleWiring(DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, oldId, newId) - ElseIf t = "B" Then - Dim d As New IO.DirectoryInfo(String.Format("{0}Blog\Files\{1}\", DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectoryMapPath, oldId)) - If d.Exists Then - d.MoveTo(String.Format("{0}Blog\Files\{1}\", DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectoryMapPath, newId)) - End If - currentBlog = newId - ElseIf t = "P" Then - Dim d As New IO.DirectoryInfo(String.Format("{0}Blog\Files\{1}\{2}\", DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectoryMapPath, currentBlog, oldId)) - If d.Exists Then - d.MoveTo(String.Format("{0}Blog\Files\{1}\{2}\", DotNetNuke.Entities.Portals.PortalSettings.Current.HomeDirectoryMapPath, currentBlog, newId)) - End If - If d.GetFiles("*.*").Count = 0 Then - Else - Dim post As PostInfo = PostsController.GetPost(newId, moduleId, "") - If post IsNot Nothing Then - Dim postPath As String = GetPostDirectoryPath(post) - For Each f As IO.FileInfo In d.GetFiles("*.*") - Dim filename As String = f.Name - Dim reg As String = "\"([^\&]*)" & filename & "\"" - Dim repl As String = """ & postPath & filename & """ - post.Content = Regex.Replace(post.Content, reg, repl) - For Each l As String In post.ContentLocalizations.Locales - post.ContentLocalizations(l) = Regex.Replace(post.ContentLocalizations(l), reg, repl) - Next - If Not String.IsNullOrEmpty(post.Summary) Then post.Summary = Regex.Replace(post.Summary, reg, repl) - For Each l As String In post.SummaryLocalizations.Locales - post.SummaryLocalizations(l) = Regex.Replace(post.SummaryLocalizations(l), reg, repl) - Next - Next - PostsController.UpdatePost(post, -1) - End If - End If - End If - End If - Loop Until line Is Nothing - sr.ReadLine() - End Using - IO.File.Delete(logFile) - End If - DotNetNuke.Common.Utilities.DataCache.SetCache(CacheKey, True) - End If - End Sub -#End Region - -#Region " IPortable Methods " - Public Function ExportModule(ByVal ModuleID As Integer) As String Implements IPortable.ExportModule - - Dim strXml As New StringBuilder - Using sw As New IO.StringWriter(strXml) - Using xml As New XmlTextWriter(sw) - xml.WriteStartElement("dnnblog") - xml.WriteElementString("ModuleId", ModuleID.ToString) - Dim tabMods As ArrayList = (New ModuleController).GetAllTabsModulesByModuleID(ModuleID) - If tabMods.Count > 0 Then - Dim vs As ViewSettings = ViewSettings.GetViewSettings(CType(tabMods(0), ModuleInfo).TabModuleID) - vs.Serialize(xml) - If vs.BlogModuleId = -1 Then - Dim ms As ModuleSettings = ModuleSettings.GetModuleSettings(ModuleID) - ms.Serialize(xml) - If ms.VocabularyId > -1 Then - TermsController.WriteVocabulary(xml, "Categories", TermsController.GetTermsByVocabulary(ModuleID, ms.VocabularyId).Values.ToList()) - End If - TermsController.WriteVocabulary(xml, "Tags", TermsController.GetTermsByModule(ModuleID, "").Where(Function(t) CBool(t.VocabularyId = 1)).ToList()) - End If - End If - For Each b As BlogInfo In BlogsController.GetBlogsByModule(ModuleID, "").Values - b.WriteXml(xml) - Next - xml.WriteEndElement() ' dnnblog - End Using - End Using - Return strXml.ToString - - End Function - - Public Sub ImportModule(ByVal ModuleID As Integer, ByVal Content As String, ByVal Version As String, ByVal UserID As Integer) Implements DotNetNuke.Entities.Modules.IPortable.ImportModule - Try - - Dim xContent As XmlNode = DotNetNuke.Common.GetContent(Content, "dnnblog") - Dim importReport As New StringBuilder - Dim oldModuleId As Integer = -1 - xContent.ReadValue("ModuleId", oldModuleId) - importReport.AppendFormat("M{0}-{1}" & vbCrLf, oldModuleId, ModuleID) - - Dim tabMods As ArrayList = (New ModuleController).GetAllTabsModulesByModuleID(ModuleID) - If tabMods.Count > 0 Then - Dim vs As ViewSettings = ViewSettings.GetViewSettings(CType(tabMods(0), ModuleInfo).TabModuleID) - vs.FromXml(xContent.SelectSingleNode("ViewSettings")) - vs.UpdateSettings() - If vs.BlogModuleId = -1 Then - Dim settings As ModuleSettings = ModuleSettings.GetModuleSettings(ModuleID) - settings.FromXml(xContent.SelectSingleNode("Settings")) - Dim vocabulary As List(Of TermInfo) = TermsController.FromXml(xContent.SelectSingleNode("Categories")) - Dim categories As New Dictionary(Of String, TermInfo) - If vocabulary.Count > 0 Then - settings.VocabularyId = Integration.CreateNewVocabulary(CType(tabMods(0), ModuleInfo).PortalID).VocabularyId - TermsController.AddVocabulary(settings.VocabularyId, vocabulary) - categories = TermsController.GetTermsByVocabulary(ModuleID, settings.VocabularyId, "", True) - End If - settings.UpdateSettings() - vocabulary = TermsController.FromXml(xContent.SelectSingleNode("Tags")) - If vocabulary.Count > 0 Then - TermsController.AddTags(ModuleID, vocabulary) - End If - Dim tags As Dictionary(Of String, TermInfo) = TermsController.GetTermsByVocabulary(ModuleID, 1, "") - For Each xBlog As XmlNode In xContent.SelectNodes("Blog") - Dim blog As New BlogInfo - blog.FromXml(xBlog) - blog.ModuleID = ModuleID - blog.OwnerUserId = UserID - blog.BlogID = BlogsController.AddBlog(blog, UserID) - importReport.AppendFormat("B{0}-{1}" & vbCrLf, blog.ImportedBlogId, blog.BlogID) - For Each p As PostInfo In blog.ImportedPosts - p.BlogID = blog.BlogID - For Each tagName As String In p.ImportedTags - If tags.ContainsKey(tagName) Then - p.Terms.Add(tags(tagName)) - End If - Next - For Each catName As String In p.ImportedCategories - If categories.ContainsKey(catName) Then - p.Terms.Add(categories(catName)) - End If - Next - PostsController.AddPost(p, UserID) - importReport.AppendFormat("P{0}-{1}" & vbCrLf, p.ImportedPostId, p.ContentItemId) - Next - Next - End If - End If - - Dim importLogFile As String = String.Format(LogFilePattern, DotNetNuke.Common.HostMapPath, ModuleID) - Common.Globals.WriteToFile(importLogFile, importReport.ToString) - - Catch ex As Exception - Exceptions.LogException(ex) - End Try - End Sub -#End Region - -#Region " Private Methods " -#End Region - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Integration/BlogModuleController_Searchable.vb b/Server/Blog/Components/Integration/BlogModuleController_Searchable.vb deleted file mode 100644 index 1618439f..00000000 --- a/Server/Blog/Components/Integration/BlogModuleController_Searchable.vb +++ /dev/null @@ -1,87 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Services.Search.Entities - -Namespace Integration - Partial Public Class BlogModuleController - Inherits ModuleSearchBase - -#Region " Search Implementation " - Public Overrides Function GetModifiedSearchDocuments(moduleInfo As ModuleInfo, beginDate As Date) As IList(Of SearchDocument) - - Dim res As New List(Of SearchDocument) - Dim settings As New ViewSettings(moduleInfo.TabModuleID, True) - If settings.BlogModuleId <> -1 And settings.BlogModuleId <> moduleInfo.ModuleID Then Return res ' bail out if it's a slave module - - ' Blogs - For Each b As BlogInfo In BlogsController.GetBlogsByModule(moduleInfo.ModuleID, "").Values - If b.LastModifiedOnDate.ToUniversalTime() >= beginDate Then - res.Add(New SearchDocument With { - .AuthorUserId = b.OwnerUserId, - .Body = b.Title & " - " & b.Description, - .Description = b.Description, - .ModifiedTimeUtc = b.LastModifiedOnDate.ToUniversalTime(), - .PortalId = moduleInfo.PortalID, - .QueryString = "Blog=" & b.BlogID.ToString(), - .Title = b.Title, - .UniqueKey = "Blog" & b.BlogID.ToString()}) - End If - Next - - ' Posts - Dim addedPrimaryPosts As New List(Of Integer) - For Each p As PostInfo In PostsController.GetChangedPosts(moduleInfo.ModuleID, beginDate) - If Not addedPrimaryPosts.Contains(p.ContentItemId) Then - res.Add(New SearchDocument With { - .AuthorUserId = p.CreatedByUserID, - .Body = p.Summary & " " & HtmlUtils.Clean(p.Content, False), - .Description = p.Summary, - .ModifiedTimeUtc = p.LastModifiedOnDate.ToUniversalTime(), - .PortalId = moduleInfo.PortalID, - .QueryString = "Post=" & p.ContentItemId.ToString(), - .Title = p.Title, - .UniqueKey = "BlogPost" & p.ContentItemId.ToString()}) - addedPrimaryPosts.Add(p.ContentItemId) - End If - If p.AltLocale <> "" Then - res.Add(New SearchDocument With { - .AuthorUserId = p.CreatedByUserID, - .Body = p.AltSummary & " " & HtmlUtils.Clean(p.AltContent, False), - .CultureCode = p.AltLocale, - .Description = p.AltSummary, - .ModifiedTimeUtc = p.LastModifiedOnDate.ToUniversalTime(), - .PortalId = moduleInfo.PortalID, - .QueryString = "Post=" & p.ContentItemId.ToString(), - .Title = p.AltTitle, - .UniqueKey = "BlogPost" & p.ContentItemId.ToString()}) - End If - Next - Return res - - End Function -#End Region - - End Class -End Namespace diff --git a/Server/Blog/Components/Integration/BlogModuleController_Upgradeable.vb b/Server/Blog/Components/Integration/BlogModuleController_Upgradeable.vb deleted file mode 100644 index 69518e12..00000000 --- a/Server/Blog/Components/Integration/BlogModuleController_Upgradeable.vb +++ /dev/null @@ -1,41 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Entities.Modules - -Namespace Integration - Partial Public Class BlogModuleController - Implements IUpgradeable - -#Region " IUpgradeable Methods " - Public Function UpgradeModule(ByVal Version As String) As String Implements IUpgradeable.UpgradeModule - Dim message As String = "" - - Select Case Version - Case "05.00.00" - NotificationController.AddNotificationTypes() - End Select - Return message - - End Function -#End Region - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Integration/FileController.vb b/Server/Blog/Components/Integration/FileController.vb deleted file mode 100644 index 47e0049e..00000000 --- a/Server/Blog/Components/Integration/FileController.vb +++ /dev/null @@ -1,74 +0,0 @@ -' -' DotNetNuke® - http://www.dotnetnuke.com -' Copyright (c) 2015 -' by DotNetNuke Corporation -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' -Imports System.IO -Imports DotNetNuke.Common -Imports DotNetNuke.Entities.Portals -Imports DotNetNuke.Modules.Blog.Entities.Posts - -Namespace Integration - - Public Class FileController - -#Region "Shared methods" - - Public Shared Function getFileList(pModulPath As String, pPost As PostInfo) As ArrayList - - Dim myList As New ArrayList - If Directory.Exists(getPostDir(pModulPath, pPost)) Then - Dim fileList() As String = System.IO.Directory.GetFiles(getPostDir(pModulPath, pPost)) - For Each s As String In fileList - myList.Add(System.IO.Path.GetFileName(s)) - Next - End If - Return myList - - End Function - - Public Shared Function getPostDir(pModulPath As String, pPost As PostInfo) As String - - Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings) - If pPost Is Nothing Then - getPostDir = System.Web.HttpContext.Current.Request.MapPath(pModulPath) & "Files\AnonymousBlogAttachments\" - Else - getPostDir = System.Web.HttpContext.Current.Request.MapPath(pModulPath) & "Files\" & pPost.BlogID.ToString() & "\" & pPost.ContentItemId.ToString() & "\" - End If - - End Function - - Public Shared Function createFileDirectory(filePath As String) As String - - Dim newFolderPath As String = filePath.Substring(0, filePath.LastIndexOf("\")) - If Not Directory.Exists(newFolderPath) Then Directory.CreateDirectory(newFolderPath) - Return newFolderPath - - End Function - - Public Shared Function getVirtualFileName(pModulPath As String, pFullPath As String) As String - Dim strReturn As String - strReturn = pFullPath.Replace(System.Web.HttpContext.Current.Request.MapPath(pModulPath), "") - strReturn = strReturn.Replace("\", "/") - strReturn = pModulPath & strReturn - getVirtualFileName = ResolveUrl(strReturn) - End Function -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Integration/Integration.vb b/Server/Blog/Components/Integration/Integration.vb deleted file mode 100644 index b15ae665..00000000 --- a/Server/Blog/Components/Integration/Integration.vb +++ /dev/null @@ -1,59 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Linq -Imports DotNetNuke.Entities.Content.Taxonomy - -Namespace Integration - Public Class Integration - - Public Const ContentTypeName As String = "DNN_Blog_Post" - Public Const JournalBlogTypeName As String = "blog" - Public Const JournalCommentTypeName As String = "comment" - Public Const NotificationPublishingTypeName As String = "DNN_Blog_Post_Publishing" - Public Const NotificationCommentApprovalTypeName As String = "DNN_Blog_Post_CommentApproval" - Public Const NotificationCommentReportedTypeName As String = "DNN_Blog_Post_CommentReported" - Public Const NotificationCommentAddedTypeName As String = "DNN_Blog_Post_CommentAdded" - - Public Shared Function CreateNewVocabulary(portalId As Integer) As Vocabulary - - Dim name As String = "Blog Categories" - Dim cntScope As New ScopeTypeController - Dim cntVocabulary As New VocabularyController - Dim i As Integer = 1 - Do While cntVocabulary.GetVocabularies.Where(Function(v) v.Name = name).Count > 0 - name = "Blog Categories " + i.ToString - Loop - Dim objScope As ScopeType = cntScope.GetScopeTypes().Where(Function(s) s.ScopeType = "Portal").SingleOrDefault() - Dim objVocab As New Vocabulary - objVocab.Name = name - objVocab.IsSystem = False - objVocab.Weight = 0 - objVocab.Description = "Automatically generated for blog module." - objVocab.ScopeId = portalId - objVocab.ScopeTypeId = objScope.ScopeTypeId - objVocab.Type = VocabularyType.Hierarchy - objVocab.VocabularyId = cntVocabulary.AddVocabulary(objVocab) - Return objVocab - - End Function - - End Class -End Namespace diff --git a/Server/Blog/Components/Integration/JournalController.vb b/Server/Blog/Components/Integration/JournalController.vb deleted file mode 100644 index 6043a3f3..00000000 --- a/Server/Blog/Components/Integration/JournalController.vb +++ /dev/null @@ -1,184 +0,0 @@ -' -' DotNetNuke® - http://www.dotnetnuke.com -' Copyright (c) 2002-2011 -' by DotNetNuke Corporation -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' -Option Strict On -Option Explicit On -Imports DotNetNuke.Services.Journal -Imports System.Linq -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Integration.Integration -Imports DotNetNuke.Entities.Modules - -Namespace Integration - - Public Class JournalController - -#Region " Public Methods " - ''' - ''' Informs the core journal that the user has posted a blog Post. - ''' - ''' - ''' - ''' - ''' - ''' - ''' - Public Shared Sub AddBlogPostToJournal(objPost As PostInfo, portalId As Integer, tabId As Integer, journalUserId As Integer, url As String) - If journalUserId = -1 Then Exit Sub - Dim objectKey As String = ContentTypeName + "_" + ContentTypeName + "_" + String.Format("{0}:{1}", objPost.BlogID, objPost.ContentItemId) - Dim ji As JournalItem = DotNetNuke.Services.Journal.JournalController.Instance.GetJournalItemByKey(portalId, objectKey) - - If Not ji Is Nothing Then - DotNetNuke.Services.Journal.JournalController.Instance.DeleteJournalItemByKey(portalId, objectKey) - End If - - ji = New JournalItem - - ji.PortalId = portalId - ji.ProfileId = journalUserId - ji.UserId = journalUserId - ji.ContentItemId = objPost.ContentItemId - ji.Title = objPost.Title - ji.ItemData = New ItemData() - ji.ItemData.Url = url - ji.Summary = HttpUtility.HtmlDecode(objPost.Summary) - ji.Body = Nothing - ji.JournalTypeId = GetBlogJournalTypeID(portalId) - ji.ObjectKey = objectKey - ji.SecuritySet = "E," - - Dim moduleInfo As ModuleInfo = ModuleController.Instance.GetModule(objPost.ModuleID, tabId, False) - DotNetNuke.Services.Journal.JournalController.Instance.SaveJournalItem(ji, moduleInfo) - End Sub - - ''' - ''' Deletes a journal item associated with the specified blog Post. - ''' - ''' - ''' - ''' - ''' - Public Shared Sub RemoveBlogPostFromJournal(blogId As Integer, PostId As Integer, portalId As Integer) - Dim objectKey As String = ContentTypeName + "_" + ContentTypeName + "_" + String.Format("{0}:{1}", blogId, PostId) - DotNetNuke.Services.Journal.JournalController.Instance.DeleteJournalItemByKey(portalId, objectKey) - End Sub - - ''' - ''' Informs the core journal that the user has commented on a blog Post. - ''' - ''' - ''' - ''' - ''' - ''' - ''' - Public Shared Sub AddOrUpdateCommentInJournal(objBlog As BlogInfo, objPost As PostInfo, objComment As Entities.Comments.CommentInfo, portalId As Integer, tabId As Integer, journalUserId As Integer, url As String) - If journalUserId = -1 Then Exit Sub - Dim objectKey As String = ContentTypeName + "_" + JournalCommentTypeName + "_" + String.Format("{0}:{1}", objPost.ContentItemId.ToString(), objComment.CommentID.ToString()) - Dim ji As JournalItem = DotNetNuke.Services.Journal.JournalController.Instance.GetJournalItemByKey(portalId, objectKey) - If Not ji Is Nothing Then - DotNetNuke.Services.Journal.JournalController.Instance.DeleteJournalItemByKey(portalId, objectKey) - End If - - ji = New JournalItem - - ji.PortalId = portalId - ji.ProfileId = journalUserId - ji.UserId = journalUserId - ji.ContentItemId = objPost.ContentItemId - ji.Title = objPost.Title - ji.ItemData = New ItemData() - ji.ItemData.Url = url - ji.Summary = HttpUtility.HtmlDecode(objComment.Comment) - ji.Body = Nothing - ji.JournalTypeId = GetCommentJournalTypeID(portalId) - ji.ObjectKey = objectKey - ji.SecuritySet = "E," - - Dim moduleInfo As ModuleInfo = ModuleController.Instance.GetModule(objPost.ModuleID, tabId, False) - DotNetNuke.Services.Journal.JournalController.Instance.SaveJournalItem(ji, moduleInfo) - - If objBlog.OwnerUserId <> journalUserId Then - Dim title As String = DotNetNuke.Services.Localization.Localization.GetString("CommentAddedNotify", SharedResourceFileName) - Dim summary As String = "" + objPost.Title + "" - NotificationController.CommentAdded(objComment, objPost, objBlog, portalId, summary, title) - End If - - End Sub - - ''' - ''' Deletes a journal item associated with the specific comment. - ''' - ''' - ''' - ''' - Public Shared Sub RemoveCommentFromJournal(PostId As Integer, commentId As Integer, portalId As Integer) - Dim objectKey As String = ContentTypeName + "_" + JournalCommentTypeName + "_" + String.Format("{0}:{1}", PostId, commentId) - DotNetNuke.Services.Journal.JournalController.Instance.DeleteJournalItemByKey(portalId, objectKey) - End Sub -#End Region - -#Region " Private Methods " - ''' - ''' Returns a journal type associated with blog Posts (using one of the core built in journal types) - ''' - ''' - ''' - ''' - Private Shared Function GetBlogJournalTypeID(portalId As Integer) As Integer - Dim colJournalTypes As IEnumerable(Of JournalTypeInfo) - colJournalTypes = (From t In DotNetNuke.Services.Journal.JournalController.Instance.GetJournalTypes(portalId) Where t.JournalType = JournalBlogTypeName) - Dim journalTypeId As Integer - - If colJournalTypes.Count() > 0 Then - Dim journalType As JournalTypeInfo = colJournalTypes.[Single]() - journalTypeId = journalType.JournalTypeId - Else - journalTypeId = 7 - End If - - Return journalTypeId - End Function - - ''' - ''' Returns a journal type associated with commenting (using one of the core built in journal types) - ''' - ''' - ''' - Private Shared Function GetCommentJournalTypeID(portalId As Integer) As Integer - Dim colJournalTypes As IEnumerable(Of JournalTypeInfo) - colJournalTypes = (From t In DotNetNuke.Services.Journal.JournalController.Instance.GetJournalTypes(portalId) Where t.JournalType = JournalCommentTypeName) - Dim journalTypeId As Integer - - If colJournalTypes.Count() > 0 Then - Dim journalType As JournalTypeInfo = colJournalTypes.[Single]() - journalTypeId = journalType.JournalTypeId - Else - journalTypeId = 18 - End If - - Return journalTypeId - End Function -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Integration/NotificationController.vb b/Server/Blog/Components/Integration/NotificationController.vb deleted file mode 100644 index a98d3403..00000000 --- a/Server/Blog/Components/Integration/NotificationController.vb +++ /dev/null @@ -1,310 +0,0 @@ -' -' DotNetNuke® - http://www.dotnetnuke.com -' Copyright (c) 2002-2011 -' by DotNetNuke Corporation -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Services.Social.Notifications -Imports DotNetNuke.Entities.Users -Imports DotNetNuke.Entities.Modules -Imports System.Linq -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Modules.Blog.Security.Permissions -Imports DotNetNuke.Modules.Blog.Entities.Comments -Imports DotNetNuke.Modules.Blog.Integration.Integration -Imports DotNetNuke.Modules.Blog.Security.Security - -Namespace Integration - - Public Class NotificationController - -#Region " Integration Methods " - ''' - ''' This method will send a core notification to blog owners when a blog Post is pending publishing approval. - ''' - ''' - ''' - ''' - ''' - ''' - ''' - Public Shared Sub PostPendingApproval(objBlog As BlogInfo, objPost As PostInfo, portalId As Integer, summary As String, title As String) - Dim notificationType As NotificationType = NotificationsController.Instance.GetNotificationType(NotificationPublishingTypeName) - - Dim notificationKey As New NotificationKey(ContentTypeName, objBlog.ModuleID, objPost.BlogID, objPost.ContentItemId, -1) - Dim objNotification As New Notification - - objNotification.NotificationTypeID = notificationType.NotificationTypeId - objNotification.Subject = title - objNotification.Body = summary - objNotification.IncludeDismissAction = False - objNotification.SenderUserID = objPost.CreatedByUserID - objNotification.Context = notificationKey.ToString - - Dim objOwner As UserInfo = UserController.GetUserById(portalId, objBlog.OwnerUserId) - Dim colUsers As List(Of UserInfo) = BlogPermissionsController.GetUsersByBlogPermission(portalId, objBlog.BlogID, BlogPermissionTypes.APPROVE).Values.ToList - If Not colUsers.Contains(objOwner) Then colUsers.Add(objOwner) - - NotificationsController.Instance.SendNotification(objNotification, portalId, Nothing, colUsers) - - End Sub - - ''' - ''' Removes any notifications associated w/ a specific blog Post pending approval. - ''' - ''' - ''' - ''' - Public Shared Sub RemovePostPendingNotification(moduleId As Integer, blogId As Integer, PostId As Integer) - Dim notificationType As NotificationType = NotificationsController.Instance.GetNotificationType(NotificationPublishingTypeName) - Dim notificationKey As New NotificationKey(ContentTypeName, moduleId, blogId, PostId, -1) - Dim objNotify As Notification = NotificationsController.Instance.GetNotificationByContext(notificationType.NotificationTypeId, notificationKey.ToString).SingleOrDefault - If objNotify IsNot Nothing Then - NotificationsController.Instance.DeleteAllNotificationRecipients(objNotify.NotificationID) - End If - End Sub - - ''' - ''' This method will send a core notification to blog owners when a comment is pending approval. - ''' - ''' - ''' - ''' - ''' - ''' - ''' - ''' - Public Shared Sub CommentPendingApproval(objComment As CommentInfo, objBlog As BlogInfo, objPost As PostInfo, portalId As Integer, summary As String, subject As String) - Dim notificationType As NotificationType = NotificationsController.Instance.GetNotificationType(NotificationCommentApprovalTypeName) - - Dim notificationKey As New NotificationKey(ContentTypeName & NotificationCommentApprovalTypeName, objBlog.ModuleID, objBlog.BlogID, objPost.ContentItemId, objComment.CommentID) - Dim objNotification As New Notification - - Dim recipientId As Integer - If objBlog.PublishAsOwner Then - recipientId = objBlog.OwnerUserId - Else - recipientId = objPost.CreatedByUserID - End If - - objNotification.NotificationTypeID = notificationType.NotificationTypeId - objNotification.Subject = subject - objNotification.Body = summary - objNotification.IncludeDismissAction = True - objNotification.SenderUserID = objComment.CreatedByUserID - objNotification.Context = notificationKey.ToString - - Dim objOwner As UserInfo = UserController.GetUserById(portalId, recipientId) - Dim colUsers As Dictionary(Of String, UserInfo) = BlogPermissionsController.GetUsersByBlogPermission(portalId, objBlog.BlogID, BlogPermissionTypes.APPROVECOMMENT) - If Not colUsers.ContainsKey(objOwner.Username) Then colUsers.Add(objOwner.Username, objOwner) - AddNotifications(portalId, colUsers.Values.ToList, objNotification) - - End Sub - - Public Shared Sub ReportComment(objComment As CommentInfo, objBlog As BlogInfo, objPost As PostInfo, portalId As Integer, summary As String, subject As String) - Dim notificationType As NotificationType = NotificationsController.Instance.GetNotificationType(NotificationCommentReportedTypeName) - - Dim notificationKey As New NotificationKey(ContentTypeName & NotificationCommentReportedTypeName, objBlog.ModuleID, objBlog.BlogID, objPost.ContentItemId, objComment.CommentID) - Dim objNotification As New Notification - - Dim recipientId As Integer - If objBlog.PublishAsOwner Then - recipientId = objBlog.OwnerUserId - Else - recipientId = objPost.CreatedByUserID - End If - - objNotification.NotificationTypeID = notificationType.NotificationTypeId - objNotification.Subject = subject - objNotification.Body = summary - objNotification.IncludeDismissAction = True - objNotification.SenderUserID = objComment.CreatedByUserID - objNotification.Context = notificationKey.ToString - - Dim objOwner As UserInfo = UserController.GetUserById(portalId, recipientId) - Dim colUsers As Dictionary(Of String, UserInfo) = BlogPermissionsController.GetUsersByBlogPermission(portalId, objBlog.BlogID, BlogPermissionTypes.APPROVECOMMENT) - If Not colUsers.ContainsKey(objOwner.Username) Then colUsers.Add(objOwner.Username, objOwner) - AddNotifications(portalId, colUsers.Values.ToList, objNotification) - - End Sub - ''' - ''' Removes any notifications associated w/ a specific blog comment pending approval. - ''' - ''' - ''' - ''' - Public Shared Sub RemoveCommentPendingNotification(moduleId As Integer, blogId As Integer, PostId As Integer, commentId As Integer) - Dim notificationType As NotificationType = NotificationsController.Instance.GetNotificationType(NotificationCommentApprovalTypeName) - Dim notificationKey As New NotificationKey(ContentTypeName & NotificationCommentApprovalTypeName, moduleId, blogId, PostId, commentId) - Dim objNotify As Notification = NotificationsController.Instance.GetNotificationByContext(notificationType.NotificationTypeId, notificationKey.ToString).SingleOrDefault - If objNotify IsNot Nothing Then - NotificationsController.Instance.DeleteAllNotificationRecipients(objNotify.NotificationID) - End If - End Sub - - ''' - ''' This method will send a core notification to blog owners when a comment is added (they can only dismiss this notification) - ''' - ''' - ''' - ''' - ''' - ''' - ''' - ''' - Public Shared Sub CommentAdded(objComment As CommentInfo, objPost As PostInfo, objBlog As BlogInfo, portalId As Integer, summary As String, subject As String) - Dim notificationType As NotificationType = NotificationsController.Instance.GetNotificationType(NotificationCommentAddedTypeName) - - Dim notificationKey As New NotificationKey(ContentTypeName & NotificationCommentAddedTypeName, objBlog.ModuleID, objBlog.BlogID, objPost.ContentItemId, objComment.CommentID) - Dim objNotification As New Notification - - Dim recipientId As Integer - If objBlog.PublishAsOwner Then - recipientId = objBlog.OwnerUserId - Else - recipientId = objPost.CreatedByUserID - End If - - objNotification.NotificationTypeID = notificationType.NotificationTypeId - objNotification.Subject = subject - objNotification.Body = summary - objNotification.IncludeDismissAction = True - objNotification.SenderUserID = objComment.CreatedByUserID - objNotification.Context = notificationKey.ToString - objNotification.SendToast = True - - Dim objOwner As UserInfo = UserController.GetUserById(portalId, recipientId) - Dim colUsers As New List(Of UserInfo) - - colUsers.Add(objOwner) - - AddNotifications(portalId, colUsers, objNotification) - - End Sub -#End Region - -#Region " Private Methods " - Private Shared Sub AddNotifications(portalId As Integer, colUsers As List(Of UserInfo), objNotification As Notification) - If colUsers.Count > DotNetNuke.Services.Social.Messaging.Internal.InternalMessagingController.Instance.RecipientLimit(portalId) Then - For Each u As UserInfo In colUsers - Dim list As New List(Of UserInfo) - list.Add(u) - NotificationsController.Instance.SendNotification(objNotification, portalId, Nothing, list) - Next - Else - NotificationsController.Instance.SendNotification(objNotification, portalId, Nothing, colUsers) - End If - End Sub -#End Region - -#Region " Install Methods " - ''' - ''' This will create a notification type associated w/ the module and also handle the actions that must be associated with it. - ''' - ''' This should only ever run once, during 5.0.0 install (via IUpgradeable) - Friend Shared Sub AddNotificationTypes() - Dim actions As List(Of NotificationTypeAction) = New List(Of NotificationTypeAction) - Dim deskModuleId As Integer = DesktopModuleController.GetDesktopModuleByFriendlyName("Blog").DesktopModuleID - - Dim objNotificationType As NotificationType = New NotificationType - objNotificationType.Name = NotificationPublishingTypeName - objNotificationType.Description = "Blog module post approval." - objNotificationType.DesktopModuleId = deskModuleId - - If NotificationsController.Instance.GetNotificationType(objNotificationType.Name) Is Nothing Then - Dim objAction As New NotificationTypeAction - objAction.NameResourceKey = "ApprovePost" - objAction.DescriptionResourceKey = "ApprovePost_Desc" - objAction.APICall = "DesktopModules/Blog/API/NotificationService/ApprovePost" - objAction.Order = 1 - actions.Add(objAction) - - objAction = New NotificationTypeAction - objAction.NameResourceKey = "DeletePost" - objAction.DescriptionResourceKey = "DeletePost_Desc" - objAction.APICall = "DesktopModules/Blog/API/NotificationService/DeletePost" - objAction.ConfirmResourceKey = "DeleteItem" - objAction.Order = 3 - actions.Add(objAction) - - NotificationsController.Instance.CreateNotificationType(objNotificationType) - NotificationsController.Instance.SetNotificationTypeActions(actions, objNotificationType.NotificationTypeId) - End If - - objNotificationType = New NotificationType - objNotificationType.Name = NotificationCommentApprovalTypeName - objNotificationType.Description = "Blog module comment approval." - objNotificationType.DesktopModuleId = deskModuleId - - If NotificationsController.Instance.GetNotificationType(objNotificationType.Name) Is Nothing Then - actions.Clear() - - Dim objAction As New NotificationTypeAction - objAction.NameResourceKey = "ApproveComment" - objAction.DescriptionResourceKey = "ApproveComment_Desc" - objAction.APICall = "DesktopModules/Blog/API/NotificationService/ApproveComment" - objAction.Order = 1 - actions.Add(objAction) - - objAction = New NotificationTypeAction - objAction.NameResourceKey = "DeleteComment" - objAction.DescriptionResourceKey = "DeleteComment_Desc" - objAction.APICall = "DesktopModules/Blog/API/NotificationService/DeleteComment" - objAction.ConfirmResourceKey = "DeleteItem" - objAction.Order = 3 - actions.Add(objAction) - - NotificationsController.Instance.CreateNotificationType(objNotificationType) - NotificationsController.Instance.SetNotificationTypeActions(actions, objNotificationType.NotificationTypeId) - End If - - objNotificationType = New NotificationType - objNotificationType.Name = NotificationCommentReportedTypeName - objNotificationType.Description = "Blog module comment reported." - objNotificationType.DesktopModuleId = deskModuleId - - If NotificationsController.Instance.GetNotificationType(objNotificationType.Name) Is Nothing Then - actions.Clear() - - Dim objAction As New NotificationTypeAction - objAction.NameResourceKey = "DeleteComment" - objAction.DescriptionResourceKey = "DeleteComment_Desc" - objAction.APICall = "DesktopModules/Blog/API/Comments/Delete" - objAction.ConfirmResourceKey = "DeleteItem" - objAction.Order = 1 - actions.Add(objAction) - - NotificationsController.Instance.CreateNotificationType(objNotificationType) - NotificationsController.Instance.SetNotificationTypeActions(actions, objNotificationType.NotificationTypeId) - End If - - objNotificationType = New NotificationType - objNotificationType.Name = NotificationCommentAddedTypeName - objNotificationType.Description = "Blog module and comments being added." - objNotificationType.DesktopModuleId = deskModuleId - - If NotificationsController.Instance.GetNotificationType(objNotificationType.Name) Is Nothing Then - NotificationsController.Instance.CreateNotificationType(objNotificationType) - End If - End Sub - -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Integration/NotificationKey.vb b/Server/Blog/Components/Integration/NotificationKey.vb deleted file mode 100644 index fc050f92..00000000 --- a/Server/Blog/Components/Integration/NotificationKey.vb +++ /dev/null @@ -1,53 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Namespace Integration - Public Class NotificationKey - - Public ID As String = "" - Public ModuleId As Integer = -1 - Public BlogId As Integer = -1 - Public ContentItemId As Integer = -1 - Public CommentId As Integer = -1 - - Public Sub New(key As String) - Dim keyParts() As String = key.Split(":"c) - If keyParts.Length < 5 Then Exit Sub - ID = keyParts(0) - ModuleId = Integer.Parse(keyParts(1)) - BlogId = Integer.Parse(keyParts(2)) - ContentItemId = Integer.Parse(keyParts(3)) - CommentId = Integer.Parse(keyParts(4)) - End Sub - - Public Sub New(id As String, moduleId As Integer, blogId As Integer, contentItemId As Integer, commentId As Integer) - Me.ID = id - Me.ModuleId = moduleId - Me.BlogId = blogId - Me.ContentItemId = contentItemId - Me.CommentId = commentId - End Sub - - Public Shadows Function ToString() As String - Return String.Format("{0}:{1}:{2}:{3}:{4}", ID, ModuleId, BlogId, ContentItemId, CommentId) - End Function - - End Class -End Namespace diff --git a/Server/Blog/Components/Integration/Services/NotificationServiceController.vb b/Server/Blog/Components/Integration/Services/NotificationServiceController.vb deleted file mode 100644 index a1350f00..00000000 --- a/Server/Blog/Components/Integration/Services/NotificationServiceController.vb +++ /dev/null @@ -1,136 +0,0 @@ -' -' DotNetNuke® - http://www.dotnetnuke.com -' Copyright (c) 2002-2011 -' by DotNetNuke Corporation -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' -Option Strict On -Option Explicit On -Imports System.Net -Imports System.Net.Http -Imports System.Web.Http -Imports DotNetNuke.Web.Api -Imports DotNetNuke.Services.Social.Notifications -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Modules.Blog.Entities.Comments -Imports DotNetNuke.Modules.Blog.Services - -Namespace Integration.Services - - Public Class NotificationServiceController - Inherits DnnApiController - - Public Class NotificationDTO - Public Property NotificationId As Integer - End Class - -#Region " Private Members " - - Private Property BlogModuleId As Integer = -1 - Private Property BlogId As Integer = -1 - Private Property Blog As BlogInfo = Nothing - Private Property ContentItemId As Integer = -1 - Private Property Post As PostInfo = Nothing - Private Property CommentId As Integer = -1 - Private Property Comment As CommentInfo = Nothing - -#End Region - -#Region " Service Methods " - - - - Public Function ApprovePost(postData As NotificationDTO) As HttpResponseMessage - Dim notify As Notification = NotificationsController.Instance.GetNotification(postData.NotificationId) - ParsePublishKey(notify.Context) - If Blog Is Nothing Or Post Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - Post.Published = True - PostsController.UpdatePost(Post, UserInfo.UserID) - NotificationsController.Instance().DeleteNotification(postData.NotificationId) - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - End Function - - - - - Public Function DeletePost(postData As NotificationDTO) As HttpResponseMessage - Dim notify As Notification = NotificationsController.Instance.GetNotification(postData.NotificationId) - ParsePublishKey(notify.Context) - If Blog Is Nothing Or Post Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - PostsController.DeletePost(ContentItemId) - NotificationsController.Instance().DeleteNotification(postData.NotificationId) - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - End Function - - - - - Public Function ApproveComment(postData As NotificationDTO) As HttpResponseMessage - Dim notify As Notification = NotificationsController.Instance.GetNotification(postData.NotificationId) - ParseCommentKey(notify.Context) - If Blog Is Nothing Or Post Is Nothing Or Comment Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - CommentsController.ApproveComment(BlogModuleId, BlogId, Comment) - NotificationsController.Instance().DeleteNotification(postData.NotificationId) - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - End Function - - - - - Public Function DeleteComment(postData As NotificationDTO) As HttpResponseMessage - Dim notify As Notification = NotificationsController.Instance.GetNotification(postData.NotificationId) - ParseCommentKey(notify.Context) - If Blog Is Nothing Or Post Is Nothing Or Comment Is Nothing Then - Return Request.CreateResponse(HttpStatusCode.BadRequest, New With {.Result = "error"}) - End If - CommentsController.DeleteComment(BlogModuleId, BlogId, Comment) - NotificationsController.Instance().DeleteNotification(postData.NotificationId) - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - End Function -#End Region - -#Region " Private Methods " - Private Sub ParsePublishKey(key As String) - Dim nKey As New NotificationKey(key) - BlogModuleId = nKey.ModuleId - BlogId = nKey.BlogId - ContentItemId = nKey.ContentItemId - Blog = BlogsController.GetBlog(BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) - Post = PostsController.GetPost(ContentItemId, BlogModuleId, Threading.Thread.CurrentThread.CurrentCulture.Name) - End Sub - - Private Sub ParseCommentKey(key As String) - Dim nKey As New NotificationKey(key) - BlogModuleId = nKey.ModuleId - BlogId = nKey.BlogId - ContentItemId = nKey.ContentItemId - CommentId = nKey.CommentId - Blog = BlogsController.GetBlog(BlogId, UserInfo.UserID, Threading.Thread.CurrentThread.CurrentCulture.Name) - Post = PostsController.GetPost(ContentItemId, BlogModuleId, Threading.Thread.CurrentThread.CurrentCulture.Name) - Comment = CommentsController.GetComment(CommentId, UserInfo.UserID) - End Sub -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Integration/SiteMapProvider.vb b/Server/Blog/Components/Integration/SiteMapProvider.vb deleted file mode 100644 index 0b45bb05..00000000 --- a/Server/Blog/Components/Integration/SiteMapProvider.vb +++ /dev/null @@ -1,62 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Services.Sitemap -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Security.Permissions -Imports DotNetNuke.Modules.Blog.Entities.Posts - -Namespace Integration - Public Class BlogSiteMapProvider - Inherits SitemapProvider - - Public Overrides Function GetUrls(portalId As Integer, ps As DotNetNuke.Entities.Portals.PortalSettings, version As String) As System.Collections.Generic.List(Of SitemapUrl) - - Dim SitemapUrls As New List(Of SitemapUrl) - Dim moduleTabs As New Dictionary(Of Integer, List(Of DotNetNuke.Entities.Tabs.TabInfo)) - For Each blog As BlogInfo In BlogsController.GetBlogsByPortal(portalId, -1, "").Values - If Not moduleTabs.ContainsKey(blog.ModuleID) Then - Dim tabs As New List(Of DotNetNuke.Entities.Tabs.TabInfo) - For Each t As DotNetNuke.Entities.Tabs.TabInfo In (New DotNetNuke.Entities.Tabs.TabController).GetTabsByModuleID(blog.ModuleID).Values - For Each tp As TabPermissionInfo In t.TabPermissions - If tp.RoleName = DotNetNuke.Common.Globals.glbRoleAllUsersName Then - tabs.Add(t) - Exit For - End If - Next - Next - moduleTabs.Add(blog.ModuleID, tabs) - End If - Dim totalRecs As Integer = 0 - For Each p As PostInfo In PostsController.GetPostsByBlog(blog.ModuleID, blog.BlogID, Threading.Thread.CurrentThread.CurrentCulture.Name, -1, -1, 0, Nothing, totalRecs).Values - If p.Published Then - For Each t As DotNetNuke.Entities.Tabs.TabInfo In moduleTabs(blog.ModuleID) - Dim smu As New SitemapUrl With {.ChangeFrequency = SitemapChangeFrequency.Daily, .LastModified = p.LastModifiedOnDate, .Priority = 0.5, .Url = p.PermaLink(t)} - SitemapUrls.Add(smu) - Next - End If - Next - Next - Return SitemapUrls - - End Function - - End Class -End Namespace diff --git a/Server/Blog/Components/Rss/BlogRssFeed.vb b/Server/Blog/Components/Rss/BlogRssFeed.vb deleted file mode 100644 index ccbc7572..00000000 --- a/Server/Blog/Components/Rss/BlogRssFeed.vb +++ /dev/null @@ -1,345 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Xml -Imports DotNetNuke.Common.Globals -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Modules.Blog.Entities.Terms -Imports DotNetNuke.Modules.Blog.Entities.Blogs - -Namespace Rss - Public Class BlogRssFeed - -#Region " Constants " - Private Const nsBlogPre As String = "blog" - Private Const nsBlogFull As String = "http://dnn-connect.org/blog/" - Private Const nsSlashPre As String = "slash" - Private Const nsSlashFull As String = "http://purl.org/rss/1.0/modules/slash/" - Private Const nsAtomPre As String = "atom" - Private Const nsAtomFull As String = "http://www.w3.org/2005/Atom" - Private Const nsMediaPre As String = "media" - Private Const nsMediaFull As String = "http://search.yahoo.com/mrss/" - Private Const nsDublinPre As String = "dc" - Private Const nsDublinFull As String = "http://purl.org/dc/elements/1.1/" - Private Const nsContentPre As String = "content" - Private Const nsContentFull As String = "http://purl.org/rss/1.0/modules/content/" - Private Const nsOpenSearchPre As String = "os" - Private Const nsOpenSearchFull As String = "http://opensearch.a9.com/spec/opensearchrss/1.0/" -#End Region - -#Region " Properties " - Public Property Settings As ModuleSettings = Nothing - Public Property PortalSettings As DotNetNuke.Entities.Portals.PortalSettings = Nothing - Public Property Posts As IEnumerable(Of PostInfo) = Nothing - Public Property CacheFile As String = "" - Public Property IsCached As Boolean = False - Public Property ImageHandlerUrl As String = "" - Public Property TotalRecords As Integer = -1 - - ' Requested Properties - Public Property TermId As Integer = -1 - Public Property BlogId As Integer = -1 - Public Property RecordsToSend As Integer = 20 - Public Property Search As String = "" - Public Property SearchTitle As Boolean = True - Public Property SearchContents As Boolean = False - Public Property ImageWidth As Integer = 144 - Public Property ImageHeight As Integer = 96 - Public Property IncludeContents As Boolean = False - - ' Feed Properties - Public Property IsSearchFeed As Boolean = False - Public Property Blog As BlogInfo = Nothing - Public Property Term As TermInfo = Nothing - Public Property Title As String = "" - Public Property Description As String = "" - Public Property Link As String = "" - Public Property FeedEmail As String = "" - Public Property Language As String = "" - Public Property Locale As String = Threading.Thread.CurrentThread.CurrentCulture.Name - Public Property Copyright As String = "" - Public Property URL As String = "" -#End Region - -#Region " Constructors " - Public Sub New(moduleId As Integer, reqParams As NameValueCollection) - - ' Initialize Settings - Settings = ModuleSettings.GetModuleSettings(moduleId) - PortalSettings = DotNetNuke.Entities.Portals.PortalSettings.Current - RecordsToSend = settings.RssDefaultNrItems - ImageWidth = settings.RssImageWidth - ImageHeight = settings.RssImageHeight - Dim port As String = String.Empty - If HttpContext.Current.Request.Url.Port <> 80 Then - port = ":" & HttpContext.Current.Request.Url.Port.ToString() - End If - ImageHandlerUrl = String.Format("{0}://{1}{2}{3}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, port, VirtualPathUtility.ToAbsolute(glbImageHandlerPath)) - - ' Read Request Values - reqParams.ReadValue("blog", BlogId) - reqParams.ReadValue("blogid", BlogId) - reqParams.ReadValue("term", TermId) - reqParams.ReadValue("termid", TermId) - If Settings.RssMaxNrItems > 0 Then - reqParams.ReadValue("recs", RecordsToSend) - If RecordsToSend > Settings.RssMaxNrItems Then RecordsToSend = Settings.RssMaxNrItems - End If - If Settings.RssImageSizeAllowOverride Then - reqParams.ReadValue("w", ImageWidth) - reqParams.ReadValue("h", ImageHeight) - End If - If Settings.RssAllowContentInFeed Then - reqParams.ReadValue("body", IncludeContents) - End If - reqParams.ReadValue("search", Search) - reqParams.ReadValue("t", SearchTitle) - reqParams.ReadValue("c", SearchContents) - reqParams.ReadValue("language", Language) - If Language <> "" Then Locale = Language - - ' Start Filling In Feed Properties - If Search <> "" Then IsSearchFeed = True - If BlogId > -1 Then Blog = BlogsController.GetBlog(BlogId, -1, Threading.Thread.CurrentThread.CurrentCulture.Name) - If TermId > -1 Then Term = TermsController.GetTerm(TermId, moduleId, Locale) - If Blog Is Nothing Then - Dim m As ModuleInfo = (New ModuleController).GetModule(moduleId) - If m IsNot Nothing Then - Title = m.ModuleTitle - End If - FeedEmail = Settings.RssEmail - Copyright = Settings.RssDefaultCopyright - Else - Title = Blog.Title - Description = Blog.Description - FeedEmail = Blog.Email - Copyright = Regex.Replace(Blog.Copyright, "(?i)\[year\](?-i)", Now.ToString("yyyy")) - End If - If Term IsNot Nothing Then - Title &= " - " & Term.LocalizedName - End If - If IsSearchFeed Then - Title = "DNN Blog Search " & Title - Description &= String.Format(" - Searching '{0}'", Search) - End If - Link = ApplicationURL() - If Blog IsNot Nothing Then Link &= String.Format("&blog={0}", BlogId) - If Term IsNot Nothing Then Link &= String.Format("&term={0}", TermId) - If RecordsToSend <> Settings.RssDefaultNrItems Then Link &= String.Format("&recs={0}", RecordsToSend) - If ImageWidth <> Settings.RssImageWidth Then Link &= String.Format("&w={0}", ImageWidth) - If ImageHeight <> Settings.RssImageHeight Then Link &= String.Format("&h={0}", ImageHeight) - If IncludeContents Then Link &= "&body=true" - If Language <> "" Then Link &= String.Format("&language={0}", Language) - If Locale <> "" Then Link &= String.Format("&locale={0}", Locale) - If IsSearchFeed Then Link &= String.Format("&search={0}&t={1}&c={2}", HttpUtility.UrlEncode(Search), SearchTitle, SearchContents) - CacheFile = Link.Substring(Link.IndexOf("?"c) + 1).Replace("&", "+").Replace("=", "-") - CacheFile = String.Format("{0}\Blog\RssCache\{1}.resources", PortalSettings.HomeDirectoryMapPath.TrimEnd("\"c), CacheFile) - URL = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority - If DotNetNuke.Entities.Host.Host.UseFriendlyUrls Then - Link = FriendlyUrl(PortalSettings.ActiveTab, Link, GetSafePageName(Title)) - Else - Link = URL + ResolveUrl(Link) - End If - - ' Check Cache - If IO.File.Exists(CacheFile) Then - Dim f As New IO.FileInfo(CacheFile) - If f.LastWriteTime.AddMinutes(Settings.RssTtl) > Now Then IsCached = True - Else - Dim pth As String = IO.Path.GetDirectoryName(CacheFile) - If Not IO.Directory.Exists(pth) Then IO.Directory.CreateDirectory(pth) - End If - - If Not IsCached Then - ' Load Posts - If IsSearchFeed Then - If Term IsNot Nothing Then - Posts = PostsController.SearchPostsByTerm(moduleId, BlogId, Locale, TermId, Search, SearchTitle, SearchContents, 1, Language, Date.Now.ToUniversalTime, -1, 0, RecordsToSend, "PUBLISHEDONDATE DESC", TotalRecords, -1, False).Values - Else - Posts = PostsController.SearchPosts(moduleId, BlogId, Locale, Search, SearchTitle, SearchContents, 1, Language, Date.Now.ToUniversalTime, -1, 0, RecordsToSend, "PUBLISHEDONDATE DESC", TotalRecords, -1, False).Values - End If - Else - If Term IsNot Nothing Then - Posts = PostsController.GetPostsByTerm(moduleId, BlogId, Locale, TermId, 1, Language, Date.Now.ToUniversalTime, -1, 0, RecordsToSend, "PUBLISHEDONDATE DESC", TotalRecords, -1, False).Values - Else - Posts = PostsController.GetPosts(moduleId, BlogId, Locale, 1, Language, Date.Now.ToUniversalTime, -1, False, 0, RecordsToSend, "PUBLISHEDONDATE DESC", TotalRecords, -1, False).Values - End If - End If - WriteRss(CacheFile) - End If - End Sub -#End Region - -#Region " Public Methods " - Public Function WriteRssToString() As String - Dim sb As New StringBuilder - WriteRss(sb) - Return sb.ToString - End Function - - Public Sub WriteRss(ByRef output As IO.Stream) - Using xtw As New XmlTextWriter(output, Encoding.UTF8) - WriteRss(xtw) - xtw.Flush() - End Using - End Sub - - Public Sub WriteRss(fileName As String) - Using fs As New IO.FileStream(fileName, IO.FileMode.Create, IO.FileAccess.Write) - Using xtw As New XmlTextWriter(fs, Encoding.UTF8) - WriteRss(xtw) - xtw.Flush() - End Using - End Using - End Sub - - Public Sub WriteRss(ByRef output As StringBuilder) - Using sw As New StringWriterWithEncoding(output, Encoding.UTF8) - Using xtw As New XmlTextWriter(sw) - WriteRss(xtw) - xtw.Flush() - End Using - sw.Flush() - End Using - End Sub - - Public Sub WriteRss(ByRef output As XmlTextWriter) - - output.Formatting = Formatting.Indented - output.WriteStartDocument() - output.WriteStartElement("rss") - output.WriteAttributeString("version", "2.0") - output.WriteAttributeString("xmlns", nsBlogPre, Nothing, nsBlogFull) - 'output.WriteAttributeString("xmlns", nsSlashPre, Nothing, nsSlashFull) - output.WriteAttributeString("xmlns", nsAtomPre, Nothing, nsAtomFull) - output.WriteAttributeString("xmlns", nsMediaPre, Nothing, nsMediaFull) - If IsSearchFeed Then output.WriteAttributeString("xmlns", nsOpenSearchPre, Nothing, nsOpenSearchFull) - If IncludeContents Then output.WriteAttributeString("xmlns", nsContentPre, Nothing, nsContentFull) - output.WriteStartElement("channel") - - ' Write the channel header block - output.WriteElementString("title", Title) - output.WriteElementString("link", Link) - output.WriteElementString("description", Description) - ' optional elements - If Language <> "" Then output.WriteElementString("language", Language) - If Copyright <> "" Then output.WriteElementString("copyright", Copyright) - If FeedEmail <> "" Then output.WriteElementString("managingEditor", FeedEmail) - output.WriteElementString("pubDate", Now.ToString("r")) - output.WriteElementString("lastBuildDate", Now.ToString("r")) - If Term IsNot Nothing Then - output.WriteElementString("category", Term.LocalizedName) - End If - output.WriteElementString("generator", "DotNetNuke Blog RSS Generator Version " & CType(System.Reflection.Assembly.GetExecutingAssembly.GetName.Version.ToString, String)) - output.WriteElementString("ttl", settings.RssTtl.ToString) - If Blog IsNot Nothing AndAlso (Blog.IncludeImagesInFeed And Blog.Image <> "") Then - output.WriteStartElement("image") - output.WriteElementString("url", ImageHandlerUrl & String.Format("?TabId={0}&ModuleId={1}&Blog={2}&w={4}&h={5}&c=1&key={3}", PortalSettings.ActiveTab.TabID, settings.ModuleId, BlogId, Blog.Image, ImageWidth, ImageHeight)) - output.WriteElementString("title", Title) - output.WriteElementString("link", Link) - output.WriteElementString("width", ImageWidth.ToString) ' default 88 max 144 - output.WriteElementString("height", ImageHeight.ToString) ' default 31 max 400 - output.WriteEndElement() ' image - End If - ' extended elements - output.WriteStartElement(nsAtomPre, "link", nsAtomFull) - output.WriteAttributeString("href", HttpContext.Current.Request.Url.AbsoluteUri) - output.WriteAttributeString("rel", "self") - output.WriteAttributeString("type", "application/rss+xml") - output.WriteEndElement() ' atom:link - If IsSearchFeed Then - output.WriteElementString(nsOpenSearchPre, "totalResults", nsOpenSearchFull, TotalRecords.ToString) - output.WriteElementString(nsOpenSearchPre, "startIndex", nsOpenSearchFull, "0") - output.WriteElementString(nsOpenSearchPre, "itemsPerPage", nsOpenSearchFull, RecordsToSend.ToString) - End If - - For Each e As PostInfo In Posts - WriteItem(output, e) - Next - - output.WriteEndElement() ' channel - output.WriteEndElement() ' rss - output.Flush() - - End Sub -#End Region - -#Region " Private Methods " - Private Sub WriteItem(ByRef writer As XmlTextWriter, item As PostInfo) - - writer.WriteStartElement("item") - - ' core data - writer.WriteElementString("title", item.LocalizedTitle) - - If DotNetNuke.Entities.Host.Host.UseFriendlyUrls Then - writer.WriteElementString("link", item.PermaLink) - Else - writer.WriteElementString("link", URL + item.PermaLink) - End If - - writer.WriteElementString("description", HttpUtility.HtmlDecode(item.LocalizedSummary)) - ' optional elements - If item.Blog.IncludeAuthorInFeed Then - writer.WriteElementString("author", String.Format("{0} ({1})", item.Email, item.DisplayName)) - writer.WriteElementString(nsBlogPre, "author", nsBlogFull, item.DisplayName) - End If - For Each t As TermInfo In TermsController.GetTermsByPost(item.ContentItemId, Settings.ModuleId, Locale) - writer.WriteElementString("category", t.LocalizedName) - Next - - ' guid needs to have the isPermaLink=false attribute for some rss readers - writer.WriteStartElement("guid") - writer.WriteAttributeString("isPermaLink", "true") - - If DotNetNuke.Entities.Host.Host.UseFriendlyUrls Then - writer.WriteRaw(String.Format("{0}", item.PermaLink)) - Else - writer.WriteRaw(String.Format("{0}", URL + HttpUtility.HtmlEncode(item.PermaLink))) - End If - - writer.WriteEndElement() - - writer.WriteElementString("pubDate", item.PublishedOnDate.ToString("r")) - ' extensions - If item.Blog.IncludeImagesInFeed And item.Image <> "" Then - writer.WriteStartElement(nsMediaPre, "thumbnail", nsMediaFull) - writer.WriteAttributeString("width", ImageWidth.ToString) - writer.WriteAttributeString("height", ImageHeight.ToString) - writer.WriteAttributeString("url", ImageHandlerUrl & String.Format("?TabId={0}&ModuleId={1}&Blog={2}&Post={3}&w={5}&h={6}&c=1&key={4}", PortalSettings.ActiveTab.TabID, settings.ModuleId, item.BlogID, item.ContentItemId, item.Image, ImageWidth, ImageHeight)) - writer.WriteEndElement() ' thumbnail - End If - If IncludeContents Then - writer.WriteStartElement(nsContentPre, "encoded", nsContentFull) - writer.WriteCData(HttpUtility.HtmlDecode(item.Content)) - writer.WriteEndElement() ' content:encoded - End If - ' Blog Extensions - writer.WriteElementString(nsBlogPre, "publishedon", nsBlogFull, item.PublishedOnDate.ToString("u")) - - writer.WriteEndElement() ' item - - End Sub -#End Region - - End Class -End Namespace diff --git a/Server/Blog/Components/Rss/StringWriterWithEncoding.vb b/Server/Blog/Components/Rss/StringWriterWithEncoding.vb deleted file mode 100644 index e8b8af5c..00000000 --- a/Server/Blog/Components/Rss/StringWriterWithEncoding.vb +++ /dev/null @@ -1,48 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Namespace Rss - - ''' - ''' Support class to allow encoded writing - ''' - ''' - ''' - ''' [pdonker] 12/14/2009 created - ''' - Public Class StringWriterWithEncoding - Inherits IO.StringWriter - - Private _encoding As System.Text.Encoding - - Public Sub New(builder As StringBuilder, encoding As System.Text.Encoding) - MyBase.New(builder) - _encoding = encoding - End Sub - - Public Overrides ReadOnly Property Encoding() As System.Text.Encoding - Get - Return _encoding - End Get - End Property - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Security/BlogUser.vb b/Server/Blog/Components/Security/BlogUser.vb deleted file mode 100644 index f4baf5bd..00000000 --- a/Server/Blog/Components/Security/BlogUser.vb +++ /dev/null @@ -1,141 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Entities.Users - -Namespace Security - - ''' - ''' This class makes the UserInfo more robust and adds the much missed IsAdministrator to this - ''' object so we don't have to keep on looking this up. - ''' - ''' - - Public Class BlogUser - Inherits UserInfo - -#Region " Private Members " -#End Region - -#Region " Constructors " - Public Sub New() - LoadUser(Nothing) - End Sub - - Public Sub New(ByRef user As UserInfo) - LoadUser(user) - End Sub - - Private Sub LoadUser(user As UserInfo) - If user Is Nothing Then - user = DotNetNuke.Entities.Users.UserController.Instance.GetCurrentUserInfo - End If - - AffiliateID = user.AffiliateID - DisplayName = Common.Globals.GetAString(user.DisplayName) - Email = Common.Globals.GetAString(user.Email) - FirstName = Common.Globals.GetAString(user.FirstName) - IsSuperUser = user.IsSuperUser - LastName = Common.Globals.GetAString(user.LastName) - Membership = user.Membership - PortalID = user.PortalID - Profile = user.Profile - Roles = user.Roles - MyBase.UserID = user.UserID - UserID = user.UserID - Username = Common.Globals.GetAString(user.Username) - - If IsSuperUser Then - IsAdministrator = True - ElseIf UserID > -1 Then - Dim objPortals As New DotNetNuke.Entities.Portals.PortalController - Dim objPortal As DotNetNuke.Entities.Portals.PortalInfo = objPortals.GetPortal(PortalID) - If IsInRole(objPortal.AdministratorRoleName) Then - IsAdministrator = True - End If - End If - - If UserID = -1 Then - Try - PortalID = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings.PortalId - Catch ex As Exception - Exit Sub - End Try - End If - - End Sub -#End Region - -#Region " Public Properties " - Public Property IsAdministrator As Boolean = False -#End Region - -#Region " Public Shared Methods " - Public Shared Function GetCurrentUser() As BlogUser - Dim dnnUser As UserInfo = DotNetNuke.Entities.Users.UserController.Instance.GetCurrentUserInfo - Dim cacheKey As String = String.Format("BlogUser{0}-{1}", dnnUser.PortalID, dnnUser.UserID) - Dim du As BlogUser = Nothing - Try - du = CType(DotNetNuke.Common.Utilities.DataCache.GetCache(cacheKey), BlogUser) - Catch - End Try - If du Is Nothing Then - du = New BlogUser(dnnUser) - DotNetNuke.Common.Utilities.DataCache.SetCache(cacheKey, du) - End If - Return du - End Function - - Public Shared Function GetUser(portalId As Integer, userId As Integer) As BlogUser - Dim cacheKey As String = String.Format("BlogUser{0}-{1}", portalId, userId) - Dim du As BlogUser = Nothing - Try - du = CType(DotNetNuke.Common.Utilities.DataCache.GetCache(cacheKey), BlogUser) - Catch - End Try - If du Is Nothing Then - Dim dnnUser As UserInfo = DotNetNuke.Entities.Users.UserController.GetUserById(portalId, userId) - If dnnUser Is Nothing Then - dnnUser = New UserInfo - dnnUser.PortalID = portalId - End If - du = New BlogUser(dnnUser) - DotNetNuke.Common.Utilities.DataCache.SetCache(cacheKey, du) - End If - Return du - End Function - - Public Shared Function GetUser(user As UserInfo) As BlogUser - Dim cacheKey As String = String.Format("BlogUser{0}-{1}", user.PortalID, user.UserID) - Dim du As BlogUser = Nothing - Try - du = CType(DotNetNuke.Common.Utilities.DataCache.GetCache(cacheKey), BlogUser) - Catch - End Try - If du Is Nothing Then - du = New BlogUser(user) - DotNetNuke.Common.Utilities.DataCache.SetCache(cacheKey, du) - End If - Return du - End Function -#End Region - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Security/ContextSecurity.vb b/Server/Blog/Components/Security/ContextSecurity.vb deleted file mode 100644 index 3a536d27..00000000 --- a/Server/Blog/Components/Security/ContextSecurity.vb +++ /dev/null @@ -1,247 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Security.Permissions -Imports DotNetNuke.Modules.Blog.Entities -Imports DotNetNuke.Entities.Users -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Security.Security -Imports DotNetNuke.Services.Tokens - -Namespace Security - - Public Class ContextSecurity - Implements IPropertyAccess - -#Region " Private Members " - Private _canAdd As Boolean = False - Private _canEdit As Boolean = False - Private _canApprove As Boolean = False - Private _canAddComment As Boolean = False - Private _canApproveComment As Boolean = False - Private _canAutoApproveComment As Boolean = False - Private _canViewComment As Boolean = False - Private _userIsAdmin As Boolean = False - Private _isBlogger As Boolean = False - Private _isEditor As Boolean = False - Private _userId As Integer = -1 -#End Region - -#Region " Constructor " - Public Sub New(moduleId As Integer, tabId As Integer, blog As BlogInfo, user As UserInfo) - _userId = user.UserID - If blog IsNot Nothing Then - IsOwner = CBool(blog.CreatedByUserID = user.UserID) - _canAdd = blog.CanAdd - _canEdit = blog.CanEdit - _canApprove = blog.CanApprove - _canViewComment = blog.Permissions.CurrentUserHasPermission("VIEWCOMMENT") - _canApproveComment = blog.Permissions.CurrentUserHasPermission("APPROVECOMMENT") - _canAutoApproveComment = blog.Permissions.CurrentUserHasPermission("AUTOAPPROVECOMMENT") - _canAddComment = blog.Permissions.CurrentUserHasPermission("ADDCOMMENT") - Else - Using ir As IDataReader = Data.DataProvider.Instance().GetUserPermissionsByModule(moduleId, user.UserID) - Do While ir.Read - Dim permissionId As Integer = CInt(ir.Item("PermissionId")) - Dim hasPermission As Integer = CInt(ir.Item("HasPermission")) - If hasPermission > 0 Then - Select Case permissionId - Case BlogPermissionTypes.ADD - _canAdd = True - Case BlogPermissionTypes.EDIT - _canEdit = True - Case BlogPermissionTypes.APPROVE - _canApprove = True - End Select - End If - Loop - End Using - End If - LoggedIn = CBool(user.UserID > -1) - _userIsAdmin = DotNetNuke.Security.PortalSecurity.IsInRole(DotNetNuke.Entities.Portals.PortalSettings.Current.AdministratorRoleName) - Dim mc As New DotNetNuke.Entities.Modules.ModuleController - Dim objMod As New DotNetNuke.Entities.Modules.ModuleInfo - objMod = mc.GetModule(moduleId, tabId, False) - If objMod IsNot Nothing Then - _isBlogger = ModulePermissionController.HasModulePermission(objMod.ModulePermissions, BloggerPermission) - _isEditor = ModulePermissionController.HasModulePermission(objMod.ModulePermissions, "EDIT") - End If - End Sub -#End Region - -#Region " Public Properties " - Public Property IsOwner As Boolean = False - Public Property LoggedIn As Boolean = False - - Public ReadOnly Property CanEditPost() As Boolean - Get - Return _canEdit Or IsOwner Or UserIsAdmin - End Get - End Property - Public Function CanEditThisPost(post As Posts.PostInfo) As Boolean - If CanEditPost Then Return True - If post Is Nothing Then Return False - If post.Blog.MustApproveGhostPosts AndAlso Not CanApprovePost Then - If post.CreatedByUserID = _userId And Not post.Published Then Return True - Else - If post.CreatedByUserID = _userId Then Return True - End If - Return False - End Function - - Public ReadOnly Property CanAddPost() As Boolean - Get - Return _canAdd Or IsOwner Or UserIsAdmin - End Get - End Property - - Public ReadOnly Property CanAddComment() As Boolean - Get - Return _canAddComment Or IsOwner Or UserIsAdmin - End Get - End Property - - Public ReadOnly Property CanViewComments() As Boolean - Get - Return _canViewComment Or IsOwner Or UserIsAdmin - End Get - End Property - - Public ReadOnly Property CanApprovePost() As Boolean - Get - Return _canApprove Or IsOwner Or UserIsAdmin - End Get - End Property - - Public ReadOnly Property CanApproveComment() As Boolean - Get - Return _canApproveComment Or IsOwner Or UserIsAdmin - End Get - End Property - - Public ReadOnly Property CanAutoApproveComment() As Boolean - Get - Return _canAutoApproveComment Or IsOwner Or UserIsAdmin - End Get - End Property - - Public ReadOnly Property CanDoSomethingWithPosts As Boolean - Get - Return _canEdit Or _canAdd Or _canApprove Or _isBlogger Or UserIsAdmin - End Get - End Property - - Public ReadOnly Property UserIsAdmin As Boolean - Get - Return _userIsAdmin - End Get - End Property - - Public ReadOnly Property IsBlogger As Boolean - Get - Return _isBlogger - End Get - End Property - - Public ReadOnly Property IsEditor As Boolean - Get - Return _isEditor - End Get - End Property -#End Region - -#Region " IPropertyAccess Implementation " - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As System.Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Select Case strPropertyName.ToLower - Case "isowner" - Return IsOwner.ToString - Case "isowneryesno" - Return PropertyAccess.Boolean2LocalizedYesNo(IsOwner, formatProvider) - Case "caneditpost" - Return CanEditPost.ToString - Case "caneditpostyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(CanEditPost, formatProvider) - Case "canaddpost" - Return CanAddPost.ToString - Case "canaddpostyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(CanAddPost, formatProvider) - Case "canaddcomment" - Return CanAddComment.ToString - Case "canaddcommentyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(CanAddComment, formatProvider) - Case "canviewcomments" - Return CanViewComments.ToString - Case "canviewcommentsyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(CanViewComments, formatProvider) - Case "canapprovepost" - Return CanApprovePost.ToString - Case "canapprovepostyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(CanApprovePost, formatProvider) - Case "canapprovecomment" - Return CanApproveComment.ToString - Case "canapprovecommentyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(CanApproveComment, formatProvider) - Case "canautoapprovecomment" - Return CanAutoApproveComment.ToString - Case "canautoapprovecommentyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(CanAutoApproveComment, formatProvider) - Case "candosomethingwithposts" - Return CanDoSomethingWithPosts.ToString - Case "candosomethingwithpostsyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(CanDoSomethingWithPosts, formatProvider) - Case "userisadmin" - Return UserIsAdmin.ToString - Case "userisadminyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(UserIsAdmin, formatProvider) - Case "isblogger" - Return IsBlogger.ToString - Case "isbloggeryesno" - Return PropertyAccess.Boolean2LocalizedYesNo(IsBlogger, formatProvider) - Case "iseditor" - Return IsEditor.ToString - Case "iseditoryesno" - Return PropertyAccess.Boolean2LocalizedYesNo(IsEditor, formatProvider) - Case "loggedin" - Return LoggedIn.ToString - Case "loggedinyesno" - Return PropertyAccess.Boolean2LocalizedYesNo(LoggedIn, formatProvider) - Case Else - PropertyNotFound = True - End Select - Return DotNetNuke.Common.Utilities.Null.NullString - End Function - - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Security/Controls/BlogPermissionsGrid.vb b/Server/Blog/Components/Security/Controls/BlogPermissionsGrid.vb deleted file mode 100644 index a5d5be65..00000000 --- a/Server/Blog/Components/Security/Controls/BlogPermissionsGrid.vb +++ /dev/null @@ -1,599 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Users -Imports DotNetNuke.Modules.Blog.Security.Permissions -Imports DotNetNuke.Modules.Blog.Security.Security - -Namespace Security.Controls - - Public Class BlogPermissionsGrid - Inherits PermissionsGrid - -#Region " Private Members " - - Private _InheritViewPermissionsFromParent As Boolean = False - Private _BlogID As Integer = -1 - Private _TabId As Integer = -1 - Private _BlogPermissions As BlogPermissionCollection - Private _ViewColumnIndex As Integer - Private _BlogType As String - Private _currentUserId As Integer = -1 - Private _userIsAdmin As Boolean = False - -#End Region - -#Region " Public Properties " - Public Property UserIsAdmin() As Boolean - Get - Return _userIsAdmin - End Get - Set(value As Boolean) - _userIsAdmin = value - End Set - End Property - - Public Property CurrentUserId() As Integer - Get - Return _currentUserId - End Get - Set(value As Integer) - _currentUserId = value - End Set - End Property - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and Sets the Id of the Blog - ''' - ''' - ''' [cnurse] 01/09/2006 Documented - ''' - ''' ----------------------------------------------------------------------------- - Public Property BlogID() As Integer - Get - Return _BlogID - End Get - Set(Value As Integer) - _BlogID = Value - If Not Page.IsPostBack Then - GetBlogPermissions() - End If - End Set - End Property - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and Sets the Id of the Tab associated with this Blog - ''' - ''' - ''' [cnurse] 24/11/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Property TabId() As Integer - Get - Return _TabId - End Get - Set(Value As Integer) - _TabId = Value - End Set - End Property - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the BlogPermission Collection - ''' - ''' - ''' [cnurse] 01/09/2006 Documented - ''' - ''' ----------------------------------------------------------------------------- - Public Property Permissions() As BlogPermissionCollection - Get - 'First Update Permissions in case they have been changed - UpdatePermissions() - - 'Return the BlogPermissions - Return _BlogPermissions - - End Get - Set(value As BlogPermissionCollection) - _BlogPermissions = value - End Set - End Property -#End Region - -#Region " Private Methods " - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the BlogPermissions from the Data Store - ''' - ''' - ''' - ''' ----------------------------------------------------------------------------- - Private Sub GetBlogPermissions() - - _BlogPermissions = BlogPermissionsController.GetBlogPermissionsCollection(BlogID) - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Parse the Permission Keys used to persist the Permissions in the ViewState - ''' - ''' A string array of settings - ''' An Arraylist to add the Permission object to - ''' - ''' - ''' ----------------------------------------------------------------------------- - Private Sub ParsePermissionKeys(Settings As String(), arrPermisions As ArrayList) - - Dim objBlogPermission As New BlogPermissionInfo - Dim permission As PermissionInfo = PermissionsController.GetPermission(Convert.ToInt32(Settings(1))) - objBlogPermission.PermissionId = permission.PermissionId - objBlogPermission.PermissionKey = permission.PermissionKey - objBlogPermission.RoleId = Convert.ToInt32(Settings(4)) - - objBlogPermission.RoleName = Settings(3) - objBlogPermission.AllowAccess = CBool(Settings(0)) - objBlogPermission.UserId = Convert.ToInt32(Settings(5)) - objBlogPermission.DisplayName = Settings(6) - - objBlogPermission.BlogId = BlogID - arrPermisions.Add(objBlogPermission) - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Check if the Role has the permission specified - ''' - ''' The Id of the Permission to check - ''' The role id to check - ''' - ''' [cnurse] 01/09/2006 Documented - ''' - ''' ----------------------------------------------------------------------------- - Private Function BlogHasRolePermission(permissionID As Integer, roleid As Integer) As BlogPermissionInfo - Dim i As Integer - For i = 0 To _BlogPermissions.Count - 1 - Dim objBlogPermission As BlogPermissionInfo = _BlogPermissions(i) - If permissionID = objBlogPermission.PermissionId And objBlogPermission.RoleId = roleid Then - Return objBlogPermission - End If - Next - Return Nothing - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Check if the Role has the permission specified - ''' - ''' The Id of the Permission to check - ''' The user id to check - ''' - ''' [cnurse] 01/09/2006 Documented - ''' - ''' ----------------------------------------------------------------------------- - Private Function BlogHasUserPermission(permissionID As Integer, userid As Integer) As BlogPermissionInfo - Dim i As Integer - For i = 0 To _BlogPermissions.Count - 1 - Dim objBlogPermission As BlogPermissionInfo = _BlogPermissions(i) - If permissionID = objBlogPermission.PermissionId And objBlogPermission.UserId = userid Then - Return objBlogPermission - End If - Next - Return Nothing - End Function - -#End Region - -#Region " Protected Methods " - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Enabled status of the permission - ''' - ''' The permission being loaded - ''' The role - ''' The column of the Grid - ''' - ''' [cnurse] 01/13/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Function GetEnabled(objPerm As PermissionInfo, role As DotNetNuke.Security.Roles.RoleInfo, column As Integer) As Boolean - - If role.RoleID = AdministratorRoleId Then - Return False - ElseIf role.RoleID = -1 Then ' all users - If objPerm.PermissionId = BlogPermissionTypes.ADD Or objPerm.PermissionId = BlogPermissionTypes.APPROVE Or objPerm.PermissionId = BlogPermissionTypes.EDIT Then - Return False - Else - Return True - End If - Else - Return True - End If - - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Enabled status of the permission - ''' - ''' The permission being loaded - ''' The user - ''' The column of the Grid - ''' - ''' [cnurse] 01/13/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Function GetEnabled(objPerm As PermissionInfo, user As DotNetNuke.Entities.Users.UserInfo, column As Integer) As Boolean - - Return True - - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Value of the permission - ''' - ''' The permission being loaded - ''' The role - ''' The column of the Grid - ''' A Boolean (True or False) - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Function GetPermission(objPerm As PermissionInfo, role As DotNetNuke.Security.Roles.RoleInfo, column As Integer) As Boolean - - Dim permission As Boolean - - Dim objBlogPermission As BlogPermissionInfo = BlogHasRolePermission(objPerm.PermissionId, role.RoleID) - If Not objBlogPermission Is Nothing Then - permission = objBlogPermission.AllowAccess - Else - permission = False - End If - - Return permission - - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Value of the permission - ''' - ''' The permission being loaded - ''' The role - ''' The column of the Grid - ''' A Boolean (True or False) - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Function GetPermission(objPerm As PermissionInfo, user As DotNetNuke.Entities.Users.UserInfo, column As Integer) As Boolean - - Dim permission As Boolean - - Dim objBlogPermission As BlogPermissionInfo = BlogHasUserPermission(objPerm.PermissionId, user.UserID) - If Not objBlogPermission Is Nothing Then - permission = objBlogPermission.AllowAccess - Else - permission = False - End If - - Return permission - - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Permissions from the Data Store - ''' - ''' - ''' [cnurse] 01/09/2006 Documented - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Function GetPermissions() As PermissionCollection - - _ViewColumnIndex = 0 - Return PermissionsController.GetPermissions - - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the users from the Database - ''' - ''' - ''' [cnurse] 01/12/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Function GetUsers() As ArrayList - - Dim arrUsers As New ArrayList - Dim objBlogPermission As BlogPermissionInfo - Dim objUser As UserInfo - Dim blnExists As Boolean - - For Each objBlogPermission In _BlogPermissions - If Not objBlogPermission.UserId = glbUserNothing Then - blnExists = False - For Each objUser In arrUsers - If objBlogPermission.UserId = objUser.UserID Then - blnExists = True - End If - Next - If Not blnExists Then - objUser = New UserInfo - objUser.UserID = objBlogPermission.UserId - objUser.Username = objBlogPermission.Username - objUser.DisplayName = objBlogPermission.DisplayName - arrUsers.Add(objUser) - End If - End If - Next - Return arrUsers - - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Load the ViewState - ''' - ''' The saved state - ''' - ''' [cnurse] 01/12/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Sub LoadViewState(savedState As Object) - - If Not (savedState Is Nothing) Then - ' Load State from the array of objects that was saved with SaveViewState. - - Dim myState As Object() = CType(savedState, Object()) - - 'Load Base Controls ViewState - If Not (myState(0) Is Nothing) Then - MyBase.LoadViewState(myState(0)) - End If - - 'Load BlogID - If Not (myState(1) Is Nothing) Then - BlogID = CInt(myState(1)) - End If - - If Not (myState(2) Is Nothing) Then - CurrentUserId = CInt(myState(2)) - End If - - 'Load BlogPermissions - If Not (myState(3) Is Nothing) Then - Dim arrPermissions As New ArrayList - Dim state As String = CStr(myState(3)) - If state <> "" Then - 'First Break the String into individual Keys - Dim permissionKeys As String() = Split(state, "##") - For Each key As String In permissionKeys - Dim Settings As String() = Split(key, "|") - ParsePermissionKeys(Settings, arrPermissions) - Next - End If - _BlogPermissions = New BlogPermissionCollection(arrPermissions) - End If - End If - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Saves the ViewState - ''' - ''' - ''' [cnurse] 01/12/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Function SaveViewState() As Object - - UpdatePermissions() - - Dim allStates(3) As Object - - allStates(0) = MyBase.SaveViewState() - allStates(1) = BlogID - allStates(2) = CurrentUserId - - 'Persist the BlogPermissions - Dim sb As New StringBuilder - Dim addDelimiter As Boolean = False - For Each objBlogPermission As BlogPermissionInfo In _BlogPermissions - If addDelimiter Then - sb.Append("##") - Else - addDelimiter = True - End If - sb.Append(BuildKey(objBlogPermission.AllowAccess, objBlogPermission.PermissionId, -1, objBlogPermission.RoleId, objBlogPermission.RoleName, objBlogPermission.UserId, objBlogPermission.DisplayName)) - Next - allStates(3) = sb.ToString() - - Return allStates - - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Updates a Permission - ''' - ''' The permission being updated - ''' The name of the role - ''' The id of the role - ''' The value of the permission - ''' - ''' [cnurse] 01/12/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Sub UpdatePermission(permission As PermissionInfo, roleId As Integer, roleName As String, allowAccess As Boolean) - - Dim isMatch As Boolean = False - Dim objPermission As BlogPermissionInfo - Dim permissionId As Integer = permission.PermissionId - - 'Search BlogPermission Collection for the permission to Update - For Each objPermission In _BlogPermissions - If objPermission.PermissionId = permissionId And objPermission.RoleId = roleId Then - 'BlogPermission is in collection - objPermission.AllowAccess = allowAccess - isMatch = True - Exit For - End If - Next - - 'BlogPermission not found so add new - If Not isMatch And allowAccess Then - objPermission = New BlogPermissionInfo - objPermission.PermissionId = permission.PermissionId - objPermission.PermissionKey = permission.PermissionKey - objPermission.BlogId = BlogID - objPermission.RoleId = roleId - objPermission.RoleName = roleName - objPermission.AllowAccess = allowAccess - objPermission.UserId = glbUserNothing - objPermission.DisplayName = Null.NullString - _BlogPermissions.Add(objPermission) - End If - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Updates a Permission - ''' - ''' The permission being updated - ''' The user's displayname - ''' The user's id - ''' The value of the permission - ''' - ''' [cnurse] 01/12/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Sub UpdatePermission(permission As PermissionInfo, displayName As String, userId As Integer, allowAccess As Boolean) - - Dim isMatch As Boolean = False - Dim objPermission As BlogPermissionInfo - Dim permissionId As Integer = permission.PermissionId - - 'Search BlogPermission Collection for the permission to Update - For Each objPermission In _BlogPermissions - If objPermission.PermissionId = permissionId And objPermission.UserId = userId Then - objPermission.AllowAccess = allowAccess - isMatch = True - Exit For - End If - Next - - 'BlogPermission not found so add new - If Not isMatch And allowAccess Then - objPermission = New BlogPermissionInfo - objPermission.PermissionId = permission.PermissionId - objPermission.PermissionKey = permission.PermissionKey - objPermission.BlogId = BlogID - objPermission.RoleId = glbRoleNothing - objPermission.RoleName = Null.NullString - objPermission.AllowAccess = allowAccess - objPermission.UserId = userId - objPermission.DisplayName = displayName - _BlogPermissions.Add(objPermission) - End If - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Updates a Permission - ''' - ''' The permissions collection - ''' The user to add - ''' - ''' [cnurse] 01/12/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Sub AddPermission(permissions As PermissionCollection, user As UserInfo) - - Dim objBlogPermission As BlogPermissionInfo - - 'Search TabPermission Collection for the user - Dim isMatch As Boolean = False - For Each objBlogPermission In _BlogPermissions - If objBlogPermission.UserId = user.UserID Then - isMatch = True - Exit For - End If - Next - - 'user not found so add new - If Not isMatch Then - Dim objPermission As PermissionInfo - For Each objPermission In permissions.Values - objBlogPermission = New BlogPermissionInfo - objBlogPermission.PermissionId = objPermission.PermissionId - objBlogPermission.PermissionKey = objPermission.PermissionKey - objBlogPermission.BlogId = BlogID - objBlogPermission.RoleId = glbRoleNothing - objBlogPermission.RoleName = Null.NullString - If objPermission.PermissionId = BlogPermissionTypes.ADD Then - objBlogPermission.AllowAccess = True - Else - objBlogPermission.AllowAccess = False - End If - objBlogPermission.UserId = user.UserID - objBlogPermission.DisplayName = user.DisplayName - _BlogPermissions.Add(objBlogPermission) - Next - End If - - End Sub - - Protected Overrides Sub CreateChildControls() - MyBase.CreateChildControls() - End Sub -#End Region - -#Region " Public Methods " - - ''' ----------------------------------------------------------------------------- - ''' - ''' Overrides the Base method to Generate the Data Grid - ''' - ''' - ''' [cnurse] 01/09/2006 Documented - ''' - ''' ----------------------------------------------------------------------------- - Public Overrides Sub GenerateDataGrid() - - End Sub - -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Security/Controls/PermissionsGrid.vb b/Server/Blog/Components/Security/Controls/PermissionsGrid.vb deleted file mode 100644 index cfcf4e3e..00000000 --- a/Server/Blog/Components/Security/Controls/PermissionsGrid.vb +++ /dev/null @@ -1,980 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Linq -Imports DotNetNuke.Security.Roles -Imports DotNetNuke.UI.WebControls -Imports DotNetNuke.Common -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Users -Imports DotNetNuke.Entities.Portals -Imports DotNetNuke.Services.Localization -Imports DotNetNuke.Modules.Blog.Security.Permissions -Imports DotNetNuke.Modules.Blog.Common.Globals - -Namespace Security.Controls - - Public MustInherit Class PermissionsGrid - Inherits Control - Implements INamingContainer - - Private pnlPermissions As Panel - Private lblGroups As Label - Private WithEvents cboRoleGroups As DropDownList - Private dgRolePermissions As DataGrid - Private lblUser As Label - Private txtUser As TextBox - Private WithEvents cmdUser As LinkButton - Private dgUserPermissions As DataGrid - -#Region " Private Members " - - Private _dtRolePermissions As New DataTable - Private _dtUserPermissions As New DataTable - Private _roles As List(Of DotNetNuke.Security.Roles.RoleInfo) - Private _users As ArrayList - Private _permissions As PermissionCollection - Private _resourceFile As String - -#End Region - -#Region " Public Properties " - -#Region " DataGrid Properties " - - Public ReadOnly Property AlternatingItemStyle() As TableItemStyle - Get - Return dgRolePermissions.AlternatingItemStyle - End Get - End Property - - Public Property AutoGenerateColumns() As Boolean - Get - Return dgRolePermissions.AutoGenerateColumns - End Get - Set(Value As Boolean) - dgRolePermissions.AutoGenerateColumns = Value - dgUserPermissions.AutoGenerateColumns = Value - End Set - End Property - - Public Property CellSpacing() As Integer - Get - Return dgRolePermissions.CellSpacing - End Get - Set(Value As Integer) - dgRolePermissions.CellSpacing = Value - dgUserPermissions.CellSpacing = Value - End Set - End Property - - Public ReadOnly Property Columns() As DataGridColumnCollection - Get - Return dgRolePermissions.Columns() - End Get - End Property - - Public ReadOnly Property FooterStyle() As TableItemStyle - Get - Return dgRolePermissions.FooterStyle - End Get - End Property - - Public Property GridLines() As GridLines - Get - Return dgRolePermissions.GridLines - End Get - Set(Value As GridLines) - dgRolePermissions.GridLines = Value - dgUserPermissions.GridLines = Value - End Set - End Property - - Public ReadOnly Property HeaderStyle() As TableItemStyle - Get - Return dgRolePermissions.HeaderStyle - End Get - End Property - - Public ReadOnly Property ItemStyle() As TableItemStyle - Get - Return dgRolePermissions.ItemStyle - End Get - End Property - - Public ReadOnly Property Items() As DataGridItemCollection - Get - Return dgRolePermissions.Items() - End Get - End Property - - Public ReadOnly Property SelectedItemStyle() As TableItemStyle - Get - Return dgRolePermissions.SelectedItemStyle - End Get - End Property - - Public Property IncludeAdministratorRole As Boolean = True -#End Region - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Id of the Administrator Role - ''' - ''' - ''' [cnurse] 01/16/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Public ReadOnly Property AdministratorRoleId() As Integer - Get - Return PortalController.Instance.GetCurrentPortalSettings.AdministratorRoleId - End Get - End Property - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Id of the Registered Users Role - ''' - ''' - ''' [cnurse] 01/16/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Public ReadOnly Property RegisteredUsersRoleId() As Integer - Get - Return PortalController.Instance.GetCurrentPortalSettings.RegisteredRoleId - End Get - End Property - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and Sets whether a Dynamic Column has been added - ''' - ''' - ''' [cnurse] 01/09/2006 Documented - ''' - ''' ----------------------------------------------------------------------------- - Public Property DynamicColumnAdded() As Boolean - Get - If ViewState("ColumnAdded") Is Nothing Then - Return False - Else - Return True - End If - End Get - Set(Value As Boolean) - ViewState("ColumnAdded") = Value - End Set - End Property - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the underlying Permissions Data Table - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Public ReadOnly Property dtRolePermissions() As DataTable - Get - Return _dtRolePermissions - End Get - End Property - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the underlying Permissions Data Table - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Public ReadOnly Property dtUserPermissions() As DataTable - Get - Return _dtUserPermissions - End Get - End Property - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Id of the Portal - ''' - ''' - ''' [cnurse] 01/16/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Public ReadOnly Property PortalId() As Integer - Get - ' Obtain PortalSettings from Current Context - Dim _portalSettings As PortalSettings = PortalController.Instance.GetCurrentPortalSettings - Dim intPortalID As Integer - - If _portalSettings.ActiveTab.ParentId = _portalSettings.SuperTabId Then 'if we are in host filemanager then we need to pass a null portal id - intPortalID = Null.NullInteger - Else - intPortalID = _portalSettings.PortalId - End If - - Return intPortalID - End Get - End Property - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and Sets the collection of Roles to display - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Property Roles() As List(Of DotNetNuke.Security.Roles.RoleInfo) - Get - Return _roles - End Get - Set(Value As list(Of DotNetNuke.Security.Roles.RoleInfo)) - _roles = Value - End Set - End Property - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and Sets the ResourceFile to localize permissions - ''' - ''' - ''' [vmasanas] 02/24/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Property ResourceFile() As String - Get - Return _resourceFile - End Get - Set(Value As String) - _resourceFile = Value - End Set - End Property -#End Region - -#Region " Abstract Methods " - - ''' ----------------------------------------------------------------------------- - ''' - ''' Generate the Data Grid - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Public MustOverride Sub GenerateDataGrid() - -#End Region - -#Region " Private Methods " - - ''' ----------------------------------------------------------------------------- - ''' - ''' Bind the data to the controls - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Private Sub BindData() - - EnsureChildControls() - - BindRolesGrid() - BindUsersGrid() - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Bind the Roles data to the Grid - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Private Sub BindRolesGrid() - - dtRolePermissions.Columns.Clear() - dtRolePermissions.Rows.Clear() - - Dim col As DataColumn - - 'Add Roles Column - col = New DataColumn("RoleId") - dtRolePermissions.Columns.Add(col) - - 'Add Roles Column - col = New DataColumn("RoleName") - dtRolePermissions.Columns.Add(col) - - For Each pi As PermissionInfo In _permissions.Values - 'Add Enabled Column - col = New DataColumn(pi.PermissionKey & "_Enabled") - dtRolePermissions.Columns.Add(col) - 'Add Permission Column - col = New DataColumn(pi.PermissionKey) - dtRolePermissions.Columns.Add(col) - Next - Dim i As Integer - - GetRoles() - - UpdateRolePermissions() - Dim row As DataRow - For i = 0 To Roles.Count - 1 - Dim role As RoleInfo = Roles(i) - row = dtRolePermissions.NewRow - row("RoleId") = role.RoleID - row("RoleName") = Localization.LocalizeRole(role.RoleName) - - Dim j As Integer = 0 - For Each pi As PermissionInfo In _permissions.Values - row(pi.PermissionKey & "_Enabled") = GetEnabled(pi, role, j + 1) - row(pi.PermissionKey) = GetPermission(pi, role, j + 1) - j += 1 - Next - dtRolePermissions.Rows.Add(row) - Next - - dgRolePermissions.DataSource = dtRolePermissions - dgRolePermissions.DataBind() - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Bind the Roles data to the Grid - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Private Sub BindUsersGrid() - - dtUserPermissions.Columns.Clear() - dtUserPermissions.Rows.Clear() - - Dim col As DataColumn - - 'Add Roles Column - col = New DataColumn("UserId") - dtUserPermissions.Columns.Add(col) - - 'Add Roles Column - col = New DataColumn("DisplayName") - dtUserPermissions.Columns.Add(col) - - Dim i As Integer - For Each pi As PermissionInfo In _permissions.Values - 'Add Enabled Column - col = New DataColumn(pi.PermissionKey & "_Enabled") - dtUserPermissions.Columns.Add(col) - 'Add Permission Column - col = New DataColumn(pi.PermissionKey) - dtUserPermissions.Columns.Add(col) - Next - - If Not dgUserPermissions Is Nothing Then - - _users = GetUsers() - - If _users.Count <> 0 Then - dgUserPermissions.Visible = True - - UpdateUserPermissions() - - Dim row As DataRow - For i = 0 To _users.Count - 1 - Dim user As UserInfo = DirectCast(_users(i), UserInfo) - row = dtUserPermissions.NewRow - row("UserId") = user.UserID - row("DisplayName") = user.DisplayName - - Dim j As Integer = 0 - For Each pi As PermissionInfo In _permissions.Values - row(pi.PermissionKey & "_Enabled") = GetEnabled(pi, user, j + 1) - row(pi.PermissionKey) = GetPermission(pi, user, j + 1) - j += 1 - Next - dtUserPermissions.Rows.Add(row) - Next - - dgUserPermissions.DataSource = dtUserPermissions - dgUserPermissions.DataBind() - Else - dgUserPermissions.Visible = False - End If - End If - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the roles from the Database and loads them into the Roles property - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Private Sub GetRoles() - Dim objRoleController As New RoleController - Dim RoleGroupId As Integer = -2 - If (Not cboRoleGroups Is Nothing) AndAlso (Not cboRoleGroups.SelectedValue Is Nothing) Then - RoleGroupId = Integer.Parse(cboRoleGroups.SelectedValue) - End If - - If RoleGroupId > -2 Then - _roles = GetRolesByGroup(PortalController.Instance.GetCurrentPortalSettings.PortalId, RoleGroupId) - Else - _roles = GetRolesByPortal(PortalController.Instance.GetCurrentPortalSettings.PortalId) - End If - If Not IncludeAdministratorRole Then - Dim newList As New List(Of DotNetNuke.Security.Roles.RoleInfo) - For Each r As RoleInfo In _roles - If r.RoleID <> AdministratorRoleId Then - newList.Add(r) - End If - Next - _roles = newList - End If - - If RoleGroupId < 0 Then - Dim r As New RoleInfo - r.RoleID = -1 ' all users - r.RoleName = glbRoleAllUsersName - _roles.Add(r) - End If - _roles.Reverse() - _roles = _roles.OrderBy(Function(r) r.RoleName.ToLower).ToList - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Sets up the columns for the Grid - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Private Sub SetUpRolesGrid() - - dgRolePermissions.Columns.Clear() - - Dim textCol As New BoundColumn - textCol.HeaderText = " " - textCol.DataField = "RoleName" - textCol.ItemStyle.Width = Unit.Parse("100px") - dgRolePermissions.Columns.Add(textCol) - - Dim idCol As New BoundColumn - idCol.HeaderText = "" - idCol.DataField = "roleid" - idCol.Visible = False - dgRolePermissions.Columns.Add(idCol) - - Dim checkCol As TemplateColumn - - 'Dim objPermission As PermissionInfo - For Each objPermission As PermissionInfo In _permissions.Values - checkCol = New TemplateColumn - Dim columnTemplate As New CheckBoxColumnTemplate - columnTemplate.DataField = objPermission.PermissionKey - columnTemplate.EnabledField = objPermission.PermissionKey & "_Enabled" - checkCol.ItemTemplate = columnTemplate - Dim locName As String = "" - locName = Localization.GetString(objPermission.PermissionKey + ".Permission", SharedResourceFileName) - If locName Is Nothing Then - locName = objPermission.PermissionKey - End If - checkCol.HeaderText = IIf(locName <> "", locName, objPermission.PermissionKey).ToString - checkCol.ItemStyle.HorizontalAlign = HorizontalAlign.Center - checkCol.HeaderStyle.Wrap = True - dgRolePermissions.Columns.Add(checkCol) - Next - - End Sub - - Private Sub SetUpUsersGrid() - - If Not dgUserPermissions Is Nothing Then - dgUserPermissions.Columns.Clear() - - Dim textCol As New BoundColumn - textCol.HeaderText = " " - textCol.DataField = "DisplayName" - textCol.ItemStyle.Width = Unit.Parse("100px") - dgUserPermissions.Columns.Add(textCol) - - Dim idCol As New BoundColumn - idCol.HeaderText = "" - idCol.DataField = "userid" - idCol.Visible = False - dgUserPermissions.Columns.Add(idCol) - - Dim checkCol As TemplateColumn - - For Each objPermission As PermissionInfo In _permissions.Values - checkCol = New TemplateColumn - Dim columnTemplate As New CheckBoxColumnTemplate - columnTemplate.DataField = objPermission.PermissionKey - columnTemplate.EnabledField = objPermission.PermissionKey & "_Enabled" - checkCol.ItemTemplate = columnTemplate - Dim locName As String = "" - locName = Localization.GetString(objPermission.PermissionKey + ".Permission", SharedResourceFileName) - If locName Is Nothing Then - locName = objPermission.PermissionKey - End If - checkCol.HeaderText = IIf(locName <> "", locName, objPermission.PermissionKey).ToString - checkCol.ItemStyle.HorizontalAlign = HorizontalAlign.Center - checkCol.HeaderStyle.Wrap = True - dgUserPermissions.Columns.Add(checkCol) - Next - End If - - End Sub - - -#End Region - -#Region " Protected Methods " - - ''' ----------------------------------------------------------------------------- - ''' - ''' Builds the key used to store the "permission" information in the ViewState - ''' - ''' Is the checkbox checked - ''' The Id of the permission - ''' The Id of the object permission - ''' The role id - ''' The role name - ''' - ''' - ''' ----------------------------------------------------------------------------- - Protected Function BuildKey(checked As Boolean, permissionId As Integer, objectPermissionId As Integer, roleId As Integer, roleName As String) As String - Return BuildKey(checked, permissionId, objectPermissionId, roleId, roleName, Null.NullInteger, Null.NullString) - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Builds the key used to store the "permission" information in the ViewState - ''' - ''' Is the checkbox checked - ''' The Id of the permission - ''' The Id of the object permission - ''' The role id - ''' The role name - ''' The user id - ''' The user display name - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Function BuildKey(checked As Boolean, permissionId As Integer, objectPermissionId As Integer, roleId As Integer, roleName As String, userID As Integer, displayName As String) As String - - Dim key As String - - If checked Then - key = "True" - Else - key = "False" - End If - - key += "|" + Convert.ToString(permissionId) - - 'Add objectPermissionId - key += "|" - If objectPermissionId > -1 Then - key += Convert.ToString(objectPermissionId) - End If - - key += "|" + roleName - key += "|" + roleId.ToString - key += "|" + userID.ToString - key += "|" + displayName.ToString - - Return key - - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Creates the Child Controls - ''' - ''' - ''' [cnurse] 02/23/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Sub CreateChildControls() - - ' get data - _permissions = GetPermissions() - - pnlPermissions = New Panel - pnlPermissions.CssClass = "DataGrid_Container" - - 'Optionally Add Role Group Filter - Dim _portalSettings As PortalSettings = PortalController.Instance.GetCurrentPortalSettings - Dim arrGroups As ArrayList = RoleController.GetRoleGroups(_portalSettings.PortalId) - If arrGroups.Count > 0 Then - lblGroups = New Label - lblGroups.Text = Localization.GetString("RoleGroupFilter") - lblGroups.CssClass = "SubHead" - pnlPermissions.Controls.Add(lblGroups) - - pnlPermissions.Controls.Add(New LiteralControl("  ")) - - cboRoleGroups = New DropDownList - cboRoleGroups.AutoPostBack = True - - cboRoleGroups.Items.Add(New ListItem(Localization.GetString("AllRoles"), "-2")) - Dim liItem As ListItem = New ListItem(Localization.GetString("GlobalRoles"), "-1") - liItem.Selected = True - cboRoleGroups.Items.Add(liItem) - For Each roleGroup As RoleGroupInfo In arrGroups - cboRoleGroups.Items.Add(New ListItem(roleGroup.RoleGroupName, roleGroup.RoleGroupID.ToString)) - Next - pnlPermissions.Controls.Add(cboRoleGroups) - - pnlPermissions.Controls.Add(New LiteralControl("

")) - End If - - dgRolePermissions = New DataGrid - dgRolePermissions.AutoGenerateColumns = False - dgRolePermissions.CellSpacing = 0 - dgRolePermissions.GridLines = GridLines.None - dgRolePermissions.CssClass = "PermissionsGrid" - dgRolePermissions.FooterStyle.CssClass = "DataGrid_Footer" - dgRolePermissions.HeaderStyle.CssClass = "DataGrid_Header" - dgRolePermissions.ItemStyle.CssClass = "DataGrid_Item" - dgRolePermissions.AlternatingItemStyle.CssClass = "DataGrid_AlternatingItem" - SetUpRolesGrid() - pnlPermissions.Controls.Add(dgRolePermissions) - - _users = GetUsers() - - If Not _users Is Nothing Then - dgUserPermissions = New DataGrid - dgUserPermissions.AutoGenerateColumns = False - dgUserPermissions.CellSpacing = 0 - dgUserPermissions.GridLines = GridLines.None - dgUserPermissions.FooterStyle.CssClass = "DataGrid_Footer" - dgUserPermissions.HeaderStyle.CssClass = "DataGrid_Header" - dgUserPermissions.ItemStyle.CssClass = "DataGrid_Item" - dgUserPermissions.AlternatingItemStyle.CssClass = "DataGrid_AlternatingItem" - SetUpUsersGrid() - pnlPermissions.Controls.Add(dgUserPermissions) - - pnlPermissions.Controls.Add(New LiteralControl("
")) - - lblUser = New Label - lblUser.Text = Localization.GetString("User") - lblUser.CssClass = "SubHead" - pnlPermissions.Controls.Add(lblUser) - - pnlPermissions.Controls.Add(New LiteralControl("  ")) - - txtUser = New TextBox - txtUser.CssClass = "NormalTextBox" - pnlPermissions.Controls.Add(txtUser) - - pnlPermissions.Controls.Add(New LiteralControl("  ")) - - cmdUser = New LinkButton - cmdUser.Text = Localization.GetString("Add") - cmdUser.CssClass = "dnnSecondaryAction" - pnlPermissions.Controls.Add(cmdUser) - End If - - Controls.Add(pnlPermissions) - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Enabled status of the permission - ''' - ''' The permission being loaded - ''' The role - ''' The column of the Grid - ''' - ''' [cnurse] 01/13/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overridable Function GetEnabled(objPerm As PermissionInfo, role As RoleInfo, column As Integer) As Boolean - Return False - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Enabled status of the permission - ''' - ''' The permission being loaded - ''' The user - ''' The column of the Grid - ''' - ''' [cnurse] 01/13/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overridable Function GetEnabled(objPerm As PermissionInfo, user As UserInfo, column As Integer) As Boolean - Return False - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Value of the permission - ''' - ''' The permission being loaded - ''' The role - ''' The column of the Grid - ''' - ''' [cnurse] 01/13/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overridable Function GetPermission(objPerm As PermissionInfo, role As RoleInfo, column As Integer) As Boolean - Return False - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the Value of the permission - ''' - ''' The permission being loaded - ''' The user - ''' The column of the Grid - ''' - ''' [cnurse] 01/13/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overridable Function GetPermission(objPerm As PermissionInfo, user As UserInfo, column As Integer) As Boolean - Return False - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the permissions from the Database - ''' - ''' - ''' [cnurse] 01/12/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overridable Function GetPermissions() As PermissionCollection - - Return Nothing - - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets the users from the Database - ''' - ''' - ''' [cnurse] 01/12/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overridable Function GetUsers() As ArrayList - - Return Nothing - - End Function - - Protected Overrides Sub OnLoad(e As EventArgs) - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Overrides the base OnPreRender method to Bind the Grid to the Permissions - ''' - ''' - ''' [cnurse] 01/09/2006 Documented - ''' - ''' ----------------------------------------------------------------------------- - Protected Overrides Sub OnPreRender(e As EventArgs) - BindData() - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Updates a Permission - ''' - ''' The permission being updated - ''' The name of the role - ''' The value of the permission - ''' - ''' [cnurse] 01/12/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overridable Sub UpdatePermission(permission As PermissionInfo, roleId As Integer, roleName As String, allowAccess As Boolean) - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Updates a Permission - ''' - ''' The permission being updated - ''' The user's displayname - ''' The user's id - ''' The value of the permission - ''' - ''' [cnurse] 01/12/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overridable Sub UpdatePermission(permission As PermissionInfo, displayName As String, userId As Integer, allowAccess As Boolean) - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Updates a Permission - ''' - ''' The permissions collection - ''' The user to add - ''' - ''' [cnurse] 01/12/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Overridable Sub AddPermission(permissions As PermissionCollection, user As UserInfo) - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Updates the permissions - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Sub UpdatePermissions() - - EnsureChildControls() - - UpdateRolePermissions() - UpdateUserPermissions() - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Updates the permissions - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Sub UpdateRolePermissions() - - If Not dgRolePermissions Is Nothing Then - Dim dgi As DataGridItem - For Each dgi In dgRolePermissions.Items - Dim i As Integer - For i = 2 To dgi.Cells.Count - 1 - 'all except first two cells which is role names and role ids - If dgi.Cells(i).Controls.Count > 0 Then - Dim cb As CheckBox = CType(dgi.Cells(i).Controls(0), CheckBox) - UpdatePermission(CType(_permissions.Item(i - 2), PermissionInfo), Integer.Parse(dgi.Cells(1).Text), dgi.Cells(0).Text, cb.Checked) - End If - Next - Next - End If - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' Updates the permissions - ''' - ''' - ''' [cnurse] 01/09/2006 Created - ''' - ''' ----------------------------------------------------------------------------- - Protected Sub UpdateUserPermissions() - - If Not dgUserPermissions Is Nothing Then - Dim dgi As DataGridItem - For Each dgi In dgUserPermissions.Items - Dim i As Integer - For i = 2 To dgi.Cells.Count - 1 - 'all except first two cells which is displayname and userid - If dgi.Cells(i).Controls.Count > 0 Then - Dim cb As CheckBox = CType(dgi.Cells(i).Controls(0), CheckBox) - UpdatePermission(CType(_permissions(i - 2), PermissionInfo), dgi.Cells(0).Text, Integer.Parse(dgi.Cells(1).Text), cb.Checked) - End If - Next - Next - End If - - End Sub - -#End Region - -#Region " Event Handlers " - - ''' ----------------------------------------------------------------------------- - ''' - ''' RoleGroupsSelectedIndexChanged runs when the Role Group is changed - ''' - ''' - ''' [cnurse] 01/06/2006 Documented - ''' - ''' ----------------------------------------------------------------------------- - Private Sub RoleGroupsSelectedIndexChanged(sender As Object, e As EventArgs) Handles cboRoleGroups.SelectedIndexChanged - - UpdatePermissions() - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' AddUser runs when the Add user linkbutton is clicked - ''' - ''' - ''' - ''' ----------------------------------------------------------------------------- - Private Sub AddUser(sender As Object, e As EventArgs) Handles cmdUser.Click - - UpdatePermissions() - - If txtUser.Text <> "" Then - ' verify username - Dim objUser As UserInfo = UserController.GetUserByName(PortalId, txtUser.Text) - If Not objUser Is Nothing Then - AddPermission(_permissions, objUser) - BindData() - Else - ' user does not exist - lblUser = New Label - lblUser.Text = "
" & Localization.GetString("InvalidUserName") - lblUser.CssClass = "NormalRed" - pnlPermissions.Controls.Add(lblUser) - End If - End If - - End Sub - -#End Region - - End Class - - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Security/Permissions/BlogPermissionCollection.vb b/Server/Blog/Components/Security/Permissions/BlogPermissionCollection.vb deleted file mode 100644 index e995f04b..00000000 --- a/Server/Blog/Components/Security/Permissions/BlogPermissionCollection.vb +++ /dev/null @@ -1,221 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Xml -Imports System.Xml.Schema -Imports System.Xml.Serialization -Imports DotNetNuke.Entities.Users - -Namespace Security.Permissions - _ - Public Class BlogPermissionCollection - Inherits List(Of BlogPermissionInfo) - Implements IXmlSerializable - - Public Sub New(BlogPermissions As ArrayList) - MyBase.New() - Dim i As Integer - For i = 0 To BlogPermissions.Count - 1 - Dim objBlogPermission As BlogPermissionInfo = CType(BlogPermissions(i), BlogPermissionInfo) - Add(objBlogPermission) - Next - End Sub - - Public Sub New() - MyBase.New() - End Sub - - Default Public Overloads Property Item(index As Integer) As BlogPermissionInfo - Get - Return CType(MyBase.Item(index), BlogPermissionInfo) - End Get - Set(Value As BlogPermissionInfo) - MyBase.Item(index) = Value - End Set - End Property - - Public Shadows Function ToString(PermissionKey As String) As String - Dim res As String = "" - For Each epi As BlogPermissionInfo In Me - If epi.PermissionKey = PermissionKey Then - If epi.RoleId = -1 Then - res &= ";" & DotNetNuke.Common.Globals.glbRoleAllUsersName - ElseIf epi.RoleId > -1 Then - res &= ";" & epi.RoleName - ElseIf epi.UserId > -1 Then - res &= ";" & epi.UserId.ToString - End If - End If - Next - Return res & ";" - End Function - - Public Function CurrentUserHasPermission(PermissionKey As String) As Boolean - Dim u As UserInfo = UserController.Instance.GetCurrentUserInfo - If u IsNot Nothing Then - For Each epi As BlogPermissionInfo In Me - If epi.PermissionKey Is Nothing Then - Dim objP As PermissionInfo = PermissionsController.GetPermission(epi.PermissionId) - epi.PermissionKey = objP.PermissionKey - End If - If epi.AllowAccess AndAlso epi.PermissionKey = PermissionKey Then - If epi.RoleId = -1 Then Return True - If epi.UserId = u.UserID Then Return True - For Each role As String In u.Roles - If epi.RoleName = role Then - Return True - Exit For - End If - Next - End If - Next - End If - Return False - End Function - - Public Function ContainsPermissionKey(permissionKey As String) As Boolean - For Each epi As BlogPermissionInfo In Me - If epi.PermissionKey Is Nothing Then - Dim objP As PermissionInfo = PermissionsController.GetPermission(epi.PermissionId) - epi.PermissionKey = objP.PermissionKey - End If - If epi.AllowAccess AndAlso epi.PermissionKey = permissionKey Then - Return True - Exit For - End If - Next - Return False - End Function - - Public Function ContainsPermission(permissionKey As String, RoleId As Integer, UserId As Integer) As Boolean - For Each epi As BlogPermissionInfo In Me - If epi.PermissionKey Is Nothing Then - Dim objP As PermissionInfo = PermissionsController.GetPermission(epi.PermissionId) - epi.PermissionKey = objP.PermissionKey - End If - If epi.PermissionKey = permissionKey And epi.RoleId = RoleId And epi.UserId = UserId Then - Return True - Exit For - End If - Next - Return False - End Function - - Public Sub AddPermission(PortalId As Integer, BlogId As Integer, PermissionKey As String, RoleId As Integer, UserId As Integer) - Dim objP As PermissionInfo = PermissionsController.GetPermissions(PermissionKey) - Dim pi As New BlogPermissionInfo(objP) - With pi - .BlogId = BlogId - .RoleId = RoleId - .UserId = UserId - End With - Add(pi) - End Sub - -#Region " IXmlSerializable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' GetSchema returns the XmlSchema for this class - ''' - ''' GetSchema is implemented as a stub method as it is not required - ''' - ''' [pdonker] 05/21/2008 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Function GetSchema() As XmlSchema Implements IXmlSerializable.GetSchema - Return Nothing - End Function - - Private Function readElement(reader As XmlReader, ElementName As String) As String - If (Not reader.NodeType = XmlNodeType.Element) OrElse reader.Name <> ElementName Then - reader.ReadToFollowing(ElementName) - End If - If reader.NodeType = XmlNodeType.Element Then - Return reader.ReadElementContentAsString - Else - Return "" - End If - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' ReadXml fills the object (de-serializes it) from the XmlReader passed - ''' - ''' - ''' The XmlReader that contains the xml for the object - ''' - ''' [pdonker] 05/21/2008 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub ReadXml(reader As XmlReader) Implements IXmlSerializable.ReadXml - Try - reader.ReadStartElement("Permissions") - Do - reader.ReadStartElement("Permission") - Dim epi As New BlogPermissionInfo - epi.ReadXml(reader) - Add(epi) - Loop While reader.ReadToNextSibling("Permission") - Catch ex As Exception - ' log exception as DNN import routine does not do that - DotNetNuke.Services.Exceptions.LogException(ex) - ' re-raise exception to make sure import routine displays a visible error to the user - Throw New Exception("An error occured during import of an Category", ex) - End Try - - End Sub - - Public Sub ReadXml(xN As XmlNode) - - For Each xPermission As XmlNode In xN.ChildNodes - Dim epi As New BlogPermissionInfo - epi.ReadXml(xPermission) - If epi.RoleName <> "" Then ' we don't import user permissions - Add(epi) - End If - Next - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' WriteXml converts the object to Xml (serializes it) and writes it using the XmlWriter passed - ''' - ''' - ''' The XmlWriter that contains the xml for the object - ''' - ''' [pdonker] 05/21/2008 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub WriteXml(writer As XmlWriter) Implements IXmlSerializable.WriteXml - writer.WriteStartElement("Permissions") - For Each epi As BlogPermissionInfo In Me - If epi.PermissionKey Is Nothing Then - Dim pi As PermissionInfo = PermissionsController.GetPermission(epi.PermissionId) - epi.PermissionKey = pi.PermissionKey - End If - epi.WriteXml(writer) - Next - writer.WriteEndElement() - End Sub -#End Region - - End Class -End Namespace diff --git a/Server/Blog/Components/Security/Permissions/BlogPermissionInfo.vb b/Server/Blog/Components/Security/Permissions/BlogPermissionInfo.vb deleted file mode 100644 index 4defe092..00000000 --- a/Server/Blog/Components/Security/Permissions/BlogPermissionInfo.vb +++ /dev/null @@ -1,122 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Runtime.Serialization -Imports System.Xml - -Imports DotNetNuke.Common.Utilities - -Imports DotNetNuke.Modules.Blog.Security.Security - -Namespace Security.Permissions - Partial Public Class BlogPermissionInfo - -#Region " Constructors " - Public Sub New() - _BlogId = Null.NullInteger - _RoleId = glbRoleNothing - _AllowAccess = False - _RoleName = Null.NullString - _UserId = glbUserNothing - _Username = Null.NullString - _DisplayName = Null.NullString - End Sub 'New - - Public Sub New(pi As PermissionInfo) - _BlogId = Null.NullInteger - _RoleId = glbRoleNothing - _AllowAccess = False - _RoleName = Null.NullString - _UserId = glbUserNothing - _Username = Null.NullString - _DisplayName = Null.NullString - PermissionId = pi.PermissionId - PermissionKey = pi.PermissionKey - End Sub 'New -#End Region - - -#Region " Public Properties " - Private _RoleName As String - - Public Property RoleName() As String - Get - If String.IsNullOrEmpty(_RoleName) Then - If RoleId = -1 Then - _RoleName = DotNetNuke.Common.glbRoleAllUsersName - End If - End If - Return _RoleName - End Get - Set(Value As String) - _RoleName = Value - End Set - End Property - - Public Property PermissionKey As String -#End Region - -#Region " Public Methods " - Public Overloads Overrides Function Equals(obj As Object) As Boolean - If obj Is Nothing Or Not [GetType]() Is obj.GetType() Then - Return False - End If - Dim perm As BlogPermissionInfo = CType(obj, BlogPermissionInfo) - Return (AllowAccess = perm.AllowAccess) And (Expires > Now) And (BlogId = perm.BlogId) And (RoleId = perm.RoleId) And (UserId = perm.UserId) And (PermissionId = perm.PermissionId) - End Function - - Public Function Clone() As BlogPermissionInfo - Dim res As New BlogPermissionInfo - With res - .AllowAccess = AllowAccess - .DisplayName = DisplayName - .BlogId = BlogId - .Expires = Expires - .PermissionId = PermissionId - .PermissionKey = PermissionKey - .RoleId = RoleId - .RoleName = RoleName - .UserId = UserId - .Username = Username - End With - Return res - End Function - - Public Overloads Sub ReadXml(xN As XmlNode) - - Dim ht As New Hashtable - For Each n As XmlNode In xN.ChildNodes - ht.Add(n.Name, n.InnerText) - Next - ht.ReadValue("PermissionId", PermissionId) - ht.ReadValue("AllowAccess", AllowAccess) - ht.ReadValue("PermissionKey", PermissionKey) - ht.ReadValue("RoleID", RoleId) - ht.ReadValue("UserID", UserId) - ht.ReadValue("RoleName", RoleName) - ht.ReadValue("UserName", Username) - - End Sub -#End Region - - End Class -End Namespace - - diff --git a/Server/Blog/Components/Security/Permissions/BlogPermissionInfo_Interfaces.vb b/Server/Blog/Components/Security/Permissions/BlogPermissionInfo_Interfaces.vb deleted file mode 100644 index e0801dd8..00000000 --- a/Server/Blog/Components/Security/Permissions/BlogPermissionInfo_Interfaces.vb +++ /dev/null @@ -1,261 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.IO -Imports System.Runtime.Serialization -Imports System.Runtime.Serialization.Json -Imports System.Xml -Imports System.Xml.Schema -Imports System.Xml.Serialization - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Modules -Imports DotNetNuke.Services.Tokens - -Namespace Security.Permissions - - - Partial Public Class BlogPermissionInfo - Implements IHydratable - Implements IPropertyAccess - Implements IXmlSerializable - -#Region " IHydratable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' Fill hydrates the object from a Datareader - ''' - ''' The Fill method is used by the CBO method to hydrtae the object - ''' rather than using the more expensive Refection methods. - ''' - ''' [pdonker] 02/08/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub Fill(dr As IDataReader) Implements IHydratable.Fill - - AllowAccess = Convert.ToBoolean(Null.SetNull(dr.Item("AllowAccess"), AllowAccess)) - BlogId = Convert.ToInt32(Null.SetNull(dr.Item("BlogId"), BlogId)) - Expires = CDate(Null.SetNull(dr.Item("Expires"), Expires)) - PermissionId = Convert.ToInt32(Null.SetNull(dr.Item("PermissionId"), PermissionId)) - RoleId = Convert.ToInt32(Null.SetNull(dr.Item("RoleId"), RoleId)) - UserId = Convert.ToInt32(Null.SetNull(dr.Item("UserId"), UserId)) - Username = Convert.ToString(Null.SetNull(dr.Item("Username"), Username)) - DisplayName = Convert.ToString(Null.SetNull(dr.Item("DisplayName"), DisplayName)) - RoleName = Convert.ToString(Null.SetNull(dr.Item("RoleName"), RoleName)) - - End Sub - ''' ----------------------------------------------------------------------------- - ''' - ''' Gets and sets the Key ID - ''' - ''' The KeyID property is part of the IHydratble interface. It is used - ''' as the key property when creating a Dictionary - ''' - ''' [pdonker] 02/08/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Property KeyID() As Integer Implements IHydratable.KeyID - Get - Return Nothing - End Get - Set(value As Integer) - End Set - End Property -#End Region - -#Region " IPropertyAccess Implementation " - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As System.Globalization.CultureInfo, AccessingUser As DotNetNuke.Entities.Users.UserInfo, AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Select Case strPropertyName.ToLower - Case "allowaccess" - Return PropertyAccess.Boolean2LocalizedYesNo(AllowAccess, formatProvider) - Case "blogid" - Return (BlogId.ToString(OutputFormat, formatProvider)) - Case "expires" - Return (Expires.ToString(OutputFormat, formatProvider)) - Case "permissionid" - Return (PermissionId.ToString(OutputFormat, formatProvider)) - Case "roleid" - Return (RoleId.ToString(OutputFormat, formatProvider)) - Case "userid" - Return (UserId.ToString(OutputFormat, formatProvider)) - Case "username" - Return PropertyAccess.FormatString(Username, strFormat) - Case "displayname" - Return PropertyAccess.FormatString(DisplayName, strFormat) - Case "rolename" - Return PropertyAccess.FormatString(RoleName, strFormat) - Case Else - PropertyNotFound = True - End Select - - Return Null.NullString - End Function - - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - -#Region " IXmlSerializable Implementation " - ''' ----------------------------------------------------------------------------- - ''' - ''' GetSchema returns the XmlSchema for this class - ''' - ''' GetSchema is implemented as a stub method as it is not required - ''' - ''' [pdonker] 02/08/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Function GetSchema() As XmlSchema Implements IXmlSerializable.GetSchema - Return Nothing - End Function - - Private Function readElement(reader As XmlReader, ElementName As String) As String - If (Not reader.NodeType = XmlNodeType.Element) OrElse reader.Name <> ElementName Then - reader.ReadToFollowing(ElementName) - End If - If reader.NodeType = XmlNodeType.Element Then - Return reader.ReadElementContentAsString - Else - Return "" - End If - End Function - - ''' ----------------------------------------------------------------------------- - ''' - ''' ReadXml fills the object (de-serializes it) from the XmlReader passed - ''' - ''' - ''' The XmlReader that contains the xml for the object - ''' - ''' [pdonker] 02/08/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Overloads Sub ReadXml(reader As XmlReader) Implements IXmlSerializable.ReadXml - Try - - Boolean.TryParse(readElement(reader, "AllowAccess"), AllowAccess) - If Not Int32.TryParse(readElement(reader, "BlogId"), BlogId) Then - BlogId = Null.NullInteger - End If - Date.TryParse(readElement(reader, "Expires"), Expires) - If Not Int32.TryParse(readElement(reader, "PermissionId"), PermissionId) Then - PermissionId = Null.NullInteger - End If - If Not Int32.TryParse(readElement(reader, "RoleId"), RoleId) Then - RoleId = Null.NullInteger - End If - If Not Int32.TryParse(readElement(reader, "UserId"), UserId) Then - UserId = Null.NullInteger - End If - Username = readElement(reader, "Username") - DisplayName = readElement(reader, "DisplayName") - RoleName = readElement(reader, "RoleName") - Catch ex As Exception - ' log exception as DNN import routine does not do that - DotNetNuke.Services.Exceptions.LogException(ex) - ' re-raise exception to make sure import routine displays a visible error to the user - Throw New Exception("An error occured during import of an BlogPermission", ex) - End Try - - End Sub - - ''' ----------------------------------------------------------------------------- - ''' - ''' WriteXml converts the object to Xml (serializes it) and writes it using the XmlWriter passed - ''' - ''' - ''' The XmlWriter that contains the xml for the object - ''' - ''' [pdonker] 02/08/2013 Created - ''' - ''' ----------------------------------------------------------------------------- - Public Sub WriteXml(writer As XmlWriter) Implements IXmlSerializable.WriteXml - writer.WriteStartElement("BlogPermission") - writer.WriteElementString("AllowAccess", AllowAccess.ToString()) - writer.WriteElementString("BlogId", BlogId.ToString()) - writer.WriteElementString("Expires", Expires.ToString()) - writer.WriteElementString("PermissionId", PermissionId.ToString()) - writer.WriteElementString("RoleId", RoleId.ToString()) - writer.WriteElementString("UserId", UserId.ToString()) - writer.WriteElementString("Username", Username) - writer.WriteElementString("DisplayName", DisplayName) - writer.WriteElementString("RoleName", RoleName) - writer.WriteEndElement() - End Sub -#End Region - -#Region " ToXml Methods " - Public Function ToXml() As String - Return ToXml("BlogPermission") - End Function - - Public Function ToXml(elementName As String) As String - Dim xml As New StringBuilder - xml.Append("<") - xml.Append(elementName) - AddAttribute(xml, "AllowAccess", AllowAccess.ToString()) - AddAttribute(xml, "BlogId", BlogId.ToString()) - AddAttribute(xml, "Expires", Expires.ToString()) - AddAttribute(xml, "PermissionId", PermissionId.ToString()) - AddAttribute(xml, "RoleId", RoleId.ToString()) - AddAttribute(xml, "UserId", UserId.ToString()) - AddAttribute(xml, "Username", Username) - AddAttribute(xml, "DisplayName", DisplayName) - AddAttribute(xml, "RoleName", RoleName) - AddAttribute(xml, "AllowAccess", AllowAccess.ToString()) - AddAttribute(xml, "BlogId", BlogId.ToString()) - AddAttribute(xml, "Expires", Expires.ToUniversalTime.ToString("u")) - AddAttribute(xml, "PermissionId", PermissionId.ToString()) - AddAttribute(xml, "RoleId", RoleId.ToString()) - AddAttribute(xml, "UserId", UserId.ToString()) - AddAttribute(xml, "Username", Username) - AddAttribute(xml, "DisplayName", DisplayName) - AddAttribute(xml, "RoleName", RoleName) - xml.Append(" />") - Return xml.ToString - End Function - - Private Sub AddAttribute(ByRef xml As StringBuilder, attributeName As String, attributeValue As String) - xml.Append(" " & attributeName) - xml.Append("=""" & attributeValue & """") - End Sub -#End Region - -#Region " JSON Serialization " - Public Sub WriteJSON(ByRef s As Stream) - Dim ser As New DataContractJsonSerializer(GetType(BlogPermissionInfo)) - ser.WriteObject(s, Me) - End Sub -#End Region - - End Class -End Namespace - - diff --git a/Server/Blog/Components/Security/Permissions/BlogPermissionInfo_Properties.vb b/Server/Blog/Components/Security/Permissions/BlogPermissionInfo_Properties.vb deleted file mode 100644 index 30b61c60..00000000 --- a/Server/Blog/Components/Security/Permissions/BlogPermissionInfo_Properties.vb +++ /dev/null @@ -1,53 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Runtime.Serialization - -Namespace Security.Permissions - Partial Public Class BlogPermissionInfo - -#Region " Private Members " -#End Region - -#Region " Public Properties " - - Public Property AllowAccess() As Boolean - - Public Property BlogId() As Int32 - - Public Property Expires() As Date - - Public Property PermissionId() As Int32 - - Public Property RoleId() As Int32 - - Public Property UserId() As Int32 - - Public Property Username() As String - - Public Property DisplayName() As String - ' - 'Public Property RoleName() As String -#End Region - - End Class -End Namespace - - diff --git a/Server/Blog/Components/Security/Permissions/BlogPermissionsController.vb b/Server/Blog/Components/Security/Permissions/BlogPermissionsController.vb deleted file mode 100644 index d8f2c177..00000000 --- a/Server/Blog/Components/Security/Permissions/BlogPermissionsController.vb +++ /dev/null @@ -1,194 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Users -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Security.Security - -Namespace Security.Permissions - Partial Public Class BlogPermissionsController - -#Region " Public Methods " - Public Shared Function HasBlogPermission(objBlogPermissions As BlogPermissionCollection, PermissionId As Integer) As Boolean - If BlogUser.GetCurrentUser.IsAdministrator Then Return True - Dim m As BlogPermissionCollection = objBlogPermissions - Dim i As Integer - For i = 0 To m.Count - 1 - Dim mp As BlogPermissionInfo - mp = m(i) - If mp.PermissionId = PermissionId AndAlso (DotNetNuke.Security.PortalSecurity.IsInRoles(mp.RoleName) Or (DotNetNuke.Entities.Users.UserController.Instance.GetCurrentUserInfo.Username = mp.Username And mp.UserId <> glbUserNothing)) AndAlso (mp.Expires > Now Or mp.Expires = Date.MinValue) Then - Return True - End If - Next - Return False - End Function - - Public Shared Function HasBlogPermission(objBlogPermissions As BlogPermissionCollection, PermissionKey As String) As Boolean - If BlogUser.GetCurrentUser.IsAdministrator Then Return True - Dim m As BlogPermissionCollection = objBlogPermissions - Dim i As Integer - For i = 0 To m.Count - 1 - Dim mp As BlogPermissionInfo - mp = m(i) - If mp.PermissionKey = PermissionKey AndAlso (DotNetNuke.Security.PortalSecurity.IsInRoles(mp.RoleName) Or (DotNetNuke.Entities.Users.UserController.Instance.GetCurrentUserInfo.Username = mp.Username And mp.UserId <> glbUserNothing)) AndAlso (mp.Expires > Now Or mp.Expires = Date.MinValue) Then - Return True - End If - Next - Return False - End Function - - Public Shared Function HasBlogPermission(objBlogPermissions As BlogPermissionCollection, PermissionKey As String, User As UserInfo) As Boolean - If BlogUser.GetUser(User).IsAdministrator Then Return True - Dim m As BlogPermissionCollection = objBlogPermissions - Dim i As Integer - For i = 0 To m.Count - 1 - Dim mp As BlogPermissionInfo - mp = m(i) - If mp.PermissionKey = PermissionKey AndAlso (User.IsInRole(mp.RoleName) Or (User.Username = mp.Username And mp.UserId <> glbUserNothing)) AndAlso (mp.Expires > Now Or mp.Expires = Date.MinValue) Then - Return True - End If - Next - Return False - End Function - - Public Shared Function GetBlogPermissionsCollection(BlogId As Integer) As BlogPermissionCollection - - Dim epc As New BlogPermissionCollection - If BlogId > 0 Then - Using ir As IDataReader = Data.DataProvider.Instance().GetBlogPermissionsByBlog(BlogId) - Do While ir.Read - epc.Add(FillBlogPermissionInfo(ir, False, False)) - Loop - End Using - End If - Return epc - - End Function - - Public Shared Sub DeleteBlogPermissionsByBlogId(BlogId As Integer) - - Data.DataProvider.Instance().DeleteBlogPermissions(BlogId) - - End Sub - - Public Shared Sub UpdateBlogPermissions(Blog As BlogInfo) - DeleteBlogPermissionsByBlogId(Blog.BlogID) - For Each objBlogPermission As BlogPermissionInfo In Blog.Permissions - objBlogPermission.BlogId = Blog.BlogID - If objBlogPermission.AllowAccess Then - Try - BlogPermissionsController.AddBlogPermission(objBlogPermission) - Catch - End Try - End If - Next - End Sub - - Public Shared Function GetUsersByBlogPermission(portalId As Integer, blogId As Integer, permissionId As Integer) As Dictionary(Of String, UserInfo) - Return DotNetNuke.Common.Utilities.CBO.FillDictionary(Of String, UserInfo)("username", Data.DataProvider.Instance.GetUsersByBlogPermission(portalId, blogId, permissionId)) - End Function - Public Shared Function GetUsersByBlogPermission(portalId As Integer, blogId As Integer, permission As String) As Dictionary(Of String, UserInfo) - Return DotNetNuke.Common.Utilities.CBO.FillDictionary(Of String, UserInfo)("username", Data.DataProvider.Instance.GetUsersByBlogPermission(portalId, blogId, GetPermissionId(permission))) - End Function - - Public Shared Function GetPermissionId(permission As String) As Integer - Select Case permission.ToUpper - Case "ADD" - Return BlogPermissionTypes.ADD - Case "ADDCOMMENT" - Return BlogPermissionTypes.ADDCOMMENT - Case "APPROVE" - Return BlogPermissionTypes.APPROVE - Case "APPROVECOMMENT" - Return BlogPermissionTypes.APPROVECOMMENT - Case "AUTOAPPROVECOMMENT" - Return BlogPermissionTypes.AUTOAPPROVECOMMENT - Case "EDIT" - Return BlogPermissionTypes.EDIT - Case Else - Return -1 - End Select - End Function -#End Region - -#Region " Fill Methods " - Private Shared Function FillBlogPermissionInfo(dr As IDataReader) As BlogPermissionInfo - Return FillBlogPermissionInfo(dr, True, True) - End Function - - Private Shared Function FillBlogPermissionInfo(dr As IDataReader, CheckForOpenDataReader As Boolean, CloseReader As Boolean) As BlogPermissionInfo - - Dim objBlogPermission As New BlogPermissionInfo - Dim canContinue As Boolean = True - If CheckForOpenDataReader Then - canContinue = False - If dr.Read Then - canContinue = True - End If - End If - If canContinue Then - With objBlogPermission - .AllowAccess = Convert.ToBoolean(Null.SetNull(dr("AllowAccess"), objBlogPermission.AllowAccess)) - .DisplayName = Convert.ToString(Null.SetNull(dr("DisplayName"), objBlogPermission.DisplayName)) - .BlogId = Convert.ToInt32(Null.SetNull(dr("BlogId"), objBlogPermission.BlogId)) - .Expires = Convert.ToDateTime(Null.SetNull(dr("Expires"), objBlogPermission.Expires)) - .PermissionId = Convert.ToInt32(Null.SetNull(dr("PermissionId"), objBlogPermission.PermissionId)) - Select Case .PermissionId - Case BlogPermissionTypes.ADD - .PermissionKey = "ADD" - Case BlogPermissionTypes.EDIT - .PermissionKey = "EDIT" - Case BlogPermissionTypes.APPROVE - .PermissionKey = "APPROVE" - Case BlogPermissionTypes.ADDCOMMENT - .PermissionKey = "ADDCOMMENT" - Case BlogPermissionTypes.APPROVECOMMENT - .PermissionKey = "APPROVECOMMENT" - Case BlogPermissionTypes.AUTOAPPROVECOMMENT - .PermissionKey = "AUTOAPPROVECOMMENT" - End Select - .RoleId = Convert.ToInt32(Null.SetNull(dr("RoleID"), objBlogPermission.RoleId)) - If .RoleId > -1 Then - Dim rn As String = Convert.ToString(Null.SetNull(dr("RoleName"), "")) - .RoleName = rn - End If - .UserId = Convert.ToInt32(Null.SetNull(dr("UserID"), objBlogPermission.UserId)) - .Username = Convert.ToString(Null.SetNull(dr("UserName"), objBlogPermission.Username)) - End With - Else - objBlogPermission = Nothing - End If - - If CloseReader Then - dr.Close() - End If - - Return objBlogPermission - - End Function - -#End Region - - End Class - - - -End Namespace diff --git a/Server/Blog/Components/Security/Permissions/BlogPermissionsController_CRUD.vb b/Server/Blog/Components/Security/Permissions/BlogPermissionsController_CRUD.vb deleted file mode 100644 index 6948488f..00000000 --- a/Server/Blog/Components/Security/Permissions/BlogPermissionsController_CRUD.vb +++ /dev/null @@ -1,37 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - - - -Imports DotNetNuke.Modules.Blog.Data - -Namespace Security.Permissions - - Partial Public Class BlogPermissionsController - - Public Shared Sub AddBlogPermission(objBlogPermission As BlogPermissionInfo) - - DataProvider.Instance().AddBlogPermission(objBlogPermission.AllowAccess, objBlogPermission.BlogId, objBlogPermission.Expires, objBlogPermission.PermissionId, objBlogPermission.RoleId, objBlogPermission.UserId) - - End Sub - - End Class -End Namespace - diff --git a/Server/Blog/Components/Security/Permissions/PermissionCollection.vb b/Server/Blog/Components/Security/Permissions/PermissionCollection.vb deleted file mode 100644 index 8cf326ad..00000000 --- a/Server/Blog/Components/Security/Permissions/PermissionCollection.vb +++ /dev/null @@ -1,164 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Modules.Blog.Security.Security - -Namespace Security.Permissions - - - Public Class PermissionCollection - Implements IDictionary(Of String, PermissionInfo) - - Private _permissions As New Dictionary(Of String, PermissionInfo) - Private _keys As New SortedDictionary(Of Integer, String) - - Public Sub New() - Add("ADD", New PermissionInfo With {.PermissionId = BlogPermissionTypes.ADD, .PermissionKey = "ADD"}) - Add("EDIT", New PermissionInfo With {.PermissionId = BlogPermissionTypes.EDIT, .PermissionKey = "EDIT"}) - Add("APPROVE", New PermissionInfo With {.PermissionId = BlogPermissionTypes.APPROVE, .PermissionKey = "APPROVE"}) - Add("VIEWCOMMENT", New PermissionInfo With {.PermissionId = BlogPermissionTypes.VIEWCOMMENT, .PermissionKey = "VIEWCOMMENT"}) - Add("ADDCOMMENT", New PermissionInfo With {.PermissionId = BlogPermissionTypes.ADDCOMMENT, .PermissionKey = "ADDCOMMENT"}) - Add("APPROVECOMMENT", New PermissionInfo With {.PermissionId = BlogPermissionTypes.APPROVECOMMENT, .PermissionKey = "APPROVECOMMENT"}) - Add("AUTOAPPROVECOMMENT", New PermissionInfo With {.PermissionId = BlogPermissionTypes.AUTOAPPROVECOMMENT, .PermissionKey = "AUTOAPPROVECOMMENT"}) - End Sub - - Public Function GetById(id As Integer) As PermissionInfo - Select Case id - Case BlogPermissionTypes.ADD - Return Me("ADD") - Case BlogPermissionTypes.EDIT - Return Me("EDIT") - Case BlogPermissionTypes.APPROVE - Return Me("APPROVE") - Case BlogPermissionTypes.ADDCOMMENT - Return Me("ADDCOMMENT") - Case BlogPermissionTypes.APPROVECOMMENT - Return Me("APPROVECOMMENT") - Case BlogPermissionTypes.AUTOAPPROVECOMMENT - Return Me("AUTOAPPROVECOMMENT") - Case BlogPermissionTypes.VIEWCOMMENT - Return Me("VIEWCOMMENT") - End Select - Return Nothing - End Function - - Public Sub Add(item As System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)) Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)).Add - If Not ContainsKey(item.Key) Then - _permissions.Add(item.Key, item.Value) - _keys.Add(_permissions.Count - 1, item.Key) - End If - End Sub - - Public Sub Clear() Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)).Clear - _permissions.Clear() - _keys.Clear() - End Sub - - Public Function Contains(item As System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)) As Boolean Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)).Contains - Return _permissions.ContainsValue(item.Value) - End Function - - Public Sub CopyTo(array() As System.Collections.Generic.KeyValuePair(Of String, PermissionInfo), arrayIndex As Integer) Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)).CopyTo - 'todo - End Sub - - Public ReadOnly Property Count() As Integer Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)).Count - Get - Return _permissions.Count - End Get - End Property - - Public ReadOnly Property IsReadOnly() As Boolean Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)).IsReadOnly - Get - Return False - End Get - End Property - - Public Function Remove(item As System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)) As Boolean Implements System.Collections.Generic.ICollection(Of System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)).Remove - If _permissions.ContainsKey(item.Key) Then - _permissions.Remove(item.Key) - Return True - End If - Return False - End Function - - Public Sub Add(key As String, value As PermissionInfo) Implements System.Collections.Generic.IDictionary(Of String, PermissionInfo).Add - If Not _permissions.ContainsKey(key) Then - _permissions.Add(key, value) - _keys.Add(_permissions.Count - 1, key) - End If - End Sub - - Public Function ContainsKey(key As String) As Boolean Implements System.Collections.Generic.IDictionary(Of String, PermissionInfo).ContainsKey - Return _permissions.ContainsKey(key) - End Function - - Default Public Property Item(key As String) As PermissionInfo Implements System.Collections.Generic.IDictionary(Of String, PermissionInfo).Item - Get - Return _permissions(key) - End Get - Set(value As PermissionInfo) - _permissions(key) = value - End Set - End Property - - Default Public Property Item(index As Integer) As PermissionInfo - Get - Return Item(_keys(index)) - End Get - Set(value As PermissionInfo) - Item(_keys(index)) = value - End Set - End Property - - Public ReadOnly Property Keys() As System.Collections.Generic.ICollection(Of String) Implements System.Collections.Generic.IDictionary(Of String, PermissionInfo).Keys - Get - Return _keys.Values - End Get - End Property - - Public Function Remove(key As String) As Boolean Implements System.Collections.Generic.IDictionary(Of String, PermissionInfo).Remove - If _permissions.ContainsKey(key) Then - _permissions.Remove(key) - Return True - End If - Return False - End Function - - Public Function TryGetValue(key As String, ByRef value As PermissionInfo) As Boolean Implements System.Collections.Generic.IDictionary(Of String, PermissionInfo).TryGetValue - Return _permissions.TryGetValue(key, value) - End Function - - Public ReadOnly Property Values() As System.Collections.Generic.ICollection(Of PermissionInfo) Implements System.Collections.Generic.IDictionary(Of String, PermissionInfo).Values - Get - Return _permissions.Values - End Get - End Property - - Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)) Implements System.Collections.Generic.IEnumerable(Of System.Collections.Generic.KeyValuePair(Of String, PermissionInfo)).GetEnumerator - Return Nothing - End Function - - Public Function GetEnumerator1() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator - Return Nothing - End Function - - End Class -End Namespace diff --git a/Server/Blog/Components/Security/Permissions/PermissionInfo_Properties.vb b/Server/Blog/Components/Security/Permissions/PermissionInfo_Properties.vb deleted file mode 100644 index 7239ce0d..00000000 --- a/Server/Blog/Components/Security/Permissions/PermissionInfo_Properties.vb +++ /dev/null @@ -1,50 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Runtime.Serialization - -Namespace Security.Permissions - - Partial Public Class PermissionInfo - -#Region " Private Members " -#End Region - -#Region " Constructors " - Public Sub New() - End Sub - - Public Sub New(PermissionId As Int32, PermissionKey As String) - Me.PermissionId = PermissionId - Me.PermissionKey = PermissionKey - End Sub -#End Region - -#Region " Public Properties " - - Public Property PermissionId() As Int32 - - Public Property PermissionKey() As String -#End Region - - End Class -End Namespace - - diff --git a/Server/Blog/Components/Security/Permissions/PermissionsController.vb b/Server/Blog/Components/Security/Permissions/PermissionsController.vb deleted file mode 100644 index cb252d94..00000000 --- a/Server/Blog/Components/Security/Permissions/PermissionsController.vb +++ /dev/null @@ -1,41 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Namespace Security.Permissions - Public Class PermissionsController - - Public Shared Function GetPermissions() As PermissionCollection - - Dim CacheKey As String = "BlogPermissions" - Dim bp As PermissionCollection = CType(DotNetNuke.Common.Utilities.DataCache.GetCache(CacheKey), PermissionCollection) - If bp Is Nothing Then - bp = New PermissionCollection - DotNetNuke.Common.Utilities.DataCache.SetCache(CacheKey, bp) - End If - Return bp - - End Function - - Public Shared Function GetPermission(permissionId As Integer) As PermissionInfo - Return GetPermissions.GetById(permissionId) - End Function - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Security/Security.vb b/Server/Blog/Components/Security/Security.vb deleted file mode 100644 index 98ee6e73..00000000 --- a/Server/Blog/Components/Security/Security.vb +++ /dev/null @@ -1,38 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Namespace Security - Public Class Security - - Public Enum BlogPermissionTypes - EDIT = 0 - ADD = 1 - APPROVE = 2 - ADDCOMMENT = 3 - APPROVECOMMENT = 4 - VIEWCOMMENT = 5 - AUTOAPPROVECOMMENT = 6 - End Enum - - Public Const glbRoleNothing As Integer = -4 - Public Const glbUserNothing As Integer = -10 - - End Class -End Namespace diff --git a/Server/Blog/Components/Services/BlogAuthorizeAttribute.vb b/Server/Blog/Components/Services/BlogAuthorizeAttribute.vb deleted file mode 100644 index 5d600a4f..00000000 --- a/Server/Blog/Components/Services/BlogAuthorizeAttribute.vb +++ /dev/null @@ -1,128 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Threading - -Imports DotNetNuke.Web.Api -Imports DotNetNuke.Common -Imports DotNetNuke.Entities.Users - -Imports DotNetNuke.Modules.Blog.Security -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Services.Social.Notifications - -Namespace Services - -#Region " Security Access Levels " - Public Enum SecurityAccessLevel As Integer - Anonymous = 0 - Admin = 1 - ViewModule = 2 - EditModule = 4 - AddPost = 8 - EditPost = 16 - ApprovePost = 32 - AddComment = 64 - ApproveComment = 128 - Blogger = 256 - Owner = 512 - End Enum -#End Region - - Public Class BlogAuthorizeAttribute - Inherits AuthorizeAttributeBase - Implements IOverrideDefaultAuthLevel - -#Region " Properties " - Public Property BlogId As Integer = -1 - Public Property NotificationId As Integer = -1 - Public Property AccessLevel As SecurityAccessLevel - Public Property UserInfo As UserInfo - Public Property Security As ContextSecurity -#End Region - -#Region " Constructors " - Public Sub New() - AccessLevel = SecurityAccessLevel.Admin - End Sub - - Public Sub New(accessLevel As SecurityAccessLevel) - Me.AccessLevel = accessLevel - End Sub -#End Region - -#Region " Public Methods " - Public Overrides Function IsAuthorized(context As Web.Api.AuthFilterContext) As Boolean - - If AccessLevel = SecurityAccessLevel.Anonymous Then Return True ' save time by not going through the code below - - HttpContext.Current.Request.Params.ReadValue("blogId", BlogId) - HttpContext.Current.Request.Params.ReadValue("NotificationId", NotificationId) - Dim moduleId As Integer = context.ActionContext.Request.FindModuleId - Dim tabId As Integer = context.ActionContext.Request.FindTabId - If Not HttpContextSource.Current.Request.IsAuthenticated Then - UserInfo = New UserInfo - Else - Dim portalSettings As DotNetNuke.Entities.Portals.PortalSettings = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings() - UserInfo = UserController.GetCachedUser(portalSettings.PortalId, HttpContextSource.Current.User.Identity.Name) - If UserInfo Is Nothing Then UserInfo = New UserInfo - End If - If NotificationId > -1 Then - Dim notify As Notification = NotificationsController.Instance.GetNotification(NotificationId) - Dim nKey As New Integration.NotificationKey(notify.Context) - BlogId = nKey.BlogId - moduleId = nKey.ModuleId - End If - Dim blog As BlogInfo = BlogsController.GetBlog(BlogId, UserInfo.UserID, Thread.CurrentThread.CurrentCulture.Name) - If blog Is Nothing Then Return False - Security = New ContextSecurity(moduleId, tabId, blog, UserInfo) - - If (AccessLevel And SecurityAccessLevel.Admin) = SecurityAccessLevel.Admin AndAlso Security.UserIsAdmin Then - Return True - ElseIf (AccessLevel And SecurityAccessLevel.ViewModule) = SecurityAccessLevel.ViewModule AndAlso DotNetNuke.Security.Permissions.ModulePermissionController.CanViewModule(context.ActionContext.Request.FindModuleInfo()) Then - Return True - ElseIf (AccessLevel And SecurityAccessLevel.EditModule) = SecurityAccessLevel.EditModule AndAlso DotNetNuke.Security.Permissions.ModulePermissionController.HasModulePermission(context.ActionContext.Request.FindModuleInfo().ModulePermissions, "EDIT") Then - Return True - ElseIf (AccessLevel And SecurityAccessLevel.AddPost) = SecurityAccessLevel.AddPost AndAlso Security.CanAddPost Then - Return True - ElseIf (AccessLevel And SecurityAccessLevel.EditPost) = SecurityAccessLevel.EditPost AndAlso Security.CanEditPost Then - Return True - ElseIf (AccessLevel And SecurityAccessLevel.ApprovePost) = SecurityAccessLevel.ApprovePost AndAlso Security.CanApprovePost Then - Return True - ElseIf (AccessLevel And SecurityAccessLevel.AddComment) = SecurityAccessLevel.AddComment AndAlso Security.CanAddComment Then - Return True - ElseIf (AccessLevel And SecurityAccessLevel.ApproveComment) = SecurityAccessLevel.ApproveComment AndAlso Security.CanApproveComment Then - Return True - ElseIf (AccessLevel And SecurityAccessLevel.Blogger) = SecurityAccessLevel.Blogger AndAlso Security.IsBlogger Then - Return True - ElseIf (AccessLevel And SecurityAccessLevel.Owner) = SecurityAccessLevel.Owner AndAlso Security.IsOwner Then - Return True - End If - - Return False - - End Function -#End Region - -#Region " Private Methods " -#End Region - - End Class -End Namespace diff --git a/Server/Blog/Components/Services/BlogRouteMapper.vb b/Server/Blog/Components/Services/BlogRouteMapper.vb deleted file mode 100644 index 8fe365a8..00000000 --- a/Server/Blog/Components/Services/BlogRouteMapper.vb +++ /dev/null @@ -1,67 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Option Strict On -Option Explicit On - -Imports DotNetNuke.Web.Api - -Namespace Services - - Public Class BlogRouteMapper - Implements IServiceRouteMapper - - Public Enum ServiceControllers - Blogs - Comments - Posts - Terms - End Enum - - Public Const ServicePath As String = "~/DesktopModules/Blog/API/" - - Public Sub RegisterRoutes(mapRouteManager As IMapRoute) Implements IServiceRouteMapper.RegisterRoutes - mapRouteManager.MapHttpRoute("Blog", "Blogs", "Blogs/{action}", New With {.Controller = "Blogs"}, New String() {"DotNetNuke.Modules.Blog.Entities.Blogs"}) - mapRouteManager.MapHttpRoute("Blog", "Comments", "Comments/{action}", New With {.Controller = "Comments"}, New String() {"DotNetNuke.Modules.Blog.Entities.Comments"}) - mapRouteManager.MapHttpRoute("Blog", "Posts", "Posts/{action}", New With {.Controller = "Posts"}, New String() {"DotNetNuke.Modules.Blog.Entities.Posts"}) - mapRouteManager.MapHttpRoute("Blog", "Terms", "Terms/{action}", New With {.Controller = "Terms"}, New String() {"DotNetNuke.Modules.Blog.Entities.Terms"}) - mapRouteManager.MapHttpRoute("Blog", "Other", "{controller}/{action}", New String() {"DotNetNuke.Modules.Blog.Services", "DotNetNuke.Modules.Blog.Integration.Services"}) - End Sub - - Public Shared Function GetRoute(controller As ServiceControllers, method As String) As String - Select Case controller - Case ServiceControllers.Blogs - Return GetRoute("Blogs", method) - Case ServiceControllers.Comments - Return GetRoute("Comments", method) - Case ServiceControllers.Posts - Return GetRoute("Posts", method) - Case Else - Return GetRoute("Terms", method) - End Select - End Function - - Public Shared Function GetRoute(controller As String, method As String) As String - Return HttpContext.Current.Request.Url.Scheme & "://" & HttpContext.Current.Request.Url.Host & DotNetNuke.Common.ResolveUrl(ServicePath & controller & "/" & method) - End Function - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Services/ModulesController.vb b/Server/Blog/Components/Services/ModulesController.vb deleted file mode 100644 index 66ad2ea6..00000000 --- a/Server/Blog/Components/Services/ModulesController.vb +++ /dev/null @@ -1,163 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Option Strict On -Option Explicit On -Imports System.Net -Imports System.Net.Http -Imports System.Web.Http -Imports DotNetNuke.Web.Api -Imports DotNetNuke.Entities.Modules -Imports System.Xml - -Namespace Services - - Public Class ModulesController - Inherits DnnApiController - - Public Class AddModuleDTO - Public Property paneName As String - Public Property position As Integer - Public Property title As String - Public Property template As String - End Class - -#Region " Private Members " -#End Region - -#Region " Service Methods " - - - - - Public Function AddModule(postData As AddModuleDTO) As HttpResponseMessage - - Dim newSettings As New Common.ViewSettings(ActiveModule.TabModuleID) - newSettings.BlogModuleId = ActiveModule.ModuleID - newSettings.Template = postData.template - - Dim objModule As New ModuleInfo - objModule.Initialize(PortalSettings.PortalId) - objModule.PortalID = PortalSettings.PortalId - objModule.TabID = PortalSettings.ActiveTab.TabID - objModule.ModuleOrder = postData.position - If postData.title = "" Then - objModule.ModuleTitle = "Blog" - Else - objModule.ModuleTitle = postData.title - End If - objModule.PaneName = postData.paneName - objModule.ModuleDefID = ActiveModule.ModuleDefID - objModule.InheritViewPermissions = True - objModule.AllTabs = False - objModule.Alignment = "" - - Dim objModules As New ModuleController - objModule.ModuleID = objModules.AddModule(objModule) - newSettings.UpdateSettings(objModule.TabModuleID) - - Return Request.CreateResponse(HttpStatusCode.OK, New With {.Result = "success"}) - - End Function - - - - - Public Function GetManifest() As HttpResponseMessage - - Dim res As New HttpResponseMessage(HttpStatusCode.OK) - - Using out As New StringWriterWithEncoding(Encoding.UTF8) - Using output As New XmlTextWriter(out) - Dim bs As ModuleSettings = ModuleSettings.GetModuleSettings(ActiveModule.ModuleID) - - output.Formatting = Formatting.Indented - output.WriteStartDocument() - output.WriteStartElement("manifest") - output.WriteAttributeString("xmlns", "http://schemas.microsoft.com/wlw/manifest/weblog") - output.WriteStartElement("options") - - output.WriteElementString("clientType", "Metaweblog") - output.WriteElementString("supportsMultipleCategories", bs.AllowMultipleCategories.ToYesNo) - output.WriteElementString("supportsCategories", CBool(bs.VocabularyId <> -1).ToYesNo) - output.WriteElementString("supportsCustomDate", "Yes") - output.WriteElementString("supportsKeywords", "Yes") - output.WriteElementString("supportsTrackbacks", "Yes") - output.WriteElementString("supportsEmbeds", "No") - output.WriteElementString("supportsAuthor", "No") - output.WriteElementString("supportsExcerpt", (CBool(bs.SummaryModel = Common.Globals.SummaryType.PlainTextIndependent)).ToYesNo) - output.WriteElementString("supportsPassword", "No") - output.WriteElementString("supportsPages", "No") - output.WriteElementString("supportsPageParent", "No") - output.WriteElementString("supportsPageOrder", "No") - output.WriteElementString("supportsEmptyTitles", "No") - output.WriteElementString("supportsExtendedEntries", (CBool(bs.SummaryModel = Common.Globals.SummaryType.HtmlPrecedesPost)).ToYesNo) - output.WriteElementString("supportsCommentPolicy", "No") - output.WriteElementString("supportsPingPolicy", "No") - output.WriteElementString("supportsPostAsDraft", "Yes") - output.WriteElementString("supportsFileUpload", "Yes") - output.WriteElementString("supportsSlug", "No") - output.WriteElementString("supportsHierarchicalCategories", "Yes") - output.WriteElementString("supportsCategoriesInline", "Yes") - output.WriteElementString("supportsNewCategories", "No") - output.WriteElementString("supportsNewCategoriesInline", "No") - output.WriteElementString("requiresXHTML", "Yes") - - output.WriteEndElement() ' options - output.WriteEndElement() ' manifest - output.Flush() - - End Using - - res.Content = New StringContent(out.ToString, System.Text.Encoding.UTF8, "application/xml") - - End Using - - Return res - - End Function -#End Region - -#Region " Private Methods " -#End Region - - End Class - -#Region " Helper Class for Manifest Writing " - Public Class StringWriterWithEncoding - Inherits IO.StringWriter - - Private Property _Encoding As Encoding - - Public Sub New(enc As Encoding) - MyBase.New() - _Encoding = enc - End Sub - - Public Overrides ReadOnly Property Encoding As System.Text.Encoding - Get - Return _Encoding - End Get - End Property - - End Class -#End Region - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Services/RSSController.vb b/Server/Blog/Components/Services/RSSController.vb deleted file mode 100644 index 904dd68d..00000000 --- a/Server/Blog/Components/Services/RSSController.vb +++ /dev/null @@ -1,56 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Option Strict On -Option Explicit On -Imports System.Net -Imports System.Net.Http -Imports System.Web.Http -Imports DotNetNuke.Web.Api -Imports DotNetNuke.Modules.Blog.Common.Globals -Imports DotNetNuke.Modules.Blog.Rss - -Namespace Services - - Public Class RSSController - Inherits DnnApiController - -#Region " Private Members " -#End Region - -#Region " Service Methods " - - - - Public Function GetRss() As HttpResponseMessage - Dim res As New HttpResponseMessage(HttpStatusCode.OK) - Dim queryString As NameValueCollection = HttpUtility.ParseQueryString(Request.RequestUri.Query) - Dim feed As New BlogRssFeed(ActiveModule.ModuleID, queryString) - res.Content = New StringContent(ReadFile(feed.CacheFile), System.Text.Encoding.UTF8, "application/xml") - Return res - End Function -#End Region - -#Region " Private Methods " -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Services/TrackAndPingBackController.vb b/Server/Blog/Components/Services/TrackAndPingBackController.vb deleted file mode 100644 index ff3f7c1b..00000000 --- a/Server/Blog/Components/Services/TrackAndPingBackController.vb +++ /dev/null @@ -1,226 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports System.Net - -Namespace Services - Public Class TrackAndPingBackController - -#Region " Private Members " - Private Shared ReadOnly TrackbackLinkRegex As New Regex("trackback:ping=""([^""]+)""", RegexOptions.IgnoreCase Or RegexOptions.Compiled) - Private Shared ReadOnly UrlsRegex As New Regex(".*?)[""'].*?>(?.*?)", RegexOptions.IgnoreCase Or RegexOptions.Compiled) - Private Property Post As PostInfo = Nothing - Private Property PortalSettings As DotNetNuke.Entities.Portals.PortalSettings = Nothing -#End Region - -#Region " TrackbackMessage " - Public Structure TrackbackMessage - -#Region " Properties " - Public Property BlogName As String - Public Property Excerpt As String - Public Property PostUrl As Uri - Public Property Title As String - Public Property UrlToNotifyTrackback As Uri -#End Region - -#Region " Constructors " - Public Sub New(post As PostInfo, urlToNotifyTrackback As Uri, portalSettings As DotNetNuke.Entities.Portals.PortalSettings) - Title = post.Title - PostUrl = New Uri(post.PermaLink(portalSettings)) - Excerpt = post.Summary - BlogName = post.Blog.Title - Me.UrlToNotifyTrackback = urlToNotifyTrackback - End Sub -#End Region - -#Region " Public Methods " - Public Overrides Function ToString() As String - Return String.Format(Globalization.CultureInfo.InvariantCulture, "title={0}&url={1}&excerpt={2}&blog_name={3}", Title, PostUrl, Excerpt, BlogName) - End Function -#End Region - - End Structure -#End Region - -#Region " Constructors " - Public Sub New(post As PostInfo) - Me.Post = post - PortalSettings = DotNetNuke.Entities.Portals.PortalSettings.Current - End Sub -#End Region - -#Region " Public Methods " - Public Sub SendTrackAndPingBacks() - - If Not Post.Blog.EnableTrackBackSend And Not Post.Blog.EnablePingBackSend Then Exit Sub - - For Each url As Uri In GetUrlsFromContent(HttpUtility.HtmlDecode(Post.Content)) - - Dim trackbackSent As Boolean = False - If Post.Blog.EnableTrackBackSend Then - Dim remoteFile As New WebPage(url) - Dim pageContent As String = remoteFile.GetFileAsString - Dim trackbackUrl As Uri = GetTrackBackUrlFromPage(pageContent) - If trackbackUrl IsNot Nothing Then - Dim message As New TrackbackMessage(Post, trackbackUrl, PortalSettings) - trackbackSent = SendTrackback(message) - End If - End If - If Not trackbackSent AndAlso Post.Blog.EnablePingBackSend Then - SendPingback(New Uri(Post.PermaLink(PortalSettings)), url) - End If - - Next - - End Sub -#End Region - -#Region " Trackback " - Public Function SendTrackback(message As TrackbackMessage) As Boolean - - Dim request As HttpWebRequest = DirectCast(WebRequest.Create(message.UrlToNotifyTrackback), HttpWebRequest) - - request.Credentials = CredentialCache.DefaultNetworkCredentials - request.Method = "POST" - request.ContentLength = message.ToString().Length - request.ContentType = "application/x-www-form-urlencoded" - request.KeepAlive = False - request.Timeout = 30000 - - Using writer As New IO.StreamWriter(request.GetRequestStream) - writer.Write(message.ToString) - End Using - - Dim result As Boolean = False - Dim response As HttpWebResponse - Try - response = DirectCast(request.GetResponse(), HttpWebResponse) - Dim answer As String - Using sr As New IO.StreamReader(response.GetResponseStream) - answer = sr.ReadToEnd - End Using - result = CBool(response.StatusCode = HttpStatusCode.OK AndAlso answer.Contains("0")) - Catch ex As Exception - End Try - - Return result - - End Function -#End Region - -#Region " Pingback " - Public Sub SendPingback(sourceUrl As Uri, targetUrl As Uri) - - Try - - Dim pingUrl As String = Nothing - Dim request As HttpWebRequest = DirectCast(WebRequest.Create(targetUrl), HttpWebRequest) - request.Credentials = CredentialCache.DefaultNetworkCredentials - Using response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse) - For Each k As String In response.Headers.AllKeys - If k.Equals("x-pingback", StringComparison.OrdinalIgnoreCase) OrElse k.Equals("pingback", StringComparison.OrdinalIgnoreCase) Then - pingUrl = response.Headers(k) - End If - Next - If String.IsNullOrEmpty(pingUrl) Then - Using reader As New IO.StreamReader(response.GetResponseStream()) - Dim content As String = reader.ReadToEnd() - Dim m As Match = Regex.Match(content, "]*rel=""pingback""[^>]*>|]*rel='pingback'[^>]*>") - If m.Success Then - Dim link As String = m.Value - Dim m2 As Match = Regex.Match(link, "href=""(?[^""]*)""|href='(?[^']*)'") - If m2.Success Then - pingUrl = m2.Groups("link").Value.Replace("&", "&") - End If - End If - End Using - End If - End Using - - Dim url As Uri = Nothing - If Not String.IsNullOrEmpty(pingUrl) AndAlso Uri.TryCreate(pingUrl, UriKind.Absolute, url) Then - request = DirectCast(WebRequest.Create(url), HttpWebRequest) - request.Method = "POST" - request.Timeout = 30000 - request.ContentType = "text/xml" - request.ProtocolVersion = HttpVersion.Version11 - request.Headers("Accept-Language") = "en-us" - AddXmlToRequest(sourceUrl, targetUrl, request) - Using response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse) - End Using - End If - - Catch ex As Exception - ex = New Exception() - End Try - - End Sub -#End Region - -#Region " Private Methods " - Private Shared Function GetTrackBackUrlFromPage(input As String) As Uri - Dim url As String = TrackbackLinkRegex.Match(input).Groups(1).ToString().Trim() - Dim uri As Uri = Nothing - Return If(uri.TryCreate(url, UriKind.Absolute, uri), uri, Nothing) - End Function - - Private Shared Function GetUrlsFromContent(content As String) As IEnumerable(Of Uri) - Dim urlsList As New List(Of Uri) - For Each m As Match In UrlsRegex.Matches(content) - Dim url As String = m.Groups("url").ToString().Trim() - Dim uri As Uri = Nothing - If uri.TryCreate(url, UriKind.Absolute, uri) Then - urlsList.Add(uri) - End If - Next - Return urlsList - End Function - - Private Shared Sub AddXmlToRequest(sourceUrl As Uri, targetUrl As Uri, webreqPing As HttpWebRequest) - Using stream As IO.Stream = webreqPing.GetRequestStream - Using writer As New System.Xml.XmlTextWriter(stream, Encoding.ASCII) - writer.WriteStartDocument(True) - writer.WriteStartElement("methodCall") - writer.WriteElementString("methodName", "pingback.ping") - writer.WriteStartElement("params") - - writer.WriteStartElement("param") - writer.WriteStartElement("value") - writer.WriteElementString("string", sourceUrl.ToString()) - writer.WriteEndElement() - writer.WriteEndElement() - - writer.WriteStartElement("param") - writer.WriteStartElement("value") - writer.WriteElementString("string", targetUrl.ToString()) - writer.WriteEndElement() - writer.WriteEndElement() - - writer.WriteEndElement() - writer.WriteEndElement() - End Using - End Using - End Sub -#End Region - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Services/WLW/BlogPostException.vb b/Server/Blog/Components/Services/WLW/BlogPostException.vb deleted file mode 100644 index 0fecfa86..00000000 --- a/Server/Blog/Components/Services/WLW/BlogPostException.vb +++ /dev/null @@ -1,41 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Namespace Services.WLW - Public Class BlogPostException - Inherits Exception - - Private _resourceKey As String - Public Sub New(resourceKey As String, defaultMessage As String) - MyBase.New(defaultMessage) - _resourceKey = resourceKey - End Sub - - Public Property ResourceKey() As String - Get - Return _resourceKey - End Get - Set(Value As String) - _resourceKey = Value - End Set - End Property - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Services/WLW/Blogger/IBlogger.vb b/Server/Blog/Components/Services/WLW/Blogger/IBlogger.vb deleted file mode 100644 index 593fdb45..00000000 --- a/Server/Blog/Components/Services/WLW/Blogger/IBlogger.vb +++ /dev/null @@ -1,48 +0,0 @@ -' -' DotNetNuke® - http://www.dotnetnuke.com -' Copyright (c) 2015 -' by DotNetNuke Corporation -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports CookComputing.XmlRpc - -Namespace Services.WLW.Blogger - - ''' - ''' Interface for Blogger Methods that WLW uses - ''' - ''' - ''' - ''' [pdonker] 12/14/2009 created - ''' - Public Interface IBlogger - - _ - Function deletePost(appKey As String, postid As String, username As String, password As String, _ - publish As Boolean) As Boolean - - _ - Function getUsersBlogs(appKey As String, username As String, password As String) As BlogInfoStruct() - - End Interface - - Public Structure BlogInfoStruct - Public url As String - Public blogName As String - Public blogid As String - End Structure -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Services/WLW/MetaWeblog/IMetaWeblog.vb b/Server/Blog/Components/Services/WLW/MetaWeblog/IMetaWeblog.vb deleted file mode 100644 index d4973fe2..00000000 --- a/Server/Blog/Components/Services/WLW/MetaWeblog/IMetaWeblog.vb +++ /dev/null @@ -1,276 +0,0 @@ -' -' DotNetNuke® - http://www.dotnetnuke.com -' Copyright (c) 2015 -' by DotNetNuke Corporation -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports CookComputing.XmlRpc - -Namespace Services.WLW.MetaWeblog - - ''' - ''' Interface for MetaWeblog methods that WLW uses - ''' - ''' - ''' - ''' [pdonker] 12/14/2009 created - ''' - Public Interface IMetaWeblog - - - Function editPost(postid As String, username As String, password As String, post As Post, publish As Boolean) As Boolean - - - Function getCategories(blogid As String, username As String, password As String) As MetaWebLogCategoryInfo() - - - Function getPost(postid As String, username As String, password As String) As Post - - - Function getRecentPosts(blogid As String, username As String, password As String, numberOfPosts As Integer) As Post() - - - Function newPost(blogid As String, username As String, password As String, post As Post, publish As Boolean) As String - - - Function newMediaObject(blogid As String, username As String, password As String, mediaobject As mediaObject) As mediaObjectInfo - - End Interface - - - Public Structure Enclosure - Public length As Integer - Public type As String - Public url As String - End Structure - - - Public Structure Source - Public name As String - Public url As String - End Structure - - ''' - ''' Central structure to pass a post between WLW and the module - ''' - ''' - ''' - ''' [pdonker] 12/20/2009 added 'publish' - ''' - - Public Structure Post - - ''' - ''' The date to publish the blog Post. - ''' - ''' - - Public pubDate As DateTime - - ''' - ''' The GMT DateTime value when the blog Post was created. - ''' - ''' - - Public date_created_gmt As DateTime - - ''' - ''' The DateTime value when the blog Post was created. - ''' - ''' - - Public dateCreated As DateTime - - ''' - ''' Post Content - ''' - ''' - - Public description As String - - ''' - ''' Post Title - ''' - ''' - - Public title As String - - ''' - ''' List of categories for the post - ''' - ''' - - Public categories As String() - - ''' - ''' - ''' - ''' - - Public mt_keywords As String - - ''' - ''' - ''' - ''' - - Public mt_allow_comments As Integer - - ''' - ''' - ''' - ''' - - Public mt_allow_pings As Integer - - ''' - ''' - ''' - ''' - Public link As String - - ''' - ''' - ''' - ''' - Public permalink As String - - ''' - ''' - ''' - ''' - - Public postid As String - - ''' - ''' - ''' - ''' - - Public publish As Boolean - - - ''' - ''' Used to track an SEO friendly description of the post, usually shorter than - ''' the Title and formatted for SEO presentation (eg. Using-Trackbacks-1). - ''' Only utilized if the supportsSlug entity is set to yes in the manifest file. - ''' - ''' - Public wp_slug As String - - ''' - ''' Only utilized if the supportsPassword entity is set to yes in the manifest file. - ''' - ''' - Public wp_password As String - - ''' - ''' Only utilized if the supportsPageParent entity is set to yes in the manifest file. - ''' - ''' - - Public wp_page_parent_id As String - - ''' - ''' Only utilized if the supportsPageOrder entity is set to yes in the manifest file. - ''' - ''' - Public wp_page_order As String - - ''' - ''' Only utilized if the supportsAuthor entity is set to yes in the manifest file. - ''' - ''' - Public wp_author_id As String - - ''' - ''' Only utilized if the supportsExcerpt entity is set to yes in the manifest file. In plain HTML. - ''' - ''' - - Public mt_excerpt As String - - ''' - ''' Only utilized if the supportsExtendedPosts entity is set to yes in the manifest file. - ''' - ''' - Public mt_text_more As String - - ''' - ''' Used to manage trackback URLs. Will only be populated if - ''' supportsTrackbacks is set to yes in the manifest file. - ''' - ''' - - Public mt_tb_ping_urls As String() - - ''' - ''' Used to track the status of the page. This is a WordPress property. - ''' - ''' - Public page_status As String - - End Structure - - Public Structure Page - - Public page_id As Object - - Public page_title As String - - Public page_parent_id As String - - Public dateCreated As DateTime - End Structure - - Public Structure CategoryInfo - Public categoryId As String - Public parentId As String - Public description As String - Public categoryName As String - Public htmlUrl As String - Public rssUrl As String - End Structure - - ''' - ''' Metaweblog specific category structure - ''' - ''' - Public Structure MetaWebLogCategoryInfo - Public description As String - Public htmlUrl As String - Public rssUrl As String - End Structure - - Public Structure NewCategory - Public name As String - Public slug As String - Public parent_id As Integer - Public description As String - End Structure - - Public Structure mediaObject - Public name As String - Public type As String - Public bits As Byte() - End Structure - - Public Structure mediaObjectInfo - Public url As String - End Structure - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Services/WLW/MoveableType/IMoveableType.vb b/Server/Blog/Components/Services/WLW/MoveableType/IMoveableType.vb deleted file mode 100644 index b049787e..00000000 --- a/Server/Blog/Components/Services/WLW/MoveableType/IMoveableType.vb +++ /dev/null @@ -1,57 +0,0 @@ -' -' DotNetNuke® - http://www.dotnetnuke.com -' Copyright (c) 2015 -' by DotNetNuke Corporation -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports CookComputing.XmlRpc - -Namespace Services.WLW.MoveableType - - ''' - ''' Interface for Moveable Type methods that WLW uses - ''' - ''' - ''' - ''' [pdonker] 12/14/2009 created - ''' - Public Interface IMoveableType - - _ - Function getPostCategories(postid As String, username As String, password As String) As Category() - - _ - Function setPostCategories(postid As String, username As String, password As String, categories As Category()) As Boolean - - End Interface - - ''' - ''' MT specific category structure - ''' - ''' - ''' - ''' [pdonker] 12/14/2009 created - ''' - Public Structure Category - Public categoryId As String - _ - Public categoryName As String - _ - Public isPrimary As Boolean - End Structure - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Services/WLW/WordPress/IWordPress.vb b/Server/Blog/Components/Services/WLW/WordPress/IWordPress.vb deleted file mode 100644 index c3ca906f..00000000 --- a/Server/Blog/Components/Services/WLW/WordPress/IWordPress.vb +++ /dev/null @@ -1,55 +0,0 @@ -' -' DotNetNuke® - http://www.dotnetnuke.com -' Copyright (c) 2015 -' by DotNetNuke Corporation -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports CookComputing.XmlRpc - -Namespace Services.WLW.WordPress - - ''' - ''' Interface for Wordpress methods that WLW uses - ''' - ''' - ''' - ''' [pdonker] 12/14/2009 created - ''' - Public Interface IWordPress - - _ - Function getCategories(blogid As String, username As String, password As String) As CategoryInfo() - - End Interface - - ''' - ''' WP specific category structure - ''' - ''' - ''' - ''' [pdonker] 12/14/2009 created - ''' - Public Structure CategoryInfo - Public categoryId As Integer - Public parentId As Integer - Public description As String - Public categoryName As String - Public htmlUrl As String - Public rssUrl As String - End Structure - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Templating/BaseCustomTokenReplace.vb b/Server/Blog/Components/Templating/BaseCustomTokenReplace.vb deleted file mode 100644 index 545903ae..00000000 --- a/Server/Blog/Components/Templating/BaseCustomTokenReplace.vb +++ /dev/null @@ -1,181 +0,0 @@ -' -' DotNetNuke® - http://www.dotnetnuke.com -' Copyright (c) 2002-2010 by DotNetNuke Corp. -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Services.Tokens -Imports DotNetNuke.Services.Localization.Localization - -Namespace Templating - ''' - ''' BaseCustomTokenReplace allows to add multiple sources implementing IPropertyAccess - ''' - ''' - Public MustInherit Class BaseCustomTokenReplace - Inherits BaseTokenReplace - -#Region " Private Fields " - Private _AccessLevel As Scope - Private _AccessingUser As DotNetNuke.Entities.Users.UserInfo - Private _debugMessages As Boolean -#End Region - -#Region "Protected Properties" - - ''' - ''' Gets/sets the current Access Level controlling access to critical user settings - ''' - ''' A TokenAccessLevel as defined above - Protected Property CurrentAccessLevel() As Scope - Get - Return _AccessLevel - End Get - Set(ByVal value As Scope) - - _AccessLevel = value - End Set - End Property - - Protected PropertySource As New System.Collections.Generic.Dictionary(Of String, IPropertyAccess) - - -#End Region - -#Region "Public Properties" - - ''' - ''' Gets/sets the user object representing the currently accessing user (permission) - ''' - ''' UserInfo oject - Public Property AccessingUser() As DotNetNuke.Entities.Users.UserInfo - Get - Return _AccessingUser - End Get - Set(ByVal value As DotNetNuke.Entities.Users.UserInfo) - _AccessingUser = value - End Set - End Property - - ''' - ''' If DebugMessages are enabled, unknown Tokens are replaced with Error Messages - ''' - ''' - ''' - ''' - Public Property DebugMessages() As Boolean - Get - Return _debugMessages - End Get - Set(ByVal value As Boolean) - _debugMessages = value - End Set - End Property - -#End Region - -#Region "Protected Methods" - - Protected Overrides Function replacedTokenValue(ByVal strObjectName As String, ByVal strPropertyName As String, ByVal strFormat As String) As String - Dim PropertyNotFound As Boolean = False - Dim result As String = String.Empty - If PropertySource.ContainsKey(strObjectName.ToLower) Then - result = PropertySource(strObjectName.ToLower).GetProperty(strPropertyName, strFormat, FormatProvider, AccessingUser, CurrentAccessLevel, PropertyNotFound) - Else - If DebugMessages Then - Dim message As String = GetString("TokenReplaceUnknownObject", SharedResourceFile, FormatProvider.ToString()) - If message = String.Empty Then message = "Error accessing [{0}:{1}], {0} is an unknown datasource" - result = String.Format(message, strObjectName, strPropertyName) - End If - End If - If DebugMessages And PropertyNotFound Then - Dim message As String - If result = PropertyAccess.ContentLocked Then - message = GetString("TokenReplaceRestrictedProperty", GlobalResourceFile, FormatProvider.ToString()) - Else - message = GetString("TokenReplaceUnknownProperty", GlobalResourceFile, FormatProvider.ToString()) - End If - - If message = String.Empty Then message = "Error accessing [{0}:{1}], {1} is unknown for datasource {0}" - result = String.Format(message, strObjectName, strPropertyName) - End If - Return result - End Function - -#End Region - -#Region "Public Methods" - - ''' - ''' Checks for present [Object:Property] tokens - ''' - ''' String with [Object:Property] tokens - ''' - ''' - ''' 08/10/2007 [sleupold] created - ''' 10/19/2007 [sleupold] corrected to ignore unchanged text returned (issue DNN-6526) - ''' - Public Function ContainsTokens(ByVal strSourceText As String) As Boolean - If Not String.IsNullOrEmpty(strSourceText) Then - For Each currentMatch As System.Text.RegularExpressions.Match In TokenizerRegex.Matches(strSourceText) - If currentMatch.Result("${object}").Length > 0 Then - Return True - End If - Next - End If - Return False - End Function - - ''' - ''' returns cacheability of the passed text regarding all contained tokens - ''' - ''' the text to parse for tokens to replace - ''' cacheability level (not - safe - fully) - ''' always check cacheability before caching a module! - ''' - ''' 10/19/2007 [sleupold] corrected to handle non-empty strings - ''' - Public Function Cacheability(ByVal strSourcetext As String) As CacheLevel - Dim IsSafe As CacheLevel = CacheLevel.fullyCacheable - If Not (strSourcetext Is Nothing) AndAlso Not String.IsNullOrEmpty(strSourcetext) Then - - 'initialize PropertyAccess classes - Dim DummyResult As String = ReplaceTokens(strSourcetext) - - Dim Result As New System.Text.StringBuilder - For Each currentMatch As System.Text.RegularExpressions.Match In TokenizerRegex.Matches(strSourcetext) - - Dim strObjectName As String = currentMatch.Result("${object}") - If strObjectName.Length > 0 Then - If strObjectName = "[" Then - 'nothing - ElseIf Not PropertySource.ContainsKey(strObjectName.ToLower) Then - 'end if - Else - Dim c As CacheLevel = PropertySource(strObjectName.ToLower).Cacheability - If c < IsSafe Then IsSafe = c - End If - End If - Next - End If - Return IsSafe - End Function - -#End Region - - End Class - -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Templating/BaseTokenReplace.vb b/Server/Blog/Components/Templating/BaseTokenReplace.vb deleted file mode 100644 index 7d7ef456..00000000 --- a/Server/Blog/Components/Templating/BaseTokenReplace.vb +++ /dev/null @@ -1,153 +0,0 @@ -' -' DotNetNuke® - http://www.dotnetnuke.com -' Copyright (c) 2002-2010 by DotNetNuke Corp. -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports System.Globalization -Imports DotNetNuke.UI.Utilities - - -Namespace Templating - - ''' - ''' The BaseTokenReplace class provides the tokenization of tokens formatted - ''' [object:property] or [object:property|format|ifEmpty] or [custom:no] within a string - ''' with the appropriate current property/custom values. - ''' - ''' - Public MustInherit Class BaseTokenReplace - -#Region "Regexp Tokenizer" - - - 'Private Const ExpressionDefault As String = "(?:\[(?:(?[^\]\[:]+):(?[^\]\[\|]+))(?:\|(?:(?[^\]\[]+)\|(?[^\]\[]+))|\|(?:(?[^\|\]\[]+)))?\])|(?\[[^\]\[]+\])|(?[^\]\[]+)" - Private Const ExpressionDefault As String = "\[(?[^\]\[:\r\n]+):(?[^\]\[\|\r\n]+)((\])|(\|(?[^\]\[\r\n]+)((\])|(\|(?[^\]\[\r\n]+)))))" - - Private Const ExpressionObjectLess As String = "(?:\[(?:(?[^\]\[:]+):(?[^\]\[\|]+))(?:\|(?:(?[^\]\[]+)\|(?[^\]\[]+))|\|(?:(?[^\|\]\[]+)))?\])" _ - & "|(?:(?\[)(?[A-Z0-9._]+)(?:\|(?:(?[^\]\[]+)\|(?[^\]\[]+))|\|(?:(?[^\|\]\[]+)))?\])" _ - & "|(?\[[^\]\[]+\])" _ - & "|(?[^\]\[]+)" - - Private _UseObjectLessExpression As Boolean = False - - Protected Property UseObjectLessExpression() As Boolean - Get - Return _UseObjectLessExpression - End Get - Set(ByVal value As Boolean) - _UseObjectLessExpression = value - End Set - End Property - - Private ReadOnly Property TokenReplaceCacheKey() As String - Get - If UseObjectLessExpression Then - Return "Blog_TokenReplaceRegEx_Objectless" - Else - Return "Blog_TokenReplaceRegEx_Default" - End If - End Get - End Property - - Private ReadOnly Property RegExpression() As String - Get - If UseObjectLessExpression Then - Return ExpressionObjectLess - Else - Return ExpressionDefault - End If - End Get - End Property - - Protected Const ObjectLessToken As String = "no_object" - - ''' - ''' Gets the Regular expression for the token to be replaced - ''' - ''' A regular Expression - Protected ReadOnly Property TokenizerRegex() As Regex - Get - Dim tokenizer As Regex = CType(DataCache.GetCache(TokenReplaceCacheKey), Regex) - If tokenizer Is Nothing Then - tokenizer = New Regex(RegExpression, RegexOptions.Compiled) - DataCache.SetCache(TokenReplaceCacheKey, tokenizer) - End If - Return tokenizer - End Get - End Property -#End Region - -#Region "Fields & Properties" - Private _Language As String - Private _FormatProvider As CultureInfo - - ''' - ''' Gets/sets the language to be used, e.g. for date format - ''' - ''' A string, representing the locale - Public Property Language() As String - Get - Return _Language - End Get - Set(ByVal value As String) - _Language = value - _FormatProvider = New CultureInfo(_Language) - End Set - End Property - - ''' - ''' Gets the Format provider as Culture info from stored language or current culture - ''' - ''' An CultureInfo - Protected ReadOnly Property FormatProvider() As System.Globalization.CultureInfo - Get - If _FormatProvider Is Nothing Then - _FormatProvider = System.Threading.Thread.CurrentThread.CurrentUICulture - End If - Return _FormatProvider - End Get - End Property -#End Region - - Protected Overridable Function ReplaceTokens(ByVal strSourceText As String) As String - If strSourceText Is Nothing Then Return String.Empty - Dim Result As New System.Text.StringBuilder - Return TokenizerRegex.Replace(strSourceText, AddressOf ReplaceTokenMatch) - End Function - - Private Function ReplaceTokenMatch(m As Match) As String - - Dim strObjectName As String = m.Result("${object}") - If strObjectName.Length > 0 Then - If strObjectName = "[" Then strObjectName = ObjectLessToken - Dim strPropertyName As String = m.Result("${property}") - Dim strFormat As String = m.Result("${format}") - Dim strIfEmptyReplacment As String = m.Result("${ifEmpty}") - Dim strConversion As String = replacedTokenValue(strObjectName, strPropertyName, strFormat) - If strIfEmptyReplacment.Length > 0 AndAlso strConversion.Length = 0 Then strConversion = strIfEmptyReplacment - Return strConversion - Else - Return m.Value - End If - - End Function - - - Protected MustOverride Function replacedTokenValue(ByVal strObjectName As String, ByVal strPropertyName As String, ByVal strFormat As String) As String - - End Class -End Namespace diff --git a/Server/Blog/Components/Templating/BlogTokenReplace.vb b/Server/Blog/Components/Templating/BlogTokenReplace.vb deleted file mode 100644 index be20ff68..00000000 --- a/Server/Blog/Components/Templating/BlogTokenReplace.vb +++ /dev/null @@ -1,259 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Entities.Portals -Imports DotNetNuke.Services.Tokens -Imports DotNetNuke.Modules.Blog.Entities.Blogs -Imports DotNetNuke.Modules.Blog.Entities.Posts -Imports DotNetNuke.Modules.Blog.Entities.Terms -Imports DotNetNuke.Modules.Blog.Entities.Comments - -Namespace Templating - Public Class BlogTokenReplace - Inherits GenericTokenReplace - - Public Sub New(moduleId As Integer) - MyBase.new(Scope.DefaultSettings) - - Dim actModule As DotNetNuke.Entities.Modules.ModuleInfo = (New DotNetNuke.Entities.Modules.ModuleController).GetModule(moduleId) - ModuleInfo = actModule - UseObjectLessExpression = False - - End Sub - - Public Sub New(actModule As DotNetNuke.Entities.Modules.ModuleInfo, security As Modules.Blog.Security.ContextSecurity, blog As BlogInfo, post As PostInfo, settings As Common.ModuleSettings, viewSettings As ViewSettings) - MyBase.new(Scope.DefaultSettings) - - ModuleInfo = actModule - UseObjectLessExpression = False - PropertySource("security") = security - PropertySource("settings") = settings - PropertySource("viewsettings") = viewSettings - If blog IsNot Nothing Then - PropertySource("blog") = blog - PropertySource("owner") = New LazyLoadingUser(PortalSettings.PortalId, blog.OwnerUserId, blog.Username) - End If - If post IsNot Nothing Then - PropertySource("post") = post - End If - - End Sub - - Public Sub New(actModule As DotNetNuke.Entities.Modules.ModuleInfo, security As Modules.Blog.Security.ContextSecurity, blog As BlogInfo, Post As PostInfo, settings As Common.ModuleSettings, viewSettings As ViewSettings, comment As CommentInfo) - MyBase.new(Scope.DefaultSettings) - - PrimaryObject = comment - ModuleInfo = actModule - UseObjectLessExpression = False - PropertySource("security") = security - PropertySource("settings") = settings - PropertySource("viewsettings") = viewSettings - If Post IsNot Nothing Then - PropertySource("post") = Post - PropertySource("author") = New LazyLoadingUser(PortalSettings.PortalId, Post.CreatedByUserID, Post.Username) - PropertySource("blog") = Post.Blog - PropertySource("owner") = New LazyLoadingUser(PortalSettings.PortalId, Post.Blog.OwnerUserId, Post.Blog.Username) - ElseIf blog IsNot Nothing Then - PropertySource("blog") = blog - PropertySource("owner") = New LazyLoadingUser(PortalSettings.PortalId, blog.OwnerUserId, blog.Username) - End If - PropertySource("comment") = comment - PropertySource("commenter") = New LazyLoadingUser(PortalSettings.PortalId, comment.CreatedByUserID, comment.Username) - - End Sub - - Public Sub New(blogModule As BlogModuleBase) - MyBase.new(Scope.DefaultSettings) - - ModuleInfo = blogModule.ModuleConfiguration - UseObjectLessExpression = False - PropertySource("query") = blogModule.BlogContext - PropertySource("security") = blogModule.BlogContext.Security - PropertySource("urls") = blogModule.BlogContext.ModuleUrls - PropertySource("settings") = blogModule.Settings - PropertySource("viewsettings") = blogModule.ViewSettings - If blogModule.BlogContext.Blog IsNot Nothing Then - PropertySource("blog") = blogModule.BlogContext.Blog - PropertySource("owner") = New LazyLoadingUser(PortalSettings.PortalId, blogModule.BlogContext.Blog.OwnerUserId, blogModule.BlogContext.Blog.Username) - End If - If blogModule.BlogContext.Post IsNot Nothing Then - PropertySource("post") = blogModule.BlogContext.Post - PropertySource("author") = New LazyLoadingUser(PortalSettings.PortalId, blogModule.BlogContext.Post.CreatedByUserID, blogModule.BlogContext.Post.Username) - End If - If blogModule.BlogContext.Term IsNot Nothing Then - PropertySource("selectedterm") = blogModule.BlogContext.Term - End If - If blogModule.BlogContext.Author IsNot Nothing Then - PropertySource("author") = blogModule.BlogContext.Author - End If - - End Sub - - Public Sub New(blogModule As BlogModuleBase, blog As BlogInfo) - MyBase.new(Scope.DefaultSettings) - - PrimaryObject = blog - ModuleInfo = blogModule.ModuleConfiguration - UseObjectLessExpression = False - PropertySource("query") = blogModule.BlogContext - PropertySource("security") = blogModule.BlogContext.Security - PropertySource("urls") = blogModule.BlogContext.ModuleUrls - PropertySource("settings") = blogModule.Settings - PropertySource("viewsettings") = blogModule.ViewSettings - PropertySource("blog") = blog - PropertySource("owner") = New LazyLoadingUser(PortalSettings.PortalId, blog.OwnerUserId, blog.Username) - If blogModule.BlogContext.Post IsNot Nothing Then - PropertySource("post") = blogModule.BlogContext.Post - PropertySource("author") = New LazyLoadingUser(PortalSettings.PortalId, blogModule.BlogContext.Post.CreatedByUserID, blogModule.BlogContext.Post.Username) - ElseIf blogModule.BlogContext.Author IsNot Nothing Then - PropertySource("author") = blogModule.BlogContext.Author - End If - If blogModule.BlogContext.Term IsNot Nothing Then - PropertySource("selectedterm") = blogModule.BlogContext.Term - End If - - End Sub - - Public Sub New(blogModule As BlogModuleBase, objBlogCalendar As BlogCalendarInfo) - MyBase.new(Scope.DefaultSettings) - - PrimaryObject = objBlogCalendar - ModuleInfo = blogModule.ModuleConfiguration - UseObjectLessExpression = False - PropertySource("query") = blogModule.BlogContext - PropertySource("security") = blogModule.BlogContext.Security - PropertySource("urls") = blogModule.BlogContext.ModuleUrls - PropertySource("settings") = blogModule.Settings - PropertySource("viewsettings") = blogModule.ViewSettings - If blogModule.BlogContext.Blog IsNot Nothing Then - PropertySource("blog") = blogModule.BlogContext.Blog - End If - PropertySource("calendar") = objBlogCalendar - If blogModule.BlogContext.Post IsNot Nothing Then - PropertySource("post") = blogModule.BlogContext.Post - PropertySource("author") = New LazyLoadingUser(PortalSettings.PortalId, blogModule.BlogContext.Post.CreatedByUserID, blogModule.BlogContext.Post.Username) - ElseIf blogModule.BlogContext.Author IsNot Nothing Then - PropertySource("author") = blogModule.BlogContext.Author - End If - If blogModule.BlogContext.Term IsNot Nothing Then - PropertySource("selectedterm") = blogModule.BlogContext.Term - End If - - End Sub - - Public Sub New(blogModule As BlogModuleBase, objAuthor As LazyLoadingUser) - MyBase.new(Scope.DefaultSettings) - - PrimaryObject = objAuthor - ModuleInfo = blogModule.ModuleConfiguration - UseObjectLessExpression = False - PropertySource("query") = blogModule.BlogContext - PropertySource("security") = blogModule.BlogContext.Security - PropertySource("urls") = blogModule.BlogContext.ModuleUrls - PropertySource("settings") = blogModule.Settings - PropertySource("viewsettings") = blogModule.ViewSettings - If blogModule.BlogContext.Blog IsNot Nothing Then - PropertySource("blog") = blogModule.BlogContext.Blog - End If - PropertySource("author") = objAuthor - If blogModule.BlogContext.Post IsNot Nothing Then - PropertySource("post") = blogModule.BlogContext.Post - End If - If blogModule.BlogContext.Term IsNot Nothing Then - PropertySource("selectedterm") = blogModule.BlogContext.Term - End If - - End Sub - - Public Sub New(blogModule As BlogModuleBase, Post As PostInfo) - MyBase.new(Scope.DefaultSettings) - - PrimaryObject = Post - ModuleInfo = blogModule.ModuleConfiguration - UseObjectLessExpression = False - PropertySource("query") = blogModule.BlogContext - PropertySource("security") = blogModule.BlogContext.Security - PropertySource("urls") = blogModule.BlogContext.ModuleUrls - PropertySource("settings") = blogModule.Settings - PropertySource("viewsettings") = blogModule.ViewSettings - PropertySource("post") = Post - PropertySource("author") = New LazyLoadingUser(PortalSettings.PortalId, Post.CreatedByUserID, Post.Username) - PropertySource("blog") = Post.Blog - PropertySource("owner") = New LazyLoadingUser(PortalSettings.PortalId, Post.Blog.OwnerUserId, Post.Blog.Username) - If blogModule.BlogContext.Term IsNot Nothing Then - PropertySource("selectedterm") = blogModule.BlogContext.Term - End If - - End Sub - - Public Sub New(blogModule As BlogModuleBase, Post As PostInfo, term As TermInfo) - MyBase.new(Scope.DefaultSettings) - - PrimaryObject = term - ModuleInfo = blogModule.ModuleConfiguration - UseObjectLessExpression = False - PropertySource("query") = blogModule.BlogContext - PropertySource("security") = blogModule.BlogContext.Security - PropertySource("urls") = blogModule.BlogContext.ModuleUrls - PropertySource("settings") = blogModule.Settings - PropertySource("viewsettings") = blogModule.ViewSettings - If Post IsNot Nothing Then - PropertySource("post") = Post - PropertySource("author") = New LazyLoadingUser(PortalSettings.PortalId, Post.CreatedByUserID, Post.Username) - PropertySource("blog") = Post.Blog - PropertySource("owner") = New LazyLoadingUser(PortalSettings.PortalId, Post.Blog.OwnerUserId, Post.Blog.Username) - ElseIf blogModule.BlogContext.Blog IsNot Nothing Then - PropertySource("blog") = blogModule.BlogContext.Blog - PropertySource("owner") = New LazyLoadingUser(PortalSettings.PortalId, blogModule.BlogContext.Blog.OwnerUserId, blogModule.BlogContext.Blog.Username) - End If - PropertySource("term") = term - If blogModule.BlogContext.Term IsNot Nothing Then - PropertySource("selectedterm") = blogModule.BlogContext.Term - End If - - End Sub - - Public Sub New(blogModule As BlogModuleBase, Post As PostInfo, comment As CommentInfo) - MyBase.new(Scope.DefaultSettings) - - PrimaryObject = comment - ModuleInfo = blogModule.ModuleConfiguration - UseObjectLessExpression = False - PropertySource("query") = blogModule.BlogContext - PropertySource("security") = blogModule.BlogContext.Security - PropertySource("urls") = blogModule.BlogContext.ModuleUrls - PropertySource("settings") = blogModule.Settings - PropertySource("viewsettings") = blogModule.ViewSettings - If Post IsNot Nothing Then - PropertySource("post") = Post - PropertySource("author") = New LazyLoadingUser(PortalSettings.PortalId, Post.CreatedByUserID, Post.Username) - PropertySource("blog") = Post.Blog - PropertySource("owner") = New LazyLoadingUser(PortalSettings.PortalId, Post.Blog.OwnerUserId, Post.Blog.Username) - ElseIf blogModule.BlogContext.Blog IsNot Nothing Then - PropertySource("blog") = blogModule.BlogContext.Blog - PropertySource("owner") = New LazyLoadingUser(PortalSettings.PortalId, blogModule.BlogContext.Blog.OwnerUserId, blogModule.BlogContext.Blog.Username) - End If - PropertySource("comment") = comment - PropertySource("commenter") = New LazyLoadingUser(PortalSettings.PortalId, comment.CreatedByUserID, comment.Username) - - End Sub - - End Class -End Namespace diff --git a/Server/Blog/Components/Templating/CustomParameters.vb b/Server/Blog/Components/Templating/CustomParameters.vb deleted file mode 100644 index 09c58ee3..00000000 --- a/Server/Blog/Components/Templating/CustomParameters.vb +++ /dev/null @@ -1,71 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Services.Tokens - -Namespace Templating - Public Class CustomParameters - Implements IPropertyAccess - -#Region " Private Members " - Private Property params As NameValueCollection -#End Region - -#Region " Constructors " - Public Sub New(ByVal ParamArray customParameters As String()) - params = New NameValueCollection - For Each sParameter As String In customParameters - params.Add(Left(sParameter.ToLower, sParameter.IndexOf("="c)), Mid(sParameter, sParameter.IndexOf("="c) + 2)) - Next - End Sub -#End Region - -#Region " IPropertyAccess " - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.notCacheable - End Get - End Property - - Public Function GetProperty(ByVal strPropertyName As String, ByVal strFormat As String, ByVal formatProvider As System.Globalization.CultureInfo, ByVal AccessingUser As DotNetNuke.Entities.Users.UserInfo, ByVal AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - If params(strPropertyName.ToLower) Is Nothing Then Return DotNetNuke.Common.Utilities.Null.NullString - Dim value As String = params(strPropertyName.ToLower) - Try - If IsNumeric(value) Then - Return CDbl(value).ToString(OutputFormat, formatProvider) - End If - If IsDate(value) Then - Return CDate(value).ToString(OutputFormat, formatProvider) - End If - Return Common.Globals.FormatBoolean(CBool(value), strFormat) - Catch ex As Exception - Return value - End Try - End Function -#End Region - - End Class -End Namespace diff --git a/Server/Blog/Components/Templating/GenericTokenReplace.vb b/Server/Blog/Components/Templating/GenericTokenReplace.vb deleted file mode 100644 index d866b428..00000000 --- a/Server/Blog/Components/Templating/GenericTokenReplace.vb +++ /dev/null @@ -1,67 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Services.Tokens - -Namespace Templating - Public MustInherit Class GenericTokenReplace - Inherits TokenReplace - - Public Property PrimaryObject As Object = Nothing - - Public Sub New(accessLevel As DotNetNuke.Services.Tokens.Scope) - MyBase.New(Scope.DefaultSettings) - End Sub - - Public Sub New(accessLevel As DotNetNuke.Services.Tokens.Scope, moduleId As Integer) - MyBase.New(Scope.DefaultSettings, moduleId) - End Sub - - Public Shadows Function ReplaceTokens(strSourceText As String) As String - strSourceText = strSourceText.Replace("\[", "{{").Replace("\]", "}}") - Return MyBase.ReplaceTokens(strSourceText).Replace("{{", "[").Replace("}}", "]") - End Function - - Public Shadows Function ReplaceTokens(strSourceText As String, ParamArray additionalParameters As String()) As String - strSourceText = strSourceText.Replace("\[", "{{").Replace("\]", "}}") - PropertySource("custom") = New CustomParameters(additionalParameters) - Return MyBase.ReplaceTokens(strSourceText).Replace("{{", "[").Replace("}}", "]") - End Function - - Public Sub AddCustomParameters(ParamArray additionalParameters As String()) - PropertySource("custom") = New CustomParameters(additionalParameters) - End Sub - - Public Sub AddResources(TemplateRelPath As String) - PropertySource("resx") = New Resources(TemplateRelPath) - End Sub - - Public Sub AddPropertySource(key As String, resource As IPropertyAccess) - PropertySource(key) = resource - End Sub - - Public Function GetTokenValue(obj As String, prop As String, format As String) As String - If Not PropertySource.ContainsKey(obj) Then Return "" - Dim bFound As Boolean = False - Return PropertySource(obj).GetProperty(prop, format, Threading.Thread.CurrentThread.CurrentCulture, Nothing, Scope.DefaultSettings, bFound) - End Function - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Templating/LazyLoadingUser.vb b/Server/Blog/Components/Templating/LazyLoadingUser.vb deleted file mode 100644 index afd97d0e..00000000 --- a/Server/Blog/Components/Templating/LazyLoadingUser.vb +++ /dev/null @@ -1,120 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Entities.Users -Imports DotNetNuke.Services.Tokens -Imports DotNetNuke.Modules.Blog.Entities.Posts - -Namespace Templating - Public Class LazyLoadingUser - Implements IPropertyAccess - -#Region " Properties " - Public Property PortalId As Integer = -1 - Public Property UserId As Integer = -1 - Public Property Username As String = "" - - Private _user As UserInfo - Public Property User() As UserInfo - Get - If _user Is Nothing Then - If UserId > -1 Then - _user = UserController.GetUserById(PortalId, UserId) - ElseIf Username <> "" Then - _user = UserController.GetCachedUser(PortalId, Username) - Else - _user = New UserInfo - End If - End If - Return _user - End Get - Set(ByVal value As UserInfo) - _user = value - End Set - End Property - - Private _postAuthor As PostAuthor = Nothing -#End Region - -#Region " Constructors " - Public Sub New(portalId As Integer, userId As Integer) - Me.PortalId = portalId - Me.UserId = userId - End Sub - - Public Sub New(portalId As Integer, userId As Integer, userName As String) - Me.PortalId = portalId - Me.UserId = userId - Me.Username = userName - End Sub - - Public Sub New(user As UserInfo) - Me.User = user - PortalId = user.PortalID - UserId = user.UserID - End Sub - - Public Sub New(user As PostAuthor) - Me.User = user - PortalId = user.PortalID - UserId = user.UserID - _postAuthor = user - End Sub -#End Region - -#Region " IPropertyAccess Implementation " - Public Function GetProperty(strPropertyName As String, strFormat As String, formatProvider As Globalization.CultureInfo, AccessingUser As UserInfo, AccessLevel As Scope, ByRef PropertyNotFound As Boolean) As String Implements IPropertyAccess.GetProperty - Select Case strPropertyName.ToLower - Case "profilepic" - If IsNumeric(strFormat) Then - Return DotNetNuke.Common.ResolveUrl(String.Format("~/DnnImageHandler.ashx?mode=profilepic&userId={0}&w={1}&h={1}", UserId, strFormat)) - Else - Return DotNetNuke.Common.ResolveUrl(String.Format("~/DnnImageHandler.ashx?mode=profilepic&userId={0}&w={1}&h={1}", UserId, 50)) - End If - Case "profileurl" - Return DotNetNuke.Common.Globals.UserProfileURL(UserId) - End Select - Dim res As String = "" - If _postAuthor IsNot Nothing Then - res = _postAuthor.GetProperty(strPropertyName, strFormat, formatProvider, AccessingUser, AccessLevel, PropertyNotFound) - Else - res = User.GetProperty(strPropertyName, strFormat, formatProvider, AccessingUser, AccessLevel, PropertyNotFound) - End If - If PropertyNotFound Then - res = HttpUtility.HtmlDecode(User.Profile.GetPropertyValue(strPropertyName)) - End If - If Not String.IsNullOrEmpty(res) Then - PropertyNotFound = False - Return res - End If - PropertyNotFound = True - Return Null.NullString - End Function - - Public ReadOnly Property Cacheability() As CacheLevel Implements IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property -#End Region - - End Class -End Namespace \ No newline at end of file diff --git a/Server/Blog/Components/Templating/Resources.vb b/Server/Blog/Components/Templating/Resources.vb deleted file mode 100644 index 48d2c013..00000000 --- a/Server/Blog/Components/Templating/Resources.vb +++ /dev/null @@ -1,74 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Imports DotNetNuke.Common.Utilities -Imports DotNetNuke.Services.Tokens -Imports DotNetNuke.Services.Localization.Localization - -Namespace Templating - Public Class Resources - Implements IPropertyAccess - - Private Property ResourcesPath As String = "" - Private Property PrimaryResourceFile As String = "" - Private Property SecondaryResourceFile As String = "" - -#Region " Constructors " - Public Sub New(ByVal TemplateRelPath As String) - PrimaryResourceFile = TemplateRelPath - ResourcesPath = TemplateRelPath.Substring(0, TemplateRelPath.LastIndexOf("/")) - If Not PrimaryResourceFile.ToLower.EndsWith(".resx") Then - PrimaryResourceFile = PrimaryResourceFile & ".resx" - End If - SecondaryResourceFile = ResourcesPath & "/SharedResources.ascx.resx" - End Sub -#End Region - -#Region " IPropertyAccess Implementation " - Public ReadOnly Property Cacheability() As DotNetNuke.Services.Tokens.CacheLevel Implements DotNetNuke.Services.Tokens.IPropertyAccess.Cacheability - Get - Return CacheLevel.fullyCacheable - End Get - End Property - - Public Function GetProperty(ByVal strPropertyName As String, ByVal strFormat As String, ByVal formatProvider As System.Globalization.CultureInfo, ByVal AccessingUser As DotNetNuke.Entities.Users.UserInfo, ByVal AccessLevel As DotNetNuke.Services.Tokens.Scope, ByRef PropertyNotFound As Boolean) As String Implements DotNetNuke.Services.Tokens.IPropertyAccess.GetProperty - Dim OutputFormat As String = String.Empty - If strFormat = String.Empty Then - OutputFormat = "D" - Else - OutputFormat = strFormat - End If - Dim res As String = GetString(strPropertyName, PrimaryResourceFile) - If String.IsNullOrEmpty(res) Then - res = GetString(strPropertyName, SecondaryResourceFile) - End If - If res IsNot Nothing Then - Select Case OutputFormat.ToLower - Case "js", "jssafe" - res = UI.Utilities.ClientAPI.GetSafeJSString(res) - End Select - Return res - End If - Return Null.NullString - End Function -#End Region - - End Class -End Namespace diff --git a/Server/Blog/Components/Templating/Template.vb b/Server/Blog/Components/Templating/Template.vb deleted file mode 100644 index 2ff0c50f..00000000 --- a/Server/Blog/Components/Templating/Template.vb +++ /dev/null @@ -1,234 +0,0 @@ -' -' DNN Connect - http://dnn-connect.org -' Copyright (c) 2015 -' by DNN Connect -' -' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -' documentation files (the "Software"), to deal in the Software without restriction, including without limitation -' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -' to permit persons to whom the Software is furnished to do so, subject to the following conditions: -' -' The above copyright notice and this permission notice shall be included in all copies or substantial portions -' of the Software. -' -' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -' DEALINGS IN THE SOFTWARE. -' - -Namespace Templating - Public Class Template - -#Region " Private Members " - Public Property FileName As String = "Template.html" - Public Property Contents As String = "" - Public Property ViewMapPath As String = "" - Public Property ViewRelPath As String = "" - Public Property Replacer As GenericTokenReplace = Nothing -#End Region - -#Region " Events " - Private Sub Template_GetData(ByVal DataSource As String, ByVal Parameters As Dictionary(Of String, String), ByRef Replacers As List(Of GenericTokenReplace), ByRef Arguments As List(Of String()), callingObject As Object) - RaiseEvent GetData(DataSource, Parameters, Replacers, Arguments, callingObject) - End Sub - - Public Event GetData(ByVal DataSource As String, ByVal Parameters As Dictionary(Of String, String), ByRef Replacers As List(Of GenericTokenReplace), ByRef Arguments As List(Of String()), callingObject As Object) -#End Region - -#Region " Constructors " - Public Sub New(ByVal ViewMapPath As String, ViewRelPath As String, ByVal Filename As String, ByVal Replacer As GenericTokenReplace, item As TemplateRepeaterItem) - Me.ViewMapPath = ViewMapPath - Me.ViewRelPath = ViewRelPath - Me.FileName = Filename - Me.Replacer = Replacer - Me.Replacer.AddResources(ViewRelPath & "App_LocalResources/" & Filename) - If item IsNot Nothing Then Me.Replacer.AddPropertySource("item", item) - End Sub - - Public Sub New(ByVal ViewMapPath As String, ViewRelPath As String, ByVal Filename As String, ByVal Replacer As GenericTokenReplace, item As TemplateRepeaterItem, ByVal Arguments As String()) - Me.ViewMapPath = ViewMapPath - Me.ViewRelPath = ViewRelPath - Me.FileName = Filename - Me.Replacer = Replacer - Me.Replacer.AddCustomParameters(Arguments) - Me.Replacer.AddResources(ViewRelPath & "App_LocalResources/" & Filename) - If item IsNot Nothing Then Me.Replacer.AddPropertySource("item", item) - End Sub -#End Region - -#Region " Public Methods " - Public Function ReplaceContents() As String - - Try - Contents = Templating.GetTemplateFile(_ViewMapPath & _FileName) - If String.IsNullOrEmpty(Contents) Then Return "" - ' Expand subtemplates - ' Simple conditional template e.g. [subtemplate|Widget.html|widget:isgood|True] - Contents = Regex.Replace(_Contents, "(?i)\[subtemplate\|([^|\]]+)\|([^:|\]]+):([^|\]]+)\|?([^|\]]+)?\](?-i)", AddressOf ReplaceConditionalTemplate) - ' Inline conditional e.g. [if|2][flight:flightid][>]4[/if] ... [endif|2] - _Contents = Regex.Replace(_Contents, "(?si)\[if\|(?