diff --git a/App_LocalResources/UploadFiles.ascx.resx b/App_LocalResources/UploadFiles.ascx.resx index 72086ee..cc05d2a 100755 --- a/App_LocalResources/UploadFiles.ascx.resx +++ b/App_LocalResources/UploadFiles.ascx.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Are you sure you want to remove this file? @@ -144,4 +144,7 @@ Add Existing File + + Upload + \ No newline at end of file diff --git a/Base/NewsArticleModuleBase.vb b/Base/NewsArticleModuleBase.vb index 3b00ee9..d4e88ef 100755 --- a/Base/NewsArticleModuleBase.vb +++ b/Base/NewsArticleModuleBase.vb @@ -226,25 +226,31 @@ Namespace Ventrian.NewsArticles.Base End If End Function - Protected Function StripHtml(ByVal html As String) As String - Const pattern As String = "<(.|\n)*?>" - Return Regex.Replace(html, pattern, String.Empty) + Public Function StripHtml(ByVal html As String) As String - End Function + Return StripHtml(html, False) + End Function - Private Function RoundToUnit(ByVal d As Double, ByVal unit As Double, ByVal roundDown As Boolean) As Double + Public Function StripHtml(ByVal html As String, ByVal cleanLineBreaks As Boolean) As String - If (roundDown) Then - Return Math.Round(Math.Round((d / unit) - 0.5, 0) * unit, 2) - Else - Return Math.Round(Math.Round((d / unit) + 0.5, 0) * unit, 2) - End If + Dim pattern As String = "<(.|\n)*?>" + Return Regex.Replace(html, pattern, String.Empty).Replace(System.Environment.NewLine, " ") - End Function + End Function + + Private Function RoundToUnit(ByVal d As Double, ByVal unit As Double, ByVal roundDown As Boolean) As Double + + If (roundDown) Then + Return Math.Round(Math.Round((d / unit) - 0.5, 0) * unit, 2) + Else + Return Math.Round(Math.Round((d / unit) + 0.5, 0) * unit, 2) + End If + + End Function - Protected Function GetRatingImage(ByVal objDataItem As Object) As String + Protected Function GetRatingImage(ByVal objDataItem As Object) As String Dim objArticle As ArticleInfo = CType(objDataItem, ArticleInfo) diff --git a/Components/Layout/TokenProcessor.vb b/Components/Layout/TokenProcessor.vb index 6330cfe..e3afbb1 100755 --- a/Components/Layout/TokenProcessor.vb +++ b/Components/Layout/TokenProcessor.vb @@ -13,360 +13,371 @@ Imports Ventrian.NewsArticles.Base Namespace Ventrian.NewsArticles - Public Class TokenProcessor + Public Class TokenProcessor #Region " Private Methods " - Private Shared Function GetModuleLink(ByVal key As String, ByVal moduleContext As NewsArticleModuleBase) As String - Return Common.GetModuleLink(moduleContext.TabId, moduleContext.ModuleId, key, moduleContext.ArticleSettings) - End Function + Private Shared Function GetModuleLink(ByVal key As String, ByVal moduleContext As NewsArticleModuleBase) As String + If moduleContext IsNot Nothing AndAlso + moduleContext.ModuleConfiguration IsNot Nothing AndAlso + Not String.IsNullOrEmpty(moduleContext.ModuleConfiguration.CultureCode) AndAlso + moduleContext.ModuleConfiguration.CultureCode.Trim() <> "" Then + + Return Common.GetModuleLink(moduleContext.TabId, moduleContext.ModuleId, key, moduleContext.ArticleSettings, "language=" + moduleContext.ModuleConfiguration.CultureCode) + + Else + + Return Common.GetModuleLink(moduleContext.TabId, moduleContext.ModuleId, key, moduleContext.ArticleSettings) + + End If + End Function #End Region #Region " Process Menu " - Public Shared Sub ProcessMenu(ByRef placeHolder As ControlCollection, ByRef moduleContext As NewsArticleModuleBase, ByVal selectedMenu As MenuOptionType) + Public Shared Sub ProcessMenu(ByRef placeHolder As ControlCollection, ByRef moduleContext As NewsArticleModuleBase, ByVal selectedMenu As MenuOptionType) - Dim objLayoutController As New LayoutController(moduleContext) - Dim objLayout As LayoutInfo = LayoutController.GetLayout(moduleContext, LayoutType.Menu_Item_Html) + Dim objLayoutController As New LayoutController(moduleContext) + Dim objLayout As LayoutInfo = LayoutController.GetLayout(moduleContext, LayoutType.Menu_Item_Html) - For iPtr As Integer = 0 To objLayout.Tokens.Length - 1 Step 2 - - placeHolder.Add(New LiteralControl(objLayoutController.ProcessImages(objLayout.Tokens(iPtr).ToString()))) - - If iPtr < objLayout.Tokens.Length - 1 Then - ProcessMenuItem(objLayout.Tokens(iPtr + 1), placeHolder, objLayoutController, moduleContext, iPtr, objLayout.Tokens, selectedMenu) - End If - - Next - - End Sub - - Public Shared Sub ProcessMenuItem(ByVal token As String, ByRef objPlaceHolder As ControlCollection, ByVal objLayoutController As LayoutController, ByVal moduleContext As NewsArticleModuleBase, ByRef iPtr As Integer, ByVal templateArray As String(), ByVal selectedMenu As MenuOptionType) - - 'Dim path As String = objPage.TemplateSourceDirectory & "/DesktopModules/DnnForge - NewsArticles/" & Localization.LocalResourceDirectory & "/" & Localization.LocalSharedResourceFile - 'path = "~" & path.Substring(path.IndexOf("/DesktopModules/"), path.Length - path.IndexOf("/DesktopModules/")) - - Dim path As String = "~/DesktopModules/DnnForge - NewsArticles/" & Localization.LocalResourceDirectory & "/" & Localization.LocalSharedResourceFile - - Select Case token - - Case "ADMINLINK" - Dim objLiteral As New Literal - - Dim parameters As New List(Of String) - parameters.Add("mid=" & moduleContext.ModuleId) - - If (moduleContext.ArticleSettings.AuthorUserIDFilter) Then - If (moduleContext.ArticleSettings.AuthorUserIDParam <> "") Then - If (HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUserIDParam) <> "") Then - parameters.Add(moduleContext.ArticleSettings.AuthorUserIDParam & "=" & HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUserIDParam)) - End If - End If - End If - - If (moduleContext.ArticleSettings.AuthorUsernameFilter) Then - If (moduleContext.ArticleSettings.AuthorUsernameParam <> "") Then - If (HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUsernameParam) <> "") Then - parameters.Add(moduleContext.ArticleSettings.AuthorUsernameParam & "=" & HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUsernameParam)) - End If - End If - End If - - objLiteral.Text = NavigateURL(moduleContext.TabId, "AdminOptions", parameters.ToArray()) - objPlaceHolder.Add(objLiteral) - - Case "ARCHIVESLINK" - Dim objLiteral As New Literal - objLiteral.Text = GetModuleLink("Archives", moduleContext) - objPlaceHolder.Add(objLiteral) - - Case "APPROVEARTICLESLINK" - Dim objLiteral As New Literal - objLiteral.Text = GetModuleLink("ApproveArticles", moduleContext) - objPlaceHolder.Add(objLiteral) - - Case "APPROVECOMMENTSLINK" - Dim objLiteral As New Literal - objLiteral.Text = GetModuleLink("ApproveComments", moduleContext) - objPlaceHolder.Add(objLiteral) - - Case "CATEGORIESLINK" - Dim objLiteral As New Literal - objLiteral.Text = GetModuleLink("Archives", moduleContext) - objPlaceHolder.Add(objLiteral) - - Case "CURRENTARTICLESLINK" - Dim objLiteral As New Literal - objLiteral.Text = GetModuleLink("", moduleContext) - objPlaceHolder.Add(objLiteral) - - Case "HASCOMMENTSENABLED" - If (moduleContext.ArticleSettings.IsCommentsEnabled = False Or moduleContext.ArticleSettings.IsCommentModerationEnabled = False) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/HASCOMMENTSENABLED") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/HASCOMMENTSENABLED" - ' Do Nothing - - Case "ISADMIN" - If (moduleContext.ArticleSettings.IsAdmin = False) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISADMIN") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISADMIN" - ' Do Nothing - - Case "ISAPPROVER" - If (moduleContext.ArticleSettings.IsApprover = False) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISAPPROVER") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISAPPROVER" - ' Do Nothing - - Case "ISSELECTEDADMIN" - If (selectedMenu <> MenuOptionType.AdminOptions) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISSELECTEDADMIN") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISSELECTEDADMIN" - ' Do Nothing - - Case "ISSELECTEDAPPROVEARTICLES" - If (selectedMenu <> MenuOptionType.ApproveArticles) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISSELECTEDAPPROVEARTICLES") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISSELECTEDAPPROVEARTICLES" - ' Do Nothing - - Case "ISSELECTEDAPPROVECOMMENTS" - If (selectedMenu <> MenuOptionType.ApproveComments) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISSELECTEDAPPROVECOMMENTS") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISSELECTEDAPPROVECOMMENTS" - ' Do Nothing - - Case "ISSELECTEDCATEGORIES" - If (selectedMenu <> MenuOptionType.Categories) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISSELECTEDCATEGORIES") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISSELECTEDCATEGORIES" - ' Do Nothing - - Case "ISSELECTEDCURRENTARTICLES" - If (selectedMenu <> MenuOptionType.CurrentArticles) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISSELECTEDCURRENTARTICLES") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISSELECTEDCURRENTARTICLES" - ' Do Nothing - - Case "ISSELECTEDMYARTICLES" - If (selectedMenu <> MenuOptionType.MyArticles) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISSELECTEDMYARTICLES") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISSELECTEDMYARTICLES" - ' Do Nothing - - Case "ISSELECTEDSEARCH" - If (selectedMenu <> MenuOptionType.Search) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISSELECTEDSEARCH") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISSELECTEDSEARCH" - ' Do Nothing - - Case "ISSELECTEDSYNDICATION" - If (selectedMenu <> MenuOptionType.Syndication) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISSELECTEDSYNDICATION") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISSELECTEDSYNDICATION" - ' Do Nothing - - Case "ISSELECTEDSUBMITARTICLE" - If (selectedMenu <> MenuOptionType.SubmitArticle) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISSELECTEDSUBMITARTICLE") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISSELECTEDSUBMITARTICLE" - ' Do Nothing - - Case "ISSYNDICATIONENABLED" - If (moduleContext.ArticleSettings.IsSyndicationEnabled = False) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISSYNDICATIONENABLED") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISSYNDICATIONENABLED" - ' Do Nothing - - Case "ISSUBMITTER" - If (moduleContext.ArticleSettings.IsSubmitter = False) Then - While (iPtr < templateArray.Length - 1) - If (templateArray(iPtr + 1) = "/ISSUBMITTER") Then - Exit While - End If - iPtr = iPtr + 1 - End While - End If - - Case "/ISSUBMITTER" - ' Do Nothing - - Case "MYARTICLESLINK" - Dim objLiteral As New Literal - objLiteral.Text = GetModuleLink("MyArticles", moduleContext) - objPlaceHolder.Add(objLiteral) - - Case "RSSLATESTLINK" - Dim objLiteral As New Literal - Dim authorIDParam As String = "" - If (moduleContext.ArticleSettings.AuthorUserIDFilter) Then - If (moduleContext.ArticleSettings.AuthorUserIDParam <> "") Then - If (HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUserIDParam) <> "") Then - authorIDParam = "&AuthorID=" & HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUserIDParam) - End If - End If - End If - - If (moduleContext.ArticleSettings.AuthorUsernameFilter) Then - If (moduleContext.ArticleSettings.AuthorUsernameParam <> "") Then - If (HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUsernameParam) <> "") Then - Try - Dim objUser As Entities.Users.UserInfo = Entities.Users.UserController.GetUserByName(PortalController.GetCurrentPortalSettings().PortalId, HttpContext.Current.Request.QueryString(moduleContext.ArticleSettings.AuthorUsernameParam)) - If (objUser IsNot Nothing) Then - authorIDParam = "&AuthorID=" & objUser.UserID.ToString() - End If - Catch - End Try - End If - End If - End If - objLiteral.Text = ArticleUtilities.ResolveUrl("~/DesktopModules/DnnForge%20-%20NewsArticles/Rss.aspx") & "?TabID=" & moduleContext.TabId & "&ModuleID=" & moduleContext.ModuleId & "&MaxCount=25" & authorIDParam - objPlaceHolder.Add(objLiteral) - - Case "SEARCHLINK" - Dim objLiteral As New Literal - objLiteral.Text = GetModuleLink("Search", moduleContext) - objPlaceHolder.Add(objLiteral) - - Case "SUBMITARTICLELINK" - Dim objLiteral As New Literal - If (moduleContext.ArticleSettings.LaunchLinks) Then - objLiteral.Text = GetModuleLink("Edit", moduleContext) - Else - objLiteral.Text = GetModuleLink("SubmitNews", moduleContext) - End If - objPlaceHolder.Add(objLiteral) - - Case "SYNDICATIONLINK" - Dim objLiteral As New Literal - objLiteral.Text = GetModuleLink("Syndication", moduleContext) - objPlaceHolder.Add(objLiteral) - - Case Else - Dim isRendered As Boolean = False - - If (templateArray(iPtr + 1).ToUpper().StartsWith("RESX:")) Then - Dim key As String = templateArray(iPtr + 1).Substring(5, templateArray(iPtr + 1).Length - 5) - Dim objLiteral As New Literal - Try - objLiteral.Text = Localization.GetString(key & ".Text", path) - If (objLiteral.Text = "") Then - objLiteral.Text = templateArray(iPtr + 1).Substring(5, templateArray(iPtr + 1).Length - 5) - End If - Catch - objLiteral.Text = templateArray(iPtr + 1).Substring(5, templateArray(iPtr + 1).Length - 5) - End Try - objLiteral.EnableViewState = False - objPlaceHolder.Add(objLiteral) - isRendered = True - End If - - If (isRendered = False) Then - Dim objLiteralOther As New Literal - objLiteralOther.Text = "[" & templateArray(iPtr + 1) & "]" - objLiteralOther.EnableViewState = False - objPlaceHolder.Add(objLiteralOther) - End If - - End Select - - End Sub + For iPtr As Integer = 0 To objLayout.Tokens.Length - 1 Step 2 + + placeHolder.Add(New LiteralControl(objLayoutController.ProcessImages(objLayout.Tokens(iPtr).ToString()))) + + If iPtr < objLayout.Tokens.Length - 1 Then + ProcessMenuItem(objLayout.Tokens(iPtr + 1), placeHolder, objLayoutController, moduleContext, iPtr, objLayout.Tokens, selectedMenu) + End If + + Next + + End Sub + + Public Shared Sub ProcessMenuItem(ByVal token As String, ByRef objPlaceHolder As ControlCollection, ByVal objLayoutController As LayoutController, ByVal moduleContext As NewsArticleModuleBase, ByRef iPtr As Integer, ByVal templateArray As String(), ByVal selectedMenu As MenuOptionType) + + 'Dim path As String = objPage.TemplateSourceDirectory & "/DesktopModules/DnnForge - NewsArticles/" & Localization.LocalResourceDirectory & "/" & Localization.LocalSharedResourceFile + 'path = "~" & path.Substring(path.IndexOf("/DesktopModules/"), path.Length - path.IndexOf("/DesktopModules/")) + + Dim path As String = "~/DesktopModules/DnnForge - NewsArticles/" & Localization.LocalResourceDirectory & "/" & Localization.LocalSharedResourceFile + + Select Case token + + Case "ADMINLINK" + Dim objLiteral As New Literal + + Dim parameters As New List(Of String) + parameters.Add("mid=" & moduleContext.ModuleId) + + If (moduleContext.ArticleSettings.AuthorUserIDFilter) Then + If (moduleContext.ArticleSettings.AuthorUserIDParam <> "") Then + If (HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUserIDParam) <> "") Then + parameters.Add(moduleContext.ArticleSettings.AuthorUserIDParam & "=" & HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUserIDParam)) + End If + End If + End If + + If (moduleContext.ArticleSettings.AuthorUsernameFilter) Then + If (moduleContext.ArticleSettings.AuthorUsernameParam <> "") Then + If (HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUsernameParam) <> "") Then + parameters.Add(moduleContext.ArticleSettings.AuthorUsernameParam & "=" & HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUsernameParam)) + End If + End If + End If + + objLiteral.Text = NavigateURL(moduleContext.TabId, "AdminOptions", parameters.ToArray()) + objPlaceHolder.Add(objLiteral) + + Case "ARCHIVESLINK" + Dim objLiteral As New Literal + objLiteral.Text = GetModuleLink("Archives", moduleContext) + objPlaceHolder.Add(objLiteral) + + Case "APPROVEARTICLESLINK" + Dim objLiteral As New Literal + objLiteral.Text = GetModuleLink("ApproveArticles", moduleContext) + objPlaceHolder.Add(objLiteral) + + Case "APPROVECOMMENTSLINK" + Dim objLiteral As New Literal + objLiteral.Text = GetModuleLink("ApproveComments", moduleContext) + objPlaceHolder.Add(objLiteral) + + Case "CATEGORIESLINK" + Dim objLiteral As New Literal + objLiteral.Text = GetModuleLink("Archives", moduleContext) + objPlaceHolder.Add(objLiteral) + + Case "CURRENTARTICLESLINK" + Dim objLiteral As New Literal + objLiteral.Text = GetModuleLink("", moduleContext) + objPlaceHolder.Add(objLiteral) + + Case "HASCOMMENTSENABLED" + If (moduleContext.ArticleSettings.IsCommentsEnabled = False Or moduleContext.ArticleSettings.IsCommentModerationEnabled = False) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/HASCOMMENTSENABLED") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/HASCOMMENTSENABLED" + ' Do Nothing + + Case "ISADMIN" + If (moduleContext.ArticleSettings.IsAdmin = False) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISADMIN") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISADMIN" + ' Do Nothing + + Case "ISAPPROVER" + If (moduleContext.ArticleSettings.IsApprover = False) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISAPPROVER") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISAPPROVER" + ' Do Nothing + + Case "ISSELECTEDADMIN" + If (selectedMenu <> MenuOptionType.AdminOptions) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISSELECTEDADMIN") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISSELECTEDADMIN" + ' Do Nothing + + Case "ISSELECTEDAPPROVEARTICLES" + If (selectedMenu <> MenuOptionType.ApproveArticles) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISSELECTEDAPPROVEARTICLES") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISSELECTEDAPPROVEARTICLES" + ' Do Nothing + + Case "ISSELECTEDAPPROVECOMMENTS" + If (selectedMenu <> MenuOptionType.ApproveComments) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISSELECTEDAPPROVECOMMENTS") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISSELECTEDAPPROVECOMMENTS" + ' Do Nothing + + Case "ISSELECTEDCATEGORIES" + If (selectedMenu <> MenuOptionType.Categories) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISSELECTEDCATEGORIES") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISSELECTEDCATEGORIES" + ' Do Nothing + + Case "ISSELECTEDCURRENTARTICLES" + If (selectedMenu <> MenuOptionType.CurrentArticles) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISSELECTEDCURRENTARTICLES") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISSELECTEDCURRENTARTICLES" + ' Do Nothing + + Case "ISSELECTEDMYARTICLES" + If (selectedMenu <> MenuOptionType.MyArticles) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISSELECTEDMYARTICLES") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISSELECTEDMYARTICLES" + ' Do Nothing + + Case "ISSELECTEDSEARCH" + If (selectedMenu <> MenuOptionType.Search) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISSELECTEDSEARCH") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISSELECTEDSEARCH" + ' Do Nothing + + Case "ISSELECTEDSYNDICATION" + If (selectedMenu <> MenuOptionType.Syndication) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISSELECTEDSYNDICATION") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISSELECTEDSYNDICATION" + ' Do Nothing + + Case "ISSELECTEDSUBMITARTICLE" + If (selectedMenu <> MenuOptionType.SubmitArticle) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISSELECTEDSUBMITARTICLE") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISSELECTEDSUBMITARTICLE" + ' Do Nothing + + Case "ISSYNDICATIONENABLED" + If (moduleContext.ArticleSettings.IsSyndicationEnabled = False) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISSYNDICATIONENABLED") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISSYNDICATIONENABLED" + ' Do Nothing + + Case "ISSUBMITTER" + If (moduleContext.ArticleSettings.IsSubmitter = False) Then + While (iPtr < templateArray.Length - 1) + If (templateArray(iPtr + 1) = "/ISSUBMITTER") Then + Exit While + End If + iPtr = iPtr + 1 + End While + End If + + Case "/ISSUBMITTER" + ' Do Nothing + + Case "MYARTICLESLINK" + Dim objLiteral As New Literal + objLiteral.Text = GetModuleLink("MyArticles", moduleContext) + objPlaceHolder.Add(objLiteral) + + Case "RSSLATESTLINK" + Dim objLiteral As New Literal + Dim authorIDParam As String = "" + If (moduleContext.ArticleSettings.AuthorUserIDFilter) Then + If (moduleContext.ArticleSettings.AuthorUserIDParam <> "") Then + If (HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUserIDParam) <> "") Then + authorIDParam = "&AuthorID=" & HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUserIDParam) + End If + End If + End If + + If (moduleContext.ArticleSettings.AuthorUsernameFilter) Then + If (moduleContext.ArticleSettings.AuthorUsernameParam <> "") Then + If (HttpContext.Current.Request(moduleContext.ArticleSettings.AuthorUsernameParam) <> "") Then + Try + Dim objUser As Entities.Users.UserInfo = Entities.Users.UserController.GetUserByName(PortalController.GetCurrentPortalSettings().PortalId, HttpContext.Current.Request.QueryString(moduleContext.ArticleSettings.AuthorUsernameParam)) + If (objUser IsNot Nothing) Then + authorIDParam = "&AuthorID=" & objUser.UserID.ToString() + End If + Catch + End Try + End If + End If + End If + objLiteral.Text = ArticleUtilities.ResolveUrl("~/DesktopModules/DnnForge%20-%20NewsArticles/Rss.aspx") & "?TabID=" & moduleContext.TabId & "&ModuleID=" & moduleContext.ModuleId & "&MaxCount=25" & authorIDParam + objPlaceHolder.Add(objLiteral) + + Case "SEARCHLINK" + Dim objLiteral As New Literal + objLiteral.Text = GetModuleLink("Search", moduleContext) + objPlaceHolder.Add(objLiteral) + + Case "SUBMITARTICLELINK" + Dim objLiteral As New Literal + If (moduleContext.ArticleSettings.LaunchLinks) Then + objLiteral.Text = GetModuleLink("Edit", moduleContext) + Else + objLiteral.Text = GetModuleLink("SubmitNews", moduleContext) + End If + objPlaceHolder.Add(objLiteral) + + Case "SYNDICATIONLINK" + Dim objLiteral As New Literal + objLiteral.Text = GetModuleLink("Syndication", moduleContext) + objPlaceHolder.Add(objLiteral) + + Case Else + Dim isRendered As Boolean = False + + If (templateArray(iPtr + 1).ToUpper().StartsWith("RESX:")) Then + Dim key As String = templateArray(iPtr + 1).Substring(5, templateArray(iPtr + 1).Length - 5) + Dim objLiteral As New Literal + Try + objLiteral.Text = Localization.GetString(key & ".Text", path) + If (objLiteral.Text = "") Then + objLiteral.Text = templateArray(iPtr + 1).Substring(5, templateArray(iPtr + 1).Length - 5) + End If + Catch + objLiteral.Text = templateArray(iPtr + 1).Substring(5, templateArray(iPtr + 1).Length - 5) + End Try + objLiteral.EnableViewState = False + objPlaceHolder.Add(objLiteral) + isRendered = True + End If + + If (isRendered = False) Then + Dim objLiteralOther As New Literal + objLiteralOther.Text = "[" & templateArray(iPtr + 1) & "]" + objLiteralOther.EnableViewState = False + objPlaceHolder.Add(objLiteralOther) + End If + + End Select + + End Sub #End Region - End Class + End Class End Namespace diff --git a/Controls/SWFUploaderFiles.ashx.vb b/Controls/SWFUploaderFiles.ashx.vb index 0443e62..ddf5471 100755 --- a/Controls/SWFUploaderFiles.ashx.vb +++ b/Controls/SWFUploaderFiles.ashx.vb @@ -165,105 +165,25 @@ Namespace Ventrian.NewsArticles.Controls Dim objFilePosted As HttpPostedFile = _context.Request.Files("Filedata") - If Not (objFilePosted Is Nothing) Then + If Not (objFilePosted Is Nothing) Then - Dim objPortalController As New PortalController() - If (objPortalController.HasSpaceAvailable(_portalID, objFilePosted.ContentLength) = False) Then - _context.Response.Write("-1") - _context.Response.End() - End If + Dim objPortalController As New PortalController() + If (objPortalController.HasSpaceAvailable(_portalID, objFilePosted.ContentLength) = False) Then + _context.Response.Write("-1") + _context.Response.End() + End If - Dim username As String = _context.User.Identity.Name + Dim username As String = _context.User.Identity.Name - If (_articleID <> Null.NullInteger) Then - FileProvider.Instance().AddFile(_articleID, _moduleID, objFilePosted) - Else - FileProvider.Instance().AddFile(_fileGuid, _moduleID, objFilePosted) - End If + If (_articleID <> Null.NullInteger) Then + FileProvider.Instance().AddFile(_articleID, _moduleID, objFilePosted) + Else + FileProvider.Instance().AddFile(_fileGuid, _moduleID, objFilePosted) + End If - 'Dim objFile As New FileInfo - - 'objFile.ArticleID = _articleID - 'If (_articleID = Null.NullInteger) Then - ' objFile.FileGuid = _fileGuid - 'End If - 'objFile.FileName = objFilePosted.FileName - 'objFile.SortOrder = 0 - - 'Dim filesList As List(Of FileInfo) = objFileController.GetFileList(_articleID, _fileGuid) - - 'If (filesList.Count > 0) Then - ' objFile.SortOrder = CType(filesList(filesList.Count - 1), FileInfo).SortOrder + 1 - 'End If - - 'Dim objPortalSettings As PortalSettings = PortalController.GetCurrentPortalSettings() - - 'Dim folder As String = "" - 'If (ArticleSettings.DefaultFilesFolder <> Null.NullInteger) Then - ' Dim objFolderController As New FolderController - ' Dim objFolder As FolderInfo = objFolderController.GetFolderInfo(_portalID, ArticleSettings.DefaultFilesFolder) - ' If (objFolder IsNot Nothing) Then - ' folder = objFolder.FolderPath - ' End If - 'End If - - 'objFile.Folder = folder - 'objFile.ContentType = objFilePosted.ContentType - - 'If (objFile.FileName.Split("."c).Length > 0) Then - ' objFile.Extension = objFile.FileName.Split("."c)(objFile.FileName.Split("."c).Length - 1) - - ' If (objFile.Extension.ToLower() = "jpg") Then - ' objFile.ContentType = "image/jpeg" - ' End If - ' If (objFile.Extension.ToLower() = "gif") Then - ' objFile.ContentType = "image/gif" - ' End If - ' If (objFile.Extension.ToLower() = "txt") Then - ' objFile.ContentType = "text/plain" - ' End If - ' If (objFile.Extension.ToLower() = "html") Then - ' objFile.ContentType = "text/html" - ' End If - ' If (objFile.Extension.ToLower() = "mp3") Then - ' objFile.ContentType = "audio/mpeg" - ' End If - - 'End If - 'objFile.Title = objFile.FileName.Replace("." & objFile.Extension, "") - - 'Dim filePath As String = objPortalSettings.HomeDirectoryMapPath & folder.Replace("/", "\") - - 'If Not (Directory.Exists(filePath)) Then - ' Directory.CreateDirectory(filePath) - 'End If - - 'If (File.Exists(filePath & objFile.FileName)) Then - ' For i As Integer = 1 To 100 - ' If (File.Exists(filePath & i.ToString() & "_" & objFile.FileName) = False) Then - ' objFile.FileName = i.ToString() & "_" & objFile.FileName - ' Exit For - ' End If - ' Next - 'End If - - 'objFile.Size = objFilePosted.ContentLength - 'objFilePosted.SaveAs(filePath & objFile.FileName) - - 'objFile.FileID = objFileController.Add(objFile) - - 'If (_articleID <> Null.NullInteger) Then - ' Dim objArticleController As New ArticleController - ' Dim objArticle As ArticleInfo = objArticleController.GetArticle(_articleID) - ' If (objArticle IsNot Nothing) Then - ' objArticle.FileCount = objArticle.FileCount + 1 - ' objArticleController.UpdateArticle(objArticle) - ' End If - 'End If - - End If + End If - _context.Response.Write("0") + _context.Response.Write("0") _context.Response.End() End Sub diff --git a/Controls/UploadFiles.ascx b/Controls/UploadFiles.ascx index 1a36b8f..9275b03 100755 --- a/Controls/UploadFiles.ascx +++ b/Controls/UploadFiles.ascx @@ -1,183 +1,109 @@ <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="UploadFiles.ascx.vb" Inherits="Ventrian.NewsArticles.Controls.UploadFiles" %> <%@ Register TagPrefix="Ventrian" Assembly="Ventrian.NewsArticles" Namespace="Ventrian.NewsArticles.Components.WebControls" %> - <%@ Register TagPrefix="dnn" TagName="SectionHead" Src="~/controls/SectionHeadControl.ascx" %> <%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> <%@ Register TagPrefix="dnn" TagName="URL" Src="~/controls/URLControl.ascx" %> - -
- - + +
- + - - - -
- +
- - - - - - -
- - - - - - - - - -
 
- -
-
- -
-
-
-
-
- - - - - -
- - - - - -

 
-
-
-
- - - - - -
- - - - - <%#DataBinder.Eval(Container.DataItem, "Title")%> - -
- - - - -
- - - <%#DataBinder.Eval(Container.DataItem, "Title")%> - -
- -
- - -
-
-
-
-
-
- + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ + +
+
+ + + + + + + + +
+ +
+
+
+
+ + + + + +
+ + + + + <%#DataBinder.Eval(Container.DataItem, "Title")%> + +
+ + + + +
+ + + <%#DataBinder.Eval(Container.DataItem, "Title")%> + +
+ +
+ + +
+
+
+ +
+
+ + + + diff --git a/Controls/UploadFiles.ascx.designer.vb b/Controls/UploadFiles.ascx.designer.vb index 57b9571..8c2c43d 100755 --- a/Controls/UploadFiles.ascx.designer.vb +++ b/Controls/UploadFiles.ascx.designer.vb @@ -11,9 +11,9 @@ Option Strict On Option Explicit On Namespace Ventrian.NewsArticles.Controls - + Partial Public Class UploadFiles - + ''' '''litModuleID control. ''' @@ -22,7 +22,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents litModuleID As Global.System.Web.UI.WebControls.Literal - + ''' '''litTabModuleID control. ''' @@ -31,7 +31,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents litTabModuleID As Global.System.Web.UI.WebControls.Literal - + ''' '''litTicketID control. ''' @@ -40,7 +40,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents litTicketID As Global.System.Web.UI.WebControls.Literal - + ''' '''litArticleGuid control. ''' @@ -49,16 +49,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents litArticleGuid As Global.System.Web.UI.WebControls.Literal - - ''' - '''lblSelectFiles control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblSelectFiles As Global.System.Web.UI.WebControls.Label - + ''' '''dshFiles control. ''' @@ -67,7 +58,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dshFiles As DotNetNuke.UI.UserControls.SectionHeadControl - + ''' '''tblFiles control. ''' @@ -76,7 +67,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents tblFiles As Global.System.Web.UI.HtmlControls.HtmlTable - + ''' '''lblFilesHelp control. ''' @@ -85,16 +76,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblFilesHelp As Global.System.Web.UI.WebControls.Label - - ''' - '''phFiles control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents phFiles As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''trUpload control. ''' @@ -103,7 +85,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents trUpload As Global.System.Web.UI.HtmlControls.HtmlTableCell - + ''' '''dshUploadFiles control. ''' @@ -112,7 +94,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dshUploadFiles As DotNetNuke.UI.UserControls.SectionHeadControl - + ''' '''tblUploadFiles control. ''' @@ -121,7 +103,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents tblUploadFiles As Global.System.Web.UI.HtmlControls.HtmlTable - + ''' '''plFolder control. ''' @@ -130,7 +112,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents plFolder As Global.System.Web.UI.UserControl - + ''' '''drpUploadFilesFolder control. ''' @@ -139,7 +121,34 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents drpUploadFilesFolder As Global.System.Web.UI.WebControls.DropDownList - + + ''' + '''Label1 control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents Label1 As Global.System.Web.UI.UserControl + + ''' + '''fupFile control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents fupFile As Global.System.Web.UI.WebControls.FileUpload + + ''' + '''btUpload control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents btUpload As Global.System.Web.UI.WebControls.Button + ''' '''trExisting control. ''' @@ -148,7 +157,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents trExisting As Global.System.Web.UI.HtmlControls.HtmlTableCell - + ''' '''dshExistingFiles control. ''' @@ -157,7 +166,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dshExistingFiles As DotNetNuke.UI.UserControls.SectionHeadControl - + ''' '''tblExistingFiles control. ''' @@ -166,7 +175,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents tblExistingFiles As Global.System.Web.UI.HtmlControls.HtmlTable - + ''' '''ctlFile control. ''' @@ -175,7 +184,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents ctlFile As DotNetNuke.UI.UserControls.UrlControl - + ''' '''cmdAddExistingFile control. ''' @@ -184,7 +193,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents cmdAddExistingFile As Global.System.Web.UI.WebControls.LinkButton - + ''' '''dshSelectedFiles control. ''' @@ -193,7 +202,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dshSelectedFiles As DotNetNuke.UI.UserControls.SectionHeadControl - + ''' '''tblSelectedFiles control. ''' @@ -202,7 +211,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents tblSelectedFiles As Global.System.Web.UI.HtmlControls.HtmlTable - + ''' '''dlFiles control. ''' @@ -211,7 +220,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dlFiles As Global.System.Web.UI.WebControls.DataList - + ''' '''lblNoFiles control. ''' @@ -220,7 +229,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblNoFiles As Global.System.Web.UI.WebControls.Label - + ''' '''cmdRefreshFiles control. ''' diff --git a/Controls/UploadFiles.ascx.vb b/Controls/UploadFiles.ascx.vb index 515c067..139502e 100755 --- a/Controls/UploadFiles.ascx.vb +++ b/Controls/UploadFiles.ascx.vb @@ -1,508 +1,483 @@ Imports DotNetNuke.Common.Utilities Imports DotNetNuke.Services.Exceptions -Imports DotNetNuke.Services.FileSystem Imports DotNetNuke.Security Imports Ventrian.NewsArticles.Base +Imports DotNetNuke.Entities.Portals Namespace Ventrian.NewsArticles.Controls - Partial Public Class UploadFiles - Inherits NewsArticleControlBase + Partial Public Class UploadFiles + Inherits NewsArticleControlBase #Region " Private Members " - Private _articleID As Integer = Null.NullInteger + Private _articleID As Integer = Null.NullInteger - Private _filesInit As Boolean = False - Private _objFiles As List(Of FileInfo) + Private _filesInit As Boolean = False + Private _objFiles As List(Of FileInfo) #End Region #Region " Private Properties " - Private ReadOnly Property ArticleModuleBase() As NewsArticleModuleBase - Get - Return CType(Parent.Parent.Parent.Parent.Parent, NewsArticleModuleBase) - End Get - End Property + Private ReadOnly Property ArticleModuleBase() As NewsArticleModuleBase + Get + Return CType(Parent.Parent.Parent.Parent.Parent, NewsArticleModuleBase) + End Get + End Property - Private ReadOnly Property ArticleSettings() As ArticleSettings - Get - Return ArticleModuleBase.ArticleSettings - End Get - End Property + Private ReadOnly Property ArticleSettings() As ArticleSettings + Get + Return ArticleModuleBase.ArticleSettings + End Get + End Property #End Region #Region " Public Properties " - Public Property ArticleGuid() As Integer - Get - If (_articleID = Null.NullInteger) Then - If (litArticleGuid.Text = Null.NullString) Then - litArticleGuid.Text = (GetRandom(1, 100000) * -1).ToString() - End If - Return Convert.ToInt32(litArticleGuid.Text) - End If - Return _articleID - End Get - Set(ByVal value As Integer) - litArticleGuid.Text = value - End Set - End Property - - Public ReadOnly Property AttachedFiles() As List(Of FileInfo) - Get - - If (_filesInit = False) Then - '_objFiles = objFileController.GetFileList(_articleID, ArticleGuid) - If (_articleID = Null.NullInteger) Then - _objFiles = FileProvider.Instance().GetFiles(ArticleGuid) - Else - _objFiles = FileProvider.Instance().GetFiles(_articleID) - End If - _filesInit = True - End If - - Return _objFiles - - End Get - End Property + Public Property ArticleGuid() As Integer + Get + If (_articleID = Null.NullInteger) Then + If (litArticleGuid.Text = Null.NullString) Then + litArticleGuid.Text = (GetRandom(1, 100000) * -1).ToString() + End If + Return Convert.ToInt32(litArticleGuid.Text) + End If + Return _articleID + End Get + Set(ByVal value As Integer) + litArticleGuid.Text = value + End Set + End Property + + Public ReadOnly Property AttachedFiles() As List(Of FileInfo) + Get + + If (_filesInit = False) Then + '_objFiles = objFileController.GetFileList(_articleID, ArticleGuid) + If (_articleID = Null.NullInteger) Then + _objFiles = FileProvider.Instance().GetFiles(ArticleGuid) + Else + _objFiles = FileProvider.Instance().GetFiles(_articleID) + End If + _filesInit = True + End If + + Return _objFiles + + End Get + End Property #End Region #Region " Private Methods " - Private Sub BindFiles() + Private Sub BindFiles() - dlFiles.DataSource = AttachedFiles - dlFiles.DataBind() + dlFiles.DataSource = AttachedFiles + dlFiles.DataBind() - dlFiles.Visible = (dlFiles.Items.Count > 0) - lblNoFiles.Visible = (dlFiles.Items.Count = 0) + dlFiles.Visible = (dlFiles.Items.Count > 0) + lblNoFiles.Visible = (dlFiles.Items.Count = 0) - End Sub + End Sub - Private Sub BindFolders() + Private Sub BindFolders() - Dim ReadRoles As String = Null.NullString - Dim WriteRoles As String = Null.NullString + Dim ReadRoles As String = Null.NullString + Dim WriteRoles As String = Null.NullString - drpUploadFilesFolder.Items.Clear() + drpUploadFilesFolder.Items.Clear() - Dim folders As ArrayList = FileSystemUtils.GetFolders(ArticleModuleBase.PortalId) - For Each folder As FolderInfo In folders - Dim FolderItem As New ListItem() - If folder.FolderPath = Null.NullString Then - FolderItem.Text = ArticleModuleBase.GetSharedResource("Root") - ReadRoles = FileSystemUtils.GetRoles("", ArticleModuleBase.PortalId, "READ") - WriteRoles = FileSystemUtils.GetRoles("", ArticleModuleBase.PortalId, "WRITE") - Else - FolderItem.Text = folder.FolderPath - ReadRoles = FileSystemUtils.GetRoles(FolderItem.Text, ArticleModuleBase.PortalId, "READ") - WriteRoles = FileSystemUtils.GetRoles(FolderItem.Text, ArticleModuleBase.PortalId, "WRITE") - End If - FolderItem.Value = folder.FolderID + Dim folders As ArrayList = FileSystemUtils.GetFolders(ArticleModuleBase.PortalId) + For Each folder As DotNetNuke.Services.FileSystem.FolderInfo In folders + If Not folder.IsProtected Then + Dim FolderItem As New ListItem() + If folder.FolderPath = Null.NullString Then + FolderItem.Text = ArticleModuleBase.GetSharedResource("Root") + ReadRoles = FileSystemUtils.GetRoles("", ArticleModuleBase.PortalId, "READ") + WriteRoles = FileSystemUtils.GetRoles("", ArticleModuleBase.PortalId, "WRITE") + Else + FolderItem.Text = folder.FolderPath + ReadRoles = FileSystemUtils.GetRoles(FolderItem.Text, ArticleModuleBase.PortalId, "READ") + WriteRoles = FileSystemUtils.GetRoles(FolderItem.Text, ArticleModuleBase.PortalId, "WRITE") + End If + FolderItem.Value = folder.FolderID - If PortalSecurity.IsInRoles(ReadRoles) OrElse PortalSecurity.IsInRoles(WriteRoles) Then - drpUploadFilesFolder.Items.Add(FolderItem) + If PortalSecurity.IsInRoles(ReadRoles) OrElse PortalSecurity.IsInRoles(WriteRoles) Then + drpUploadFilesFolder.Items.Add(FolderItem) + End If End If Next If (drpUploadFilesFolder.Items.FindByValue(ArticleSettings.DefaultFilesFolder.ToString()) IsNot Nothing) Then - drpUploadFilesFolder.SelectedValue = ArticleSettings.DefaultFilesFolder.ToString() - End If + drpUploadFilesFolder.SelectedValue = ArticleSettings.DefaultFilesFolder.ToString() + End If - End Sub + End Sub - Protected Function GetArticleID() As String + Protected Function GetArticleID() As String - Return _articleID.ToString() + Return _articleID.ToString() - End Function + End Function - Protected Function GetMaximumFileSize() As String + Protected Function GetMaximumFileSize() As String - Return "20480" + Return "20480" - End Function + End Function - Protected Function GetPostBackReference() As String + Private Function GetRandom(ByVal Min As Integer, ByVal Max As Integer) As Integer + Dim Generator As System.Random = New System.Random() + Return Generator.Next(Min, Max) + End Function - Return Page.ClientScript.GetPostBackEventReference(cmdRefreshFiles, "Refresh") + Public Function GetResourceKey(ByVal key As String) As String - End Function + Dim path As String = "~/DesktopModules/DnnForge - NewsArticles/App_LocalResources/UploadFiles.ascx.resx" + Return DotNetNuke.Services.Localization.Localization.GetString(key, path) - Private Function GetRandom(ByVal Min As Integer, ByVal Max As Integer) As Integer - Dim Generator As System.Random = New System.Random() - Return Generator.Next(Min, Max) - End Function + End Function - Public Function GetResourceKey(ByVal key As String) As String - - Dim path As String = "~/DesktopModules/DnnForge - NewsArticles/App_LocalResources/UploadFiles.ascx.resx" - Return DotNetNuke.Services.Localization.Localization.GetString(key, path) - - End Function - - Protected Function GetUploadUrl() As String - - Dim link As String = Page.ResolveUrl("~/DesktopModules/DnnForge%20-%20NewsArticles/Controls/SWFUploaderFiles.ashx?PortalID=" & ArticleModuleBase.PortalId.ToString()) - - If (link.ToLower().StartsWith("http")) Then - Return link - Else - If (Request.Url.Port = 80) Then - Return DotNetNuke.Common.AddHTTP(Request.Url.Host & link) - Else - Return DotNetNuke.Common.AddHTTP(Request.Url.Host & ":" & Request.Url.Port.ToString() & link) - End If - End If - - End Function - - Private Sub ReadQueryString() - - If (ArticleSettings.UrlModeType = Components.Types.UrlModeType.Shorterned) Then - Try - If (IsNumeric(Request(ArticleSettings.ShortenedID))) Then - _articleID = Convert.ToInt32(Request(ArticleSettings.ShortenedID)) - End If - Catch - End Try - End If + Private Sub ReadQueryString() - If (IsNumeric(Request("ArticleID"))) Then - _articleID = Convert.ToInt32(Request("ArticleID")) - End If + If (ArticleSettings.UrlModeType = Components.Types.UrlModeType.Shorterned) Then + Try + If (IsNumeric(Request(ArticleSettings.ShortenedID))) Then + _articleID = Convert.ToInt32(Request(ArticleSettings.ShortenedID)) + End If + Catch + End Try + End If - End Sub + If (IsNumeric(Request("ArticleID"))) Then + _articleID = Convert.ToInt32(Request("ArticleID")) + End If - Private Sub RegisterScripts() + End Sub - DotNetNuke.Framework.jQuery.RequestRegistration() + Private Sub RegisterScripts() - 'If (HttpContext.Current.Items("jquery_registered") Is Nothing And HttpContext.Current.Items("jQueryRequested") Is Nothing) Then - ' If (HttpContext.Current.Items("PropertyAgent-jQuery-ScriptsRegistered") Is Nothing And HttpContext.Current.Items("SimpleGallery-ScriptsRegistered") Is Nothing And HttpContext.Current.Items("NewsArticles-ScriptsRegistered") Is Nothing) Then - ' Dim objCSS As System.Web.UI.Control = Page.FindControl("CSS") + DotNetNuke.Framework.JavaScriptLibraries.JavaScript.RequestRegistration(DotNetNuke.Framework.JavaScriptLibraries.CommonJs.jQuery) - ' If Not (objCSS Is Nothing) Then - ' Dim litLink As New Literal - ' litLink.Text = "" & vbCrLf _ - ' & "" & vbCrLf - ' objCSS.Controls.Add(litLink) - ' End If - ' HttpContext.Current.Items.Add("NewsArticles-ScriptsRegistered", "true") - ' End If - 'End If + End Sub - End Sub + Private Sub SetLocalization() - Private Sub SetLocalization() + dshFiles.Text = GetResourceKey("Files") + lblFilesHelp.Text = GetResourceKey("FilesHelp") - dshFiles.Text = GetResourceKey("Files") - lblFilesHelp.Text = GetResourceKey("FilesHelp") + dshExistingFiles.Text = GetResourceKey("SelectExisting") + dshUploadFiles.Text = GetResourceKey("UploadFiles") + dshSelectedFiles.Text = GetResourceKey("SelectedFiles") - dshExistingFiles.Text = GetResourceKey("SelectExisting") - dshUploadFiles.Text = GetResourceKey("UploadFiles") - dshSelectedFiles.Text = GetResourceKey("SelectedFiles") + lblNoFiles.Text = GetResourceKey("NoFiles") - lblNoFiles.Text = GetResourceKey("NoFiles") + cmdAddExistingFile.Text = GetResourceKey("cmdAddExistingFile") - cmdAddExistingFile.Text = GetResourceKey("cmdAddExistingFile") + btUpload.Text = GetResourceKey("Upload") - End Sub + End Sub #End Region #Region " Public Methods " - Public Sub UpdateFiles(ByVal articleID As Integer) + Public Sub UpdateFiles(ByVal articleID As Integer) - For Each objFile As FileInfo In AttachedFiles - objFile.ArticleID = articleID - FileProvider.Instance().UpdateFile(objFile) - ' objFileController.Update(objFile) - Next + For Each objFile As FileInfo In AttachedFiles + objFile.ArticleID = articleID + FileProvider.Instance().UpdateFile(objFile) + Next - End Sub + End Sub #End Region #Region " Event Handlers " - Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load + Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load - Try + Try + ReadQueryString() + SetLocalization() - ReadQueryString() - SetLocalization() + If (ArticleSettings.IsFilesEnabled = False) Then + Me.Visible = False + Return + End If - 'trUpload.Visible = ArticleSettings.EnableImagesUpload - 'trExisting.Visible = ArticleSettings.EnablePortalImages + If (IsPostBack = False) Then - 'phFiles.Visible = (trUpload.Visible Or trExisting.Visible) + litModuleID.Text = Me.ArticleModuleBase.ModuleId.ToString() + litTabModuleID.Text = Me.ArticleModuleBase.TabModuleId.ToString() - If (ArticleSettings.IsFilesEnabled = False) Then - Me.Visible = False - Return - End If + If (Request.IsAuthenticated) Then + litTicketID.Text = Request.Cookies(System.Web.Security.FormsAuthentication.FormsCookieName()).Value + End If + litArticleGuid.Text = ArticleGuid.ToString() - If (IsPostBack = False) Then + BindFolders() + BindFiles() + End If - lblSelectFiles.Text = GetResourceKey("SelectFiles") - litModuleID.Text = Me.ArticleModuleBase.ModuleId.ToString() - litTabModuleID.Text = Me.ArticleModuleBase.TabModuleId.ToString() + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try - If (Request.IsAuthenticated) Then - litTicketID.Text = Request.Cookies(System.Web.Security.FormsAuthentication.FormsCookieName()).Value - End If - litArticleGuid.Text = ArticleGuid.ToString() + End Sub - BindFolders() - BindFiles() - End If + Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try + Try - End Sub + RegisterScripts() - Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try - Try + End Sub - RegisterScripts() + Protected Sub cmdRefreshPhotos_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdRefreshFiles.Click - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try + Try - End Sub + BindFiles() - Protected Sub cmdRefreshPhotos_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdRefreshFiles.Click + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try - Try + End Sub - BindFiles() - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try + Private Sub dlFiles_OnItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlFiles.ItemDataBound - End Sub + Try + If (e.Item.ItemType = Web.UI.WebControls.ListItemType.Item Or e.Item.ItemType = Web.UI.WebControls.ListItemType.AlternatingItem) Then - Private Sub dlFiles_OnItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlFiles.ItemDataBound + Dim objFile As FileInfo = CType(e.Item.DataItem, FileInfo) - Try + Dim btnEdit As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnEdit"), System.Web.UI.WebControls.ImageButton) + Dim btnDelete As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnDelete"), System.Web.UI.WebControls.ImageButton) + Dim btnUp As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnUp"), System.Web.UI.WebControls.ImageButton) + Dim btnDown As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnDown"), System.Web.UI.WebControls.ImageButton) - If (e.Item.ItemType = Web.UI.WebControls.ListItemType.Item Or e.Item.ItemType = Web.UI.WebControls.ListItemType.AlternatingItem) Then + If Not (btnDelete Is Nothing) Then + btnDelete.Attributes.Add("onClick", "javascript:return confirm('" & GetResourceKey("DeleteFile") & "');") - Dim objFile As FileInfo = CType(e.Item.DataItem, FileInfo) + If Not (objFile Is Nothing) Then + btnDelete.CommandArgument = objFile.FileID.ToString() + End If - Dim btnEdit As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnEdit"), System.Web.UI.WebControls.ImageButton) - Dim btnDelete As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnDelete"), System.Web.UI.WebControls.ImageButton) - Dim btnUp As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnUp"), System.Web.UI.WebControls.ImageButton) - Dim btnDown As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnDown"), System.Web.UI.WebControls.ImageButton) + End If - If Not (btnDelete Is Nothing) Then - btnDelete.Attributes.Add("onClick", "javascript:return confirm('" & GetResourceKey("DeleteFile") & "');") + If Not (btnEdit Is Nothing) Then - If Not (objFile Is Nothing) Then - btnDelete.CommandArgument = objFile.FileID.ToString() - End If + If Not (objFile Is Nothing) Then + btnEdit.CommandArgument = objFile.FileID.ToString() + End If - End If + End If - If Not (btnEdit Is Nothing) Then + If Not (btnUp Is Nothing And btnDown Is Nothing) Then - If Not (objFile Is Nothing) Then - btnEdit.CommandArgument = objFile.FileID.ToString() - End If + If (objFile.FileID = CType(AttachedFiles(0), FileInfo).FileID) Then + btnUp.Visible = False + End If - End If + If (objFile.FileID = CType(AttachedFiles(AttachedFiles.Count - 1), FileInfo).FileID) Then + btnDown.Visible = False + End If - If Not (btnUp Is Nothing And btnDown Is Nothing) Then + btnUp.CommandArgument = objFile.FileID.ToString() + btnUp.CommandName = "Up" + btnUp.CausesValidation = False - If (objFile.FileID = CType(AttachedFiles(0), FileInfo).FileID) Then - btnUp.Visible = False - End If + btnDown.CommandArgument = objFile.FileID.ToString() + btnDown.CommandName = "Down" + btnDown.CausesValidation = False - If (objFile.FileID = CType(AttachedFiles(AttachedFiles.Count - 1), FileInfo).FileID) Then - btnDown.Visible = False - End If + End If - btnUp.CommandArgument = objFile.FileID.ToString() - btnUp.CommandName = "Up" - btnUp.CausesValidation = False + End If - btnDown.CommandArgument = objFile.FileID.ToString() - btnDown.CommandName = "Down" - btnDown.CausesValidation = False + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try - End If + End Sub - End If + Private Sub dlFiles_OnItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlFiles.ItemCommand - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try + Try - End Sub + If (e.CommandName = "Delete") Then - Private Sub dlFiles_OnItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlFiles.ItemCommand + Dim objFile As FileInfo = FileProvider.Instance().GetFile(Convert.ToInt32(e.CommandArgument)) - Try + If Not (objFile Is Nothing) Then + FileProvider.Instance().DeleteFile(_articleID, Convert.ToInt32(e.CommandArgument)) + End If - If (e.CommandName = "Delete") Then + End If - Dim objFile As FileInfo = FileProvider.Instance().GetFile(Convert.ToInt32(e.CommandArgument)) + If (e.CommandName = "Edit") Then - If Not (objFile Is Nothing) Then - 'Dim objPortalSettings As PortalSettings = PortalController.GetCurrentPortalSettings() - 'Dim filePath As String = objPortalSettings.HomeDirectoryMapPath & objFile.Folder & objFile.FileName - 'If (File.Exists(filePath)) Then - ' File.Delete(filePath) - 'End If - FileProvider.Instance().DeleteFile(_articleID, Convert.ToInt32(e.CommandArgument)) - ' objFileController.Delete(Convert.ToInt32(e.CommandArgument)) - End If + dlFiles.EditItemIndex = e.Item.ItemIndex - End If + End If - If (e.CommandName = "Edit") Then + If (e.CommandName = "Up") Then - dlFiles.EditItemIndex = e.Item.ItemIndex + Dim fileID As Integer = Convert.ToInt32(e.CommandArgument) - End If + For i As Integer = 0 To AttachedFiles.Count - 1 + Dim objFile As FileInfo = CType(AttachedFiles(i), FileInfo) + If (fileID = objFile.FileID) Then - If (e.CommandName = "Up") Then + Dim objFileToSwap As FileInfo = CType(AttachedFiles(i - 1), FileInfo) - Dim fileID As Integer = Convert.ToInt32(e.CommandArgument) + Dim sortOrder As Integer = objFile.SortOrder + Dim sortOrderPrevious As Integer = objFileToSwap.SortOrder - For i As Integer = 0 To AttachedFiles.Count - 1 - Dim objFile As FileInfo = CType(AttachedFiles(i), FileInfo) - If (fileID = objFile.FileID) Then + objFile.SortOrder = sortOrderPrevious + objFileToSwap.SortOrder = sortOrder - Dim objFileToSwap As FileInfo = CType(AttachedFiles(i - 1), FileInfo) + FileProvider.Instance().UpdateFile(objFile) + FileProvider.Instance().UpdateFile(objFileToSwap) - Dim sortOrder As Integer = objFile.SortOrder - Dim sortOrderPrevious As Integer = objFileToSwap.SortOrder + End If + Next - objFile.SortOrder = sortOrderPrevious - objFileToSwap.SortOrder = sortOrder + End If - FileProvider.Instance().UpdateFile(objFile) - FileProvider.Instance().UpdateFile(objFileToSwap) + If (e.CommandName = "Down") Then - End If - Next + Dim fileID As Integer = Convert.ToInt32(e.CommandArgument) - End If + For i As Integer = 0 To AttachedFiles.Count - 1 + Dim objFile As FileInfo = CType(AttachedFiles(i), FileInfo) + If (fileID = objFile.FileID) Then + Dim objFileToSwap As FileInfo = CType(AttachedFiles(i + 1), FileInfo) - If (e.CommandName = "Down") Then + Dim sortOrder As Integer = objFile.SortOrder + Dim sortOrderNext As Integer = objFileToSwap.SortOrder - Dim fileID As Integer = Convert.ToInt32(e.CommandArgument) + objFile.SortOrder = sortOrderNext + objFileToSwap.SortOrder = sortOrder - For i As Integer = 0 To AttachedFiles.Count - 1 - Dim objFile As FileInfo = CType(AttachedFiles(i), FileInfo) - If (fileID = objFile.FileID) Then - Dim objFileToSwap As FileInfo = CType(AttachedFiles(i + 1), FileInfo) + FileProvider.Instance().UpdateFile(objFile) + FileProvider.Instance().UpdateFile(objFileToSwap) + End If + Next - Dim sortOrder As Integer = objFile.SortOrder - Dim sortOrderNext As Integer = objFileToSwap.SortOrder + End If - objFile.SortOrder = sortOrderNext - objFileToSwap.SortOrder = sortOrder + If (e.CommandName = "Cancel") Then - FileProvider.Instance().UpdateFile(objFile) - FileProvider.Instance().UpdateFile(objFileToSwap) - End If - Next + dlFiles.EditItemIndex = -1 - End If + End If - If (e.CommandName = "Cancel") Then + If (e.CommandName = "Update") Then - dlFiles.EditItemIndex = -1 + Dim txtTitle As TextBox = CType(e.Item.FindControl("txtTitle"), TextBox) - End If + Dim objFile As FileInfo = FileProvider.Instance().GetFile(Convert.ToInt32(dlFiles.DataKeys(e.Item.ItemIndex))) - If (e.CommandName = "Update") Then + If Not (objFile Is Nothing) Then + objFile.Title = txtTitle.Text + FileProvider.Instance().UpdateFile(objFile) + End If - Dim txtTitle As TextBox = CType(e.Item.FindControl("txtTitle"), TextBox) + dlFiles.EditItemIndex = -1 - Dim objFile As FileInfo = FileProvider.Instance().GetFile(Convert.ToInt32(dlFiles.DataKeys(e.Item.ItemIndex))) + End If - If Not (objFile Is Nothing) Then - objFile.Title = txtTitle.Text - FileProvider.Instance().UpdateFile(objFile) - End If + _filesInit = False + BindFiles() - dlFiles.EditItemIndex = -1 + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try - End If + End Sub - _filesInit = False - BindFiles() + Protected Sub cmdAddExistingFile_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdAddExistingFile.Click - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try + Try - End Sub + If (ctlFile.Url <> "") Then + If (ctlFile.Url.ToLower().StartsWith("fileid=")) Then + If (IsNumeric(ctlFile.Url.ToLower().Replace("fileid=", ""))) Then + Dim fileID As Integer = Convert.ToInt32(ctlFile.Url.ToLower().Replace("fileid=", "")) + Dim objDnnFileController As New DotNetNuke.Services.FileSystem.FileController + Dim objDnnFile As DotNetNuke.Services.FileSystem.FileInfo = objDnnFileController.GetFileById(fileID, ArticleModuleBase.PortalId) + If (objDnnFile IsNot Nothing) Then - Protected Sub cmdAddExistingFile_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdAddExistingFile.Click + Dim objFileController As New FileController - Try + Dim objFile As New FileInfo - If (ctlFile.Url <> "") Then - If (ctlFile.Url.ToLower().StartsWith("fileid=")) Then - If (IsNumeric(ctlFile.Url.ToLower().Replace("fileid=", ""))) Then - Dim fileID As Integer = Convert.ToInt32(ctlFile.Url.ToLower().Replace("fileid=", "")) - Dim objDnnFileController As New DotNetNuke.Services.FileSystem.FileController - Dim objDnnFile As DotNetNuke.Services.FileSystem.FileInfo = objDnnFileController.GetFileById(fileID, ArticleModuleBase.PortalId) - If (objDnnFile IsNot Nothing) Then + objFile.ArticleID = _articleID + If (_articleID = Null.NullInteger) Then + objFile.ArticleID = ArticleGuid + End If + objFile.FileName = objDnnFile.FileName + objFile.ContentType = objDnnFile.ContentType + objFile.SortOrder = 0 + Dim filesList As List(Of FileInfo) = objFileController.GetFileList(_articleID, ArticleGuid) + If (filesList.Count > 0) Then + objFile.SortOrder = CType(filesList(filesList.Count - 1), FileInfo).SortOrder + 1 + End If + objFile.Folder = objDnnFile.Folder + objFile.Extension = objDnnFile.Extension + objFile.Size = objDnnFile.Size + objFile.Title = objFile.FileName.Replace("." & objFile.Extension, "") - Dim objFileController As New FileController + objFileController.Add(objFile) + BindFiles() - Dim objFile As New FileInfo + End If + End If + End If + End If - objFile.ArticleID = _articleID - If (_articleID = Null.NullInteger) Then - objFile.ArticleID = ArticleGuid - End If - objFile.FileName = objDnnFile.FileName - objFile.ContentType = objDnnFile.ContentType - objFile.SortOrder = 0 - Dim filesList As List(Of FileInfo) = objFileController.GetFileList(_articleID, ArticleGuid) - If (filesList.Count > 0) Then - objFile.SortOrder = CType(filesList(filesList.Count - 1), FileInfo).SortOrder + 1 - End If - objFile.Folder = objDnnFile.Folder - objFile.Extension = objDnnFile.Extension - objFile.Size = objDnnFile.Size - objFile.Title = objFile.FileName.Replace("." & objFile.Extension, "") + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try - objFileController.Add(objFile) - BindFiles() + End Sub - End If - End If - End If - End If + Protected Sub btUpload_Click(sender As Object, e As EventArgs) + Dim objFileController As New FileController + Dim objPortalController As New PortalController() + + For Each file As HttpPostedFile In fupFile.PostedFiles + If objPortalController.HasSpaceAvailable(ArticleModuleBase.PortalId, file.ContentLength) Then + + Dim folderId As Integer = Integer.Parse(drpUploadFilesFolder.SelectedValue) + If (_articleID <> Null.NullInteger) Then + FileProvider.Instance().AddFile(_articleID, ArticleModuleBase.ModuleId, folderId, file) + Else + FileProvider.Instance().AddFile(ArticleGuid, ArticleModuleBase.ModuleId, folderId, file) + End If + End If + Next - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try + DotNetNuke.Services.FileSystem.FolderManager.Instance.Synchronize(PortalController.Instance.GetCurrentPortalSettings().PortalId, drpUploadFilesFolder.SelectedItem.Text, True, True) - End Sub + BindFiles() + End Sub #End Region - End Class + End Class End Namespace \ No newline at end of file diff --git a/Controls/UploadImages.ascx b/Controls/UploadImages.ascx index 109b0ea..57c65dd 100755 --- a/Controls/UploadImages.ascx +++ b/Controls/UploadImages.ascx @@ -1,197 +1,134 @@ <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="UploadImages.ascx.vb" Inherits="Ventrian.NewsArticles.Controls.UploadImages" %> <%@ Register TagPrefix="Ventrian" Assembly="Ventrian.NewsArticles" Namespace="Ventrian.NewsArticles.Components.WebControls" %> - <%@ Register TagPrefix="dnn" TagName="SectionHead" Src="~/controls/SectionHeadControl.ascx" %> <%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> <%@ Register TagPrefix="dnn" TagName="URL" Src="~/controls/URLControl.ascx" %> - -
- + + - -
-
- - - - - - -
- - - - - - - - - -
 
- -
-
- -
-
-
-
-
- - - - - -
- - - - - -

 
-
-
-
- - - - - -
- - - - Photo
- - <%#DataBinder.Eval(Container.DataItem, "Title")%> - -
- - - - - - -
- - Photo
- -
- -
- - -
-
-
-
-
- -
- - - - - - -
-
-
- + + + + + + +
+ + + + + + + + + + + + + + + + +
+ +  
+ +
+ +
+ + +
+
+ + + + + + + + +
+ +
+
+
+
+ + + + + +
+ + + + Photo
+ + <%#DataBinder.Eval(Container.DataItem, "Title")%> + +
+ + + + + + +
+ + Photo
+ +
+ +
+ + +
+
+
+ +
+
+
+ +
+ + + + + + +
+ + +
+
+ + + diff --git a/Controls/UploadImages.ascx.designer.vb b/Controls/UploadImages.ascx.designer.vb index d3bcf32..dc3dd99 100755 --- a/Controls/UploadImages.ascx.designer.vb +++ b/Controls/UploadImages.ascx.designer.vb @@ -11,9 +11,9 @@ Option Strict On Option Explicit On Namespace Ventrian.NewsArticles.Controls - + Partial Public Class UploadImages - + ''' '''litModuleID control. ''' @@ -22,7 +22,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents litModuleID As Global.System.Web.UI.WebControls.Literal - + ''' '''litTabModuleID control. ''' @@ -31,7 +31,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents litTabModuleID As Global.System.Web.UI.WebControls.Literal - + ''' '''litTicketID control. ''' @@ -40,7 +40,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents litTicketID As Global.System.Web.UI.WebControls.Literal - + ''' '''litArticleGuid control. ''' @@ -49,16 +49,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents litArticleGuid As Global.System.Web.UI.WebControls.Literal - - ''' - '''lblSelectImages control. - ''' - ''' - '''Auto-generated field. - '''To modify move field declaration from designer file to code-behind file. - ''' - Protected WithEvents lblSelectImages As Global.System.Web.UI.WebControls.Label - + ''' '''dshImages control. ''' @@ -67,7 +58,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dshImages As DotNetNuke.UI.UserControls.SectionHeadControl - + ''' '''tblImages control. ''' @@ -76,7 +67,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents tblImages As Global.System.Web.UI.HtmlControls.HtmlTable - + ''' '''lblImagesHelp control. ''' @@ -85,7 +76,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblImagesHelp As Global.System.Web.UI.WebControls.Label - + ''' '''phImages control. ''' @@ -94,7 +85,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents phImages As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''trUpload control. ''' @@ -103,7 +94,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents trUpload As Global.System.Web.UI.HtmlControls.HtmlTableCell - + ''' '''dshUploadImages control. ''' @@ -112,7 +103,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dshUploadImages As DotNetNuke.UI.UserControls.SectionHeadControl - + ''' '''tblUploadImages control. ''' @@ -121,7 +112,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents tblUploadImages As Global.System.Web.UI.HtmlControls.HtmlTable - + ''' '''plFolder control. ''' @@ -130,7 +121,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents plFolder As Global.System.Web.UI.UserControl - + ''' '''drpUploadImageFolder control. ''' @@ -139,7 +130,34 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents drpUploadImageFolder As Global.System.Web.UI.WebControls.DropDownList - + + ''' + '''Label1 control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents Label1 As Global.System.Web.UI.UserControl + + ''' + '''fupFile control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents fupFile As Global.System.Web.UI.WebControls.FileUpload + + ''' + '''btUpload control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents btUpload As Global.System.Web.UI.WebControls.Button + ''' '''trExisting control. ''' @@ -148,7 +166,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents trExisting As Global.System.Web.UI.HtmlControls.HtmlTableCell - + ''' '''dshExistingImages control. ''' @@ -157,7 +175,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dshExistingImages As DotNetNuke.UI.UserControls.SectionHeadControl - + ''' '''tblExistingImages control. ''' @@ -166,7 +184,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents tblExistingImages As Global.System.Web.UI.HtmlControls.HtmlTable - + ''' '''ctlImage control. ''' @@ -175,6 +193,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents ctlImage As DotNetNuke.UI.UserControls.UrlControl + ''' '''cmdAddExistingImage control. ''' @@ -183,7 +202,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents cmdAddExistingImage As Global.System.Web.UI.WebControls.LinkButton - + ''' '''dshSelectedImages control. ''' @@ -192,7 +211,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dshSelectedImages As DotNetNuke.UI.UserControls.SectionHeadControl - + ''' '''tblSelectedImages control. ''' @@ -201,7 +220,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents tblSelectedImages As Global.System.Web.UI.HtmlControls.HtmlTable - + ''' '''dlImages control. ''' @@ -210,7 +229,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dlImages As Global.System.Web.UI.WebControls.DataList - + ''' '''lblNoImages control. ''' @@ -219,7 +238,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblNoImages As Global.System.Web.UI.WebControls.Label - + ''' '''phExternalImage control. ''' @@ -228,7 +247,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents phExternalImage As Global.System.Web.UI.WebControls.PlaceHolder - + ''' '''dshExternalImage control. ''' @@ -237,7 +256,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents dshExternalImage As DotNetNuke.UI.UserControls.SectionHeadControl - + ''' '''tblExternalImage control. ''' @@ -246,7 +265,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents tblExternalImage As Global.System.Web.UI.HtmlControls.HtmlTable - + ''' '''plImageUrl control. ''' @@ -255,7 +274,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents plImageUrl As Global.System.Web.UI.UserControl - + ''' '''txtImageExternal control. ''' @@ -264,7 +283,7 @@ Namespace Ventrian.NewsArticles.Controls '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtImageExternal As Global.System.Web.UI.WebControls.TextBox - + ''' '''cmdRefreshPhotos control. ''' diff --git a/Controls/UploadImages.ascx.vb b/Controls/UploadImages.ascx.vb index 223b4ae..0ac582a 100755 --- a/Controls/UploadImages.ascx.vb +++ b/Controls/UploadImages.ascx.vb @@ -4,603 +4,799 @@ Imports DotNetNuke.Common.Utilities Imports DotNetNuke.Entities.Portals Imports DotNetNuke.Services.Exceptions Imports DotNetNuke.Services.Localization -Imports DotNetNuke.Services.FileSystem Imports DotNetNuke.Security Imports Ventrian.NewsArticles.Base +Imports System.Drawing +Imports System.Drawing.Drawing2D +Imports System.Drawing.Imaging Namespace Ventrian.NewsArticles.Controls - Partial Public Class UploadImages - Inherits NewsArticleControlBase + Partial Public Class UploadImages + Inherits NewsArticleControlBase #Region " Private Members " - Private _articleID As Integer = Null.NullInteger + Private _articleID As Integer = Null.NullInteger - Private _imagesInit As Boolean = False - Private _objImages As List(Of ImageInfo) + Private _imagesInit As Boolean = False + Private _objImages As List(Of ImageInfo) #End Region #Region " Private Properties " - Private ReadOnly Property ArticleModuleBase() As NewsArticleModuleBase - Get - Return CType(Parent.Parent.Parent.Parent.Parent, NewsArticleModuleBase) - End Get - End Property + Private ReadOnly Property ArticleModuleBase() As NewsArticleModuleBase + Get + Return CType(Parent.Parent.Parent.Parent.Parent, NewsArticleModuleBase) + End Get + End Property - Private ReadOnly Property ArticleSettings() As ArticleSettings - Get - Return ArticleModuleBase.ArticleSettings - End Get - End Property + Private ReadOnly Property ArticleSettings() As ArticleSettings + Get + Return ArticleModuleBase.ArticleSettings + End Get + End Property #End Region #Region " Public Properties " - Public Property ArticleGuid() As String - Get - If (_articleID = Null.NullInteger) Then - If (litArticleGuid.Text = Null.NullString) Then - litArticleGuid.Text = Guid.NewGuid.ToString() - End If - End If - Return litArticleGuid.Text - End Get - Set(ByVal value As String) - litArticleGuid.Text = value - End Set - End Property - - Public ReadOnly Property AttachedImages() As List(Of ImageInfo) - Get - - If (_imagesInit = False) Then - Dim objImageController As New ImageController - _objImages = objImageController.GetImageList(_articleID, ArticleGuid) - _imagesInit = True - End If - - Return _objImages - - End Get - End Property - - Public Property ImageExternalUrl() As String - Get - Return txtImageExternal.Text - End Get - Set(ByVal value As String) - txtImageExternal.Text = value - End Set - End Property + Public Property ArticleGuid() As String + Get + If (_articleID = Null.NullInteger) Then + If (litArticleGuid.Text = Null.NullString) Then + litArticleGuid.Text = Guid.NewGuid.ToString() + End If + End If + Return litArticleGuid.Text + End Get + Set(ByVal value As String) + litArticleGuid.Text = value + End Set + End Property + + Public ReadOnly Property AttachedImages() As List(Of ImageInfo) + Get + + If (_imagesInit = False) Then + Dim objImageController As New ImageController + _objImages = objImageController.GetImageList(_articleID, ArticleGuid) + _imagesInit = True + End If + + Return _objImages + + End Get + End Property + + Public Property ImageExternalUrl() As String + Get + Return txtImageExternal.Text + End Get + Set(ByVal value As String) + txtImageExternal.Text = value + End Set + End Property #End Region #Region " Private Methods " - Private Sub BindFolders() - - Dim ReadRoles As String = Null.NullString - Dim WriteRoles As String = Null.NullString - - drpUploadImageFolder.Items.Clear() - - Dim folders As ArrayList = FileSystemUtils.GetFolders(ArticleModuleBase.PortalId) - For Each folder As FolderInfo In folders - Dim FolderItem As New ListItem() - If folder.FolderPath = Null.NullString Then - FolderItem.Text = ArticleModuleBase.GetSharedResource("Root") - ReadRoles = FileSystemUtils.GetRoles("", ArticleModuleBase.PortalId, "READ") - WriteRoles = FileSystemUtils.GetRoles("", ArticleModuleBase.PortalId, "WRITE") - Else - FolderItem.Text = folder.FolderPath - ReadRoles = FileSystemUtils.GetRoles(FolderItem.Text, ArticleModuleBase.PortalId, "READ") - WriteRoles = FileSystemUtils.GetRoles(FolderItem.Text, ArticleModuleBase.PortalId, "WRITE") - End If - FolderItem.Value = folder.FolderID + Private Sub BindFolders() + + Dim ReadRoles As String = Null.NullString + Dim WriteRoles As String = Null.NullString + + drpUploadImageFolder.Items.Clear() + + Dim folders As ArrayList = FileSystemUtils.GetFolders(ArticleModuleBase.PortalId) + For Each folder As DotNetNuke.Services.FileSystem.FolderInfo In folders + If Not folder.IsProtected Then + Dim FolderItem As New ListItem() + If folder.FolderPath = Null.NullString Then + FolderItem.Text = ArticleModuleBase.GetSharedResource("Root") + ReadRoles = FileSystemUtils.GetRoles("", ArticleModuleBase.PortalId, "READ") + WriteRoles = FileSystemUtils.GetRoles("", ArticleModuleBase.PortalId, "WRITE") + Else + FolderItem.Text = folder.FolderPath + ReadRoles = FileSystemUtils.GetRoles(FolderItem.Text, ArticleModuleBase.PortalId, "READ") + WriteRoles = FileSystemUtils.GetRoles(FolderItem.Text, ArticleModuleBase.PortalId, "WRITE") + End If + FolderItem.Value = folder.FolderID - If PortalSecurity.IsInRoles(ReadRoles) OrElse PortalSecurity.IsInRoles(WriteRoles) Then - drpUploadImageFolder.Items.Add(FolderItem) + If PortalSecurity.IsInRoles(ReadRoles) OrElse PortalSecurity.IsInRoles(WriteRoles) Then + drpUploadImageFolder.Items.Add(FolderItem) + End If End If Next If (drpUploadImageFolder.Items.FindByValue(ArticleSettings.DefaultImagesFolder.ToString()) IsNot Nothing) Then - drpUploadImageFolder.SelectedValue = ArticleSettings.DefaultImagesFolder.ToString() - End If + drpUploadImageFolder.SelectedValue = ArticleSettings.DefaultImagesFolder.ToString() + End If - End Sub + End Sub - Private Sub BindImages() + Private Sub BindImages() - Dim objImageController As New ImageController() + Dim objImageController As New ImageController() - dlImages.DataSource = AttachedImages - dlImages.DataBind() + dlImages.DataSource = AttachedImages + dlImages.DataBind() - dlImages.Visible = (dlImages.Items.Count > 0) - lblNoImages.Visible = (dlImages.Items.Count = 0) + dlImages.Visible = (dlImages.Items.Count > 0) + lblNoImages.Visible = (dlImages.Items.Count = 0) - End Sub + End Sub - Protected Function GetArticleID() As String + Protected Function GetArticleID() As String - Return _articleID.ToString() + Return _articleID.ToString() - End Function + End Function - Protected Function GetImageUrl(ByVal objImage As ImageInfo) As String + Protected Function GetImageUrl(ByVal objImage As ImageInfo) As String - Dim thumbWidth As Integer = 150 - Dim thumbHeight As Integer = 150 + Dim thumbWidth As Integer = 150 + Dim thumbHeight As Integer = 150 - Dim width As Integer - If (objImage.Width > thumbWidth) Then - width = thumbWidth - Else - width = objImage.Width - End If + Dim width As Integer + If (objImage.Width > thumbWidth) Then + width = thumbWidth + Else + width = objImage.Width + End If - Dim height As Integer = Convert.ToInt32(objImage.Height / (objImage.Width / width)) - If (height > thumbHeight) Then - height = thumbHeight - width = Convert.ToInt32(objImage.Width / (objImage.Height / height)) - End If + Dim height As Integer = Convert.ToInt32(objImage.Height / (objImage.Width / width)) + If (height > thumbHeight) Then + height = thumbHeight + width = Convert.ToInt32(objImage.Width / (objImage.Height / height)) + End If - Dim settings As PortalSettings = PortalController.GetCurrentPortalSettings() + Dim settings As PortalSettings = PortalController.GetCurrentPortalSettings() - Return Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/ImageHandler.ashx?Width=" & width.ToString() & "&Height=" & height.ToString() & "&HomeDirectory=" & Server.UrlEncode(settings.HomeDirectory) & "&FileName=" & Server.UrlEncode(objImage.Folder & objImage.FileName) & "&PortalID=" & settings.PortalId.ToString() & "&q=1") + Return Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/ImageHandler.ashx?Width=" & width.ToString() & "&Height=" & height.ToString() & "&HomeDirectory=" & Server.UrlEncode(settings.HomeDirectory) & "&FileName=" & Server.UrlEncode(objImage.Folder & objImage.FileName) & "&PortalID=" & settings.PortalId.ToString() & "&q=1") - End Function + End Function - Protected Function GetMaximumFileSize() As String + Protected Function GetMaximumFileSize() As String - Return "20480" + Return "20480" - End Function + End Function - Protected Function GetPostBackReference() As String + Public Function GetResourceKey(ByVal key As String) As String - Return Page.ClientScript.GetPostBackEventReference(cmdRefreshPhotos, "Refresh") + Dim path As String = "~/DesktopModules/DnnForge - NewsArticles/App_LocalResources/UploadImages.ascx.resx" + Return DotNetNuke.Services.Localization.Localization.GetString(key, path) - End Function + End Function - Public Function GetResourceKey(ByVal key As String) As String + Private Sub ReadQueryString() - Dim path As String = "~/DesktopModules/DnnForge - NewsArticles/App_LocalResources/UploadImages.ascx.resx" - Return DotNetNuke.Services.Localization.Localization.GetString(key, path) + If (ArticleSettings.UrlModeType = Components.Types.UrlModeType.Shorterned) Then + Try + If (IsNumeric(Request(ArticleSettings.ShortenedID))) Then + _articleID = Convert.ToInt32(Request(ArticleSettings.ShortenedID)) + End If + Catch + End Try + End If - End Function + If (IsNumeric(Request("ArticleID"))) Then + _articleID = Convert.ToInt32(Request("ArticleID")) + End If - Protected Function GetUploadUrl() As String + End Sub - Dim link As String = Page.ResolveUrl("~/DesktopModules/DnnForge%20-%20NewsArticles/Controls/SWFUploader.ashx?PortalID=" & ArticleModuleBase.PortalId.ToString()) + Private Sub RegisterScripts() - If (link.ToLower().StartsWith("http")) Then - Return link - Else - If (Request.Url.Port = 80) Then - Return DotNetNuke.Common.AddHTTP(Request.Url.Host & link) - Else - Return DotNetNuke.Common.AddHTTP(Request.Url.Host & ":" & Request.Url.Port.ToString() & link) - End If - End If + DotNetNuke.Framework.JavaScriptLibraries.JavaScript.RequestRegistration(DotNetNuke.Framework.JavaScriptLibraries.CommonJs.jQuery) - End Function + End Sub - Private Sub ReadQueryString() + Private Sub SetLocalization() - If (ArticleSettings.UrlModeType = Components.Types.UrlModeType.Shorterned) Then - Try - If (IsNumeric(Request(ArticleSettings.ShortenedID))) Then - _articleID = Convert.ToInt32(Request(ArticleSettings.ShortenedID)) - End If - Catch - End Try - End If + dshImages.Text = GetResourceKey("Images") + lblImagesHelp.Text = GetResourceKey("ImagesHelp") - If (IsNumeric(Request("ArticleID"))) Then - _articleID = Convert.ToInt32(Request("ArticleID")) - End If + dshExistingImages.Text = GetResourceKey("SelectExisting") + dshUploadImages.Text = GetResourceKey("UploadImages") + dshSelectedImages.Text = GetResourceKey("SelectedImages") + dshExternalImage.Text = GetResourceKey("ExternalImage") - End Sub + lblNoImages.Text = GetResourceKey("NoImages") - Private Sub RegisterScripts() + btUpload.Text = GetResourceKey("Upload") - DotNetNuke.Framework.jQuery.RequestRegistration() + End Sub - 'If (HttpContext.Current.Items("jquery_registered") Is Nothing And HttpContext.Current.Items("jQueryRequested") Is Nothing) Then - ' If (HttpContext.Current.Items("PropertyAgent-jQuery-ScriptsRegistered") Is Nothing And HttpContext.Current.Items("SimpleGallery-ScriptsRegistered") Is Nothing And HttpContext.Current.Items("NewsArticles-ScriptsRegistered") Is Nothing) Then - ' Dim objCSS As System.Web.UI.Control = Page.FindControl("CSS") +#End Region - ' If Not (objCSS Is Nothing) Then - ' Dim litLink As New Literal - ' litLink.Text = "" & vbCrLf _ - ' & "" & vbCrLf - ' If (HttpContext.Current.Items("NewsArticles-ScriptsRegistered") IsNot Nothing) Then - ' objCSS.Controls.Add(litLink) - ' End If - ' End If - ' If (HttpContext.Current.Items("NewsArticles-ScriptsRegistered") IsNot Nothing) Then - ' HttpContext.Current.Items.Add("NewsArticles-ScriptsRegistered", "true") - ' End If - ' End If - 'End If +#Region " Public Methods " - End Sub + Public Sub UpdateImages(ByVal articleID As Integer) - Private Sub SetLocalization() + Dim objImageController As New ImageController + For Each objImage As ImageInfo In AttachedImages + objImage.ArticleID = articleID + objImageController.Update(objImage) + Next - dshImages.Text = GetResourceKey("Images") - lblImagesHelp.Text = GetResourceKey("ImagesHelp") + End Sub - dshExistingImages.Text = GetResourceKey("SelectExisting") - dshUploadImages.Text = GetResourceKey("UploadImages") - dshSelectedImages.Text = GetResourceKey("SelectedImages") - dshExternalImage.Text = GetResourceKey("ExternalImage") +#End Region - lblNoImages.Text = GetResourceKey("NoImages") +#Region " Event Handlers " - End Sub + Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load -#End Region + Try + ReadQueryString() + SetLocalization() -#Region " Public Methods " + trUpload.Visible = ArticleSettings.EnableImagesUpload + trExisting.Visible = ArticleSettings.EnablePortalImages - Public Sub UpdateImages(ByVal articleID As Integer) + phImages.Visible = (trUpload.Visible Or trExisting.Visible) - Dim objImageController As New ImageController - For Each objImage As ImageInfo In AttachedImages - objImage.ArticleID = articleID - objImageController.Update(objImage) - Next + phExternalImage.Visible = ArticleSettings.EnableExternalImages - End Sub + If (ArticleSettings.IsImagesEnabled = False Or (trUpload.Visible = False And trExisting.Visible = False And phExternalImage.Visible = False)) Then + Me.Visible = False + Return + End If -#End Region + If (IsPostBack = False) Then + litModuleID.Text = Me.ArticleModuleBase.ModuleId.ToString() + litTabModuleID.Text = Me.ArticleModuleBase.TabModuleId.ToString() -#Region " Event Handlers " + If (Request.IsAuthenticated) Then + litTicketID.Text = Request.Cookies(System.Web.Security.FormsAuthentication.FormsCookieName()).Value + End If + litArticleGuid.Text = ArticleGuid.ToString() - Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load + BindFolders() + BindImages() + End If - Try + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try - ReadQueryString() - SetLocalization() + End Sub - trUpload.Visible = ArticleSettings.EnableImagesUpload - trExisting.Visible = ArticleSettings.EnablePortalImages + Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender - phImages.Visible = (trUpload.Visible Or trExisting.Visible) + Try - phExternalImage.Visible = ArticleSettings.EnableExternalImages + RegisterScripts() - If (ArticleSettings.IsImagesEnabled = False Or (trUpload.Visible = False And trExisting.Visible = False And phExternalImage.Visible = False)) Then - Me.Visible = False - Return - End If + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try - If (IsPostBack = False) Then - lblSelectImages.Text = GetResourceKey("SelectImages") - litModuleID.Text = Me.ArticleModuleBase.ModuleId.ToString() - litTabModuleID.Text = Me.ArticleModuleBase.TabModuleId.ToString() + End Sub - If (Request.IsAuthenticated) Then - litTicketID.Text = Request.Cookies(System.Web.Security.FormsAuthentication.FormsCookieName()).Value - End If - litArticleGuid.Text = ArticleGuid.ToString() + Protected Sub cmdRefreshPhotos_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdRefreshPhotos.Click - BindFolders() - BindImages() - End If + Try - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try + BindImages() - End Sub + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try - Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender + End Sub - Try - RegisterScripts() + Private Sub dlImages_OnItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlImages.ItemDataBound - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try + Try - End Sub + If (e.Item.ItemType = Web.UI.WebControls.ListItemType.Item Or e.Item.ItemType = Web.UI.WebControls.ListItemType.AlternatingItem) Then - Protected Sub cmdRefreshPhotos_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdRefreshPhotos.Click + Dim objImage As ImageInfo = CType(e.Item.DataItem, ImageInfo) - Try + Dim btnEdit As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnEdit"), System.Web.UI.WebControls.ImageButton) + Dim btnDelete As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnDelete"), System.Web.UI.WebControls.ImageButton) + Dim btnTop As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnTop"), System.Web.UI.WebControls.ImageButton) + Dim btnUp As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnUp"), System.Web.UI.WebControls.ImageButton) + Dim btnDown As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnDown"), System.Web.UI.WebControls.ImageButton) + Dim btnBottom As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnBottom"), System.Web.UI.WebControls.ImageButton) - BindImages() + If Not (btnDelete Is Nothing) Then + btnDelete.Attributes.Add("onClick", "javascript:return confirm('" & GetResourceKey("DeleteImage") & "');") - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try + If Not (objImage Is Nothing) Then + btnDelete.CommandArgument = objImage.ImageID.ToString() + End If - End Sub + End If + If Not (btnEdit Is Nothing) Then - Private Sub dlImages_OnItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlImages.ItemDataBound + If Not (objImage Is Nothing) Then + btnEdit.CommandArgument = objImage.ImageID.ToString() + End If - Try + End If - If (e.Item.ItemType = Web.UI.WebControls.ListItemType.Item Or e.Item.ItemType = Web.UI.WebControls.ListItemType.AlternatingItem) Then + If Not (btnUp Is Nothing And btnDown Is Nothing) Then - Dim objImage As ImageInfo = CType(e.Item.DataItem, ImageInfo) + If (objImage.ImageID = CType(AttachedImages(0), ImageInfo).ImageID) Then + btnUp.Visible = False + btnTop.Visible = False + End If - Dim btnEdit As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnEdit"), System.Web.UI.WebControls.ImageButton) - Dim btnDelete As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnDelete"), System.Web.UI.WebControls.ImageButton) - Dim btnTop As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnTop"), System.Web.UI.WebControls.ImageButton) - Dim btnUp As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnUp"), System.Web.UI.WebControls.ImageButton) - Dim btnDown As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnDown"), System.Web.UI.WebControls.ImageButton) - Dim btnBottom As System.Web.UI.WebControls.ImageButton = CType(e.Item.FindControl("btnBottom"), System.Web.UI.WebControls.ImageButton) + If (objImage.ImageID = CType(AttachedImages(AttachedImages.Count - 1), ImageInfo).ImageID) Then + btnDown.Visible = False + btnBottom.Visible = False + End If - If Not (btnDelete Is Nothing) Then - btnDelete.Attributes.Add("onClick", "javascript:return confirm('" & GetResourceKey("DeleteImage") & "');") + btnTop.CommandArgument = objImage.ImageID.ToString() + btnTop.CommandName = "Top" + btnTop.CausesValidation = False - If Not (objImage Is Nothing) Then - btnDelete.CommandArgument = objImage.ImageID.ToString() - End If + btnUp.CommandArgument = objImage.ImageID.ToString() + btnUp.CommandName = "Up" + btnUp.CausesValidation = False - End If + btnDown.CommandArgument = objImage.ImageID.ToString() + btnDown.CommandName = "Down" + btnDown.CausesValidation = False - If Not (btnEdit Is Nothing) Then + btnBottom.CommandArgument = objImage.ImageID.ToString() + btnBottom.CommandName = "Bottom" + btnBottom.CausesValidation = False - If Not (objImage Is Nothing) Then - btnEdit.CommandArgument = objImage.ImageID.ToString() - End If + End If - End If + End If - If Not (btnUp Is Nothing And btnDown Is Nothing) Then + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try - If (objImage.ImageID = CType(AttachedImages(0), ImageInfo).ImageID) Then - btnUp.Visible = False - btnTop.Visible = False - End If + End Sub - If (objImage.ImageID = CType(AttachedImages(AttachedImages.Count - 1), ImageInfo).ImageID) Then - btnDown.Visible = False - btnBottom.Visible = False - End If + Private Sub dlImages_OnItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlImages.ItemCommand - btnTop.CommandArgument = objImage.ImageID.ToString() - btnTop.CommandName = "Top" - btnTop.CausesValidation = False + Try - btnUp.CommandArgument = objImage.ImageID.ToString() - btnUp.CommandName = "Up" - btnUp.CausesValidation = False + Dim objImageController As New ImageController - btnDown.CommandArgument = objImage.ImageID.ToString() - btnDown.CommandName = "Down" - btnDown.CausesValidation = False + If (e.CommandName = "Delete") Then - btnBottom.CommandArgument = objImage.ImageID.ToString() - btnBottom.CommandName = "Bottom" - btnBottom.CausesValidation = False + Dim objImage As ImageInfo = objImageController.Get(Convert.ToInt32(e.CommandArgument)) - End If + If Not (objImage Is Nothing) Then + objImageController.Delete(Convert.ToInt32(e.CommandArgument), _articleID, objImage.ImageGuid) + End If - End If + End If - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try + If (e.CommandName = "Edit") Then - End Sub + dlImages.EditItemIndex = e.Item.ItemIndex - Private Sub dlImages_OnItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlImages.ItemCommand + End If - Try + If (e.CommandName = "Top") Then - Dim objImageController As New ImageController + Dim imageID As Integer = Convert.ToInt32(e.CommandArgument) - If (e.CommandName = "Delete") Then + Dim objImagesSorted As New List(Of ImageInfo) - Dim objImage As ImageInfo = objImageController.Get(Convert.ToInt32(e.CommandArgument)) + For i As Integer = 0 To AttachedImages.Count - 1 + Dim objImage As ImageInfo = CType(AttachedImages(i), ImageInfo) + If (imageID = objImage.ImageID) Then + objImagesSorted.Insert(0, objImage) + Else + objImagesSorted.Add(objImage) + End If + Next - If Not (objImage Is Nothing) Then - objImageController.Delete(Convert.ToInt32(e.CommandArgument), _articleID, objImage.ImageGuid) - End If + Dim sortOrder As Integer = 0 + For Each objImage As ImageInfo In objImagesSorted + objImage.SortOrder = sortOrder + objImageController.Update(objImage) + sortOrder = sortOrder + 1 + Next - End If + End If - If (e.CommandName = "Edit") Then + If (e.CommandName = "Up") Then - dlImages.EditItemIndex = e.Item.ItemIndex + Dim imageID As Integer = Convert.ToInt32(e.CommandArgument) - End If + For i As Integer = 0 To AttachedImages.Count - 1 + Dim objImage As ImageInfo = CType(AttachedImages(i), ImageInfo) + If (imageID = objImage.ImageID) Then - If (e.CommandName = "Top") Then + Dim objImageToSwap As ImageInfo = CType(AttachedImages(i - 1), ImageInfo) - Dim imageID As Integer = Convert.ToInt32(e.CommandArgument) + Dim sortOrder As Integer = objImage.SortOrder + Dim sortOrderPrevious As Integer = objImageToSwap.SortOrder - Dim objImagesSorted As New List(Of ImageInfo) + objImage.SortOrder = sortOrderPrevious + objImageToSwap.SortOrder = sortOrder - For i As Integer = 0 To AttachedImages.Count - 1 - Dim objImage As ImageInfo = CType(AttachedImages(i), ImageInfo) - If (imageID = objImage.ImageID) Then - objImagesSorted.Insert(0, objImage) - Else - objImagesSorted.Add(objImage) - End If - Next + objImageController.Update(objImage) + objImageController.Update(objImageToSwap) - Dim sortOrder As Integer = 0 - For Each objImage As ImageInfo In objImagesSorted - objImage.SortOrder = sortOrder - objImageController.Update(objImage) - sortOrder = sortOrder + 1 - Next + End If + Next - End If + End If - If (e.CommandName = "Up") Then + If (e.CommandName = "Down") Then - Dim imageID As Integer = Convert.ToInt32(e.CommandArgument) + Dim imageID As Integer = Convert.ToInt32(e.CommandArgument) - For i As Integer = 0 To AttachedImages.Count - 1 - Dim objImage As ImageInfo = CType(AttachedImages(i), ImageInfo) - If (imageID = objImage.ImageID) Then + For i As Integer = 0 To AttachedImages.Count - 1 + Dim objImage As ImageInfo = CType(AttachedImages(i), ImageInfo) + If (imageID = objImage.ImageID) Then + Dim objImageToSwap As ImageInfo = CType(AttachedImages(i + 1), ImageInfo) - Dim objImageToSwap As ImageInfo = CType(AttachedImages(i - 1), ImageInfo) + Dim sortOrder As Integer = objImage.SortOrder + Dim sortOrderNext As Integer = objImageToSwap.SortOrder - Dim sortOrder As Integer = objImage.SortOrder - Dim sortOrderPrevious As Integer = objImageToSwap.SortOrder + objImage.SortOrder = sortOrderNext + objImageToSwap.SortOrder = sortOrder - objImage.SortOrder = sortOrderPrevious - objImageToSwap.SortOrder = sortOrder + objImageController.Update(objImage) + objImageController.Update(objImageToSwap) + End If + Next - objImageController.Update(objImage) - objImageController.Update(objImageToSwap) + End If - End If - Next + If (e.CommandName = "Bottom") Then - End If + Dim imageID As Integer = Convert.ToInt32(e.CommandArgument) - If (e.CommandName = "Down") Then + Dim objImageEnd As ImageInfo = Nothing + Dim objImagesSorted As New List(Of ImageInfo) - Dim imageID As Integer = Convert.ToInt32(e.CommandArgument) + For i As Integer = 0 To AttachedImages.Count - 1 + Dim objImage As ImageInfo = CType(AttachedImages(i), ImageInfo) + If (imageID = objImage.ImageID) Then + objImageEnd = objImage + Else + objImagesSorted.Add(objImage) + End If + Next - For i As Integer = 0 To AttachedImages.Count - 1 - Dim objImage As ImageInfo = CType(AttachedImages(i), ImageInfo) - If (imageID = objImage.ImageID) Then - Dim objImageToSwap As ImageInfo = CType(AttachedImages(i + 1), ImageInfo) + If (objImageEnd IsNot Nothing) Then + objImagesSorted.Add(objImageEnd) - Dim sortOrder As Integer = objImage.SortOrder - Dim sortOrderNext As Integer = objImageToSwap.SortOrder + Dim sortOrder As Integer = 0 + For Each objImage As ImageInfo In objImagesSorted + objImage.SortOrder = sortOrder + objImageController.Update(objImage) + sortOrder = sortOrder + 1 + Next + End If - objImage.SortOrder = sortOrderNext - objImageToSwap.SortOrder = sortOrder + End If - objImageController.Update(objImage) - objImageController.Update(objImageToSwap) - End If - Next + If (e.CommandName = "Cancel") Then - End If + dlImages.EditItemIndex = -1 - If (e.CommandName = "Bottom") Then + End If - Dim imageID As Integer = Convert.ToInt32(e.CommandArgument) + If (e.CommandName = "Update") Then - Dim objImageEnd As ImageInfo = Nothing - Dim objImagesSorted As New List(Of ImageInfo) + Dim txtTitle As TextBox = CType(e.Item.FindControl("txtTitle"), TextBox) + Dim txtDescription As TextBox = CType(e.Item.FindControl("txtDescription"), TextBox) - For i As Integer = 0 To AttachedImages.Count - 1 - Dim objImage As ImageInfo = CType(AttachedImages(i), ImageInfo) - If (imageID = objImage.ImageID) Then - objImageEnd = objImage - Else - objImagesSorted.Add(objImage) - End If - Next + Dim objImage As ImageInfo = objImageController.Get(Convert.ToInt32(dlImages.DataKeys(e.Item.ItemIndex))) - If (objImageEnd IsNot Nothing) Then - objImagesSorted.Add(objImageEnd) + If Not (objImage Is Nothing) Then + objImage.Title = txtTitle.Text + objImage.Description = txtDescription.Text + objImageController.Update(objImage) + End If - Dim sortOrder As Integer = 0 - For Each objImage As ImageInfo In objImagesSorted - objImage.SortOrder = sortOrder - objImageController.Update(objImage) - sortOrder = sortOrder + 1 - Next - End If + dlImages.EditItemIndex = -1 - End If + End If - If (e.CommandName = "Cancel") Then + _imagesInit = False + BindImages() - dlImages.EditItemIndex = -1 + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try - End If + End Sub - If (e.CommandName = "Update") Then + Protected Sub cmdAddExistingImage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdAddExistingImage.Click - Dim txtTitle As TextBox = CType(e.Item.FindControl("txtTitle"), TextBox) - Dim txtDescription As TextBox = CType(e.Item.FindControl("txtDescription"), TextBox) + Try - Dim objImage As ImageInfo = objImageController.Get(Convert.ToInt32(dlImages.DataKeys(e.Item.ItemIndex))) + If (ctlImage.Url <> "") Then + If (ctlImage.Url.ToLower().StartsWith("fileid=")) Then + If (IsNumeric(ctlImage.Url.ToLower().Replace("fileid=", ""))) Then + Dim fileID As Integer = Convert.ToInt32(ctlImage.Url.ToLower().Replace("fileid=", "")) + Dim objFileController As New DotNetNuke.Services.FileSystem.FileController + Dim objFile As DotNetNuke.Services.FileSystem.FileInfo = objFileController.GetFileById(fileID, ArticleModuleBase.PortalId) + If (objFile IsNot Nothing) Then - If Not (objImage Is Nothing) Then - objImage.Title = txtTitle.Text - objImage.Description = txtDescription.Text - objImageController.Update(objImage) - End If + Dim objImageController As New ImageController + Dim objImage As New ImageInfo - dlImages.EditItemIndex = -1 + objImage.ArticleID = _articleID + If (_articleID = Null.NullInteger) Then + objImage.ImageGuid = ArticleGuid + End If + objImage.FileName = objFile.FileName + objImage.ContentType = objFile.ContentType + objImage.Width = objFile.Width + objImage.Height = objFile.Height + objImage.SortOrder = 0 + Dim imagesList As List(Of ImageInfo) = objImageController.GetImageList(_articleID, ArticleGuid) + If (imagesList.Count > 0) Then + objImage.SortOrder = CType(imagesList(imagesList.Count - 1), ImageInfo).SortOrder + 1 + End If + objImage.Folder = objFile.Folder + objImage.Extension = objFile.Extension + objImage.Title = objFile.FileName.Replace("." & objImage.Extension, "") + objImage.Size = objFile.Size + objImage.Description = "" - End If + objImageController.Add(objImage) + BindImages() - _imagesInit = False - BindImages() - - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try - - End Sub - - Protected Sub cmdAddExistingImage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdAddExistingImage.Click - - Try - - If (ctlImage.Url <> "") Then - If (ctlImage.Url.ToLower().StartsWith("fileid=")) Then - If (IsNumeric(ctlImage.Url.ToLower().Replace("fileid=", ""))) Then - Dim fileID As Integer = Convert.ToInt32(ctlImage.Url.ToLower().Replace("fileid=", "")) - Dim objFileController As New DotNetNuke.Services.FileSystem.FileController - Dim objFile As DotNetNuke.Services.FileSystem.FileInfo = objFileController.GetFileById(fileID, ArticleModuleBase.PortalId) - If (objFile IsNot Nothing) Then - - Dim objImageController As New ImageController - Dim objImage As New ImageInfo - - objImage.ArticleID = _articleID - If (_articleID = Null.NullInteger) Then - objImage.ImageGuid = ArticleGuid - End If - objImage.FileName = objFile.FileName - objImage.ContentType = objFile.ContentType - objImage.Width = objFile.Width - objImage.Height = objFile.Height - objImage.SortOrder = 0 - Dim imagesList As List(Of ImageInfo) = objImageController.GetImageList(_articleID, ArticleGuid) - If (imagesList.Count > 0) Then - objImage.SortOrder = CType(imagesList(imagesList.Count - 1), ImageInfo).SortOrder + 1 - End If - objImage.Folder = objFile.Folder - objImage.Extension = objFile.Extension - objImage.Title = objFile.FileName.Replace("." & objImage.Extension, "") - objImage.Size = objFile.Size - objImage.Description = "" - - objImageController.Add(objImage) - BindImages() - - End If - End If - End If - End If + End If + End If + End If + End If + + Catch exc As Exception 'Module failed to load + ProcessModuleLoadException(Me, exc) + End Try + + End Sub + + Protected Sub btUpload_Click(sender As Object, e As EventArgs) + Dim objImageController As New ImageController + Dim objPortalController As New PortalController() + + For Each objFile As HttpPostedFile In fupFile.PostedFiles + If objPortalController.HasSpaceAvailable(ArticleModuleBase.PortalId, objFile.ContentLength) Then + + Dim objImage As New ImageInfo - Catch exc As Exception 'Module failed to load - ProcessModuleLoadException(Me, exc) - End Try + objImage.ArticleID = _articleID + If (_articleID = Null.NullInteger) Then + objImage.ImageGuid = ArticleGuid + End If + objImage.FileName = objFile.FileName - End Sub + If (objFile.FileName.ToLower().EndsWith(".jpg")) Then + objImage.ContentType = "image/jpeg" + End If + If (objFile.FileName.ToLower().EndsWith(".gif")) Then + objImage.ContentType = "image/gif" + End If + + If (objFile.FileName.ToLower().EndsWith(".png")) Then + objImage.ContentType = "image/png" + End If + + Dim maxWidth As Integer = ArticleSettings.MaxImageWidth + Dim maxHeight As Integer = ArticleSettings.MaxImageHeight + + Dim photo As Drawing.Image = Drawing.Image.FromStream(objFile.InputStream) + + objImage.Width = photo.Width + objImage.Height = photo.Height + + If (objImage.Width > maxWidth) Then + objImage.Width = maxWidth + objImage.Height = Convert.ToInt32(objImage.Height / (photo.Width / maxWidth)) + End If + + If (objImage.Height > maxHeight) Then + objImage.Height = maxHeight + objImage.Width = Convert.ToInt32(photo.Width / (photo.Height / maxHeight)) + End If + + objImage.SortOrder = 0 + + Dim imagesList As List(Of ImageInfo) = objImageController.GetImageList(_articleID, ArticleGuid) + + If (imagesList.Count > 0) Then + objImage.SortOrder = CType(imagesList(imagesList.Count - 1), ImageInfo).SortOrder + 1 + End If + + Dim objPortalSettings As PortalSettings = PortalController.GetCurrentPortalSettings() + + Dim folder As String = "" + Dim folderId As Integer = Integer.Parse(drpUploadImageFolder.SelectedValue) + + If (folderId <> Null.NullInteger) Then + Dim objFolderController As New DotNetNuke.Services.FileSystem.FolderController + Dim objFolder As DotNetNuke.Services.FileSystem.FolderInfo = objFolderController.GetFolderInfo(ArticleModuleBase.PortalId, folderId) + If (objFolder IsNot Nothing) Then + folder = objFolder.FolderPath + End If + End If + + objImage.Folder = folder + + Select Case objImage.ContentType.ToLower() + Case "image/jpeg" + objImage.Extension = "jpg" + Exit Select + Case "image/gif" + objImage.Extension = "gif" + Exit Select + Case "image/png" + objImage.Extension = "png" + Exit Select + End Select + + objImage.Title = objFile.FileName.Replace("." & objImage.Extension, "") + + Dim filePath As String = objPortalSettings.HomeDirectoryMapPath & folder.Replace("/", "\") + + If Not (Directory.Exists(filePath)) Then + Directory.CreateDirectory(filePath) + End If + + If (File.Exists(filePath & objImage.FileName)) Then + For i As Integer = 1 To 100 + If (File.Exists(filePath & i.ToString() & "_" & objImage.FileName) = False) Then + objImage.FileName = i.ToString() & "_" & objImage.FileName + Exit For + End If + Next + End If + + objImage.Size = objFile.ContentLength + If ((photo.Width < maxWidth And photo.Height < maxHeight) Or (ArticleSettings.ResizeImages = False)) Then + objFile.SaveAs(filePath & objImage.FileName) + Else + Dim bmp As New Bitmap(objImage.Width, objImage.Height) + Dim g As Graphics = Graphics.FromImage(DirectCast(bmp, Drawing.Image)) + + g.InterpolationMode = InterpolationMode.HighQualityBicubic + g.SmoothingMode = SmoothingMode.HighQuality + g.PixelOffsetMode = PixelOffsetMode.HighQuality + g.CompositingQuality = CompositingQuality.HighQuality + + g.DrawImage(photo, 0, 0, objImage.Width, objImage.Height) + + If (ArticleSettings.WatermarkEnabled And ArticleSettings.WatermarkText <> "") Then + Dim crSize As SizeF = New SizeF + Dim brushColor As Brush = Brushes.Yellow + Dim fnt As Font = New Font("Verdana", 11, FontStyle.Bold) + Dim strDirection As StringFormat = New StringFormat + + strDirection.Alignment = StringAlignment.Center + crSize = g.MeasureString(ArticleSettings.WatermarkText, fnt) + + Dim yPixelsFromBottom As Integer = Convert.ToInt32(Convert.ToDouble(objImage.Height) * 0.05) + Dim yPosFromBottom As Single = Convert.ToSingle((objImage.Height - yPixelsFromBottom) - (crSize.Height / 2)) + Dim xCenterOfImage As Single = Convert.ToSingle((objImage.Width / 2)) + + g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias + + Dim semiTransBrush2 As SolidBrush = New SolidBrush(Color.FromArgb(153, 0, 0, 0)) + g.DrawString(ArticleSettings.WatermarkText, fnt, semiTransBrush2, New PointF(xCenterOfImage + 1, yPosFromBottom + 1), strDirection) + + Dim semiTransBrush As SolidBrush = New SolidBrush(Color.FromArgb(153, 255, 255, 255)) + g.DrawString(ArticleSettings.WatermarkText, fnt, semiTransBrush, New PointF(xCenterOfImage, yPosFromBottom), strDirection) + End If + + If (ArticleSettings.WatermarkEnabled And ArticleSettings.WatermarkImage <> "") Then + Dim watermark As String = objPortalSettings.HomeDirectoryMapPath & ArticleSettings.WatermarkImage + If (File.Exists(watermark)) Then + Dim imgWatermark As Image = New Bitmap(watermark) + Dim wmWidth As Integer = imgWatermark.Width + Dim wmHeight As Integer = imgWatermark.Height + + Dim objImageAttributes As New ImageAttributes() + Dim objColorMap As New ColorMap() + objColorMap.OldColor = Color.FromArgb(255, 0, 255, 0) + objColorMap.NewColor = Color.FromArgb(0, 0, 0, 0) + Dim remapTable As ColorMap() = {objColorMap} + objImageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap) + + Dim colorMatrixElements As Single()() = {New Single() {1.0F, 0.0F, 0.0F, 0.0F, 0.0F}, New Single() {0.0F, 1.0F, 0.0F, 0.0F, 0.0F}, New Single() {0.0F, 0.0F, 1.0F, 0.0F, 0.0F}, New Single() {0.0F, 0.0F, 0.0F, 0.3F, 0.0F}, New Single() {0.0F, 0.0F, 0.0F, 0.0F, 1.0F}} + Dim wmColorMatrix As New ColorMatrix(colorMatrixElements) + objImageAttributes.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.[Default], ColorAdjustType.Bitmap) + + Dim xPosOfWm As Integer = ((objImage.Width - wmWidth) - 10) + Dim yPosOfWm As Integer = 10 + + Select Case ArticleSettings.WatermarkPosition + Case WatermarkPosition.TopLeft + xPosOfWm = 10 + yPosOfWm = 10 + Exit Select + + Case WatermarkPosition.TopRight + xPosOfWm = ((objImage.Width - wmWidth) - 10) + yPosOfWm = 10 + Exit Select + + Case WatermarkPosition.BottomLeft + xPosOfWm = 10 + yPosOfWm = ((objImage.Height - wmHeight) - 10) + + Case WatermarkPosition.BottomRight + xPosOfWm = ((objImage.Width - wmWidth) - 10) + yPosOfWm = ((objImage.Height - wmHeight) - 10) + End Select + + g.DrawImage(imgWatermark, New Rectangle(xPosOfWm, yPosOfWm, wmWidth, wmHeight), 0, 0, wmWidth, wmHeight, + GraphicsUnit.Pixel, objImageAttributes) + imgWatermark.Dispose() + End If + End If + + photo.Dispose() + + Select Case objFile.ContentType.ToLower() + Case "image/jpeg" + Dim info As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders() + Dim encoderParameters As New EncoderParameters(1) + encoderParameters.Param(0) = New EncoderParameter(Encoder.Quality, 100L) + bmp.Save(filePath & objImage.FileName, info(1), encoderParameters) + + Case "image/gif" + 'Dim quantizer As New ImageQuantization.OctreeQuantizer(255, 8) + 'Dim bmpQuantized As Bitmap = quantizer.Quantize(bmp) + 'bmpQuantized.Save(filePath & objPhoto.Filename, ImageFormat.Gif) + ' Not working in medium trust. + bmp.Save(filePath & objImage.FileName, ImageFormat.Gif) + + Case Else + 'Shouldn't get to here because of validators. + Dim info As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders() + Dim encoderParameters As New EncoderParameters(1) + encoderParameters.Param(0) = New EncoderParameter(Encoder.Quality, 100L) + bmp.Save(filePath & objImage.FileName, info(1), encoderParameters) + End Select + + bmp.Dispose() + + If (File.Exists(filePath & objImage.FileName)) Then + Dim fi As New IO.FileInfo(filePath & objImage.FileName) + If (fi IsNot Nothing) Then + objImage.Size = Convert.ToInt32(fi.Length) + End If + End If + End If + + objImage.ImageID = objImageController.Add(objImage) + + If (_articleID <> Null.NullInteger) Then + Dim objArticleController As New ArticleController + Dim objArticle As ArticleInfo = objArticleController.GetArticle(_articleID) + If (objArticle IsNot Nothing) Then + objArticle.ImageCount = objArticle.ImageCount + 1 + objArticleController.UpdateArticle(objArticle) + End If + End If + + End If + Next + + DotNetNuke.Services.FileSystem.FolderManager.Instance.Synchronize(PortalController.Instance.GetCurrentPortalSettings().PortalId, drpUploadImageFolder.SelectedItem.Text, True, True) + + BindImages() + End Sub #End Region - End Class + End Class End Namespace \ No newline at end of file diff --git a/My Project/Application.Designer.vb b/My Project/Application.Designer.vb index abb97d9..db8b8b3 100755 --- a/My Project/Application.Designer.vb +++ b/My Project/Application.Designer.vb @@ -1,7 +1,7 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:4.0.30319.17929 +' Runtime Version:4.0.30319.42000 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. diff --git a/My Project/Resources.Designer.vb b/My Project/Resources.Designer.vb index 02a2246..daaa2f6 100755 --- a/My Project/Resources.Designer.vb +++ b/My Project/Resources.Designer.vb @@ -1,7 +1,7 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:4.0.30319.17929 +' Runtime Version:4.0.30319.42000 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. diff --git a/My Project/Settings.Designer.vb b/My Project/Settings.Designer.vb index 8f257c0..da211fc 100755 --- a/My Project/Settings.Designer.vb +++ b/My Project/Settings.Designer.vb @@ -1,7 +1,7 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:4.0.30319.17929 +' Runtime Version:4.0.30319.42000 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/Providers/DataProvider/SqlDataProvider/Ventrian.NewsArticles.SqlDataProvider.vbproj b/Providers/DataProvider/SqlDataProvider/Ventrian.NewsArticles.SqlDataProvider.vbproj index b1b0253..d1b8936 100755 --- a/Providers/DataProvider/SqlDataProvider/Ventrian.NewsArticles.SqlDataProvider.vbproj +++ b/Providers/DataProvider/SqlDataProvider/Ventrian.NewsArticles.SqlDataProvider.vbproj @@ -33,7 +33,7 @@ 3.5 - v3.5 + v4.5 publish\ true @@ -69,6 +69,7 @@ 1 42016,42017,42018,42019,42032,42353,42354,42355 full + false ..\..\..\..\..\bin\ @@ -88,6 +89,7 @@ 1 42016,42017,42018,42019,42032,42353,42354,42355 none + false diff --git a/Providers/FileProvider/CoreFileProvider.vb b/Providers/FileProvider/CoreFileProvider.vb index aff6975..76f944e 100755 --- a/Providers/FileProvider/CoreFileProvider.vb +++ b/Providers/FileProvider/CoreFileProvider.vb @@ -12,102 +12,97 @@ Namespace Ventrian.NewsArticles #Region " Public Methods " - Public Overrides Function AddFile(ByVal articleID As Integer, ByVal moduleID As Integer, ByVal objPostedFile As System.Web.HttpPostedFile) As Integer - - Dim objFile As New FileInfo - - objFile.ArticleID = articleID - objFile.FileName = objPostedFile.FileName - objFile.SortOrder = 0 - - Dim filesList As List(Of FileInfo) = GetFiles(articleID) - - If (filesList.Count > 0) Then - objFile.SortOrder = CType(filesList(filesList.Count - 1), FileInfo).SortOrder + 1 - End If - - Dim objPortalSettings As PortalSettings = PortalController.GetCurrentPortalSettings() - - Dim folder As String = "" - - Dim objModuleController As New ModuleController() - Dim objSettings As Hashtable = objModuleController.GetModuleSettings(moduleID) - - Dim folderID As Integer = Null.NullInteger - If (IsNumeric(HttpContext.Current.Request.Form("FolderID"))) Then - folderID = Convert.ToInt32(HttpContext.Current.Request.Form("FolderID")) - End If - - If (folderID <> Null.NullInteger) Then - Dim objFolderController As New FolderController - Dim objFolder As FolderInfo = objFolderController.GetFolderInfo(objPortalSettings.PortalId, folderID) - If (objFolder IsNot Nothing) Then - folder = objFolder.FolderPath - End If - End If - - objFile.Folder = folder - objFile.ContentType = objPostedFile.ContentType - - If (objFile.FileName.Split("."c).Length > 0) Then - objFile.Extension = objFile.FileName.Split("."c)(objFile.FileName.Split("."c).Length - 1) - - If (objFile.Extension.ToLower() = "jpg") Then - objFile.ContentType = "image/jpeg" - End If - If (objFile.Extension.ToLower() = "gif") Then - objFile.ContentType = "image/gif" - End If - If (objFile.Extension.ToLower() = "txt") Then - objFile.ContentType = "text/plain" - End If - If (objFile.Extension.ToLower() = "html") Then - objFile.ContentType = "text/html" - End If - If (objFile.Extension.ToLower() = "mp3") Then - objFile.ContentType = "audio/mpeg" - End If - - End If - objFile.Title = objFile.FileName.Replace("." & objFile.Extension, "") - - Dim filePath As String = objPortalSettings.HomeDirectoryMapPath & folder.Replace("/", "\") - - If Not (Directory.Exists(filePath)) Then - Directory.CreateDirectory(filePath) - End If - - If (File.Exists(filePath & objFile.FileName)) Then - For i As Integer = 1 To 100 - If (File.Exists(filePath & i.ToString() & "_" & objFile.FileName) = False) Then - objFile.FileName = i.ToString() & "_" & objFile.FileName - Exit For - End If - Next - End If - - objFile.Size = objPostedFile.ContentLength - objPostedFile.SaveAs(filePath & objFile.FileName) - - Dim objFileController As New FileController - objFile.FileID = objFileController.Add(objFile) - - If (articleID > 0) Then - Dim objArticleController As New ArticleController - Dim objArticle As ArticleInfo = objArticleController.GetArticle(articleID) - objArticle.FileCount = objArticle.FileCount + 1 - objArticleController.UpdateArticle(objArticle) - End If - - Return objFile.FileID + Public Overrides Function AddFile(ByVal articleID As Integer, ByVal moduleID As Integer, folderID As Integer, ByVal objPostedFile As System.Web.HttpPostedFile) As Integer - End Function + Dim objFile As New FileInfo - Public Overrides Function AddFile(ByVal articleID As Integer, ByVal moduleID As Integer, ByVal objPostedFile As HttpPostedFile, ByVal providerParams As Object) As Integer - Return AddFile(articleID, moduleID, objPostedFile) - End Function + objFile.ArticleID = articleID + objFile.FileName = objPostedFile.FileName + objFile.SortOrder = 0 + + Dim filesList As List(Of FileInfo) = GetFiles(articleID) + + If (filesList.Count > 0) Then + objFile.SortOrder = CType(filesList(filesList.Count - 1), FileInfo).SortOrder + 1 + End If + + Dim objPortalSettings As PortalSettings = PortalController.GetCurrentPortalSettings() + + Dim folder As String = "" + + Dim objModuleController As New ModuleController() + Dim objSettings As Hashtable = objModuleController.GetModuleSettings(moduleID) + + If (folderID <> Null.NullInteger) Then + Dim objFolderController As New FolderController + Dim objFolder As FolderInfo = objFolderController.GetFolderInfo(objPortalSettings.PortalId, folderID) + If (objFolder IsNot Nothing) Then + folder = objFolder.FolderPath + End If + End If + + objFile.Folder = folder + objFile.ContentType = objPostedFile.ContentType + + If (objFile.FileName.Split("."c).Length > 0) Then + objFile.Extension = objFile.FileName.Split("."c)(objFile.FileName.Split("."c).Length - 1) + + If (objFile.Extension.ToLower() = "jpg") Then + objFile.ContentType = "image/jpeg" + End If + If (objFile.Extension.ToLower() = "gif") Then + objFile.ContentType = "image/gif" + End If + If (objFile.Extension.ToLower() = "txt") Then + objFile.ContentType = "text/plain" + End If + If (objFile.Extension.ToLower() = "html") Then + objFile.ContentType = "text/html" + End If + If (objFile.Extension.ToLower() = "mp3") Then + objFile.ContentType = "audio/mpeg" + End If + + End If + objFile.Title = objFile.FileName.Replace("." & objFile.Extension, "") + + Dim filePath As String = objPortalSettings.HomeDirectoryMapPath & folder.Replace("/", "\") + + If Not (Directory.Exists(filePath)) Then + Directory.CreateDirectory(filePath) + End If + + If (File.Exists(filePath & objFile.FileName)) Then + For i As Integer = 1 To 100 + If (File.Exists(filePath & i.ToString() & "_" & objFile.FileName) = False) Then + objFile.FileName = i.ToString() & "_" & objFile.FileName + Exit For + End If + Next + End If + + objFile.Size = objPostedFile.ContentLength + objPostedFile.SaveAs(filePath & objFile.FileName) + + Dim objFileController As New FileController + objFile.FileID = objFileController.Add(objFile) + + If (articleID > 0) Then + Dim objArticleController As New ArticleController + Dim objArticle As ArticleInfo = objArticleController.GetArticle(articleID) + objArticle.FileCount = objArticle.FileCount + 1 + objArticleController.UpdateArticle(objArticle) + End If + + Return objFile.FileID + + End Function + + Public Overrides Function AddFile(ByVal articleID As Integer, ByVal moduleID As Integer, folderID As Integer, ByVal objPostedFile As HttpPostedFile, ByVal providerParams As Object) As Integer + Return AddFile(articleID, moduleID, folderID, objPostedFile) + End Function - Public Overrides Function AddExistingFile(ByVal articleID As Integer, ByVal moduleID As Integer, ByVal providerParams As Object) As Integer + Public Overrides Function AddExistingFile(ByVal articleID As Integer, ByVal moduleID As Integer, ByVal providerParams As Object) As Integer Throw New NotImplementedException() End Function diff --git a/Providers/FileProvider/FileProvider.vb b/Providers/FileProvider/FileProvider.vb index 78f377c..0475bb5 100755 --- a/Providers/FileProvider/FileProvider.vb +++ b/Providers/FileProvider/FileProvider.vb @@ -33,9 +33,9 @@ Namespace Ventrian.NewsArticles #Region " Abstract methods " - Public MustOverride Function AddFile(ByVal articleID As Integer, ByVal moduleID As Integer, ByVal objPostedFile As System.Web.HttpPostedFile) As Integer - Public MustOverride Function AddFile(ByVal articleID As Integer, ByVal moduleID As Integer, ByVal objPostedFile As System.Web.HttpPostedFile, ByVal providerParams As Object) As Integer - Public MustOverride Function AddExistingFile(ByVal articleID As Integer, ByVal moduleID As Integer, ByVal providerParams As Object) As Integer + Public MustOverride Function AddFile(ByVal articleID As Integer, ByVal moduleID As Integer, folderID As Integer, ByVal objPostedFile As System.Web.HttpPostedFile) As Integer + Public MustOverride Function AddFile(ByVal articleID As Integer, ByVal moduleID As Integer, folderID As Integer, ByVal objPostedFile As System.Web.HttpPostedFile, ByVal providerParams As Object) As Integer + Public MustOverride Function AddExistingFile(ByVal articleID As Integer, ByVal moduleID As Integer, ByVal providerParams As Object) As Integer Public MustOverride Sub DeleteFile(ByVal articleID As Integer, ByVal fileID As Integer) Public MustOverride Function GetFile(ByVal fileID As Integer) As FileInfo Public MustOverride Function GetFiles(ByVal articleID As Integer) As List(Of FileInfo) diff --git a/SqlDataProvider/00.00.01.SqlDataProvider b/SqlDataProvider/00.00.01.SqlDataProvider new file mode 100644 index 0000000..55d4ae4 --- /dev/null +++ b/SqlDataProvider/00.00.01.SqlDataProvider @@ -0,0 +1,442 @@ +if not exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article') and OBJECTPROPERTY(id, N'IsTable') = 1) +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [ArticleID] [int] IDENTITY (1, 1) NOT NULL , + [CategoryID] [int] NOT NULL , + [AuthorID] [int] NOT NULL , + [ApproverID] [int] NULL , + [CreatedDate] [datetime] NOT NULL , + [LastUpdate] [datetime] NOT NULL , + [Title] [nvarchar] (255) NOT NULL , + [Summary] [nvarchar] (4000) NOT NULL , + [IsApproved] [bit] NOT NULL , + [NumberOfViews] [int] NOT NULL +) ON [PRIMARY] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category') and OBJECTPROPERTY(id, N'IsTable') = 1) +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ( + [CategoryID] [int] IDENTITY (1, 1) NOT NULL , + [ModuleID] [int] NOT NULL , + [Name] [nvarchar] (255) NOT NULL , + [Image] [nvarchar] (255) NULL +) ON [PRIMARY] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment') and OBJECTPROPERTY(id, N'IsTable') = 1) +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ( + [CommentID] [int] IDENTITY (1, 1) NOT NULL , + [ArticleID] [int] NOT NULL , + [UserID] [int] NOT NULL , + [CreatedDate] [datetime] NOT NULL , + [Comment] [ntext] NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'PK_{objectQualifier}DnnForge_NewsArticles_Article') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_Article] PRIMARY KEY CLUSTERED + ( + [ArticleID] + ) ON [PRIMARY] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'DF_{objectQualifier}DnnForge_NewsArticles_Article_CreatedDate') and OBJECTPROPERTY(id, N'IsConstraint') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + CONSTRAINT [DF_{objectQualifier}DnnForge_NewsArticles_Article_CreatedDate] DEFAULT (getdate()) FOR [CreatedDate] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'DF_{objectQualifier}DnnForge_NewsArticles_Article_LastUpdate') and OBJECTPROPERTY(id, N'IsConstraint') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + CONSTRAINT [DF_{objectQualifier}DnnForge_NewsArticles_Article_LastUpdate] DEFAULT (getdate()) FOR [LastUpdate] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'DF_{objectQualifier}DnnForge_NewsArticles_Article_IsApproved') and OBJECTPROPERTY(id, N'IsConstraint') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + CONSTRAINT [DF_{objectQualifier}DnnForge_NewsArticles_Article_IsApproved] DEFAULT (0) FOR [IsApproved] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'DF_{objectQualifier}DnnForge_NewsArticles_Article_NumberOfViews') and OBJECTPROPERTY(id, N'IsConstraint') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + CONSTRAINT [DF_{objectQualifier}DnnForge_NewsArticles_Article_NumberOfViews] DEFAULT (0) FOR [NumberOfViews] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'PK_{objectQualifier}DnnForge_NewsArticles_Category') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_Category] PRIMARY KEY CLUSTERED + ( + [CategoryID] + ) ON [PRIMARY] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'PK_{objectQualifier}DnnForge_NewsArticles_Comment') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_Comment] PRIMARY KEY CLUSTERED + ( + [CommentID] + ) ON [PRIMARY] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'DF_{objectQualifier}DnnForge_NewsArticles_Comment_CreatedDate') and OBJECTPROPERTY(id, N'IsConstraint') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ADD + CONSTRAINT [DF_{objectQualifier}DnnForge_NewsArticles_Comment_CreatedDate] DEFAULT (getdate()) FOR [CreatedDate] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'FK_{objectQualifier}DnnForge_NewsArticles_Article_{objectQualifier}DnnForge_NewsArticles_Category') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + CONSTRAINT [FK_{objectQualifier}DnnForge_NewsArticles_Article_{objectQualifier}DnnForge_NewsArticles_Category] FOREIGN KEY + ( + [CategoryID] + ) REFERENCES {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ( + [CategoryID] + ) ON DELETE CASCADE +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'FK_{objectQualifier}DnnForge_NewsArticles_Article_{objectQualifier}Users') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + CONSTRAINT [FK_{objectQualifier}DnnForge_NewsArticles_Article_{objectQualifier}Users] FOREIGN KEY + ( + [AuthorID] + ) REFERENCES {databaseOwner}{objectQualifier}Users ( + [UserID] + ) ON DELETE CASCADE +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'FK_{objectQualifier}DnnForge_NewsArticles_Category_{objectQualifier}Modules') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ADD + CONSTRAINT [FK_{objectQualifier}DnnForge_NewsArticles_Category_{objectQualifier}Modules] FOREIGN KEY + ( + [ModuleID] + ) REFERENCES {databaseOwner}{objectQualifier}Modules ( + [ModuleID] + ) ON DELETE CASCADE +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'FK_{objectQualifier}DnnForge_NewsArticles_Comment_{objectQualifier}DnnForge_NewsArticles_Article') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ADD + CONSTRAINT [FK_{objectQualifier}DnnForge_NewsArticles_Comment_{objectQualifier}DnnForge_NewsArticles_Article] FOREIGN KEY + ( + [ArticleID] + ) REFERENCES {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [ArticleID] + ) ON DELETE CASCADE +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteArticle') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteArticle +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteCategory') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteCategory +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteComment') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteComment +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByApproved') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByApproved +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @CategoryID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary nvarchar(4000), + @IsApproved bit, + @NumberOfViews int +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [CategoryID], + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews] +) VALUES ( + @CategoryID, + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews +) + +select SCOPE_IDENTITY() +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory + @ModuleID int, + @Name nvarchar(255), + @Image nvarchar(255) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ( + [ModuleID], + [Name], + [Image] +) VALUES ( + @ModuleID, + @Name, + @Image +) + +select SCOPE_IDENTITY() +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment + @ArticleID int, + @UserID int, + @Comment ntext +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ( + [ArticleID], + [UserID], + [Comment] +) VALUES ( + @ArticleID, + @UserID, + @Comment +) + +select SCOPE_IDENTITY() +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteArticle + @ArticleID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +WHERE + [ArticleID] = @ArticleID + +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteCategory + @CategoryID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [CategoryID] = @CategoryID + +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteComment + @CommentID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment +WHERE + [CommentID] = @CommentID + +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList + @ModuleID int +AS +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor + @ModuleID int, + @AuthorID int +AS +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByApproved + @ModuleID int, + @AuthorID int, + @IsApproved bit +AS +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID int, + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255) +AS +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory + @CategoryID int +AS + +SELECT + [CategoryID], + [ModuleID], + [Name], + [Image] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [CategoryID] = @CategoryID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList + @ModuleID int +AS + +SELECT + [CategoryID], + [ModuleID], + [Name], + [Image] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [ModuleID] = @ModuleID + +ORDER BY Name +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment + @CommentID int +AS +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList + @ArticleID int +AS +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @CategoryID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary nvarchar(4000), + @IsApproved bit, + @NumberOfViews int +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [CategoryID] = @CategoryID, + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews +WHERE + [ArticleID] = @ArticleID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory + @CategoryID int, + @ModuleID int, + @Name nvarchar(255), + @Image nvarchar(255) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category SET + [ModuleID] = @ModuleID, + [Name] = @Name, + [Image] = @Image +WHERE + [CategoryID] = @CategoryID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment + @CommentID int, + @ArticleID int, + @UserID int, + @Comment ntext +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment SET + [ArticleID] = @ArticleID, + [UserID] = @UserID, + [Comment] = @Comment +WHERE + [CommentID] = @CommentID +GO diff --git a/SqlDataProvider/00.00.02.SqlDataProvider b/SqlDataProvider/00.00.02.SqlDataProvider new file mode 100644 index 0000000..692bbf9 --- /dev/null +++ b/SqlDataProvider/00.00.02.SqlDataProvider @@ -0,0 +1,271 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + Add [IsDraft] bit NOT NULL DEFAULT 0 +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page') and OBJECTPROPERTY(id, N'IsTable') = 1) +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page ( + [PageID] [int] IDENTITY (1, 1) NOT NULL , + [ArticleID] [int] NOT NULL , + [Title] [nvarchar] (255) NOT NULL , + [PageText] [ntext] NOT NULL , + [SortOrder] [int] NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'PK_{objectQualifier}DnnForge_NewsArticles_Page') and OBJECTPROPERTY(id, N'IsPrimaryKey') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_Page] PRIMARY KEY CLUSTERED + ( + [PageID] + ) ON [PRIMARY] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'DF_{objectQualifier}DnnForge_NewsArticles_Page_SortOrder') and OBJECTPROPERTY(id, N'IsConstraint') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page ADD + CONSTRAINT [DF_{objectQualifier}DnnForge_NewsArticles_Page_SortOrder] DEFAULT (0) FOR [SortOrder] +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'FK_{objectQualifier}DnnForge_NewsArticles_Page_{objectQualifier}DnnForge_NewsArticles_Article') and OBJECTPROPERTY(id, N'IsForeignKey') = 1) +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page ADD + CONSTRAINT [FK_{objectQualifier}DnnForge_NewsArticles_Page_{objectQualifier}DnnForge_NewsArticles_Article] FOREIGN KEY + ( + [ArticleID] + ) REFERENCES {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [ArticleID] + ) ON DELETE CASCADE +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @CategoryID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary nvarchar(4000), + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [CategoryID], + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft] +) VALUES ( + @CategoryID, + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft +) + +select SCOPE_IDENTITY() +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddPage') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddPage +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddPage + @ArticleID int, + @Title nvarchar(255), + @PageText ntext, + @SortOrder int +AS + +declare @count int + +select @count = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where ArticleID = @ArticleID) + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page ( + [ArticleID], + [Title], + [PageText], + [SortOrder] +) VALUES ( + @ArticleID, + @Title, + @PageText, + @count +) + +select SCOPE_IDENTITY() +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeletePage') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeletePage +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeletePage + @PageID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page +WHERE + [PageID] = @PageID +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList + @ModuleID int +AS +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor + @ModuleID int, + @AuthorID int +AS +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByApproved') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus + @ModuleID int, + @AuthorID int, + @IsApproved bit, + @IsDraft bit +AS +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetPage') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetPage +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetPage + @PageID int +AS + +SELECT + [PageID], + [ArticleID], + [Title], + [PageText], + [SortOrder] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page +WHERE + [PageID] = @PageID +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetPageList') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetPageList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetPageList + @ArticleID int +AS + +SELECT + [PageID], + [ArticleID], + [Title], + [PageText], + [SortOrder] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page + +WHERE + [ArticleID] = @ArticleID + +ORDER BY + [SortOrder] ASC +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @CategoryID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary nvarchar(4000), + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [CategoryID] = @CategoryID, + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft +WHERE + [ArticleID] = @ArticleID +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdatePage') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdatePage +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdatePage + @PageID int, + @ArticleID int, + @Title nvarchar(255), + @PageText ntext, + @SortOrder int +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page SET + [ArticleID] = @ArticleID, + [Title] = @Title, + [PageText] = @PageText, + [SortOrder] = @SortOrder +WHERE + [PageID] = @PageID +GO diff --git a/SqlDataProvider/00.00.03.SqlDataProvider b/SqlDataProvider/00.00.03.SqlDataProvider new file mode 100644 index 0000000..c2cb0cf --- /dev/null +++ b/SqlDataProvider/00.00.03.SqlDataProvider @@ -0,0 +1,14 @@ +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID int, + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255) +AS +GO diff --git a/SqlDataProvider/00.00.04.SqlDataProvider b/SqlDataProvider/00.00.04.SqlDataProvider new file mode 100644 index 0000000..81ab8d3 --- /dev/null +++ b/SqlDataProvider/00.00.04.SqlDataProvider @@ -0,0 +1,8 @@ +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics + @ModuleID int +AS +GO diff --git a/SqlDataProvider/00.00.05.SqlDataProvider b/SqlDataProvider/00.00.05.SqlDataProvider new file mode 100644 index 0000000..0b13bbd --- /dev/null +++ b/SqlDataProvider/00.00.05.SqlDataProvider @@ -0,0 +1,255 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + StartDate datetime NULL, + EndDate datetime NULL, + ModuleID int NULL +GO + +UPDATE + {databaseOwner}{objectQualifier}dnnforge_newsarticles_article +SET + {databaseOwner}{objectQualifier}dnnforge_newsarticles_article.moduleid = (select moduleid from {databaseOwner}{objectQualifier}dnnforge_newsarticles_category where {databaseOwner}{objectQualifier}dnnforge_newsarticles_category.categoryid = {databaseOwner}{objectQualifier}dnnforge_newsarticles_article.categoryid) +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories') and OBJECTPROPERTY(id, N'IsUserTable') = 1) +drop table {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories +GO + +if not exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories') and OBJECTPROPERTY(id, N'IsUserTable') = 1) +BEGIN +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ( + [ArticleID] [int] NOT NULL , + [CategoryID] [int] NOT NULL +) ON [PRIMARY] +END +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories WITH NOCHECK ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_ArticleCategories] PRIMARY KEY CLUSTERED + ( + [ArticleID], + [CategoryID] + ) ON [PRIMARY] +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ADD + CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_ArticleCategories_DnnForge_NewsArticles_Article FOREIGN KEY + ( + [ArticleID] + ) REFERENCES {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [ArticleID] + ) , + CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_ArticleCategories_DnnForge_NewsArticles_Category FOREIGN KEY + ( + [CategoryID] + ) REFERENCES {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ( + [CategoryID] + ) +GO + +insert into {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories select ArticleID, CategoryID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + DROP CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_Article_{objectQualifier}DnnForge_NewsArticles_Category +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + DROP COLUMN CategoryID +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article WITH NOCHECK ADD CONSTRAINT + FK_{objectQualifier}DnnForge_NewsArticles_Article_Modules FOREIGN KEY + ( + ModuleID + ) REFERENCES {databaseOwner}{objectQualifier}Modules + ( + ModuleID + ) ON DELETE CASCADE + +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary nvarchar(4000), + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID +WHERE + [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary nvarchar(4000), + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList + @ModuleID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor + @ModuleID int, + @AuthorID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus + @ModuleID int, + @AuthorID int, + @IsApproved bit, + @IsDraft bit +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255) +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics + @ModuleID int +AS +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteArticleCategories + @ArticleID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories +WHERE + [ArticleID] = @ArticleID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticleCategory + @ArticleID int, + @CategoryID int +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories( ArticleID, CategoryID ) +VALUES (@ArticleID, @CategoryID) +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleCategories + @ArticleID int +AS + +SELECT + Category.CategoryID, + Category.[Name] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category Category + +WHERE + ArticleCategories.CategoryID = Category.CategoryID + AND + ArticleCategories.ArticleID = @ArticleID +GO diff --git a/SqlDataProvider/00.00.06.SqlDataProvider b/SqlDataProvider/00.00.06.SqlDataProvider new file mode 100644 index 0000000..6da1874 --- /dev/null +++ b/SqlDataProvider/00.00.06.SqlDataProvider @@ -0,0 +1,13 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255) +AS +GO diff --git a/SqlDataProvider/00.00.07.SqlDataProvider b/SqlDataProvider/00.00.07.SqlDataProvider new file mode 100644 index 0000000..04a7f21 --- /dev/null +++ b/SqlDataProvider/00.00.07.SqlDataProvider @@ -0,0 +1,144 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + ImageUrl nvarchar(255) NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary nvarchar(4000), + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary nvarchar(4000), + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl +WHERE + [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor + @ModuleID int, + @AuthorID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus + @ModuleID int, + @AuthorID int, + @IsApproved bit, + @IsDraft bit +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255) +AS +GO diff --git a/SqlDataProvider/00.00.10.SqlDataProvider b/SqlDataProvider/00.00.10.SqlDataProvider new file mode 100644 index 0000000..7a3d1a5 --- /dev/null +++ b/SqlDataProvider/00.00.10.SqlDataProvider @@ -0,0 +1,15 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteArticle + @ArticleID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories +WHERE + [ArticleID] = @ArticleID + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +WHERE + [ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.01.00.SqlDataProvider b/SqlDataProvider/00.01.00.SqlDataProvider new file mode 100644 index 0000000..a1da093 --- /dev/null +++ b/SqlDataProvider/00.01.00.SqlDataProvider @@ -0,0 +1,269 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + IsFeatured bit NOT NULL CONSTRAINT DF_{objectQualifier}DnnForge_NewsArticles_Article_IsFeatured DEFAULT 0 +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment + DROP CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_Comment_{objectQualifier}DnnForge_NewsArticles_Article +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ADD + Rating float NULL, + RemoteAddress nvarchar(50) NULL +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment WITH NOCHECK ADD CONSTRAINT + FK_{objectQualifier}DnnForge_NewsArticles_Comment_{objectQualifier}DnnForge_NewsArticles_Article FOREIGN KEY + ( + ArticleID + ) REFERENCES {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + ( + ArticleID + ) ON DELETE CASCADE + +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary nvarchar(4000), + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl], + [IsFeatured] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl, + @IsFeatured +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary nvarchar(4000), + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl, + [IsFeatured] = @IsFeatured +WHERE + [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor + @ModuleID int, + @AuthorID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus + @ModuleID int, + @AuthorID int, + @IsApproved bit, + @IsDraft bit +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList + @ModuleID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment + @ArticleID int, + @UserID int, + @Comment ntext, + @Rating float, + @RemoteAddress nvarchar(50) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ( + [ArticleID], + [UserID], + [Comment], + [Rating], + [RemoteAddress] +) VALUES ( + @ArticleID, + @UserID, + @Comment, + @Rating, + @RemoteAddress +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment + @CommentID int, + @ArticleID int, + @UserID int, + @Comment ntext, + @Rating float, + @RemoteAddress nvarchar(50) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment SET + [ArticleID] = @ArticleID, + [UserID] = @UserID, + [Comment] = @Comment, + [Rating] = @Rating, + [RemoteAddress] = @RemoteAddress +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment + @CommentID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList + @ArticleID int +AS +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorList + @ModuleID int +AS + +SELECT DISTINCT + Authors.UserID, + Authors.Username, + Authors.FirstName, + Authors.LastName + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles, {databaseOwner}{objectQualifier}Users Authors + +WHERE + Articles.AuthorID = Authors.UserID + and + Articles.ModuleID = @ModuleID + and + Articles.IsApproved = 1 + +ORDER BY + Authors.FirstName, Authors.LastName +GO diff --git a/SqlDataProvider/00.01.01.SqlDataProvider b/SqlDataProvider/00.01.01.SqlDataProvider new file mode 100644 index 0000000..3479865 --- /dev/null +++ b/SqlDataProvider/00.01.01.SqlDataProvider @@ -0,0 +1,16 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit +AS +GO diff --git a/SqlDataProvider/00.01.02.SqlDataProvider b/SqlDataProvider/00.01.02.SqlDataProvider new file mode 100644 index 0000000..d7c25f7 --- /dev/null +++ b/SqlDataProvider/00.01.02.SqlDataProvider @@ -0,0 +1,291 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + DROP CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_Article_{objectQualifier}Users +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + DROP CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_Article_Modules +GO + +CREATE TABLE {databaseOwner}{objectQualifier}Tmp_DnnForge_NewsArticles_Article + ( + ArticleID int NOT NULL IDENTITY (1, 1), + AuthorID int NOT NULL, + ApproverID int NULL, + CreatedDate datetime NOT NULL, + LastUpdate datetime NOT NULL, + Title nvarchar(255) NOT NULL, + Summary ntext NOT NULL, + IsApproved bit NOT NULL, + NumberOfViews int NOT NULL, + IsDraft bit NOT NULL, + StartDate datetime NULL, + EndDate datetime NULL, + ModuleID int NULL, + ImageUrl nvarchar(255) NULL, + IsFeatured bit NOT NULL + ) ON [PRIMARY] + TEXTIMAGE_ON [PRIMARY] +GO + +SET IDENTITY_INSERT {databaseOwner}{objectQualifier}Tmp_DnnForge_NewsArticles_Article ON +GO + +IF EXISTS(SELECT * FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article) + EXEC('INSERT INTO {databaseOwner}{objectQualifier}Tmp_DnnForge_NewsArticles_Article (ArticleID, AuthorID, ApproverID, CreatedDate, LastUpdate, Title, Summary, IsApproved, NumberOfViews, IsDraft, StartDate, EndDate, ModuleID, ImageUrl, IsFeatured) + SELECT ArticleID, AuthorID, ApproverID, CreatedDate, LastUpdate, Title, CONVERT(ntext, Summary), IsApproved, NumberOfViews, IsDraft, StartDate, EndDate, ModuleID, ImageUrl, IsFeatured FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article (HOLDLOCK TABLOCKX)') +GO + +SET IDENTITY_INSERT {databaseOwner}{objectQualifier}Tmp_DnnForge_NewsArticles_Article OFF +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories + DROP CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_ArticleCategories_DnnForge_NewsArticles_Article +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment + DROP CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_Comment_{objectQualifier}DnnForge_NewsArticles_Article +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page + DROP CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_Page_{objectQualifier}DnnForge_NewsArticles_Article +GO + +DROP TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +GO + +EXECUTE sp_rename N'{objectQualifier}Tmp_DnnForge_NewsArticles_Article', N'{objectQualifier}DnnForge_NewsArticles_Article', 'OBJECT' +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD CONSTRAINT + PK_{objectQualifier}DnnForge_NewsArticles_Article PRIMARY KEY CLUSTERED + ( + ArticleID + ) ON [PRIMARY] + +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article WITH NOCHECK ADD CONSTRAINT + FK_{objectQualifier}DnnForge_NewsArticles_Article_Modules FOREIGN KEY + ( + ModuleID + ) REFERENCES {databaseOwner}{objectQualifier}Modules + ( + ModuleID + ) ON DELETE CASCADE + + +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article WITH NOCHECK ADD CONSTRAINT + FK_{objectQualifier}DnnForge_NewsArticles_Article_Users FOREIGN KEY + ( + AuthorID + ) REFERENCES {databaseOwner}{objectQualifier}Users + ( + UserID + ) ON DELETE CASCADE + +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page WITH NOCHECK ADD CONSTRAINT + FK_{objectQualifier}DnnForge_NewsArticles_Page_{objectQualifier}DnnForge_NewsArticles_Article FOREIGN KEY + ( + ArticleID + ) REFERENCES {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + ( + ArticleID + ) ON DELETE CASCADE + +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment WITH NOCHECK ADD CONSTRAINT + FK_{objectQualifier}DnnForge_NewsArticles_Comment_{objectQualifier}DnnForge_NewsArticles_Article FOREIGN KEY + ( + ArticleID + ) REFERENCES {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + ( + ArticleID + ) ON DELETE CASCADE + + +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories WITH NOCHECK ADD CONSTRAINT + FK_{objectQualifier}DnnForge_NewsArticles_ArticleCategories_{objectQualifier}DnnForge_NewsArticles_Article FOREIGN KEY + ( + ArticleID + ) REFERENCES {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + ( + ArticleID + ) + +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + LastUpdateID int NULL +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET LastUpdateID = AuthorID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl], + [IsFeatured], + [LastUpdateID] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl, + @IsFeatured, + @LastUpdateID +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl, + [IsFeatured] = @IsFeatured, + [LastUpdateID] = @LastUpdateID +WHERE + [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor + @ModuleID int, + @AuthorID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus + @ModuleID int, + @AuthorID int, + @IsApproved bit, + @IsDraft bit +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList + @ModuleID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit +AS +GO diff --git a/SqlDataProvider/00.02.00.SqlDataProvider b/SqlDataProvider/00.02.00.SqlDataProvider new file mode 100644 index 0000000..aa1724c --- /dev/null +++ b/SqlDataProvider/00.02.00.SqlDataProvider @@ -0,0 +1,15 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteCategory + @CategoryID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories +WHERE + [CategoryID] = @CategoryID + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [CategoryID] = @CategoryID +GO diff --git a/SqlDataProvider/00.02.05.SqlDataProvider b/SqlDataProvider/00.02.05.SqlDataProvider new file mode 100644 index 0000000..76ca8b4 --- /dev/null +++ b/SqlDataProvider/00.02.05.SqlDataProvider @@ -0,0 +1,111 @@ +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplate ( + [TemplateID] [int] IDENTITY (1, 1) NOT NULL , + [ModuleID] [int] NOT NULL , + [Name] [nvarchar] (50) NOT NULL , + [Subject] [nvarchar] (255) NOT NULL , + [Template] [ntext] NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplate ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_EmailTemplate] PRIMARY KEY CLUSTERED + ( + [TemplateID] + ) ON [PRIMARY] +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplateGet + @TemplateID int +AS + +SELECT + [TemplateID], + [ModuleID], + [Name], + [Subject], + [Template] +FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplate +WHERE + [TemplateID] = @TemplateID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplateList + @ModuleID int +AS + +SELECT + [TemplateID], + [ModuleID], + [Name], + [Subject], + [Template] +FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplate +WHERE + [ModuleID] = @ModuleID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplateAdd + @ModuleID int, + @Name nvarchar(50), + @Subject nvarchar(255), + @Template ntext +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplate ( + [ModuleID], + [Name], + [Subject], + [Template] +) VALUES ( + @ModuleID, + @Name, + @Subject, + @Template +) + +select SCOPE_IDENTITY() +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplateUpdate + @TemplateID int, + @ModuleID int, + @Name nvarchar(50), + @Subject nvarchar(255), + @Template ntext +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplate SET + [ModuleID] = @ModuleID, + [Name] = @Name, + [Subject] = @Subject, + [Template] = @Template +WHERE + [TemplateID] = @TemplateID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplateDelete + @TemplateID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplate +WHERE + [TemplateID] = @TemplateID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplateGetByName + @ModuleID int, + @Name nvarchar(50) +AS + +SELECT + [TemplateID], + [ModuleID], + [Name], + [Subject], + [Template] +FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_EmailTemplate +WHERE + [ModuleID] = @ModuleID + and + [Name] = @Name +GO diff --git a/SqlDataProvider/00.02.07.SqlDataProvider b/SqlDataProvider/00.02.07.SqlDataProvider new file mode 100644 index 0000000..8a841e6 --- /dev/null +++ b/SqlDataProvider/00.02.07.SqlDataProvider @@ -0,0 +1,4 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + DROP CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_Article_Users +GO + diff --git a/SqlDataProvider/00.03.00.SqlDataProvider b/SqlDataProvider/00.03.00.SqlDataProvider new file mode 100644 index 0000000..003edf4 --- /dev/null +++ b/SqlDataProvider/00.03.00.SqlDataProvider @@ -0,0 +1,7 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +GO diff --git a/SqlDataProvider/00.03.02.SqlDataProvider b/SqlDataProvider/00.03.02.SqlDataProvider new file mode 100644 index 0000000..545140e --- /dev/null +++ b/SqlDataProvider/00.03.02.SqlDataProvider @@ -0,0 +1,8 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS +GO diff --git a/SqlDataProvider/00.04.02.SqlDataProvider b/SqlDataProvider/00.04.02.SqlDataProvider new file mode 100644 index 0000000..66f89b0 --- /dev/null +++ b/SqlDataProvider/00.04.02.SqlDataProvider @@ -0,0 +1,18 @@ + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50) +AS +GO diff --git a/SqlDataProvider/00.04.03.SqlDataProvider b/SqlDataProvider/00.04.03.SqlDataProvider new file mode 100644 index 0000000..6f77a10 --- /dev/null +++ b/SqlDataProvider/00.04.03.SqlDataProvider @@ -0,0 +1,171 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + URL nvarchar(255) NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50) +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl], + [IsFeatured], + [LastUpdateID], + [Url] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl, + @IsFeatured, + @LastUpdateID, + @Url +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl, + [IsFeatured] = @IsFeatured, + [LastUpdateID] = @LastUpdateID, + [Url] = @Url +WHERE + [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor + @ModuleID int, + @AuthorID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus + @ModuleID int, + @AuthorID int, + @IsApproved bit, + @IsDraft bit +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList + @ModuleID int +AS +GO diff --git a/SqlDataProvider/00.04.08.SqlDataProvider b/SqlDataProvider/00.04.08.SqlDataProvider new file mode 100644 index 0000000..f399767 --- /dev/null +++ b/SqlDataProvider/00.04.08.SqlDataProvider @@ -0,0 +1,23 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories DROP + CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_ArticleCategories_{objectQualifier}DnnForge_NewsArticles_Article +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories DROP + CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_ArticleCategories_DnnForge_NewsArticles_Category +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ADD + CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_ArticleCategories_{objectQualifier}DnnForge_NewsArticles_Article FOREIGN KEY + ( + [ArticleID] + ) REFERENCES {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [ArticleID] + ) ON DELETE CASCADE + , + CONSTRAINT FK_{objectQualifier}DnnForge_NewsArticles_ArticleCategories_{objectQualifier}DnnForge_NewsArticles_Category FOREIGN KEY + ( + [CategoryID] + ) REFERENCES {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ( + [CategoryID] + ) +GO diff --git a/SqlDataProvider/00.04.09.SqlDataProvider b/SqlDataProvider/00.04.09.SqlDataProvider new file mode 100644 index 0000000..56fbcd7 --- /dev/null +++ b/SqlDataProvider/00.04.09.SqlDataProvider @@ -0,0 +1,12 @@ +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET StartDate = CreatedDate +WHERE StartDate IS NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics + @ModuleID int +AS +GO diff --git a/SqlDataProvider/00.05.00.SqlDataProvider b/SqlDataProvider/00.05.00.SqlDataProvider new file mode 100644 index 0000000..ceef179 --- /dev/null +++ b/SqlDataProvider/00.05.00.SqlDataProvider @@ -0,0 +1,116 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ADD + Type int NOT NULL Default 0, + TrackbackUrl nvarchar(255) NULL, + TrackbackTitle nvarchar(255) NULL, + TrackbackBlogName nvarchar(255) NULL, + TrackbackExcerpt ntext NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment + @ArticleID int, + @UserID int, + @Comment ntext, + @Rating float, + @RemoteAddress nvarchar(50) , + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ( + [ArticleID], + [UserID], + [Comment], + [Rating], + [RemoteAddress], + [Type], + [TrackbackUrl], + [TrackbackTitle], + [TrackbackBlogName], + [TrackbackExcerpt] +) VALUES ( + @ArticleID, + @UserID, + @Comment, + @Rating, + @RemoteAddress, + @Type, + @TrackbackUrl, + @TrackbackTitle, + @TrackbackBlogName, + @TrackbackExcerpt +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment + @CommentID int, + @ArticleID int, + @UserID int, + @Comment ntext, + @Rating float, + @RemoteAddress nvarchar(50), + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment SET + [ArticleID] = @ArticleID, + [UserID] = @UserID, + [Comment] = @Comment, + [Rating] = @Rating, + [RemoteAddress] = @RemoteAddress, + [Type] = @Type, + [TrackbackUrl] = @TrackbackUrl, + [TrackbackTitle] = @TrackbackTitle, + [TrackbackBlogName] = @TrackbackBlogName, + [TrackbackExcerpt] = @TrackbackExcerpt +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment + @CommentID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList + @ArticleID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50) +AS +GO diff --git a/SqlDataProvider/00.05.02.SqlDataProvider b/SqlDataProvider/00.05.02.SqlDataProvider new file mode 100644 index 0000000..d715247 --- /dev/null +++ b/SqlDataProvider/00.05.02.SqlDataProvider @@ -0,0 +1,19 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics + @ModuleID int +AS + +select + Category.CategoryID, + Category.Name, + (select count(*) from {databaseOwner}{objectQualifier}dnnforge_newsarticles_articlecategories articleCategories, {databaseOwner}{objectQualifier}dnnforge_newsarticles_article articles where categoryid = Category.CategoryID and articleCategories.articleID = articles.ArticleID and articles.IsApproved = 1 AND (articles.StartDate is null or articles.StartDate < DateAdd(mi, 1, GetDate())) AND (articles.EndDate is null or articles.EndDate > DateAdd(mi, 1, GetDate())) ) as 'NumberOfArticles', + (select sum(NumberOfViews) from {databaseOwner}{objectQualifier}dnnforge_newsarticles_articlecategories articleCategories, {databaseOwner}{objectQualifier}dnnforge_newsarticles_article articles where categoryid = Category.CategoryID and articleCategories.articleID = articles.ArticleID AND (articles.StartDate is null or articles.StartDate < DateAdd(mi, 1, GetDate())) AND (articles.EndDate is null or articles.EndDate > DateAdd(mi, 1, GetDate())) ) as 'NumberOfViews' +from + {databaseOwner}{objectQualifier}dnnforge_newsarticles_category Category +where + Category.ModuleID = @ModuleID +ORDER BY + Category.Name +GO diff --git a/SqlDataProvider/00.05.05.SqlDataProvider b/SqlDataProvider/00.05.05.SqlDataProvider new file mode 100644 index 0000000..a4123b7 --- /dev/null +++ b/SqlDataProvider/00.05.05.SqlDataProvider @@ -0,0 +1,30 @@ +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int +AS + +select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] +from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article +where ModuleID = @ModuleID and IsApproved = 1 and IsDraft = 0 +group by Year(StartDate), Month(StartDate) +order by [Year] desc, [Month] desc +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.09.SqlDataProvider b/SqlDataProvider/00.05.09.SqlDataProvider new file mode 100644 index 0000000..b577129 --- /dev/null +++ b/SqlDataProvider/00.05.09.SqlDataProvider @@ -0,0 +1,25 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +EXEC(' +select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] +from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article +where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' +group by Year(StartDate), Month(StartDate) +order by [Year] desc, [Month] desc') +GO diff --git a/SqlDataProvider/00.05.11.SqlDataProvider b/SqlDataProvider/00.05.11.SqlDataProvider new file mode 100644 index 0000000..18adc9e --- /dev/null +++ b/SqlDataProvider/00.05.11.SqlDataProvider @@ -0,0 +1,28 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +EXEC(' +select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] +from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article +where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' +group by Year(StartDate), Month(StartDate) +order by [Year] desc, [Month] desc') +GO diff --git a/SqlDataProvider/00.05.12.SqlDataProvider b/SqlDataProvider/00.05.12.SqlDataProvider new file mode 100644 index 0000000..72726b7 --- /dev/null +++ b/SqlDataProvider/00.05.12.SqlDataProvider @@ -0,0 +1,465 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +EXEC(' +select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] +from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article +where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' +group by Year(StartDate), Month(StartDate) +order by [Year] desc, [Month] desc') +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50), + @Month int, + @Year int +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = ' 1 = 1 ' + +IF (@MaxCount is not null) + SELECT @strTop = ' TOP ' + convert(nvarchar, @MaxCount) + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@MaxAge is not null) and (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND Article.CreatedDate > ''' + convert(nvarchar, DateAdd(day, @MaxAge, @StartDate)) + '''' + +IF (@MaxAge is not null) and (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND Article.CreatedDate < ''' + convert(nvarchar, @StartDate) + '''' + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' + +IF (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null or Article.EndDate > ''' + convert(nvarchar, DateAdd(day, -1, GetDate())) + ''')' + +IF (@Month is not null) + SELECT @strWhere = @strWhere + ' AND Month(Article.StartDate) = ' + convert(nvarchar, @Month) + +IF (@Year is not null) + SELECT @strWhere = @strWhere + ' AND Year(Article.StartDate) = ' + convert(nvarchar, @Year) + +EXEC(' +SELECT ' + @strTop + ' + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '''' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '''' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as ''PageCount'', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as ''CommentCount'', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as ''Rating'', + case when Images.FileName is null then '''' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article INNER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID INNER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = ''fileid='' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = ''fileid='' + CONVERT(nvarchar, Images.FileID) + +WHERE ' + + @strWhere + ' + +ORDER BY + ' + @SortBy + ' DESC') +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article INNER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID INNER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) + +WHERE + Article.[ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article INNER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID INNER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) + +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[IsApproved] = @IsApproved + AND + Article.[IsDraft] = 0 + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor + @ModuleID int, + @AuthorID int +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article INNER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID INNER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[AuthorID] = @AuthorID + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus + @ModuleID int, + @AuthorID int, + @IsApproved bit, + @IsDraft bit +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as CommentCount, + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as Rating, + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS Url + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article INNER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID INNER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[AuthorID] = @AuthorID + AND + Article.[IsApproved] = @IsApproved + AND + Article.[IsDraft] = @IsDraft + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList + @ModuleID int +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article INNER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID INNER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment + @CommentID int +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[Rating], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList + @ArticleID int +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[Rating], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + Comment.[ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.05.13.SqlDataProvider b/SqlDataProvider/00.05.13.SqlDataProvider new file mode 100644 index 0000000..56a37de --- /dev/null +++ b/SqlDataProvider/00.05.13.SqlDataProvider @@ -0,0 +1,30 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' + +EXEC(' +select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] +from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article +where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' +group by Year(StartDate), Month(StartDate) +order by [Year] desc, [Month] desc') +GO diff --git a/SqlDataProvider/00.05.17.SqlDataProvider b/SqlDataProvider/00.05.17.SqlDataProvider new file mode 100644 index 0000000..f54b157 --- /dev/null +++ b/SqlDataProvider/00.05.17.SqlDataProvider @@ -0,0 +1,274 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + IsSecure int NOT NULL Default 0 +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50), + @Month int, + @Year int +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = ' 1 = 1 ' + +IF (@MaxCount is not null) + SELECT @strTop = ' TOP ' + convert(nvarchar, @MaxCount) + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@MaxAge is not null) and (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND Article.CreatedDate > ''' + convert(nvarchar, DateAdd(day, @MaxAge, @StartDate)) + '''' + +IF (@MaxAge is not null) and (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND Article.CreatedDate < ''' + convert(nvarchar, @StartDate) + '''' + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' + +IF (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null or Article.EndDate > ''' + convert(nvarchar, DateAdd(day, -1, GetDate())) + ''')' + +IF (@Month is not null) + SELECT @strWhere = @strWhere + ' AND Month(Article.StartDate) = ' + convert(nvarchar, @Month) + +IF (@Year is not null) + SELECT @strWhere = @strWhere + ' AND Year(Article.StartDate) = ' + convert(nvarchar, @Year) + +EXEC(' +SELECT ' + @strTop + ' + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + '''' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '''' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as ''PageCount'', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as ''CommentCount'', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as ''Rating'', + case when Images.FileName is null then '''' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article INNER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID INNER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = ''fileid='' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = ''fileid='' + CONVERT(nvarchar, Images.FileID) + +WHERE ' + + @strWhere + ' + +ORDER BY + ' + @SortBy + ' DESC') +GO + + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article INNER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID INNER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) + +WHERE + Article.[ArticleID] = @ArticleID +GO + + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl], + [IsFeatured], + [LastUpdateID], + [Url], + [IsSecure] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl, + @IsFeatured, + @LastUpdateID, + @Url, + @IsSecure +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl, + [IsFeatured] = @IsFeatured, + [LastUpdateID] = @LastUpdateID, + [Url] = @Url, + [IsSecure] = @IsSecure +WHERE + [ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.05.20.SqlDataProvider b/SqlDataProvider/00.05.20.SqlDataProvider new file mode 100644 index 0000000..4302af5 --- /dev/null +++ b/SqlDataProvider/00.05.20.SqlDataProvider @@ -0,0 +1,163 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ADD + AnonymousName nvarchar(255) NULL, + AnonymousEmail nvarchar(255) NULL, + AnonymousURL nvarchar(255) NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment + @ArticleID int, + @UserID int, + @Comment ntext, + @Rating float, + @RemoteAddress nvarchar(50) , + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext, + @AnonymousName nvarchar(255), + @AnonymousEmail nvarchar(255), + @AnonymousURL nvarchar(255) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ( + [ArticleID], + [UserID], + [Comment], + [Rating], + [RemoteAddress], + [Type], + [TrackbackUrl], + [TrackbackTitle], + [TrackbackBlogName], + [TrackbackExcerpt], + [AnonymousName], + [AnonymousEmail], + [AnonymousURL] +) VALUES ( + @ArticleID, + @UserID, + @Comment, + @Rating, + @RemoteAddress, + @Type, + @TrackbackUrl, + @TrackbackTitle, + @TrackbackBlogName, + @TrackbackExcerpt, + @AnonymousName, + @AnonymousEmail, + @AnonymousURL +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment + @CommentID int, + @ArticleID int, + @UserID int, + @Comment ntext, + @Rating float, + @RemoteAddress nvarchar(50), + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext, + @AnonymousName nvarchar(255), + @AnonymousEmail nvarchar(255), + @AnonymousURL nvarchar(255) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment SET + [ArticleID] = @ArticleID, + [UserID] = @UserID, + [Comment] = @Comment, + [Rating] = @Rating, + [RemoteAddress] = @RemoteAddress, + [Type] = @Type, + [TrackbackUrl] = @TrackbackUrl, + [TrackbackTitle] = @TrackbackTitle, + [TrackbackBlogName] = @TrackbackBlogName, + [TrackbackExcerpt] = @TrackbackExcerpt, + [AnonymousName] = @AnonymousName, + [AnonymousEmail] = @AnonymousEmail, + [AnonymousURL] = @AnonymousURL +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment + @CommentID int +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[Rating], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList + @ArticleID int +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[Rating], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + Comment.[ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.05.21.SqlDataProvider b/SqlDataProvider/00.05.21.SqlDataProvider new file mode 100644 index 0000000..888905b --- /dev/null +++ b/SqlDataProvider/00.05.21.SqlDataProvider @@ -0,0 +1,168 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ADD + NotifyMe bit NOT NULL CONSTRAINT DF_{objectQualifier}DnnForge_NewsArticles_Comment_NotifyMe DEFAULT 0 +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment + @ArticleID int, + @UserID int, + @Comment ntext, + @Rating float, + @RemoteAddress nvarchar(50) , + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext, + @AnonymousName nvarchar(255), + @AnonymousEmail nvarchar(255), + @AnonymousURL nvarchar(255), + @NotifyMe bit +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ( + [ArticleID], + [UserID], + [Comment], + [Rating], + [RemoteAddress], + [Type], + [TrackbackUrl], + [TrackbackTitle], + [TrackbackBlogName], + [TrackbackExcerpt], + [AnonymousName], + [AnonymousEmail], + [AnonymousURL], + [NotifyMe] +) VALUES ( + @ArticleID, + @UserID, + @Comment, + @Rating, + @RemoteAddress, + @Type, + @TrackbackUrl, + @TrackbackTitle, + @TrackbackBlogName, + @TrackbackExcerpt, + @AnonymousName, + @AnonymousEmail, + @AnonymousURL, + @NotifyMe +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment + @CommentID int, + @ArticleID int, + @UserID int, + @Comment ntext, + @Rating float, + @RemoteAddress nvarchar(50), + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext, + @AnonymousName nvarchar(255), + @AnonymousEmail nvarchar(255), + @AnonymousURL nvarchar(255), + @NotifyMe bit +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment SET + [ArticleID] = @ArticleID, + [UserID] = @UserID, + [Comment] = @Comment, + [Rating] = @Rating, + [RemoteAddress] = @RemoteAddress, + [Type] = @Type, + [TrackbackUrl] = @TrackbackUrl, + [TrackbackTitle] = @TrackbackTitle, + [TrackbackBlogName] = @TrackbackBlogName, + [TrackbackExcerpt] = @TrackbackExcerpt, + [AnonymousName] = @AnonymousName, + [AnonymousEmail] = @AnonymousEmail, + [AnonymousURL] = @AnonymousURL, + [NotifyMe] = @NotifyMe +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment + @CommentID int +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[Rating], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + Comment.[NotifyMe], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList + @ArticleID int +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[Rating], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + Comment.[NotifyMe], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + Comment.[ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.05.22.SqlDataProvider b/SqlDataProvider/00.05.22.SqlDataProvider new file mode 100644 index 0000000..65c926c --- /dev/null +++ b/SqlDataProvider/00.05.22.SqlDataProvider @@ -0,0 +1,109 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50), + @Month int, + @Year int +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = ' 1 = 1 ' + +IF (@MaxCount is not null) + SELECT @strTop = ' TOP ' + convert(nvarchar, @MaxCount) + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@MaxAge is not null) and (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND Article.CreatedDate > ''' + convert(nvarchar, DateAdd(day, @MaxAge, @StartDate)) + '''' + +IF (@MaxAge is not null) and (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND Article.CreatedDate < ''' + convert(nvarchar, @StartDate) + '''' + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' + +IF (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null or Article.EndDate > ''' + convert(nvarchar, GetDate()) + ''')' + +IF (@Month is not null) + SELECT @strWhere = @strWhere + ' AND Month(Article.StartDate) = ' + convert(nvarchar, @Month) + +IF (@Year is not null) + SELECT @strWhere = @strWhere + ' AND Year(Article.StartDate) = ' + convert(nvarchar, @Year) + +EXEC(' +SELECT ' + @strTop + ' + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + '''' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '''' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as ''PageCount'', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as ''CommentCount'', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as ''Rating'', + case when Images.FileName is null then '''' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article INNER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID INNER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = ''fileid='' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = ''fileid='' + CONVERT(nvarchar, Images.FileID) + +WHERE ' + + @strWhere + ' + +ORDER BY + ' + @SortBy + ' DESC') +GO diff --git a/SqlDataProvider/00.05.24.SqlDataProvider b/SqlDataProvider/00.05.24.SqlDataProvider new file mode 100644 index 0000000..7fd7a31 --- /dev/null +++ b/SqlDataProvider/00.05.24.SqlDataProvider @@ -0,0 +1,37 @@ + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList + @ArticleID int +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[Rating], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + Comment.[NotifyMe], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + Comment.[ArticleID] = @ArticleID +ORDER BY + Comment.[CreatedDate] ASC +GO diff --git a/SqlDataProvider/00.05.26.SqlDataProvider b/SqlDataProvider/00.05.26.SqlDataProvider new file mode 100644 index 0000000..a72ca9d --- /dev/null +++ b/SqlDataProvider/00.05.26.SqlDataProvider @@ -0,0 +1,378 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50), + @Month int, + @Year int +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = ' 1 = 1 ' + +IF (@MaxCount is not null) + SELECT @strTop = ' TOP ' + convert(nvarchar, @MaxCount) + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@MaxAge is not null) and (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, DateAdd(day, @MaxAge, @StartDate)) + '''' + +IF (@MaxAge is not null) and (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND Article.StartDate < ''' + convert(nvarchar, @StartDate) + '''' + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' + +IF (@ShowHiddenAndExpired = 0) + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null or Article.EndDate > ''' + convert(nvarchar, GetDate()) + ''')' + +IF (@Month is not null) + SELECT @strWhere = @strWhere + ' AND Month(Article.StartDate) = ' + convert(nvarchar, @Month) + +IF (@Year is not null) + SELECT @strWhere = @strWhere + ' AND Year(Article.StartDate) = ' + convert(nvarchar, @Year) + +EXEC(' +SELECT ' + @strTop + ' + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + '''' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '''' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as ''PageCount'', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as ''CommentCount'', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as ''Rating'', + case when Images.FileName is null then '''' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = ''fileid='' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = ''fileid='' + CONVERT(nvarchar, Images.FileID) + +WHERE ' + + @strWhere + ' + +ORDER BY + ' + @SortBy + ' DESC') +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) + +WHERE + Article.[ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor + @ModuleID int, + @AuthorID int +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[AuthorID] = @AuthorID + +ORDER BY + Article.[CreatedDate] DESC +GO + + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus + @ModuleID int, + @AuthorID int, + @IsApproved bit, + @IsDraft bit +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[AuthorID] = @AuthorID + AND + Article.[IsApproved] = @IsApproved + AND + Article.[IsDraft] = @IsDraft + +ORDER BY + Article.[CreatedDate] DESC +GO + + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList + @ModuleID int +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) + +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[IsApproved] = @IsApproved + AND + Article.[IsDraft] = 0 + +ORDER BY + Article.[CreatedDate] DESC +GO diff --git a/SqlDataProvider/00.05.28.SqlDataProvider b/SqlDataProvider/00.05.28.SqlDataProvider new file mode 100644 index 0000000..61e0abe --- /dev/null +++ b/SqlDataProvider/00.05.28.SqlDataProvider @@ -0,0 +1,19 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.40.SqlDataProvider b/SqlDataProvider/00.05.40.SqlDataProvider new file mode 100644 index 0000000..b8ddf41 --- /dev/null +++ b/SqlDataProvider/00.05.40.SqlDataProvider @@ -0,0 +1,33 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics + @ModuleID int, + @CategoryID varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Category.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND CategoryID in (' + @CategoryID + ')' + +EXEC(' +select + Category.CategoryID, + Category.Name, + (select count(*) from {databaseOwner}{objectQualifier}dnnforge_newsarticles_articlecategories articleCategories, {databaseOwner}{objectQualifier}dnnforge_newsarticles_article articles where categoryid = Category.CategoryID and articleCategories.articleID = articles.ArticleID and articles.IsApproved = 1 AND (articles.StartDate is null or articles.StartDate < DateAdd(mi, 1, GetDate())) AND (articles.EndDate is null or articles.EndDate > DateAdd(mi, 1, GetDate())) ) as ''NumberOfArticles'', + (select sum(NumberOfViews) from {databaseOwner}{objectQualifier}dnnforge_newsarticles_articlecategories articleCategories, {databaseOwner}{objectQualifier}dnnforge_newsarticles_article articles where categoryid = Category.CategoryID and articleCategories.articleID = articles.ArticleID AND (articles.StartDate is null or articles.StartDate < DateAdd(mi, 1, GetDate())) AND (articles.EndDate is null or articles.EndDate > DateAdd(mi, 1, GetDate())) ) as ''NumberOfViews'' +from + {databaseOwner}{objectQualifier}dnnforge_newsarticles_category Category +where 1 = 1 ' + + @strWhere + ' +ORDER BY + Category.Name') +GO diff --git a/SqlDataProvider/00.05.41.SqlDataProvider b/SqlDataProvider/00.05.41.SqlDataProvider new file mode 100644 index 0000000..10e755a --- /dev/null +++ b/SqlDataProvider/00.05.41.SqlDataProvider @@ -0,0 +1,27 @@ +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics + @ModuleID int, + @CategoryID varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + '))' + +EXEC(' +SELECT + UserID, UserName, FirstName, LastName, count(*) as ''ArticleCount'' +FROM + {databaseOwner}{objectQualifier}Users Users, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles +where 1 = 1 and Users.UserID = Articles.AuthorID ' + + @strWhere + ' +GROUP BY + UserID, UserName, FirstName, LastName') +GO diff --git a/SqlDataProvider/00.05.46.SqlDataProvider b/SqlDataProvider/00.05.46.SqlDataProvider new file mode 100644 index 0000000..e5c1013 --- /dev/null +++ b/SqlDataProvider/00.05.46.SqlDataProvider @@ -0,0 +1,537 @@ +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating ( + [RatingID] [int] IDENTITY (1, 1) NOT NULL , + [ArticleID] [int] NOT NULL , + [UserID] [int] NOT NULL , + [CreatedDate] [datetime] NOT NULL , + [Rating] [float] NULL +) ON [PRIMARY] +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_Rating] PRIMARY KEY CLUSTERED + ( + [RatingID] + ) ON [PRIMARY] +GO + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating(ArticleID, UserID, CreatedDate, Rating) +SELECT ArticleID, UserID, CreatedDate, Rating FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment WHERE Rating is not null +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_RatingAdd + @ArticleID int, + @UserID int, + @CreatedDate datetime, + @Rating float +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating ( + [ArticleID], + [UserID], + [CreatedDate], + [Rating] +) VALUES ( + @ArticleID, + @UserID, + @CreatedDate, + @Rating +) + +select SCOPE_IDENTITY() +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_RatingDelete + @RatingID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating +WHERE + [RatingID] = @RatingID + +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_RatingGet + @ArticleID int, + @UserID int + +AS + +SELECT + [RatingID], + [ArticleID], + [UserID], + [CreatedDate], + [Rating] +FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating +WHERE + [ArticleID] = @ArticleID + and + [UserID] = @UserID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_RatingGetByID + @RatingID int + +AS + +SELECT + [RatingID], + [ArticleID], + [UserID], + [CreatedDate], + [Rating] +FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating +WHERE + [RatingID] = @RatingID +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment + DROP COLUMN Rating +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment + @ArticleID int, + @UserID int, + @Comment ntext, + @RemoteAddress nvarchar(50) , + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext, + @AnonymousName nvarchar(255), + @AnonymousEmail nvarchar(255), + @AnonymousURL nvarchar(255), + @NotifyMe bit +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ( + [ArticleID], + [UserID], + [Comment], + [RemoteAddress], + [Type], + [TrackbackUrl], + [TrackbackTitle], + [TrackbackBlogName], + [TrackbackExcerpt], + [AnonymousName], + [AnonymousEmail], + [AnonymousURL], + [NotifyMe] +) VALUES ( + @ArticleID, + @UserID, + @Comment, + @RemoteAddress, + @Type, + @TrackbackUrl, + @TrackbackTitle, + @TrackbackBlogName, + @TrackbackExcerpt, + @AnonymousName, + @AnonymousEmail, + @AnonymousURL, + @NotifyMe +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment + @CommentID int +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + Comment.[NotifyMe], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList + @ArticleID int +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + Comment.[NotifyMe], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + Comment.[ArticleID] = @ArticleID +ORDER BY + Comment.[CreatedDate] ASC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment + @CommentID int, + @ArticleID int, + @UserID int, + @Comment ntext, + @RemoteAddress nvarchar(50), + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext, + @AnonymousName nvarchar(255), + @AnonymousEmail nvarchar(255), + @AnonymousURL nvarchar(255), + @NotifyMe bit +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment SET + [ArticleID] = @ArticleID, + [UserID] = @UserID, + [Comment] = @Comment, + [RemoteAddress] = @RemoteAddress, + [Type] = @Type, + [TrackbackUrl] = @TrackbackUrl, + [TrackbackTitle] = @TrackbackTitle, + [TrackbackBlogName] = @TrackbackBlogName, + [TrackbackExcerpt] = @TrackbackExcerpt, + [AnonymousName] = @AnonymousName, + [AnonymousEmail] = @AnonymousEmail, + [AnonymousURL] = @AnonymousURL, + [NotifyMe] = @NotifyMe +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) + +WHERE + Article.[ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList + @ModuleID int +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) + +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[IsApproved] = @IsApproved + AND + Article.[IsDraft] = 0 + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor + @ModuleID int, + @AuthorID int +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[AuthorID] = @AuthorID + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus + @ModuleID int, + @AuthorID int, + @IsApproved bit, + @IsDraft bit +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'Rating', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[AuthorID] = @AuthorID + AND + Article.[IsApproved] = @IsApproved + AND + Article.[IsDraft] = @IsDraft + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.48.SqlDataProvider b/SqlDataProvider/00.05.48.SqlDataProvider new file mode 100644 index 0000000..bdd6972 --- /dev/null +++ b/SqlDataProvider/00.05.48.SqlDataProvider @@ -0,0 +1,421 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + ADD IsNewWindow bit NOT NULL CONSTRAINT DF_{objectQualifier}DnnForge_NewsArticles_Article_IsNewWindow DEFAULT 0 +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl], + [IsFeatured], + [LastUpdateID], + [Url], + [IsSecure], + [IsNewWindow] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl, + @IsFeatured, + @LastUpdateID, + @Url, + @IsSecure, + @IsNewWindow +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl, + [IsFeatured] = @IsFeatured, + [LastUpdateID] = @LastUpdateID, + [Url] = @Url, + [IsSecure] = @IsSecure, + [IsNewWindow] = @IsNewWindow +WHERE + [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'Rating', + (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'RatingCount', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) + +WHERE + Article.[ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList + @ModuleID int +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'Rating', + (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'RatingCount', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved + @ModuleID int, + @IsApproved bit +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'Rating', + (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'RatingCount', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) + +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[IsApproved] = @IsApproved + AND + Article.[IsDraft] = 0 + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor + @ModuleID int, + @AuthorID int +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'Rating', + (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'RatingCount', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[AuthorID] = @AuthorID + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus + @ModuleID int, + @AuthorID int, + @IsApproved bit, + @IsDraft bit +AS + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'Rating', + (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'RatingCount', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) +WHERE + Article.[ModuleID] = @ModuleID + AND + Article.[AuthorID] = @AuthorID + AND + Article.[IsApproved] = @IsApproved + AND + Article.[IsDraft] = @IsDraft + +ORDER BY + Article.[CreatedDate] DESC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.51.SqlDataProvider b/SqlDataProvider/00.05.51.SqlDataProvider new file mode 100644 index 0000000..af63768 --- /dev/null +++ b/SqlDataProvider/00.05.51.SqlDataProvider @@ -0,0 +1,20 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.55.SqlDataProvider b/SqlDataProvider/00.05.55.SqlDataProvider new file mode 100644 index 0000000..9809e46 --- /dev/null +++ b/SqlDataProvider/00.05.55.SqlDataProvider @@ -0,0 +1,21 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.56.SqlDataProvider b/SqlDataProvider/00.05.56.SqlDataProvider new file mode 100644 index 0000000..e219be2 --- /dev/null +++ b/SqlDataProvider/00.05.56.SqlDataProvider @@ -0,0 +1,22 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowHiddenAndExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.58.SqlDataProvider b/SqlDataProvider/00.05.58.SqlDataProvider new file mode 100644 index 0000000..c70c337 --- /dev/null +++ b/SqlDataProvider/00.05.58.SqlDataProvider @@ -0,0 +1,23 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.66.SqlDataProvider b/SqlDataProvider/00.05.66.SqlDataProvider new file mode 100644 index 0000000..c70c337 --- /dev/null +++ b/SqlDataProvider/00.05.66.SqlDataProvider @@ -0,0 +1,23 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.68.SqlDataProvider b/SqlDataProvider/00.05.68.SqlDataProvider new file mode 100644 index 0000000..c70c337 --- /dev/null +++ b/SqlDataProvider/00.05.68.SqlDataProvider @@ -0,0 +1,23 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved int, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.69.SqlDataProvider b/SqlDataProvider/00.05.69.SqlDataProvider new file mode 100644 index 0000000..1278d26 --- /dev/null +++ b/SqlDataProvider/00.05.69.SqlDataProvider @@ -0,0 +1,50 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + '' as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + '' as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'Rating', + (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'RatingCount', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) + +WHERE + Article.[ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.05.74.SqlDataProvider b/SqlDataProvider/00.05.74.SqlDataProvider new file mode 100644 index 0000000..00e3a7b --- /dev/null +++ b/SqlDataProvider/00.05.74.SqlDataProvider @@ -0,0 +1,36 @@ +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleList +GO + +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByApproved +GO + +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthor +GO + +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListByAuthorByStatus +GO + +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved bit, + @IsDraft bit, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.76.SqlDataProvider b/SqlDataProvider/00.05.76.SqlDataProvider new file mode 100644 index 0000000..5035125 --- /dev/null +++ b/SqlDataProvider/00.05.76.SqlDataProvider @@ -0,0 +1,24 @@ +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved bit, + @IsDraft bit, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.05.77.SqlDataProvider b/SqlDataProvider/00.05.77.SqlDataProvider new file mode 100644 index 0000000..fb77adb --- /dev/null +++ b/SqlDataProvider/00.05.77.SqlDataProvider @@ -0,0 +1,52 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment.ArticleID = Article.ArticleID) as 'CommentCount', + (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page.ArticleID = Article.ArticleID) as 'PageCount', + (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'Rating', + (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating.ArticleID = Article.ArticleID) as 'RatingCount', + case when Images.FileName is null then '' else Images.Folder + Images.FileName end AS ImageUrlResolved, + case when UrlFiles.FileName is null then Article.URL else UrlFiles.Folder + UrlFiles.FileName end AS URL + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files UrlFiles ON Article.URL = 'fileid=' + CONVERT(nvarchar, UrlFiles.FileID) LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Files Images ON Article.ImageUrl = 'fileid=' + CONVERT(nvarchar, Images.FileID) + +WHERE + Article.[ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.05.78.SqlDataProvider b/SqlDataProvider/00.05.78.SqlDataProvider new file mode 100644 index 0000000..5315552 --- /dev/null +++ b/SqlDataProvider/00.05.78.SqlDataProvider @@ -0,0 +1,84 @@ +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved bit, + @IsDraft bit, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO + +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorList + @ModuleID int +AS + +SELECT DISTINCT + Authors.UserID, + Authors.Username, + Authors.FirstName, + Authors.LastName, + Authors.DisplayName + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles, {databaseOwner}{objectQualifier}Users Authors + +WHERE + Articles.AuthorID = Authors.UserID + and + Articles.ModuleID = @ModuleID + and + Articles.IsApproved = 1 + +ORDER BY + Authors.FirstName, Authors.LastName +GO + +drop procedure {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' +SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null or Article.EndDate > ''' + convert(nvarchar, DateAdd(mi, -1, GetDate())) + ''')' + +EXEC(' +select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] +from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article +where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' +group by Year(StartDate), Month(StartDate) +order by [Year] desc, [Month] desc') +GO diff --git a/SqlDataProvider/00.06.00.SqlDataProvider b/SqlDataProvider/00.06.00.SqlDataProvider new file mode 100644 index 0000000..d02eaf6 --- /dev/null +++ b/SqlDataProvider/00.06.00.SqlDataProvider @@ -0,0 +1,218 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ADD + isApproved bit NOT NULL CONSTRAINT DF_{objectQualifier}DnnForge_NewsArticles_Comment_isApproved DEFAULT 1, + approvedBy int NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment + @ArticleID int, + @UserID int, + @Comment ntext, + @RemoteAddress nvarchar(50) , + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext, + @AnonymousName nvarchar(255), + @AnonymousEmail nvarchar(255), + @AnonymousURL nvarchar(255), + @NotifyMe bit, + @IsApproved bit, + @ApprovedBy int +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ( + [ArticleID], + [UserID], + [Comment], + [RemoteAddress], + [Type], + [TrackbackUrl], + [TrackbackTitle], + [TrackbackBlogName], + [TrackbackExcerpt], + [AnonymousName], + [AnonymousEmail], + [AnonymousURL], + [NotifyMe], + [IsApproved], + [ApprovedBy] +) VALUES ( + @ArticleID, + @UserID, + @Comment, + @RemoteAddress, + @Type, + @TrackbackUrl, + @TrackbackTitle, + @TrackbackBlogName, + @TrackbackExcerpt, + @AnonymousName, + @AnonymousEmail, + @AnonymousURL, + @NotifyMe, + @IsApproved, + @ApprovedBy +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment + @CommentID int, + @ArticleID int, + @UserID int, + @Comment ntext, + @RemoteAddress nvarchar(50), + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext, + @AnonymousName nvarchar(255), + @AnonymousEmail nvarchar(255), + @AnonymousURL nvarchar(255), + @NotifyMe bit, + @IsApproved bit, + @ApprovedBy int +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment SET + [ArticleID] = @ArticleID, + [UserID] = @UserID, + [Comment] = @Comment, + [RemoteAddress] = @RemoteAddress, + [Type] = @Type, + [TrackbackUrl] = @TrackbackUrl, + [TrackbackTitle] = @TrackbackTitle, + [TrackbackBlogName] = @TrackbackBlogName, + [TrackbackExcerpt] = @TrackbackExcerpt, + [AnonymousName] = @AnonymousName, + [AnonymousEmail] = @AnonymousEmail, + [AnonymousURL] = @AnonymousURL, + [NotifyMe] = @NotifyMe, + [IsApproved] = @IsApproved, + [ApprovedBy] = @ApprovedBy +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList + @ModuleID int, + @ArticleID int, + @IsApproved bit +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + Comment.[NotifyMe], + Comment.[IsApproved], + Comment.[ApprovedBy], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article on Comment.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + Article.ModuleID = @ModuleID + and + (@ArticleID is null OR Comment.[ArticleID] = @ArticleID) + and + Comment.IsApproved = @IsApproved +ORDER BY + Comment.[CreatedDate] ASC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment + @CommentID int +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + Comment.[NotifyMe], + Comment.[IsApproved], + Comment.[ApprovedBy], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved bit, + @IsDraft bit, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +GO diff --git a/SqlDataProvider/00.06.04.SqlDataProvider b/SqlDataProvider/00.06.04.SqlDataProvider new file mode 100644 index 0000000..ebe987a --- /dev/null +++ b/SqlDataProvider/00.06.04.SqlDataProvider @@ -0,0 +1,45 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(255), + @GroupBy varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' +SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null or Article.EndDate > ''' + convert(nvarchar, DateAdd(mi, -1, GetDate())) + ''')' + +IF( @GroupBy = 'Month' ) +BEGIN +EXEC(' +select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] +from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article +where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' +group by Year(StartDate), Month(StartDate) +order by [Year] desc, [Month] desc') +END +ELSE +BEGIN +EXEC(' +select 1 as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] +from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article +where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' +group by Year(StartDate) +order by [Year] desc') +END +GO diff --git a/SqlDataProvider/00.06.07.SqlDataProvider b/SqlDataProvider/00.06.07.SqlDataProvider new file mode 100644 index 0000000..ef042eb --- /dev/null +++ b/SqlDataProvider/00.06.07.SqlDataProvider @@ -0,0 +1,74 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + Add Summary2 ntext +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + SET Summary2 = Summary +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + DROP COLUMN Summary +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + Add Summary ntext +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + SET Summary = Summary2 +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + DROP COLUMN Summary2 +GO + +CREATE TABLE #Article +( + ArticleID INT +) + +INSERT INTO #Article +select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article where Article.ArticleID not in (select ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page WHERE Article.ArticleID = Page.ArticleID) + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page(ArticleID, Title, PageText, SortOrder) +select ArticleID, Title, Summary, 0 from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article where Article.ArticleID not in (select ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page WHERE Article.ArticleID = Page.ArticleID) + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET Summary = null +WHERE ArticleID in (select ArticleID from #Article) + +DROP TABLE #Article +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved bit, + @IsDraft bit, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.06.08.SqlDataProvider b/SqlDataProvider/00.06.08.SqlDataProvider new file mode 100644 index 0000000..5f3ba71 --- /dev/null +++ b/SqlDataProvider/00.06.08.SqlDataProvider @@ -0,0 +1,24 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved bit, + @IsDraft bit, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.06.09.SqlDataProvider b/SqlDataProvider/00.06.09.SqlDataProvider new file mode 100644 index 0000000..5f3ba71 --- /dev/null +++ b/SqlDataProvider/00.06.09.SqlDataProvider @@ -0,0 +1,24 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved bit, + @IsDraft bit, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.06.11.SqlDataProvider b/SqlDataProvider/00.06.11.SqlDataProvider new file mode 100644 index 0000000..2a67d7d --- /dev/null +++ b/SqlDataProvider/00.06.11.SqlDataProvider @@ -0,0 +1,63 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics + @ModuleID int, + @CategoryID varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + '))' + +EXEC(' +SELECT + UserID, UserName, DisplayName, FirstName, LastName, count(*) as ''ArticleCount'' +FROM + {databaseOwner}{objectQualifier}Users Users, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles +where 1 = 1 and Users.UserID = Articles.AuthorID ' + + @strWhere + ' +GROUP BY + UserID, UserName, DisplayName, FirstName, LastName') +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved bit, + @IsDraft bit, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +GO diff --git a/SqlDataProvider/00.06.14.SqlDataProvider b/SqlDataProvider/00.06.14.SqlDataProvider new file mode 100644 index 0000000..f10fae9 --- /dev/null +++ b/SqlDataProvider/00.06.14.SqlDataProvider @@ -0,0 +1,26 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @MaxAge int, + @IsApproved bit, + @IsDraft bit, + @StartDate datetime, + @KeyWords varchar(255), + @ShowPending bit, + @ShowExpired bit, + @AuthorID int, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @SortBy varchar(50), + @SortDirection varchar(50), + @Month int, + @Year int +AS +GO diff --git a/SqlDataProvider/00.06.16.SqlDataProvider b/SqlDataProvider/00.06.16.SqlDataProvider new file mode 100644 index 0000000..cb7943d --- /dev/null +++ b/SqlDataProvider/00.06.16.SqlDataProvider @@ -0,0 +1,116 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetComment + @CommentID int +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + Comment.[NotifyMe], + Comment.[IsApproved], + Comment.[ApprovedBy], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + [CommentID] = @CommentID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList + @ModuleID int, + @ArticleID int, + @IsApproved bit +AS + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + Comment.[NotifyMe], + Comment.[IsApproved], + Comment.[ApprovedBy], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article on Comment.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + Article.ModuleID = @ModuleID + and + (@ArticleID is null OR Comment.[ArticleID] = @ArticleID) + and + Comment.IsApproved = @IsApproved +ORDER BY + Comment.[CreatedDate] ASC +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics + @ModuleID int, + @CategoryID varchar(255), + @SortBy varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + '))' + +EXEC(' +SELECT + UserID, UserName, DisplayName, FirstName, LastName, count(*) as ''ArticleCount'' +FROM + {databaseOwner}{objectQualifier}Users Users, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles +where 1 = 1 and Users.UserID = Articles.AuthorID ' + + @strWhere + ' +GROUP BY + UserID, UserName, DisplayName, FirstName, LastName +ORDER BY ' + + @SortBy) +GO diff --git a/SqlDataProvider/00.07.00.SqlDataProvider b/SqlDataProvider/00.07.00.SqlDataProvider new file mode 100644 index 0000000..346ef73 --- /dev/null +++ b/SqlDataProvider/00.07.00.SqlDataProvider @@ -0,0 +1,653 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + ADD [CommentCount] int, [PageCount] int, [Rating] decimal(3,2), [RatingCount] int +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords varchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit +AS +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as UpdatedDisplayName, + Page.PageText as 'Body' + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + Article.[ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(255), + @GroupBy varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' + +IF( @GroupBy = 'Month' ) +BEGIN +EXEC(' + select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate), Month(StartDate) + order by [Year] desc, [Month] desc') +END +ELSE +BEGIN +EXEC(' + select 1 as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate) + order by [Year] desc') +END +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics + @ModuleID int, + @CategoryID varchar(255), + @SortBy varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + '))' + +EXEC(' +SELECT + UserID, UserName, DisplayName, FirstName, LastName, count(*) as ''ArticleCount'' +FROM + {databaseOwner}{objectQualifier}Users Users, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles +where Articles.IsApproved = 1 and Articles.IsDraft = 0 and Users.UserID = Articles.AuthorID ' + + @strWhere + ' +GROUP BY + UserID, UserName, DisplayName, FirstName, LastName +ORDER BY ' + + @SortBy) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics + @ModuleID int, + @CategoryID varchar(255) +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND c.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND c.CategoryID in (' + @CategoryID + ')' + +EXEC(' +SELECT + c.CategoryID, c.Name, count(ac.ArticleID) as ''NumberOfArticles'', sum(a.NumberOfViews) as ''NumberOfViews'' +FROM + {databaseOwner}{objectQualifier}dnnforge_newsarticles_category c + INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON c.CategoryID = ac.CategoryID + INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON + a.ArticleID = ac.ArticleID AND + a.IsDraft = 0 AND + a.IsApproved = 1 AND + (a.StartDate is null or a.StartDate < DateAdd(mi, 1, GetDate())) +WHERE + 1=1 ' + + @strWhere + ' +GROUP BY + c.CategoryID, c.Name +ORDER BY + c.Name') +GO + +DELETE FROM {databaseOwner}{objectQualifier}ModuleControls WHERE ControlSrc = 'DesktopModules/DnnForge - NewsArticles/ucArticleView.ascx' +GO + +DELETE FROM {databaseOwner}{objectQualifier}ModuleControls WHERE ControlSrc = 'DesktopModules/DnnForge - NewsArticles/ucArchiveView.ascx' +GO + +DELETE FROM {databaseOwner}{objectQualifier}ModuleControls WHERE ControlSrc = 'DesktopModules/DnnForge - NewsArticles/ucAuthorView.ascx' +GO + +DELETE FROM {databaseOwner}{objectQualifier}ModuleControls WHERE ControlSrc = 'DesktopModules/DnnForge - NewsArticles/ucCategories.ascx' +GO + +DELETE FROM {databaseOwner}{objectQualifier}ModuleControls WHERE ControlSrc = 'DesktopModules/DnnForge - NewsArticles/ucCategoryView.ascx' +GO + +DELETE FROM {databaseOwner}{objectQualifier}ModuleControls WHERE ControlSrc = 'DesktopModules/DnnForge - NewsArticles/ucDeleteComment.ascx' +GO + +DELETE FROM {databaseOwner}{objectQualifier}ModuleControls WHERE ControlSrc = 'DesktopModules/DnnForge - NewsArticles/ucPostComment.ascx' +GO + +DELETE FROM {databaseOwner}{objectQualifier}ModuleControls WHERE ControlSrc = 'DesktopModules/DnnForge - NewsArticles/ucSearch.ascx' +GO + +DELETE FROM {databaseOwner}{objectQualifier}ModuleControls WHERE ControlSrc = 'DesktopModules/DnnForge - NewsArticles/ucSyndication.ascx' +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddPage +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddPage + @ArticleID int, + @Title nvarchar(255), + @PageText ntext, + @SortOrder int +AS + +declare @count int + +select @count = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where ArticleID = @ArticleID) + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page ( + [ArticleID], + [Title], + [PageText], + [SortOrder] +) VALUES ( + @ArticleID, + @Title, + @PageText, + @count +) + +select SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeletePage +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeletePage + @PageID int +AS + +DECLARE @ArticleID int +SELECT @ArticleID = ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page WHERE [PageID] = @PageID + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page +WHERE + [PageID] = @PageID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdatePage +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdatePage + @PageID int, + @ArticleID int, + @Title nvarchar(255), + @PageText ntext, + @SortOrder int +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page SET + [ArticleID] = @ArticleID, + [Title] = @Title, + [PageText] = @PageText, + [SortOrder] = @SortOrder +WHERE + [PageID] = @PageID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment + @ArticleID int, + @UserID int, + @Comment ntext, + @RemoteAddress nvarchar(50) , + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext, + @AnonymousName nvarchar(255), + @AnonymousEmail nvarchar(255), + @AnonymousURL nvarchar(255), + @NotifyMe bit, + @IsApproved bit, + @ApprovedBy int +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ( + [ArticleID], + [UserID], + [Comment], + [RemoteAddress], + [Type], + [TrackbackUrl], + [TrackbackTitle], + [TrackbackBlogName], + [TrackbackExcerpt], + [AnonymousName], + [AnonymousEmail], + [AnonymousURL], + [NotifyMe], + [IsApproved], + [ApprovedBy] +) VALUES ( + @ArticleID, + @UserID, + @Comment, + @RemoteAddress, + @Type, + @TrackbackUrl, + @TrackbackTitle, + @TrackbackBlogName, + @TrackbackExcerpt, + @AnonymousName, + @AnonymousEmail, + @AnonymousURL, + @NotifyMe, + @IsApproved, + @ApprovedBy +) + +select SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteComment + @CommentID int +AS + +DECLARE @ArticleID int +SELECT @ArticleID = ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment WHERE [CommentID] = @CommentID + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment +WHERE [CommentID] = @CommentID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateComment + @CommentID int, + @ArticleID int, + @UserID int, + @Comment ntext, + @RemoteAddress nvarchar(50), + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext, + @AnonymousName nvarchar(255), + @AnonymousEmail nvarchar(255), + @AnonymousURL nvarchar(255), + @NotifyMe bit, + @IsApproved bit, + @ApprovedBy int +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment SET + [ArticleID] = @ArticleID, + [UserID] = @UserID, + [Comment] = @Comment, + [RemoteAddress] = @RemoteAddress, + [Type] = @Type, + [TrackbackUrl] = @TrackbackUrl, + [TrackbackTitle] = @TrackbackTitle, + [TrackbackBlogName] = @TrackbackBlogName, + [TrackbackExcerpt] = @TrackbackExcerpt, + [AnonymousName] = @AnonymousName, + [AnonymousEmail] = @AnonymousEmail, + [AnonymousURL] = @AnonymousURL, + [NotifyMe] = @NotifyMe, + [IsApproved] = @IsApproved, + [ApprovedBy] = @ApprovedBy +WHERE + [CommentID] = @CommentID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_RatingAdd +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_RatingAdd + @ArticleID int, + @UserID int, + @CreatedDate datetime, + @Rating float +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating ( + [ArticleID], + [UserID], + [CreatedDate], + [Rating] +) VALUES ( + @ArticleID, + @UserID, + @CreatedDate, + @Rating +) + +select SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_RatingDelete +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_RatingDelete + @RatingID int +AS + +DECLARE @ArticleID int +SELECT @ArticleID = ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating WHERE [RatingID] = @RatingID + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating +WHERE [RatingID] = @RatingID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl], + [IsFeatured], + [LastUpdateID], + [Url], + [IsSecure], + [IsNewWindow] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl, + @IsFeatured, + @LastUpdateID, + @Url, + @IsSecure, + @IsNewWindow +) + +select SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl, + [IsFeatured] = @IsFeatured, + [LastUpdateID] = @LastUpdateID, + [Url] = @Url, + [IsSecure] = @IsSecure, + [IsNewWindow] = @IsNewWindow +WHERE + [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.07.01.SqlDataProvider b/SqlDataProvider/00.07.01.SqlDataProvider new file mode 100644 index 0000000..0c86f53 --- /dev/null +++ b/SqlDataProvider/00.07.01.SqlDataProvider @@ -0,0 +1,204 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords varchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + ''')' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate > ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO diff --git a/SqlDataProvider/00.07.05.SqlDataProvider b/SqlDataProvider/00.07.05.SqlDataProvider new file mode 100644 index 0000000..e115479 --- /dev/null +++ b/SqlDataProvider/00.07.05.SqlDataProvider @@ -0,0 +1,204 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords varchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate < GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate > ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO diff --git a/SqlDataProvider/00.07.06.SqlDataProvider b/SqlDataProvider/00.07.06.SqlDataProvider new file mode 100644 index 0000000..c0beb9e --- /dev/null +++ b/SqlDataProvider/00.07.06.SqlDataProvider @@ -0,0 +1,170 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + ADD [ParentID] int NULL +GO + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +SET + [ParentID] = -1 +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ( + [ModuleID], + [ParentID], + [Name], + [Image] +) VALUES ( + @ModuleID, + @ParentID, + @Name, + @Image +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory + @CategoryID int, + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category SET + [ModuleID] = @ModuleID, + [ParentID] = @ParentID, + [Name] = @Name, + [Image] = @Image +WHERE + [CategoryID] = @CategoryID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory + @CategoryID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [CategoryID] = @CategoryID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList + @ModuleID int, + @ParentID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [ModuleID] = @ModuleID + AND + [ParentID] = @ParentID +ORDER BY + [Name] +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @Current int, + @CategoryID varchar(255) +AS + +SET NOCOUNT ON +DECLARE @level int, @line int + +CREATE TABLE #hierarchy(HierarchyID int IDENTITY (1,1), CategoryID int, level int) +CREATE TABLE #stack (item int, level int) +INSERT INTO #stack VALUES (@current, 1) +SELECT @level = 1 + +WHILE @level > 0 +BEGIN + IF EXISTS (SELECT * FROM #stack WHERE level = @level) + BEGIN + SELECT @current = item + FROM #stack + WHERE level = @level + + insert into #hierarchy(CategoryID, level) values(@current, @level) + + DELETE FROM #stack + WHERE level = @level + AND item = @current + + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [Name] DESC + + IF @@ROWCOUNT > 0 + SELECT @level = @level + 1 + END + ELSE + SELECT @level = @level - 1 +END -- WHILE + +DECLARE @strModuleID nvarchar(50) +SELECT @strModuleID = convert(varchar, @ModuleID) + +DECLARE @strCategoryId nvarchar(255) +IF (@CategoryId is not null) + SELECT @strCategoryId = ' AND c.CategoryID in (' + @CategoryID + ')' + +EXEC(' +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE(''.'',(level-2)*2) + c.[Name] as ''NameIndented'', + c.[Image], + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac WHERE ac.CategoryID = c.CategoryID) as ''NumberofArticles'', + (SELECT SUM(a.NumberOfViews) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON a.ArticleID = ac.ArticleID WHERE ac.CategoryID = c.CategoryID) as ''NumberofViews'' +FROM + #hierarchy h INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON h.CategoryID = c.CategoryID +WHERE + c.[ModuleID] = ' + @strModuleID + @strCategoryId + ' +ORDER BY + h.HierarchyID ASC') + +drop table #hierarchy +drop table #stack +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryStatistics +GO diff --git a/SqlDataProvider/00.07.08.SqlDataProvider b/SqlDataProvider/00.07.08.SqlDataProvider new file mode 100644 index 0000000..b6a7fb3 --- /dev/null +++ b/SqlDataProvider/00.07.08.SqlDataProvider @@ -0,0 +1,173 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + ADD [Description] ntext +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255), + @Description ntext +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ( + [ModuleID], + [ParentID], + [Name], + [Image], + [Description] +) VALUES ( + @ModuleID, + @ParentID, + @Name, + @Image, + @Description +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory + @CategoryID int, + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255), + @Description ntext +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category SET + [ModuleID] = @ModuleID, + [ParentID] = @ParentID, + [Name] = @Name, + [Image] = @Image, + [Description] = @Description +WHERE + [CategoryID] = @CategoryID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory + @CategoryID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image], + [Description] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [CategoryID] = @CategoryID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList + @ModuleID int, + @ParentID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image], + [Description] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [ModuleID] = @ModuleID + AND + [ParentID] = @ParentID +ORDER BY + [Name] +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @Current int, + @CategoryID varchar(255) +AS + +SET NOCOUNT ON +DECLARE @level int, @line int + +CREATE TABLE #hierarchy(HierarchyID int IDENTITY (1,1), CategoryID int, level int) +CREATE TABLE #stack (item int, level int) +INSERT INTO #stack VALUES (@current, 1) +SELECT @level = 1 + +WHILE @level > 0 +BEGIN + IF EXISTS (SELECT * FROM #stack WHERE level = @level) + BEGIN + SELECT @current = item + FROM #stack + WHERE level = @level + + insert into #hierarchy(CategoryID, level) values(@current, @level) + + DELETE FROM #stack + WHERE level = @level + AND item = @current + + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [Name] DESC + + IF @@ROWCOUNT > 0 + SELECT @level = @level + 1 + END + ELSE + SELECT @level = @level - 1 +END -- WHILE + +DECLARE @strModuleID nvarchar(50) +SELECT @strModuleID = convert(varchar, @ModuleID) + +DECLARE @strCategoryId nvarchar(255) +IF (@CategoryId is not null) + SELECT @strCategoryId = ' AND c.CategoryID in (' + @CategoryID + ')' + +EXEC(' +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE(''.'',(level-2)*2) + c.[Name] as ''NameIndented'', + c.[Image], + [Description], + level-1 as ''Level'', + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac WHERE ac.CategoryID = c.CategoryID) as ''NumberofArticles'', + (SELECT SUM(a.NumberOfViews) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON a.ArticleID = ac.ArticleID WHERE ac.CategoryID = c.CategoryID) as ''NumberofViews'' +FROM + #hierarchy h INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON h.CategoryID = c.CategoryID +WHERE + c.[ModuleID] = ' + @strModuleID + @strCategoryId + ' +ORDER BY + h.HierarchyID ASC') + +drop table #hierarchy +drop table #stack +GO diff --git a/SqlDataProvider/00.07.10.SqlDataProvider b/SqlDataProvider/00.07.10.SqlDataProvider new file mode 100644 index 0000000..01fd7c2 --- /dev/null +++ b/SqlDataProvider/00.07.10.SqlDataProvider @@ -0,0 +1,197 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + ADD SortOrder int +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category SET SortOrder = 0 +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255), + @Description ntext, + @SortOrder int +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ( + [ModuleID], + [ParentID], + [Name], + [Image], + [Description], + [SortOrder] +) VALUES ( + @ModuleID, + @ParentID, + @Name, + @Image, + @Description, + @SortOrder +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory + @CategoryID int, + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255), + @Description ntext, + @SortOrder int +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category SET + [ModuleID] = @ModuleID, + [ParentID] = @ParentID, + [Name] = @Name, + [Image] = @Image, + [Description] = @Description, + [SortOrder] = @SortOrder +WHERE + [CategoryID] = @CategoryID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory + @CategoryID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image], + [Description], + [SortOrder] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [CategoryID] = @CategoryID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList + @ModuleID int, + @ParentID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image], + [Description], + [SortOrder] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [ModuleID] = @ModuleID + AND + [ParentID] = @ParentID +ORDER BY + [SortOrder], [Name] +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @Current int, + @CategoryID varchar(255), + @MaxDepth int +AS + +SET NOCOUNT ON + +DECLARE @FilterID int +SET @FilterID = @Current + +DECLARE @level int, @line int + +CREATE TABLE #hierarchy(HierarchyID int IDENTITY (1,1), CategoryID int, level int) +CREATE TABLE #stack (item int, level int) +INSERT INTO #stack VALUES (@current, 1) +SELECT @level = 1 + +WHILE @level > 0 +BEGIN + IF EXISTS (SELECT * FROM #stack WHERE level = @level) + BEGIN + SELECT @current = item + FROM #stack + WHERE level = @level + + insert into #hierarchy(CategoryID, level) values(@current, @level) + + DELETE FROM #stack + WHERE level = @level + AND item = @current + + IF( @MaxDepth IS NULL OR @MaxDepth >= @level ) + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [SortOrder] DESC, [Name] DESC + + IF @@ROWCOUNT > 0 + SELECT @level = @level + 1 + END + END + ELSE + SELECT @level = @level - 1 +END -- WHILE + +IF( @FilterID IS NOT NULL ) +BEGIN + DELETE FROM #hierarchy WHERE CategoryID = @FilterID +END + +DECLARE @strModuleID nvarchar(50) +SELECT @strModuleID = convert(varchar, @ModuleID) + +DECLARE @strCategoryId nvarchar(255) +IF (@CategoryId is not null) + SELECT @strCategoryId = ' AND c.CategoryID in (' + @CategoryID + ')' + +EXEC(' +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE(''.'',(level-2)*2) + c.[Name] as ''NameIndented'', + c.[Image], + c.[Description], + c.[SortOrder], + level-1 as ''Level'', + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac WHERE ac.CategoryID = c.CategoryID) as ''NumberofArticles'', + (SELECT SUM(a.NumberOfViews) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON a.ArticleID = ac.ArticleID WHERE ac.CategoryID = c.CategoryID) as ''NumberofViews'' +FROM + #hierarchy h INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON h.CategoryID = c.CategoryID +WHERE + c.[ModuleID] = ' + @strModuleID + @strCategoryId + ' +ORDER BY + h.HierarchyID ASC') + +drop table #hierarchy +drop table #stack +GO diff --git a/SqlDataProvider/00.07.13.SqlDataProvider b/SqlDataProvider/00.07.13.SqlDataProvider new file mode 100644 index 0000000..df1894b --- /dev/null +++ b/SqlDataProvider/00.07.13.SqlDataProvider @@ -0,0 +1,207 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords varchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate < GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate > ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO diff --git a/SqlDataProvider/00.07.14.SqlDataProvider b/SqlDataProvider/00.07.14.SqlDataProvider new file mode 100644 index 0000000..de13278 --- /dev/null +++ b/SqlDataProvider/00.07.14.SqlDataProvider @@ -0,0 +1,88 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @Current int, + @CategoryID varchar(255), + @MaxDepth int +AS + +SET NOCOUNT ON + +DECLARE @FilterID int +SET @FilterID = @Current + +DECLARE @level int, @line int + +CREATE TABLE #hierarchy(HierarchyID int IDENTITY (1,1), CategoryID int, level int) +CREATE TABLE #stack (item int, level int) +INSERT INTO #stack VALUES (@current, 1) +SELECT @level = 1 + +WHILE @level > 0 +BEGIN + IF EXISTS (SELECT * FROM #stack WHERE level = @level) + BEGIN + SELECT @current = item + FROM #stack + WHERE level = @level + + insert into #hierarchy(CategoryID, level) values(@current, @level) + + DELETE FROM #stack + WHERE level = @level + AND item = @current + + IF( @MaxDepth IS NULL OR @MaxDepth >= @level ) + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [SortOrder] DESC, [Name] DESC + + IF @@ROWCOUNT > 0 + SELECT @level = @level + 1 + END + END + ELSE + SELECT @level = @level - 1 +END -- WHILE + +IF( @FilterID IS NOT NULL ) +BEGIN + DELETE FROM #hierarchy WHERE CategoryID = @FilterID +END + +DECLARE @strModuleID nvarchar(50) +SELECT @strModuleID = convert(varchar, @ModuleID) + +DECLARE @strCategoryId nvarchar(255) +IF (@CategoryId is not null) + SELECT @strCategoryId = ' AND c.CategoryID in (' + @CategoryID + ')' + +EXEC(' +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE(''.'',(level-2)*2) + c.[Name] as ''NameIndented'', + c.[Image], + c.[Description], + c.[SortOrder], + level-1 as ''Level'', + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1) as ''NumberofArticles'', + (SELECT SUM(a.NumberOfViews) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON a.ArticleID = ac.ArticleID WHERE ac.CategoryID = c.CategoryID) as ''NumberofViews'' +FROM + #hierarchy h INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON h.CategoryID = c.CategoryID +WHERE + c.[ModuleID] = ' + @strModuleID + @strCategoryId + ' +ORDER BY + h.HierarchyID ASC') + +drop table #hierarchy +drop table #stack +GO diff --git a/SqlDataProvider/00.07.20.SqlDataProvider b/SqlDataProvider/00.07.20.SqlDataProvider new file mode 100644 index 0000000..cf51d8f --- /dev/null +++ b/SqlDataProvider/00.07.20.SqlDataProvider @@ -0,0 +1,138 @@ +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Handout( + [HandoutID] [int] IDENTITY(1,1) NOT NULL, + [ModuleID] [int] NOT NULL, + [UserID] [int] NULL, + [Name] [nvarchar](255) NOT NULL, + [Description] [ntext] NULL +) ON [PRIMARY] +GO + +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_HandoutArticle( + [HandoutID] [int] NOT NULL, + [ArticleID] [int] NOT NULL, + [SortOrder] [int] NOT NULL +) ON [PRIMARY] +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddHandout + @ModuleID int, + @UserID int, + @Name nvarchar(255), + @Description ntext +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Handout ( + [ModuleID], + [UserID], + [Name], + [Description] +) VALUES ( + @ModuleID, + @UserID, + @Name, + @Description +) + +select SCOPE_IDENTITY() +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddHandoutArticle + @HandoutID int, + @ArticleID int, + @SortOrder int +AS + +INSERT INTO + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_HandoutArticle(HandoutID, ArticleID, SortOrder) +VALUES + (@HandoutID, @ArticleID, @SortOrder) +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteHandout + @HandoutID int +AS + +DELETE FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Handout +WHERE + HandoutID = @HandoutID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteHandoutArticleList + @HandoutID int +AS + +DELETE FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_HandoutArticle +WHERE + HandoutID = @HandoutID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetHandout + @HandoutID int +AS + +SELECT + [HandoutID], + [ModuleID], + [UserID], + [Name], + [Description] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Handout +WHERE + HandoutID = @HandoutID +Go + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetHandoutArticleList + @HandoutID int +AS + +SELECT + [HandoutID], + [ArticleID], + [SortOrder] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_HandoutArticle +WHERE + HandoutID = @HandoutID +ORDER BY + [SortOrder] ASC +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetHandoutList + @UserID int +AS + +SELECT + [HandoutID], + [ModuleID], + [UserID], + [Name], + [Description] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Handout +WHERE + [UserID] = @UserID +ORDER BY + [Name] +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateHandout + @HandoutID int, + @ModuleID int, + @UserID int, + @Name nvarchar(255), + @Description ntext +AS + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Handout +SET + [ModuleID] = @ModuleID, + [UserID] = @UserID, + [Name] = @Name, + [Description] = @Description +WHERE + HandoutID = @HandoutID +GO diff --git a/SqlDataProvider/00.07.32.SqlDataProvider b/SqlDataProvider/00.07.32.SqlDataProvider new file mode 100644 index 0000000..a3ad3b5 --- /dev/null +++ b/SqlDataProvider/00.07.32.SqlDataProvider @@ -0,0 +1,398 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics + @ModuleID int, + @CategoryID varchar(255), + @SortBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@ShowPending is null ) + SELECT @strWhere = @strWhere + ' AND (Articles.StartDate is null OR Articles.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' + +EXEC(' +SELECT + UserID, UserName, DisplayName, FirstName, LastName, count(*) as ''ArticleCount'' +FROM + {databaseOwner}{objectQualifier}Users Users, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles +where Articles.IsApproved = 1 and Articles.IsDraft = 0 and Users.UserID = Articles.AuthorID ' + + @strWhere + ' +GROUP BY + UserID, UserName, DisplayName, FirstName, LastName +ORDER BY ' + + @SortBy) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @Current int, + @CategoryID varchar(255), + @MaxDepth int, + @ShowPending bit +AS + +SET NOCOUNT ON + +DECLARE @FilterID int +SET @FilterID = @Current + +DECLARE @level int, @line int + +CREATE TABLE #hierarchy(HierarchyID int IDENTITY (1,1), CategoryID int, level int) +CREATE TABLE #stack (item int, level int) +INSERT INTO #stack VALUES (@current, 1) +SELECT @level = 1 + +WHILE @level > 0 +BEGIN + IF EXISTS (SELECT * FROM #stack WHERE level = @level) + BEGIN + SELECT @current = item + FROM #stack + WHERE level = @level + + insert into #hierarchy(CategoryID, level) values(@current, @level) + + DELETE FROM #stack + WHERE level = @level + AND item = @current + + IF( @MaxDepth IS NULL OR @MaxDepth >= @level ) + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [SortOrder] DESC, [Name] DESC + + IF @@ROWCOUNT > 0 + SELECT @level = @level + 1 + END + END + ELSE + SELECT @level = @level - 1 +END -- WHILE + +IF( @FilterID IS NOT NULL ) +BEGIN + DELETE FROM #hierarchy WHERE CategoryID = @FilterID +END + +DECLARE @strModuleID nvarchar(50) +SELECT @strModuleID = convert(varchar, @ModuleID) + +DECLARE @strCategoryId nvarchar(255) +IF (@CategoryId is not null) + SELECT @strCategoryId = ' AND c.CategoryID in (' + @CategoryID + ')' + +DECLARE @strPending nvarchar(2000) +IF (@ShowPending is null) + SELECT @strPending = ' AND (a.StartDate IS NULL OR a.StartDate < GetDate())' + +EXEC(' +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE(''.'',(level-2)*2) + c.[Name] as ''NameIndented'', + c.[Image], + c.[Description], + c.[SortOrder], + level-1 as ''Level'', + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 ' + @strPending + ') as ''NumberofArticles'', + (SELECT SUM(a.NumberOfViews) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON a.ArticleID = ac.ArticleID WHERE ac.CategoryID = c.CategoryID) as ''NumberofViews'' +FROM + #hierarchy h INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON h.CategoryID = c.CategoryID +WHERE + c.[ModuleID] = ' + @strModuleID + @strCategoryId + ' +ORDER BY + h.HierarchyID ASC') + +drop table #hierarchy +drop table #stack +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(255), + @GroupBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@ShowPending is null) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' +END + +IF( @GroupBy = 'Month' ) +BEGIN +EXEC(' + select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate), Month(StartDate) + order by [Year] desc, [Month] desc') +END +ELSE +BEGIN +EXEC(' + select 1 as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate) + order by [Year] desc') +END +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords varchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate < GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @CurrentDate is not null AND @AgedDate is not null ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + '''))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' + END +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate > ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO diff --git a/SqlDataProvider/00.07.33.SqlDataProvider b/SqlDataProvider/00.07.33.SqlDataProvider new file mode 100644 index 0000000..8e7de48 --- /dev/null +++ b/SqlDataProvider/00.07.33.SqlDataProvider @@ -0,0 +1,193 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics + @ModuleID int, + @CategoryID varchar(255), + @AuthorID int, + @SortBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@ShowPending is null ) + SELECT @strWhere = @strWhere + ' AND (Articles.StartDate is null OR Articles.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' + +EXEC(' +SELECT + UserID, UserName, DisplayName, FirstName, LastName, count(*) as ''ArticleCount'' +FROM + {databaseOwner}{objectQualifier}Users Users, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles +where Articles.IsApproved = 1 and Articles.IsDraft = 0 and Users.UserID = Articles.AuthorID ' + + @strWhere + ' +GROUP BY + UserID, UserName, DisplayName, FirstName, LastName +ORDER BY ' + + @SortBy) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(255), + @AuthorID int, + @GroupBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@ShowPending is null) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' +END + +IF( @GroupBy = 'Month' ) +BEGIN +EXEC(' + select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate), Month(StartDate) + order by [Year] desc, [Month] desc') +END +ELSE +BEGIN +EXEC(' + select 1 as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate) + order by [Year] desc') +END +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @Current int, + @CategoryID varchar(255), + @AuthorID int, + @MaxDepth int, + @ShowPending bit +AS + +SET NOCOUNT ON + +DECLARE @FilterID int +SET @FilterID = @Current + +DECLARE @level int, @line int + +CREATE TABLE #hierarchy(HierarchyID int IDENTITY (1,1), CategoryID int, level int) +CREATE TABLE #stack (item int, level int) +INSERT INTO #stack VALUES (@current, 1) +SELECT @level = 1 + +WHILE @level > 0 +BEGIN + IF EXISTS (SELECT * FROM #stack WHERE level = @level) + BEGIN + SELECT @current = item + FROM #stack + WHERE level = @level + + insert into #hierarchy(CategoryID, level) values(@current, @level) + + DELETE FROM #stack + WHERE level = @level + AND item = @current + + IF( @MaxDepth IS NULL OR @MaxDepth >= @level ) + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [SortOrder] DESC, [Name] DESC + + IF @@ROWCOUNT > 0 + SELECT @level = @level + 1 + END + END + ELSE + SELECT @level = @level - 1 +END -- WHILE + +IF( @FilterID IS NOT NULL ) +BEGIN + DELETE FROM #hierarchy WHERE CategoryID = @FilterID +END + +DECLARE @strModuleID nvarchar(50) +SELECT @strModuleID = convert(varchar, @ModuleID) + +DECLARE @strCategoryId nvarchar(255) +IF (@CategoryId is not null) + SELECT @strCategoryId = ' AND c.CategoryID in (' + @CategoryID + ')' + +DECLARE @strAuthorId nvarchar(255) +IF (@authorId is not null) + SELECT @strAuthorId = ' AND a.AuthorID = ' + cast(@AuthorID as nvarchar) + +DECLARE @strPending nvarchar(2000) +IF (@ShowPending is null) + SELECT @strPending = ' AND (a.StartDate IS NULL OR a.StartDate < GetDate())' + +EXEC(' +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE(''.'',(level-2)*2) + c.[Name] as ''NameIndented'', + c.[Image], + c.[Description], + c.[SortOrder], + level-1 as ''Level'', + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 ' + @strAuthorId + @strPending + ') as ''NumberofArticles'', + (SELECT SUM(a.NumberOfViews) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON a.ArticleID = ac.ArticleID WHERE ac.CategoryID = c.CategoryID) as ''NumberofViews'' +FROM + #hierarchy h INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON h.CategoryID = c.CategoryID +WHERE + c.[ModuleID] = ' + @strModuleID + @strCategoryId + ' +ORDER BY + h.HierarchyID ASC') + +drop table #hierarchy +drop table #stack +GO diff --git a/SqlDataProvider/00.07.41.SqlDataProvider b/SqlDataProvider/00.07.41.SqlDataProvider new file mode 100644 index 0000000..2ea988d --- /dev/null +++ b/SqlDataProvider/00.07.41.SqlDataProvider @@ -0,0 +1,217 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(255), + @CategoryIDCount int, + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate < GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @CurrentDate is not null AND @AgedDate is not null ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + '''))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' + END +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate > ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO diff --git a/SqlDataProvider/00.07.44.SqlDataProvider b/SqlDataProvider/00.07.44.SqlDataProvider new file mode 100644 index 0000000..07b58c2 --- /dev/null +++ b/SqlDataProvider/00.07.44.SqlDataProvider @@ -0,0 +1,230 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + MetaTitle nvarchar(200) NULL, + MetaDescription nvarchar(500) NULL, + MetaKeywords nvarchar(500) NULL, + PageHeadText nvarchar(500) NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500), + @PageHeadText nvarchar(500) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl], + [IsFeatured], + [LastUpdateID], + [Url], + [IsSecure], + [IsNewWindow], + [MetaTitle], + [MetaDescription], + [MetaKeywords], + [PageHeadText] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl, + @IsFeatured, + @LastUpdateID, + @Url, + @IsSecure, + @IsNewWindow, + @MetaTitle, + @MetaDescription, + @MetaKeywords, + @PageHeadText +) + +select SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500), + @PageHeadText nvarchar(500) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl, + [IsFeatured] = @IsFeatured, + [LastUpdateID] = @LastUpdateID, + [Url] = @Url, + [IsSecure] = @IsSecure, + [IsNewWindow] = @IsNewWindow, + [MetaTitle] = @MetaTitle, + [MetaDescription] = @MetaDescription, + [MetaKeywords] = @MetaKeywords, + [PageHeadText] = @PageHeadText +WHERE + [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as UpdatedDisplayName, + Page.PageText as 'Body' + +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + Article.[ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.07.46.SqlDataProvider b/SqlDataProvider/00.07.46.SqlDataProvider new file mode 100644 index 0000000..2c30ff8 --- /dev/null +++ b/SqlDataProvider/00.07.46.SqlDataProvider @@ -0,0 +1,221 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate < GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @CurrentDate is not null AND @AgedDate is not null ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + '''))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' + END +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate > ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO diff --git a/SqlDataProvider/00.07.47.SqlDataProvider b/SqlDataProvider/00.07.47.SqlDataProvider new file mode 100644 index 0000000..c4f6d02 --- /dev/null +++ b/SqlDataProvider/00.07.47.SqlDataProvider @@ -0,0 +1,288 @@ +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomField( + [CustomFieldID] [int] IDENTITY(1,1) NOT NULL, + [ModuleID] [int] NOT NULL, + [Name] [nvarchar](255) NOT NULL, + [FieldType] [int] NOT NULL, + [FieldElements] [ntext] NULL, + [DefaultValue] [nvarchar](255) NULL, + [Caption] [nvarchar](255) NULL, + [CaptionHelp] [nvarchar](255) NULL, + [IsRequired] [bit] NOT NULL, + [IsVisible] [bit] NOT NULL, + [SortOrder] [int] NOT NULL, + [ValidationType] [int] NOT NULL, + [RegularExpression] [nvarchar](4000) NULL, + [Length] [int] NULL +) ON [PRIMARY] +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomField ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_CustomField] PRIMARY KEY CLUSTERED + ( + [CustomFieldID] + ) ON [PRIMARY] +GO + +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue( + [CustomValueID] [int] IDENTITY(1,1) NOT NULL, + [ArticleID] [int] NOT NULL, + [CustomFieldID] [int] NOT NULL, + [CustomValue] [ntext] NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_CustomValue] PRIMARY KEY CLUSTERED + ( + [CustomValueID] + ) ON [PRIMARY] +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteArticle + @ArticleID int +AS + +DELETE FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue +WHERE + [ArticleID] = @ArticleID + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories +WHERE + [ArticleID] = @ArticleID + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +WHERE + [ArticleID] = @ArticleID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteCustomField + @CustomFieldID int +AS + +DELETE FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue +WHERE + CustomFieldID = @CustomFieldID + +DELETE FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomField +WHERE + CustomFieldID = @CustomFieldID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteCustomValue + @CustomValueID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue +WHERE + [CustomValueID] = @CustomValueID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCustomField + @CustomFieldID int +AS + +SELECT + CustomFieldID, + ModuleID, + [Name], + FieldType, + FieldElements, + DefaultValue, + Caption, + CaptionHelp, + IsRequired, + IsVisible, + SortOrder, + ValidationType, + RegularExpression, + [Length] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomField +WHERE + [CustomFieldID] = @CustomFieldID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCustomFieldList + @ModuleID int +AS + +SELECT + CustomFieldID, + ModuleID, + [Name], + FieldType, + FieldElements, + DefaultValue, + Caption, + CaptionHelp, + IsRequired, + IsVisible, + SortOrder, + ValidationType, + RegularExpression, + [Length] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomField +WHERE + [ModuleID] = @ModuleID +ORDER BY + SortOrder +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCustomValueByField + @ArticleID int, + @CustomFieldID int +AS + +SELECT + [CustomValueID], + [ArticleID], + [CustomFieldID], + [CustomValue] +FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue +WHERE + [ArticleID] = @ArticleID + and + [CustomFieldID] = @CustomFieldID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCustomValueList + @ArticleID int +AS + +SELECT + [CustomValueID], + [ArticleID], + [CustomFieldID], + [CustomValue] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue +WHERE + [ArticleID] = @ArticleID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCustomField + @CustomFieldID int, + @ModuleID int, + @Name nvarchar(255), + @FieldType int, + @FieldElements ntext, + @DefaultValue nvarchar(255), + @Caption nvarchar(255), + @CaptionHelp nvarchar(255), + @IsRequired bit, + @IsVisible bit, + @SortOrder int, + @ValidationType int, + @Length int, + @RegularExpression nvarchar(4000) +AS + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomField +SET + [ModuleID] = @ModuleID, + [Name] = @Name, + [FieldType] = @FieldType, + [FieldElements] = @FieldElements, + [DefaultValue] = @DefaultValue, + [Caption] = @Caption, + [CaptionHelp] = @CaptionHelp, + [IsRequired] = @IsRequired, + [IsVisible] = @IsVisible, + [SortOrder] = @SortOrder, + [ValidationType] = @ValidationType, + [Length] = @Length, + [RegularExpression] = @RegularExpression +WHERE + CustomFieldID = @CustomFieldID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCustomValue + @CustomValueID int, + @ArticleID int, + @CustomFieldID int, + @CustomValue ntext +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue SET + [ArticleID] = @ArticleID, + [CustomFieldID] = @CustomFieldID, + [CustomValue] = @CustomValue +WHERE + [CustomValueID] = @CustomValueID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCustomField + @ModuleID int, + @Name nvarchar(255), + @FieldType int, + @FieldElements ntext, + @DefaultValue nvarchar(255), + @Caption nvarchar(255), + @CaptionHelp nvarchar(255), + @IsRequired bit, + @IsVisible bit, + @SortOrder int, + @ValidationType int, + @Length int, + @RegularExpression nvarchar(4000) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomField ( + [ModuleID], + [Name], + [FieldType], + [FieldElements], + [DefaultValue], + [Caption], + [CaptionHelp], + [IsRequired], + [IsVisible], + [SortOrder], + [ValidationType], + [Length], + [RegularExpression] +) VALUES ( + @ModuleID, + @Name, + @FieldType, + @FieldElements, + @DefaultValue, + @Caption, + @CaptionHelp, + @IsRequired, + @IsVisible, + @SortOrder, + @ValidationType, + @Length, + @RegularExpression +) + +select SCOPE_IDENTITY() +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCustomValue + @ArticleID int, + @CustomFieldID int, + @CustomValue ntext +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue ( + [ArticleID], + [CustomFieldID], + [CustomValue] +) VALUES ( + @ArticleID, + @CustomFieldID, + @CustomValue +) + +select SCOPE_IDENTITY() +GO diff --git a/SqlDataProvider/00.07.48.SqlDataProvider b/SqlDataProvider/00.07.48.SqlDataProvider new file mode 100644 index 0000000..6c5a327 --- /dev/null +++ b/SqlDataProvider/00.07.48.SqlDataProvider @@ -0,0 +1,10 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue DROP + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_CustomValue] +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_CustomValue] PRIMARY KEY CLUSTERED + ( + [CustomValueID] + ) ON [PRIMARY] +GO diff --git a/SqlDataProvider/00.07.52.SqlDataProvider b/SqlDataProvider/00.07.52.SqlDataProvider new file mode 100644 index 0000000..35eb390 --- /dev/null +++ b/SqlDataProvider/00.07.52.SqlDataProvider @@ -0,0 +1,6 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Handout ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_Handout] PRIMARY KEY CLUSTERED + ( + [HandoutID] + ) ON [PRIMARY] +GO diff --git a/SqlDataProvider/00.07.53.SqlDataProvider b/SqlDataProvider/00.07.53.SqlDataProvider new file mode 100644 index 0000000..dc85c42 --- /dev/null +++ b/SqlDataProvider/00.07.53.SqlDataProvider @@ -0,0 +1,487 @@ +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag( + [TagID] [int] IDENTITY(1,1) NOT NULL, + [ModuleID] [int] NOT NULL, + [Name] [nvarchar](255) NOT NULL, + [NameLowered] [nvarchar](255) NOT NULL, + [Usages] [int] NULL +) ON [PRIMARY] +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_Tag] PRIMARY KEY CLUSTERED + ( + [TagID] + ) ON [PRIMARY] +GO + +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag( + [ArticleID] [int] NOT NULL, + [TagID] [int] NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_ArticleTag] PRIMARY KEY CLUSTERED + ( + [ArticleID] ASC, + [TagID] ASC + ) ON [PRIMARY] +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_TagAdd + @ModuleID int, + @Name nvarchar(50), + @NameLowered nvarchar(50) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag ( + [ModuleID], + [Name], + [NameLowered] +) VALUES ( + @ModuleID, + @Name, + @NameLowered +) + +select SCOPE_IDENTITY() +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_TagGet + @TagID int +AS + +SELECT + [TagID], + [ModuleID], + [Name], + [NameLowered], + [Usages] +FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag +WHERE + [TagID] = @TagID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_TagGetByName + @ModuleID int, + @NameLowered nvarchar(50) +AS + +SELECT TOP 1 + [TagID], + [ModuleID], + [Name], + [NameLowered], + [Usages] +FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag +WHERE + [ModuleID] = @ModuleID + and + [NameLowered] = @NameLowered +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_TagList + @ModuleID int, + @MaxCount int +AS + +if( @MaxCount is not null ) +begin + SET ROWCOUNT @MaxCount +end + +SELECT + t.[TagID], + t.[ModuleID], + t.[Name], + t.[NameLowered], + t.[Usages] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag t +WHERE + t.[ModuleID] = @ModuleID +ORDER BY + t.[Usages] DESC +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_TagUpdate + @TagID int, + @ModuleID int, + @Name nvarchar(50), + @NameLowered nvarchar(50), + @Usages int +AS + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag +SET + [ModuleID] = @ModuleID, + [Name] = @Name, + [NameLowered] = @NameLowered, + [Usages] = @Usages +WHERE + [TagID] = @TagID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTagAdd + @ArticleID int, + @TagID int +AS + +IF( (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag WHERE ArticleID = @ArticleID and TagID = @TagID) = 0 ) +BEGIN + INSERT INTO + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag(ArticleID, TagID) + VALUES(@ArticleID, @TagID) + + UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag + SET + Usages = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag pt where pt.TagID = @TagID) + WHERE + TagID = @TagID +END +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTagDelete + @ArticleID int +AS + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag +SET + Usages = Usages - 1 +WHERE + TagID in (SELECT pt.TagID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag pt where ArticleID = @ArticleID) + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag +WHERE Usages = 0 + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag +WHERE ArticleID = @ArticleID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTagDeleteByTag + @TagID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag +WHERE TagID = @TagID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_TagDelete + @TagID int +AS + +exec {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTagDeleteByTag @TagID + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag +WHERE + [TagID] = @TagID +GO + +CREATE FUNCTION {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags +(@ArticleID int) +RETURNS nvarchar(2000) +AS + BEGIN + + DECLARE @p_str nvarchar(2000) + SET @p_str = '' + + SELECT @p_str = @p_str + ' ' + CAST(t.[Name] AS NVARCHAR(50)) + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag t, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag at + WHERE t.TagID = at.TagID and at.ArticleID = @ArticleID + + RETURN LTRIM(@p_str) + +END +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate < GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @CurrentDate is not null AND @AgedDate is not null ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + '''))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' + END +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate > ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as UpdatedDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + Article.[ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.07.55.SqlDataProvider b/SqlDataProvider/00.07.55.SqlDataProvider new file mode 100644 index 0000000..de1d46b --- /dev/null +++ b/SqlDataProvider/00.07.55.SqlDataProvider @@ -0,0 +1,469 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + ShortUrl nvarchar(50) NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500), + @PageHeadText nvarchar(500), + @ShortUrl nvarchar(50) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl], + [IsFeatured], + [LastUpdateID], + [Url], + [IsSecure], + [IsNewWindow], + [MetaTitle], + [MetaDescription], + [MetaKeywords], + [PageHeadText], + [ShortUrl] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl, + @IsFeatured, + @LastUpdateID, + @Url, + @IsSecure, + @IsNewWindow, + @MetaTitle, + @MetaDescription, + @MetaKeywords, + @PageHeadText, + @ShortUrl +) + +select SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500), + @PageHeadText nvarchar(500), + @ShortUrl nvarchar(50) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl, + [IsFeatured] = @IsFeatured, + [LastUpdateID] = @LastUpdateID, + [Url] = @Url, + [IsSecure] = @IsSecure, + [IsNewWindow] = @IsNewWindow, + [MetaTitle] = @MetaTitle, + [MetaDescription] = @MetaDescription, + [MetaKeywords] = @MetaKeywords, + [PageHeadText] = @PageHeadText, + [ShortUrl] = @ShortUrl +WHERE + [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate < GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @CurrentDate is not null AND @AgedDate is not null ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + '''))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' + END +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate > ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE ''%' + @Keywords + '%'' OR Article.Summary LIKE ''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE ''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as UpdatedDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + Article.[ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.07.56.SqlDataProvider b/SqlDataProvider/00.07.56.SqlDataProvider new file mode 100644 index 0000000..d129b8c --- /dev/null +++ b/SqlDataProvider/00.07.56.SqlDataProvider @@ -0,0 +1,261 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate < GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @CurrentDate is not null AND @AgedDate is not null ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + '''))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' + END +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate > ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO + +DROP FUNCTION {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags +GO + +CREATE FUNCTION {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags +(@ArticleID int) +RETURNS nvarchar(2000) +AS + BEGIN + + DECLARE @p_str nvarchar(2000) + SET @p_str = '' + + SELECT @p_str = @p_str + ',' + CAST(t.[Name] AS NVARCHAR(50)) + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag t, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag at + WHERE t.TagID = at.TagID and at.ArticleID = @ArticleID + + IF( LEN(@p_str) > 0 ) + BEGIN + SELECT @p_str = SUBSTRING(@p_str, 2, (LEN(@p_str)-1)) + END + + RETURN LTRIM(@p_str) + +END +GO diff --git a/SqlDataProvider/00.07.57.SqlDataProvider b/SqlDataProvider/00.07.57.SqlDataProvider new file mode 100644 index 0000000..3f2a0eb --- /dev/null +++ b/SqlDataProvider/00.07.57.SqlDataProvider @@ -0,0 +1,615 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + RssGuid nvarchar(255) NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate < GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @CurrentDate is not null AND @AgedDate is not null ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + '''))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' + END +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate > ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO + +DROP FUNCTION {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags +GO + +CREATE FUNCTION {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags +(@ArticleID int) +RETURNS nvarchar(2000) +AS + BEGIN + + DECLARE @p_str nvarchar(2000) + SET @p_str = '' + + SELECT @p_str = @p_str + ',' + CAST(t.[Name] AS NVARCHAR(50)) + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag t, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag at + WHERE t.TagID = at.TagID and at.ArticleID = @ArticleID + + IF( LEN(@p_str) > 0 ) + BEGIN + SELECT @p_str = SUBSTRING(@p_str, 2, (LEN(@p_str)-1)) + END + + RETURN LTRIM(@p_str) + +END +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500), + @PageHeadText nvarchar(500), + @ShortUrl nvarchar(50), + @RssGuid nvarchar(255) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl], + [IsFeatured], + [LastUpdateID], + [Url], + [IsSecure], + [IsNewWindow], + [MetaTitle], + [MetaDescription], + [MetaKeywords], + [PageHeadText], + [ShortUrl], + [RssGuid] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl, + @IsFeatured, + @LastUpdateID, + @Url, + @IsSecure, + @IsNewWindow, + @MetaTitle, + @MetaDescription, + @MetaKeywords, + @PageHeadText, + @ShortUrl, + @RssGuid +) + +select SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500), + @PageHeadText nvarchar(500), + @ShortUrl nvarchar(50), + @RssGuid nvarchar(255) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl, + [IsFeatured] = @IsFeatured, + [LastUpdateID] = @LastUpdateID, + [Url] = @Url, + [IsSecure] = @IsSecure, + [IsNewWindow] = @IsNewWindow, + [MetaTitle] = @MetaTitle, + [MetaDescription] = @MetaDescription, + [MetaKeywords] = @MetaKeywords, + [PageHeadText] = @PageHeadText, + [ShortUrl] = @ShortUrl, + [RssGuid] = @RssGuid +WHERE + [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID +GO + +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed( + [FeedID] [int] IDENTITY(1,1) NOT NULL, + [ModuleID] [int] NOT NULL, + [Title] [nvarchar](255) NULL, + [Url] [nvarchar](255) NOT NULL, + [UserID] [int] NOT NULL, + [AutoFeature] [bit] NOT NULL, + [IsActive] [bit] NOT NULL, +) ON [PRIMARY] +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_Feed] PRIMARY KEY CLUSTERED + ( + [FeedID] + ) ON [PRIMARY] +GO + +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedCategory( + [FeedID] [int] NOT NULL, + [CategoryID] [int] NOT NULL, +) ON [PRIMARY] +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedCategory ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_FeedCategory] PRIMARY KEY CLUSTERED + ( + [FeedID], + [CategoryID] + ) ON [PRIMARY] +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedAdd + @ModuleID int, + @Title nvarchar(255), + @Url nvarchar(255), + @UserID int, + @AutoFeature bit, + @IsActive bit +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed ( + [ModuleID], + [Title], + [Url], + [UserID], + [AutoFeature], + [IsActive] +) VALUES ( + @ModuleID, + @Title, + @Url, + @UserID, + @AutoFeature, + @IsActive +) + +select SCOPE_IDENTITY() +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedCategoryAdd + @FeedID int, + @CategoryID int +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedCategory(FeedID, CategoryID) + VALUES(@FeedID, @CategoryID) +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedCategoryDelete + @FeedID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedCategory +WHERE FeedID = @FeedID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedCategoryList + @FeedID int +AS + +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + c.[Image], + c.[Description], + c.[SortOrder] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedCategory fc INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON fc.categoryID = c.categoryID +WHERE + fc.FeedID = @FeedID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedDelete + @FeedID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed +WHERE + [FeedID] = @FeedID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedGet + @FeedID int +AS + +SELECT + FeedID, + ModuleID, + Title, + Url, + UserID, + AutoFeature, + IsActive +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed +WHERE + FeedID = @FeedID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedList + @ModuleID int, + @ShowActiveOnly bit +AS + +SELECT + FeedID, + ModuleID, + Title, + Url, + UserID, + AutoFeature, + IsActive +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed +WHERE + (@ModuleID = -1 OR ModuleID = @ModuleID) + AND + (@ShowActiveOnly = 0 OR IsActive = 1) +ORDER BY + Title +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedUpdate + @FeedID int, + @ModuleID int, + @Title nvarchar(255), + @Url nvarchar(255), + @UserID int, + @AutoFeature bit, + @IsActive bit +AS + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed +SET + [ModuleID] = @ModuleID, + [Title] = @Title, + [Url] = @Url, + [UserID] = @UserID, + [AutoFeature] = @AutoFeature, + [IsActive] = @IsActive +WHERE + [FeedID] = @FeedID +GO diff --git a/SqlDataProvider/00.07.58.SqlDataProvider b/SqlDataProvider/00.07.58.SqlDataProvider new file mode 100644 index 0000000..979be18 --- /dev/null +++ b/SqlDataProvider/00.07.58.SqlDataProvider @@ -0,0 +1,299 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate < GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @CurrentDate is not null AND @AgedDate is not null ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate < ''' + convert(nvarchar, @CurrentDate) + '''))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate > ''' + convert(nvarchar, @AgedDate) + '''' + END +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate > ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as UpdatedDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + Article.[ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.07.59.SqlDataProvider b/SqlDataProvider/00.07.59.SqlDataProvider new file mode 100644 index 0000000..fdfe20a --- /dev/null +++ b/SqlDataProvider/00.07.59.SqlDataProvider @@ -0,0 +1,240 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate <= GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @CurrentDate is not null AND @AgedDate is not null ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + convert(nvarchar, @CurrentDate) + '''))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' + END +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate >= ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO diff --git a/SqlDataProvider/00.07.61.SqlDataProvider b/SqlDataProvider/00.07.61.SqlDataProvider new file mode 100644 index 0000000..ca873c0 --- /dev/null +++ b/SqlDataProvider/00.07.61.SqlDataProvider @@ -0,0 +1,806 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed ADD + DateMode int NOT NULL CONSTRAINT DF_{objectQualifier}DnnForge_NewsArticles_Feed_DateMode DEFAULT 0, + AutoExpire int NULL, + AutoExpireUnit int NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedAdd +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedAdd + @ModuleID int, + @Title nvarchar(255), + @Url nvarchar(255), + @UserID int, + @AutoFeature bit, + @IsActive bit, + @DateMode int, + @AutoExpire int, + @AutoExpireUnit int +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed ( + [ModuleID], + [Title], + [Url], + [UserID], + [AutoFeature], + [IsActive], + [DateMode], + [AutoExpire], + [AutoExpireUnit] +) VALUES ( + @ModuleID, + @Title, + @Url, + @UserID, + @AutoFeature, + @IsActive, + @DateMode, + @AutoExpire, + @AutoExpireUnit +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedGet +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedGet + @FeedID int +AS + +SELECT + FeedID, + ModuleID, + Title, + Url, + UserID, + AutoFeature, + IsActive, + DateMode, + AutoExpire, + AutoExpireUnit +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed +WHERE + FeedID = @FeedID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedList + @ModuleID int, + @ShowActiveOnly bit +AS + +SELECT + FeedID, + ModuleID, + Title, + Url, + UserID, + AutoFeature, + IsActive, + DateMode, + AutoExpire, + AutoExpireUnit +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed +WHERE + (@ModuleID = -1 OR ModuleID = @ModuleID) + AND + (@ShowActiveOnly = 0 OR IsActive = 1) +ORDER BY + Title +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedUpdate +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FeedUpdate + @FeedID int, + @ModuleID int, + @Title nvarchar(255), + @Url nvarchar(255), + @UserID int, + @AutoFeature bit, + @IsActive bit, + @DateMode int, + @AutoExpire int, + @AutoExpireUnit int +AS + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Feed +SET + [ModuleID] = @ModuleID, + [Title] = @Title, + [Url] = @Url, + [UserID] = @UserID, + [AutoFeature] = @AutoFeature, + [IsActive] = @IsActive, + [DateMode] = @DateMode, + [AutoExpire] = @AutoExpire, + [AutoExpireUnit] = @AutoExpireUnit +WHERE + [FeedID] = @FeedID +GO + +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image( + [ImageID] [int] IDENTITY(1,1) NOT NULL, + [ArticleID] [int] NULL, + [Title] [nvarchar](100) NULL, + [FileName] [nvarchar](100) NULL, + [Extension] [nvarchar](100) NULL, + [Size] [int] NULL, + [Width] [int] NULL, + [Height] [int] NULL, + [ContentType] [nvarchar](200) NULL, + [Folder] [nvarchar](200) NULL, + [SortOrder] [int] NOT NULL CONSTRAINT [DF_{objectQualifier}DnnForge_NewsArticles_Image_SortOrder] DEFAULT ((0)), + [ImageGuid] [nvarchar](50) NULL, + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_Image] PRIMARY KEY CLUSTERED +( + [ImageID] ASC +) +) ON [PRIMARY] +GO + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image(ArticleID, Title, FileName, Extension, Size, Width, Height, ContentType, Folder, SortOrder) +SELECT + a.ArticleID, + f.FileName, + f.FileName, + f.Extension, + f.Size, + f.Width, + f.Height, + f.ContentType, + f.Folder, + 0 +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN + {databaseOwner}{objectQualifier}Files f ON 'FileID=' + CONVERT(varchar, f.FileID) = a.ImageUrl +GO + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET + ImageUrl = NULL +WHERE + ArticleID IN (SELECT a.ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}Files f ON 'FileID=' + CONVERT(varchar, f.FileID) = a.ImageUrl) +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageAdd + @ArticleID int, + @Title nvarchar(100), + @FileName nvarchar(100), + @Extension nvarchar(100), + @Size int, + @Width int, + @Height int, + @ContentType nvarchar(200), + @Folder nvarchar(200), + @SortOrder int, + @ImageGuid nvarchar(50) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image ( + [ArticleID], + [Title], + [FileName], + [Extension], + [Size], + [Width], + [Height], + [ContentType], + [Folder], + [SortOrder], + [ImageGuid] +) VALUES ( + @ArticleID, + @Title, + @FileName, + @Extension, + @Size, + @Width, + @Height, + @ContentType, + @Folder, + @SortOrder, + @ImageGuid +) + +select SCOPE_IDENTITY() +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageUpdate + @ImageID int, + @ArticleID int, + @Title nvarchar(100), + @FileName nvarchar(100), + @Extension nvarchar(100), + @Size int, + @Width int, + @Height int, + @ContentType nvarchar(200), + @Folder nvarchar(200), + @SortOrder int, + @ImageGuid nvarchar(50) +AS + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +SET + [ArticleID] = @ArticleID, + [Title] = @Title, + [FileName] = @FileName, + [Extension] = @Extension, + [Size] = @Size, + [Width] = @Width, + [Height] = @Height, + [ContentType] = @ContentType, + [Folder] = @Folder, + [SortOrder] = @SortOrder, + [ImageGuid] = @ImageGuid +WHERE + [ImageID] = @ImageID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageGet + @ImageID int +AS + +SELECT + ImageID, + ArticleID, + Title, + FileName, + Extension, + Size, + Width, + Height, + ContentType, + Folder, + SortOrder, + ImageGuid +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +WHERE + ImageID = @ImageID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageList + @ArticleID int, + @ImageGuid nvarchar(50) +AS + +SELECT + ImageID, + ArticleID, + Title, + FileName, + Extension, + Size, + Width, + Height, + ContentType, + Folder, + SortOrder, + ImageGuid +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +WHERE + (@ArticleID IS NULL OR ArticleID = @ArticleID) + AND + (@ImageGuid IS NULL OR ImageGuid = @ImageGuid) +ORDER BY + SortOrder +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageDelete + @ImageID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image WHERE ImageID = @ImageID +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + ImageCount int NULL +GO + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET + ImageCount = (SELECT count(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image i WHERE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID = i.ArticleID) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate <= GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @CurrentDate is not null AND @AgedDate is not null ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + convert(nvarchar, @CurrentDate) + '''))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' + END +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate >= ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as UpdatedDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + Article.[ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500), + @PageHeadText nvarchar(500), + @ShortUrl nvarchar(50), + @RssGuid nvarchar(255) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl], + [IsFeatured], + [LastUpdateID], + [Url], + [IsSecure], + [IsNewWindow], + [MetaTitle], + [MetaDescription], + [MetaKeywords], + [PageHeadText], + [ShortUrl], + [RssGuid] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl, + @IsFeatured, + @LastUpdateID, + @Url, + @IsSecure, + @IsNewWindow, + @MetaTitle, + @MetaDescription, + @MetaKeywords, + @PageHeadText, + @ShortUrl, + @RssGuid +) + +select SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [ImageCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image i where i.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500), + @PageHeadText nvarchar(500), + @ShortUrl nvarchar(50), + @RssGuid nvarchar(255) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl, + [IsFeatured] = @IsFeatured, + [LastUpdateID] = @LastUpdateID, + [Url] = @Url, + [IsSecure] = @IsSecure, + [IsNewWindow] = @IsNewWindow, + [MetaTitle] = @MetaTitle, + [MetaDescription] = @MetaDescription, + [MetaKeywords] = @MetaKeywords, + [PageHeadText] = @PageHeadText, + [ShortUrl] = @ShortUrl, + [RssGuid] = @RssGuid +WHERE + [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [ImageCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image i where i.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.07.63.SqlDataProvider b/SqlDataProvider/00.07.63.SqlDataProvider new file mode 100644 index 0000000..ecd96e9 --- /dev/null +++ b/SqlDataProvider/00.07.63.SqlDataProvider @@ -0,0 +1,236 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate <= GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate >= ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO diff --git a/SqlDataProvider/00.07.64.SqlDataProvider b/SqlDataProvider/00.07.64.SqlDataProvider new file mode 100644 index 0000000..6e61c57 --- /dev/null +++ b/SqlDataProvider/00.07.64.SqlDataProvider @@ -0,0 +1,241 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255), + @CustomFieldID int, + @CustomValue nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate <= GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate >= ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + +IF (@CustomFieldID is not null AND @CustomValue is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID IN (SELECT ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue cv WHERE cv.customFieldID = ' + convert(nvarchar, @CustomFieldID) + ' AND cv.CustomValue LIKE N''%' + @CustomValue + '%'')' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO diff --git a/SqlDataProvider/00.07.66.SqlDataProvider b/SqlDataProvider/00.07.66.SqlDataProvider new file mode 100644 index 0000000..2b1c5c7 --- /dev/null +++ b/SqlDataProvider/00.07.66.SqlDataProvider @@ -0,0 +1,13 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteCustomValue +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteCustomValue + @ArticleID int, + @CustomFieldID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue +WHERE + [ArticleID] = @ArticleID AND + [CustomFieldID] = @CustomFieldID +GO diff --git a/SqlDataProvider/00.07.67.SqlDataProvider b/SqlDataProvider/00.07.67.SqlDataProvider new file mode 100644 index 0000000..da532f6 --- /dev/null +++ b/SqlDataProvider/00.07.67.SqlDataProvider @@ -0,0 +1,110 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @Current int, + @CategoryID varchar(255), + @AuthorID int, + @MaxDepth int, + @ShowPending bit, + @SortType int +AS + +SET NOCOUNT ON + +DECLARE @FilterID int +SET @FilterID = @Current + +DECLARE @level int, @line int + +CREATE TABLE #hierarchy(HierarchyID int IDENTITY (1,1), CategoryID int, level int) +CREATE TABLE #stack (item int, level int) +INSERT INTO #stack VALUES (@current, 1) +SELECT @level = 1 + +WHILE @level > 0 +BEGIN + IF EXISTS (SELECT * FROM #stack WHERE level = @level) + BEGIN + SELECT @current = item + FROM #stack + WHERE level = @level + + insert into #hierarchy(CategoryID, level) values(@current, @level) + + DELETE FROM #stack + WHERE level = @level + AND item = @current + + IF( @MaxDepth IS NULL OR @MaxDepth >= @level ) + BEGIN + IF( @SortType = 0 ) + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [SortOrder] DESC, [Name] DESC + END + ELSE + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [Name] DESC + END + + IF @@ROWCOUNT > 0 + SELECT @level = @level + 1 + END + END + ELSE + SELECT @level = @level - 1 +END -- WHILE + +IF( @FilterID IS NOT NULL ) +BEGIN + DELETE FROM #hierarchy WHERE CategoryID = @FilterID +END + +DECLARE @strModuleID nvarchar(50) +SELECT @strModuleID = convert(varchar, @ModuleID) + +DECLARE @strCategoryId nvarchar(255) +IF (@CategoryId is not null) + SELECT @strCategoryId = ' AND c.CategoryID in (' + @CategoryID + ')' + +DECLARE @strAuthorId nvarchar(255) +IF (@authorId is not null) + SELECT @strAuthorId = ' AND a.AuthorID = ' + cast(@AuthorID as nvarchar) + +DECLARE @strPending nvarchar(2000) +IF (@ShowPending is null) + SELECT @strPending = ' AND (a.StartDate IS NULL OR a.StartDate < GetDate())' + +EXEC(' +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE(''.'',(level-2)*2) + c.[Name] as ''NameIndented'', + c.[Image], + c.[Description], + c.[SortOrder], + level-1 as ''Level'', + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 ' + @strAuthorId + @strPending + ') as ''NumberofArticles'', + (SELECT SUM(a.NumberOfViews) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON a.ArticleID = ac.ArticleID WHERE ac.CategoryID = c.CategoryID) as ''NumberofViews'' +FROM + #hierarchy h INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON h.CategoryID = c.CategoryID +WHERE + c.[ModuleID] = ' + @strModuleID + @strCategoryId + ' +ORDER BY + h.HierarchyID ASC') + +drop table #hierarchy +drop table #stack +GO diff --git a/SqlDataProvider/00.07.68.SqlDataProvider b/SqlDataProvider/00.07.68.SqlDataProvider new file mode 100644 index 0000000..5891c66 --- /dev/null +++ b/SqlDataProvider/00.07.68.SqlDataProvider @@ -0,0 +1,601 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ADD + FileCount int NULL +GO + +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File ( + [FileID] [int] IDENTITY(1,1) NOT NULL, + [ArticleID] [int] NULL, + [Title] [nvarchar](255) NULL, + [FileName] [nvarchar](255) NULL, + [Extension] [nvarchar](100) NULL, + [Size] [int] NULL, + [ContentType] [nvarchar](255) NULL, + [Folder] [nvarchar](255) NULL, + [SortOrder] [int] NOT NULL, + [FileGuid] [nvarchar](50) NULL +) ON [PRIMARY] +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File ADD + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_File] PRIMARY KEY CLUSTERED + ( + [FileID] + ) ON [PRIMARY] +GO + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File +SELECT + a.ArticleID, + f.FileName, + CASE WHEN fo.StorageLocation = 0 THEN f.FileName ELSE f.FileName + '.resources' END AS 'FileName', + f.Extension, + f.Size, + f.ContentType, + f.Folder, + 0 AS 'SortOrder', + '' AS 'FileGuid' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN + {databaseOwner}{objectQualifier}Files f ON replace(a.Url, 'FileID=', '') = f.FileID INNER JOIN + {databaseOwner}{objectQualifier}Folders fo ON f.FolderID = fo.FolderID +WHERE + a.Url LIKE 'FileID=%' +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET Url = null +WHERE articleID IN +( + SELECT a.articleID + FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN + {databaseOwner}{objectQualifier}Files f ON replace(a.Url, 'FileID=', '') = f.FileID INNER JOIN + {databaseOwner}{objectQualifier}Folders fo ON f.FolderID = fo.FolderID + WHERE + a.Url LIKE 'FileID=%' +) +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [FileCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File f where f.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FileAdd + @ArticleID int, + @Title nvarchar(255), + @FileName nvarchar(255), + @Extension nvarchar(200), + @Size int, + @ContentType nvarchar(200), + @Folder nvarchar(255), + @SortOrder int, + @FileGuid nvarchar(50) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File ( + [ArticleID], + [Title], + [FileName], + [Extension], + [Size], + [ContentType], + [Folder], + [SortOrder], + [FileGuid] +) VALUES ( + @ArticleID, + @Title, + @FileName, + @Extension, + @Size, + @ContentType, + @Folder, + @SortOrder, + @FileGuid +) + +select SCOPE_IDENTITY() +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FileDelete + @FileID int +AS + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File WHERE FileID = @FileID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FileGet + @FileID int +AS + +SELECT + FileID, + ArticleID, + Title, + FileName, + Extension, + Size, + ContentType, + Folder, + SortOrder, + FileGuid +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File +WHERE + FileID = @FileID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FileList + @ArticleID int, + @FileGuid nvarchar(50) +AS + +SELECT + FileID, + ArticleID, + Title, + FileName, + Extension, + Size, + ContentType, + Folder, + SortOrder, + FileGuid +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File +WHERE + (@ArticleID IS NULL OR ArticleID = @ArticleID) + AND + (@FileGuid IS NULL OR FileGuid = @FileGuid) +ORDER BY + SortOrder +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_FileUpdate + @FileID int, + @ArticleID int, + @Title nvarchar(255), + @FileName nvarchar(255), + @Extension nvarchar(200), + @Size int, + @ContentType nvarchar(200), + @Folder nvarchar(255), + @SortOrder int, + @FileGuid nvarchar(50) +AS + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File +SET + [ArticleID] = @ArticleID, + [Title] = @Title, + [FileName] = @FileName, + [Extension] = @Extension, + [Size] = @Size, + [ContentType] = @ContentType, + [Folder] = @Folder, + [SortOrder] = @SortOrder, + [FileGuid] = @FileGuid +WHERE + [FileID] = @FileID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_DeleteArticle + @ArticleID int +AS + +DELETE FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue +WHERE + [ArticleID] = @ArticleID + +DELETE FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +WHERE + [ArticleID] = @ArticleID + +DELETE FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File +WHERE + [ArticleID] = @ArticleID + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories +WHERE + [ArticleID] = @ArticleID + +DELETE FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +WHERE + [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255), + @CustomFieldID int, + @CustomValue nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate <= GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate >= ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) + if(@CategoryIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + +IF (@CustomFieldID is not null AND @CustomValue is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID IN (SELECT ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue cv WHERE cv.customFieldID = ' + convert(nvarchar, @CustomFieldID) + ' AND cv.CustomValue LIKE N''%' + @CustomValue + '%'')' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[FileCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO + + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticle + @ArticleID int, + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500), + @PageHeadText nvarchar(500), + @ShortUrl nvarchar(50), + @RssGuid nvarchar(255) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article SET + [AuthorID] = @AuthorID, + [ApproverID] = @ApproverID, + [CreatedDate] = @CreatedDate, + [LastUpdate] = @LastUpdate, + [Title] = @Title, + [Summary] = @Summary, + [IsApproved] = @IsApproved, + [NumberOfViews] = @NumberOfViews, + [IsDraft] = @IsDraft, + [StartDate] = @StartDate, + [EndDate] = @EndDate, + [ModuleID] = @ModuleID, + [ImageUrl] = @ImageUrl, + [IsFeatured] = @IsFeatured, + [LastUpdateID] = @LastUpdateID, + [Url] = @Url, + [IsSecure] = @IsSecure, + [IsNewWindow] = @IsNewWindow, + [MetaTitle] = @MetaTitle, + [MetaDescription] = @MetaDescription, + [MetaKeywords] = @MetaKeywords, + [PageHeadText] = @PageHeadText, + [ShortUrl] = @ShortUrl, + [RssGuid] = @RssGuid +WHERE + [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [ImageCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image i where i.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [FileCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File f where f.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticle + @ArticleID int +AS +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[IsDraft], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[FileCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as UpdatedDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + Article.[ArticleID] = @ArticleID +GO diff --git a/SqlDataProvider/00.07.69.SqlDataProvider b/SqlDataProvider/00.07.69.SqlDataProvider new file mode 100644 index 0000000..1893b6a --- /dev/null +++ b/SqlDataProvider/00.07.69.SqlDataProvider @@ -0,0 +1,53 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCommentList + @ModuleID int, + @ArticleID int, + @IsApproved bit, + @SortDirection int, + @MaxCount int +AS + +IF( @MaxCount is not null ) +BEGIN + SET ROWCOUNT @MaxCount +END + +SELECT + Comment.[CommentID], + Comment.[ArticleID], + Comment.[UserID], + Comment.[CreatedDate], + Comment.[Comment], + Comment.[RemoteAddress], + Comment.[Type], + Comment.[TrackbackUrl], + Comment.[TrackbackTitle], + Comment.[TrackbackBlogName], + Comment.[TrackbackExcerpt], + Comment.[AnonymousName], + Comment.[AnonymousEmail], + Comment.[AnonymousURL], + Comment.[NotifyMe], + Comment.[IsApproved], + Comment.[ApprovedBy], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article on Comment.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Comment.UserID = Author.UserID +WHERE + Article.ModuleID = @ModuleID + and + (@ArticleID is null OR Comment.[ArticleID] = @ArticleID) + and + Comment.IsApproved = @IsApproved +ORDER BY + CASE WHEN @SortDirection = 0 THEN Comment.[CreatedDate] END ASC, + CASE WHEN @SortDirection = 1 THEN Comment.[CreatedDate] END DESC +GO diff --git a/SqlDataProvider/00.07.71.SqlDataProvider b/SqlDataProvider/00.07.71.SqlDataProvider new file mode 100644 index 0000000..f9f6dac --- /dev/null +++ b/SqlDataProvider/00.07.71.SqlDataProvider @@ -0,0 +1,223 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ADD + InheritSecurity bit NOT NULL CONSTRAINT DF_{objectQualifier}DnnForge_NewsArticles_Category_InheritSecurity DEFAULT 1 +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255), + @Description ntext, + @SortOrder int, + @InheritSecurity bit +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ( + [ModuleID], + [ParentID], + [Name], + [Image], + [Description], + [SortOrder], + [InheritSecurity] +) VALUES ( + @ModuleID, + @ParentID, + @Name, + @Image, + @Description, + @SortOrder, + @InheritSecurity +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory + @CategoryID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image], + [Description], + [SortOrder], + [InheritSecurity] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [CategoryID] = @CategoryID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList + @ModuleID int, + @ParentID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image], + [Description], + [SortOrder], + [InheritSecurity] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [ModuleID] = @ModuleID + AND + [ParentID] = @ParentID +ORDER BY + [SortOrder], [Name] +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @Current int, + @CategoryID varchar(255), + @AuthorID int, + @MaxDepth int, + @ShowPending bit, + @SortType int +AS + +SET NOCOUNT ON + +DECLARE @FilterID int +SET @FilterID = @Current + +DECLARE @level int, @line int + +CREATE TABLE #hierarchy(HierarchyID int IDENTITY (1,1), CategoryID int, level int) +CREATE TABLE #stack (item int, level int) +INSERT INTO #stack VALUES (@current, 1) +SELECT @level = 1 + +WHILE @level > 0 +BEGIN + IF EXISTS (SELECT * FROM #stack WHERE level = @level) + BEGIN + SELECT @current = item + FROM #stack + WHERE level = @level + + insert into #hierarchy(CategoryID, level) values(@current, @level) + + DELETE FROM #stack + WHERE level = @level + AND item = @current + + IF( @MaxDepth IS NULL OR @MaxDepth >= @level ) + BEGIN + IF( @SortType = 0 ) + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [SortOrder] DESC, [Name] DESC + END + ELSE + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [Name] DESC + END + IF @@ROWCOUNT > 0 + SELECT @level = @level + 1 + END + END + ELSE + SELECT @level = @level - 1 +END -- WHILE + +IF( @FilterID IS NOT NULL ) +BEGIN + DELETE FROM #hierarchy WHERE CategoryID = @FilterID +END + +DECLARE @strModuleID nvarchar(50) +SELECT @strModuleID = convert(varchar, @ModuleID) + +DECLARE @strCategoryId nvarchar(255) +IF (@CategoryId is not null) + SELECT @strCategoryId = ' AND c.CategoryID in (' + @CategoryID + ')' + +DECLARE @strAuthorId nvarchar(255) +IF (@authorId is not null) + SELECT @strAuthorId = ' AND a.AuthorID = ' + cast(@AuthorID as nvarchar) + +DECLARE @strPending nvarchar(2000) +IF (@ShowPending is null) + SELECT @strPending = ' AND (a.StartDate IS NULL OR a.StartDate < GetDate())' + +EXEC(' +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE(''.'',(level-2)*2) + c.[Name] as ''NameIndented'', + c.[Image], + c.[Description], + c.[SortOrder], + c.[InheritSecurity], + level-1 as ''Level'', + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 ' + @strAuthorId + @strPending + ') as ''NumberofArticles'', + (SELECT SUM(a.NumberOfViews) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON a.ArticleID = ac.ArticleID WHERE ac.CategoryID = c.CategoryID) as ''NumberofViews'' +FROM + #hierarchy h INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON h.CategoryID = c.CategoryID +WHERE + c.[ModuleID] = ' + @strModuleID + @strCategoryId + ' +ORDER BY + h.HierarchyID ASC') + +drop table #hierarchy +drop table #stack +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory + @CategoryID int, + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255), + @Description ntext, + @SortOrder int, + @InheritSecurity bit +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category SET + [ModuleID] = @ModuleID, + [ParentID] = @ParentID, + [Name] = @Name, + [Image] = @Image, + [Description] = @Description, + [SortOrder] = @SortOrder, + [InheritSecurity] = @InheritSecurity +WHERE + [CategoryID] = @CategoryID +GO diff --git a/SqlDataProvider/00.07.72.SqlDataProvider b/SqlDataProvider/00.07.72.SqlDataProvider new file mode 100644 index 0000000..b1c6f7d --- /dev/null +++ b/SqlDataProvider/00.07.72.SqlDataProvider @@ -0,0 +1,18 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleCategories +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleCategories + @ArticleID int +AS + +SELECT + Category.CategoryID, + Category.[Name], + Category.[InheritSecurity] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category Category +WHERE + ArticleCategories.CategoryID = Category.CategoryID + AND + ArticleCategories.ArticleID = @ArticleID +GO diff --git a/SqlDataProvider/00.07.73.SqlDataProvider b/SqlDataProvider/00.07.73.SqlDataProvider new file mode 100644 index 0000000..d735d3a --- /dev/null +++ b/SqlDataProvider/00.07.73.SqlDataProvider @@ -0,0 +1,231 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ADD + CategorySecurityType int NOT NULL CONSTRAINT DF_{objectQualifier}DnnForge_NewsArticles_Category_CategorySecurityType DEFAULT 0 +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255), + @Description ntext, + @SortOrder int, + @InheritSecurity bit, + @CategorySecurityType int +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ( + [ModuleID], + [ParentID], + [Name], + [Image], + [Description], + [SortOrder], + [InheritSecurity], + [CategorySecurityType] +) VALUES ( + @ModuleID, + @ParentID, + @Name, + @Image, + @Description, + @SortOrder, + @InheritSecurity, + @CategorySecurityType +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory + @CategoryID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image], + [Description], + [SortOrder], + [InheritSecurity], + [CategorySecurityType] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [CategoryID] = @CategoryID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList + @ModuleID int, + @ParentID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image], + [Description], + [SortOrder], + [InheritSecurity], + [CategorySecurityType] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [ModuleID] = @ModuleID + AND + [ParentID] = @ParentID +ORDER BY + [SortOrder], [Name] +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @Current int, + @CategoryID varchar(255), + @AuthorID int, + @MaxDepth int, + @ShowPending bit, + @SortType int +AS + +SET NOCOUNT ON + +DECLARE @FilterID int +SET @FilterID = @Current + +DECLARE @level int, @line int + +CREATE TABLE #hierarchy(HierarchyID int IDENTITY (1,1), CategoryID int, level int) +CREATE TABLE #stack (item int, level int) +INSERT INTO #stack VALUES (@current, 1) +SELECT @level = 1 + +WHILE @level > 0 +BEGIN + IF EXISTS (SELECT * FROM #stack WHERE level = @level) + BEGIN + SELECT @current = item + FROM #stack + WHERE level = @level + + insert into #hierarchy(CategoryID, level) values(@current, @level) + + DELETE FROM #stack + WHERE level = @level + AND item = @current + + IF( @MaxDepth IS NULL OR @MaxDepth >= @level ) + BEGIN + IF( @SortType = 0 ) + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [SortOrder] DESC, [Name] DESC + END + ELSE + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [Name] DESC + END + IF @@ROWCOUNT > 0 + SELECT @level = @level + 1 + END + END + ELSE + SELECT @level = @level - 1 +END -- WHILE + +IF( @FilterID IS NOT NULL ) +BEGIN + DELETE FROM #hierarchy WHERE CategoryID = @FilterID +END + +DECLARE @strModuleID nvarchar(50) +SELECT @strModuleID = convert(varchar, @ModuleID) + +DECLARE @strCategoryId nvarchar(255) +IF (@CategoryId is not null) + SELECT @strCategoryId = ' AND c.CategoryID in (' + @CategoryID + ')' + +DECLARE @strAuthorId nvarchar(255) +IF (@authorId is not null) + SELECT @strAuthorId = ' AND a.AuthorID = ' + cast(@AuthorID as nvarchar) + +DECLARE @strPending nvarchar(2000) +IF (@ShowPending is null) + SELECT @strPending = ' AND (a.StartDate IS NULL OR a.StartDate < GetDate())' + +EXEC(' +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE(''.'',(level-2)*2) + c.[Name] as ''NameIndented'', + c.[Image], + c.[Description], + c.[SortOrder], + c.[InheritSecurity], + c.[CategorySecurityType], + level-1 as ''Level'', + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 ' + @strAuthorId + @strPending + ') as ''NumberofArticles'', + (SELECT SUM(a.NumberOfViews) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON a.ArticleID = ac.ArticleID WHERE ac.CategoryID = c.CategoryID) as ''NumberofViews'' +FROM + #hierarchy h INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON h.CategoryID = c.CategoryID +WHERE + c.[ModuleID] = ' + @strModuleID + @strCategoryId + ' +ORDER BY + h.HierarchyID ASC') + +drop table #hierarchy +drop table #stack +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory + @CategoryID int, + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255), + @Description ntext, + @SortOrder int, + @InheritSecurity bit, + @CategorySecurityType int +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category SET + [ModuleID] = @ModuleID, + [ParentID] = @ParentID, + [Name] = @Name, + [Image] = @Image, + [Description] = @Description, + [SortOrder] = @SortOrder, + [InheritSecurity] = @InheritSecurity, + [CategorySecurityType] = @CategorySecurityType +WHERE + [CategoryID] = @CategoryID +GO diff --git a/SqlDataProvider/00.07.74.SqlDataProvider b/SqlDataProvider/00.07.74.SqlDataProvider new file mode 100644 index 0000000..836856f --- /dev/null +++ b/SqlDataProvider/00.07.74.SqlDataProvider @@ -0,0 +1,383 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255), + @CustomFieldID int, + @CustomValue nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate <= GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate >= ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) +BEGIN + IF(@CategoryIDCount is not null) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + END + ELSE + BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Article.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END + END +END + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + +IF (@CustomFieldID is not null AND @CustomValue is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID IN (SELECT ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue cv WHERE cv.customFieldID = ' + convert(nvarchar, @CustomFieldID) + ' AND cv.CustomValue LIKE N''%' + @CustomValue + '%'')' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[FileCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(2000), + @CategoryIDExclude varchar(2000), + @AuthorID int, + @GroupBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) +BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Article.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END +END + +IF (@CategoryIDExclude is not null) +BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID NOT IN (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' +END + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@ShowPending is null) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' +END + +IF( @GroupBy = 'Month' ) +BEGIN +EXEC(' + select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate), Month(StartDate) + order by [Year] desc, [Month] desc') +END +ELSE +BEGIN +EXEC(' + select 1 as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate) + order by [Year] desc') +END +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics + @ModuleID int, + @CategoryID varchar(2000), + @CategoryIDExclude varchar(2000), + @AuthorID int, + @SortBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) +BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Articles.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END +END + +IF (@CategoryIDExclude is not null) +BEGIN + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID NOT IN (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' +END + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@ShowPending is null ) + SELECT @strWhere = @strWhere + ' AND (Articles.StartDate is null OR Articles.StartDate < ''' + convert(nvarchar, DateAdd(mi, 1, GetDate())) + ''')' + +EXEC(' +SELECT + UserID, UserName, DisplayName, FirstName, LastName, count(*) as ''ArticleCount'' +FROM + {databaseOwner}{objectQualifier}Users Users, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles +where Articles.IsApproved = 1 and Articles.IsDraft = 0 and Users.UserID = Articles.AuthorID ' + + @strWhere + ' +GROUP BY + UserID, UserName, DisplayName, FirstName, LastName +ORDER BY ' + + @SortBy) +GO diff --git a/SqlDataProvider/00.07.75.SqlDataProvider b/SqlDataProvider/00.07.75.SqlDataProvider new file mode 100644 index 0000000..be29e92 --- /dev/null +++ b/SqlDataProvider/00.07.75.SqlDataProvider @@ -0,0 +1,7 @@ +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_SecureCheck + @PortalID int, + @ArticleID int, + @UserID int +AS + SELECT 1 +GO diff --git a/SqlDataProvider/00.07.77.SqlDataProvider b/SqlDataProvider/00.07.77.SqlDataProvider new file mode 100644 index 0000000..9509b22 --- /dev/null +++ b/SqlDataProvider/00.07.77.SqlDataProvider @@ -0,0 +1,262 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255), + @CustomFieldID int, + @CustomValue nvarchar(255), + @LinkFilter nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate <= GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate >= ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) +BEGIN + IF(@CategoryIDCount is not null) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + END + ELSE + BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Article.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END + END +END + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + +IF (@CustomFieldID is not null AND @CustomValue is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID IN (SELECT ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue cv WHERE cv.customFieldID = ' + convert(nvarchar, @CustomFieldID) + ' AND cv.CustomValue LIKE N''%' + @CustomValue + '%'')' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +IF (@LinkFilter is not null) + SELECT @strWhere = @strWhere + ' AND Article.Url = N''' + @LinkFilter + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[FileCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO diff --git a/SqlDataProvider/00.07.81.SqlDataProvider b/SqlDataProvider/00.07.81.SqlDataProvider new file mode 100644 index 0000000..a7871e9 --- /dev/null +++ b/SqlDataProvider/00.07.81.SqlDataProvider @@ -0,0 +1,257 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ADD + MetaTitle nvarchar(200) NULL, + MetaDescription nvarchar(500) NULL, + MetaKeywords nvarchar(500) NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddCategory + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255), + @Description ntext, + @SortOrder int, + @InheritSecurity bit, + @CategorySecurityType bit, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category ( + [ModuleID], + [ParentID], + [Name], + [Image], + [Description], + [SortOrder], + [InheritSecurity], + [CategorySecurityType], + [MetaTitle], + [MetaDescription], + [MetaKeywords] +) VALUES ( + @ModuleID, + @ParentID, + @Name, + @Image, + @Description, + @SortOrder, + @InheritSecurity, + @CategorySecurityType, + @MetaTitle, + @MetaDescription, + @MetaKeywords +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateCategory + @CategoryID int, + @ModuleID int, + @ParentID int, + @Name nvarchar(255), + @Image nvarchar(255), + @Description ntext, + @SortOrder int, + @InheritSecurity bit, + @CategorySecurityType int, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500) +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category SET + [ModuleID] = @ModuleID, + [ParentID] = @ParentID, + [Name] = @Name, + [Image] = @Image, + [Description] = @Description, + [SortOrder] = @SortOrder, + [InheritSecurity] = @InheritSecurity, + [CategorySecurityType] = @CategorySecurityType, + [MetaTitle] = @MetaTitle, + [MetaDescription] = @MetaDescription, + [MetaKeywords] = @MetaKeywords +WHERE + [CategoryID] = @CategoryID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategory + @CategoryID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image], + [Description], + [SortOrder], + [InheritSecurity], + [CategorySecurityType], + [MetaTitle], + [MetaDescription], + [MetaKeywords] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [CategoryID] = @CategoryID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryList + @ModuleID int, + @ParentID int +AS + +SELECT + [CategoryID], + [ParentID], + [ModuleID], + [Name], + [Image], + [Description], + [SortOrder], + [InheritSecurity], + [CategorySecurityType], + [MetaTitle], + [MetaDescription], + [MetaKeywords] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category +WHERE + [ModuleID] = @ModuleID + AND + [ParentID] = @ParentID +ORDER BY + [SortOrder], [Name] +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @Current int, + @CategoryID varchar(255), + @AuthorID int, + @MaxDepth int, + @ShowPending bit, + @SortType int +AS + +SET NOCOUNT ON + +DECLARE @FilterID int +SET @FilterID = @Current + +DECLARE @level int, @line int + +CREATE TABLE #hierarchy(HierarchyID int IDENTITY (1,1), CategoryID int, level int) +CREATE TABLE #stack (item int, level int) +INSERT INTO #stack VALUES (@current, 1) +SELECT @level = 1 + +WHILE @level > 0 +BEGIN + IF EXISTS (SELECT * FROM #stack WHERE level = @level) + BEGIN + SELECT @current = item + FROM #stack + WHERE level = @level + + insert into #hierarchy(CategoryID, level) values(@current, @level) + + DELETE FROM #stack + WHERE level = @level + AND item = @current + + IF( @MaxDepth IS NULL OR @MaxDepth >= @level ) + BEGIN + IF( @SortType = 0 ) + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [SortOrder] DESC, [Name] DESC + END + ELSE + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [Name] DESC + END + IF @@ROWCOUNT > 0 + SELECT @level = @level + 1 + END + END + ELSE + SELECT @level = @level - 1 +END -- WHILE + +IF( @FilterID IS NOT NULL ) +BEGIN + DELETE FROM #hierarchy WHERE CategoryID = @FilterID +END + +DECLARE @strModuleID nvarchar(50) +SELECT @strModuleID = convert(varchar, @ModuleID) + +DECLARE @strCategoryId nvarchar(255) +IF (@CategoryId is not null) + SELECT @strCategoryId = ' AND c.CategoryID in (' + @CategoryID + ')' + +DECLARE @strAuthorId nvarchar(255) +IF (@authorId is not null) + SELECT @strAuthorId = ' AND a.AuthorID = ' + cast(@AuthorID as nvarchar) + +DECLARE @strPending nvarchar(2000) +IF (@ShowPending is null) + SELECT @strPending = ' AND (a.StartDate IS NULL OR a.StartDate < GetDate())' + +EXEC(' +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE(''.'',(level-2)*2) + c.[Name] as ''NameIndented'', + c.[Image], + c.[Description], + c.[SortOrder], + c.[InheritSecurity], + c.[CategorySecurityType], + c.[MetaTitle], + c.[MetaDescription], + c.[MetaKeywords], + level-1 as ''Level'', + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 ' + @strAuthorId + @strPending + ') as ''NumberofArticles'', + (SELECT SUM(a.NumberOfViews) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON a.ArticleID = ac.ArticleID WHERE ac.CategoryID = c.CategoryID) as ''NumberofViews'' +FROM + #hierarchy h INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON h.CategoryID = c.CategoryID +WHERE + c.[ModuleID] = ' + @strModuleID + @strCategoryId + ' +ORDER BY + h.HierarchyID ASC') + +drop table #hierarchy +drop table #stack +GO diff --git a/SqlDataProvider/00.07.84.SqlDataProvider b/SqlDataProvider/00.07.84.SqlDataProvider new file mode 100644 index 0000000..2b3c7b0 --- /dev/null +++ b/SqlDataProvider/00.07.84.SqlDataProvider @@ -0,0 +1,105 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +ADD Title2 nvarchar(100) +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +SET Title2 = Title +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +DROP COLUMN Title +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +ADD Title nvarchar(255) +GO + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +SET Title = Title2 +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +DROP COLUMN Title2 +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageAdd +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageAdd + @ArticleID int, + @Title nvarchar(255), + @FileName nvarchar(100), + @Extension nvarchar(100), + @Size int, + @Width int, + @Height int, + @ContentType nvarchar(200), + @Folder nvarchar(200), + @SortOrder int, + @ImageGuid nvarchar(50) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image ( + [ArticleID], + [Title], + [FileName], + [Extension], + [Size], + [Width], + [Height], + [ContentType], + [Folder], + [SortOrder], + [ImageGuid] +) VALUES ( + @ArticleID, + @Title, + @FileName, + @Extension, + @Size, + @Width, + @Height, + @ContentType, + @Folder, + @SortOrder, + @ImageGuid +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageUpdate +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageUpdate + @ImageID int, + @ArticleID int, + @Title nvarchar(255), + @FileName nvarchar(100), + @Extension nvarchar(100), + @Size int, + @Width int, + @Height int, + @ContentType nvarchar(200), + @Folder nvarchar(200), + @SortOrder int, + @ImageGuid nvarchar(50) +AS + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +SET + [ArticleID] = @ArticleID, + [Title] = @Title, + [FileName] = @FileName, + [Extension] = @Extension, + [Size] = @Size, + [Width] = @Width, + [Height] = @Height, + [ContentType] = @ContentType, + [Folder] = @Folder, + [SortOrder] = @SortOrder, + [ImageGuid] = @ImageGuid +WHERE + [ImageID] = @ImageID +GO diff --git a/SqlDataProvider/00.07.85.SqlDataProvider b/SqlDataProvider/00.07.85.SqlDataProvider new file mode 100644 index 0000000..026d8fb --- /dev/null +++ b/SqlDataProvider/00.07.85.SqlDataProvider @@ -0,0 +1,39 @@ +CREATE NONCLUSTERED INDEX [_dta_index_{objectQualifier}DnnForge_NewsArticles_Page] ON {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page +( + [SortOrder] ASC, + [ArticleID] ASC +) ON [PRIMARY] +GO + +CREATE NONCLUSTERED INDEX [_dta_index_{objectQualifier}DnnForge_NewsArticles_Article] ON {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +( + [ModuleID] ASC, + [ArticleID] ASC, + [IsApproved] ASC, + [IsDraft] ASC, + [EndDate] ASC, + [StartDate] ASC +) ON [PRIMARY] +GO + +CREATE NONCLUSTERED INDEX [_dta_index_{objectQualifier}DnnForge_NewsArticles_Article_Category] ON {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories +( + [ArticleID] ASC, + [CategoryID] ASC +)ON [PRIMARY] +GO + +CREATE NONCLUSTERED INDEX [_dta_index_{objectQualifier}DnnForge_NewsArticles_Article_Views] ON {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +( + [ArticleID] ASC +) +INCLUDE ( [NumberOfViews]) ON [PRIMARY] +GO + +CREATE NONCLUSTERED INDEX [_dta_index_{objectQualifier}DnnForge_NewsArticles_Article_Status] ON {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +( + [ArticleID] ASC, + [IsDraft] ASC, + [IsApproved] ASC +)ON [PRIMARY] +GO diff --git a/SqlDataProvider/00.07.87.SqlDataProvider b/SqlDataProvider/00.07.87.SqlDataProvider new file mode 100644 index 0000000..4c1f01e --- /dev/null +++ b/SqlDataProvider/00.07.87.SqlDataProvider @@ -0,0 +1,271 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255), + @CustomFieldID int, + @CustomValue nvarchar(255), + @LinkFilter nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + convert(nvarchar, @CurrentDate) + ''' AND Article.StartDate <= GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END +ELSE +BEGIN + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + convert(nvarchar, @AgedDate) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate >= ''' + convert(nvarchar, @CurrentDate) + ''')' +END + +IF (@CategoryId is not null) +BEGIN + IF(@CategoryIDCount is not null) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + END + ELSE + BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Article.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END + END +END + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) +BEGIN + IF( LEN(@Keywords) = 1 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''' + @Keywords + '%'')' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + END +END + +IF (@CustomFieldID is not null AND @CustomValue is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID IN (SELECT ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue cv WHERE cv.customFieldID = ' + convert(nvarchar, @CustomFieldID) + ' AND cv.CustomValue LIKE N''%' + @CustomValue + '%'')' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +IF (@LinkFilter is not null) + SELECT @strWhere = @strWhere + ' AND Article.Url = N''' + @LinkFilter + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[FileCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO diff --git a/SqlDataProvider/00.07.88.SqlDataProvider b/SqlDataProvider/00.07.88.SqlDataProvider new file mode 100644 index 0000000..ad7300b --- /dev/null +++ b/SqlDataProvider/00.07.88.SqlDataProvider @@ -0,0 +1,61 @@ +CREATE TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Mirror( + [ArticleID] [int] NOT NULL, + [LinkedArticleID] [int] NOT NULL, + [LinkedPortalID] [int] NOT NULL, + [AutoUpdate] [bit] NOT NULL, + CONSTRAINT [PK_{objectQualifier}DnnForge_NewsArticles_Mirror] PRIMARY KEY CLUSTERED +( + [ArticleID] ASC +) +) ON [PRIMARY] +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetMirrorArticle + @ArticleID int +AS + +SELECT + m.[ArticleID], + m.[LinkedArticleID], + m.[LinkedPortalID], + m.[AutoUpdate] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Mirror m +WHERE + m.[ArticleID] = @ArticleID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetMirrorArticleList + @LinkedArticleID int +AS + +SELECT + m.[ArticleID], + m.[LinkedArticleID], + m.[LinkedPortalID], + m.[AutoUpdate] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Mirror m +WHERE + m.[LinkedArticleID] = @LinkedArticleID +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddMirrorArticle + @ArticleID int, + @LinkedArticleID int, + @LinkedPortalID int, + @AutoUpdate bit +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Mirror ( + [ArticleID], + [LinkedArticleID], + [LinkedPortalID], + [AutoUpdate] +) VALUES ( + @ArticleID, + @LinkedArticleID, + @LinkedPortalID, + @AutoUpdate +) +GO diff --git a/SqlDataProvider/00.07.89.SqlDataProvider b/SqlDataProvider/00.07.89.SqlDataProvider new file mode 100644 index 0000000..07f29bc --- /dev/null +++ b/SqlDataProvider/00.07.89.SqlDataProvider @@ -0,0 +1,21 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetMirrorArticleList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetMirrorArticleList + @LinkedArticleID int +AS + +SELECT + m.[ArticleID], + m.[LinkedArticleID], + m.[LinkedPortalID], + m.[AutoUpdate], + mo.[PortalID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Mirror m INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON m.ArticleID = a.ArticleID INNER JOIN + {databaseOwner}{objectQualifier}Modules mo ON a.ModuleID = mo.ModuleID +WHERE + m.[LinkedArticleID] = @LinkedArticleID +GO + \ No newline at end of file diff --git a/SqlDataProvider/00.07.96.SqlDataProvider b/SqlDataProvider/00.07.96.SqlDataProvider new file mode 100644 index 0000000..6a7fc91 --- /dev/null +++ b/SqlDataProvider/00.07.96.SqlDataProvider @@ -0,0 +1,396 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255), + @CustomFieldID int, + @CustomValue nvarchar(255), + @LinkFilter nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + CONVERT(char(24), @CurrentDate, 126) + ''' AND Article.StartDate <= GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + CONVERT(char(24), @AgedDate, 126) + '''' +END +ELSE +BEGIN + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + CONVERT(char(24), @AgedDate, 126) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate >= ''' + CONVERT(char(24), @CurrentDate, 126) + ''')' +END + +IF (@CategoryId is not null) +BEGIN + IF(@CategoryIDCount is not null) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + END + ELSE + BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Article.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END + END +END + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) +BEGIN + IF( LEN(@Keywords) = 1 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''' + @Keywords + '%'')' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0))' + END +END + +IF (@CustomFieldID is not null AND @CustomValue is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID IN (SELECT ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue cv WHERE cv.customFieldID = ' + convert(nvarchar, @CustomFieldID) + ' AND cv.CustomValue LIKE N''%' + @CustomValue + '%'')' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +IF (@LinkFilter is not null) + SELECT @strWhere = @strWhere + ' AND Article.Url = N''' + @LinkFilter + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[FileCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(2000), + @CategoryIDExclude varchar(2000), + @AuthorID int, + @GroupBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) +BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Article.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END +END + +IF (@CategoryIDExclude is not null) +BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID NOT IN (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' +END + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@ShowPending is null) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + CONVERT(char(24), DateAdd(mi, 1, GetDate()), 126) + ''')' +END + +IF( @GroupBy = 'Month' ) +BEGIN +EXEC(' + select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate), Month(StartDate) + order by [Year] desc, [Month] desc') +END +ELSE +BEGIN +EXEC(' + select 1 as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate) + order by [Year] desc') +END +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics + @ModuleID int, + @CategoryID varchar(2000), + @CategoryIDExclude varchar(2000), + @AuthorID int, + @SortBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) +BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Articles.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END +END + +IF (@CategoryIDExclude is not null) +BEGIN + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID NOT IN (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' +END + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@ShowPending is null ) + SELECT @strWhere = @strWhere + ' AND (Articles.StartDate is null OR Articles.StartDate < ''' + CONVERT(char(24), DateAdd(mi, 1, GetDate()), 126) + ''')' + +EXEC(' +SELECT + UserID, UserName, DisplayName, FirstName, LastName, count(*) as ''ArticleCount'' +FROM + {databaseOwner}{objectQualifier}Users Users, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles +where Articles.IsApproved = 1 and Articles.IsDraft = 0 and Users.UserID = Articles.AuthorID ' + + @strWhere + ' +GROUP BY + UserID, UserName, DisplayName, FirstName, LastName +ORDER BY ' + + @SortBy) +GO diff --git a/SqlDataProvider/00.07.97.SqlDataProvider b/SqlDataProvider/00.07.97.SqlDataProvider new file mode 100644 index 0000000..9c1bea1 --- /dev/null +++ b/SqlDataProvider/00.07.97.SqlDataProvider @@ -0,0 +1,149 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image ADD + Description ntext NULL +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageAdd +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageAdd + @ArticleID int, + @Title nvarchar(255), + @FileName nvarchar(100), + @Extension nvarchar(100), + @Size int, + @Width int, + @Height int, + @ContentType nvarchar(200), + @Folder nvarchar(200), + @SortOrder int, + @ImageGuid nvarchar(50), + @Description ntext +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image ( + [ArticleID], + [Title], + [FileName], + [Extension], + [Size], + [Width], + [Height], + [ContentType], + [Folder], + [SortOrder], + [ImageGuid], + [Description] +) VALUES ( + @ArticleID, + @Title, + @FileName, + @Extension, + @Size, + @Width, + @Height, + @ContentType, + @Folder, + @SortOrder, + @ImageGuid, + @Description +) + +select SCOPE_IDENTITY() +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageGet +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageGet + @ImageID int +AS + +SELECT + ImageID, + ArticleID, + Title, + FileName, + Extension, + Size, + Width, + Height, + ContentType, + Folder, + SortOrder, + ImageGuid, + Description +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +WHERE + ImageID = @ImageID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageList +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageList + @ArticleID int, + @ImageGuid nvarchar(50) +AS + +SELECT + ImageID, + ArticleID, + Title, + FileName, + Extension, + Size, + Width, + Height, + ContentType, + Folder, + SortOrder, + ImageGuid, + Description +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +WHERE + (@ArticleID IS NULL OR ArticleID = @ArticleID) + AND + (@ImageGuid IS NULL OR ImageGuid = @ImageGuid) +ORDER BY + SortOrder +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageUpdate +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ImageUpdate + @ImageID int, + @ArticleID int, + @Title nvarchar(255), + @FileName nvarchar(100), + @Extension nvarchar(100), + @Size int, + @Width int, + @Height int, + @ContentType nvarchar(200), + @Folder nvarchar(200), + @SortOrder int, + @ImageGuid nvarchar(50), + @Description ntext +AS + +UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image +SET + [ArticleID] = @ArticleID, + [Title] = @Title, + [FileName] = @FileName, + [Extension] = @Extension, + [Size] = @Size, + [Width] = @Width, + [Height] = @Height, + [ContentType] = @ContentType, + [Folder] = @Folder, + [SortOrder] = @SortOrder, + [ImageGuid] = @ImageGuid, + [Description] = @Description +WHERE + [ImageID] = @ImageID +GO diff --git a/SqlDataProvider/00.07.98.SqlDataProvider b/SqlDataProvider/00.07.98.SqlDataProvider new file mode 100644 index 0000000..66fa360 --- /dev/null +++ b/SqlDataProvider/00.07.98.SqlDataProvider @@ -0,0 +1,402 @@ +CREATE NONCLUSTERED INDEX [_dta_index_{objectQualifier}DnnForge_NewsArticles_Articl_5_160719625__K2] ON {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories +( + [CategoryID] ASC +)WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY] +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255), + @CustomFieldID int, + @CustomValue nvarchar(255), + @LinkFilter nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + CONVERT(char(24), @CurrentDate, 126) + ''' AND Article.StartDate <= GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + CONVERT(char(24), @AgedDate, 126) + '''' +END +ELSE +BEGIN + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + CONVERT(char(24), @AgedDate, 126) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate >= ''' + CONVERT(char(24), @CurrentDate, 126) + ''')' +END + +IF (@CategoryId is not null) +BEGIN + IF(@CategoryIDCount is not null) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + END + ELSE + BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Article.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END + END +END + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) +BEGIN + IF( LEN(@Keywords) = 1 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''' + @Keywords + '%'')' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0) OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue cv where cv.ArticleID = Article.ArticleID and cv.CustomValue LIKE N''%' + @Keywords + '%'') > 0))' + END +END + +IF (@CustomFieldID is not null AND @CustomValue is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID IN (SELECT ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue cv WHERE cv.customFieldID = ' + convert(nvarchar, @CustomFieldID) + ' AND cv.CustomValue LIKE N''%' + @CustomValue + '%'')' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +IF (@LinkFilter is not null) + SELECT @strWhere = @strWhere + ' AND Article.Url = N''' + @LinkFilter + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[FileCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(2000), + @CategoryIDExclude varchar(2000), + @AuthorID int, + @GroupBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) +BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Article.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END +END + +IF (@CategoryIDExclude is not null) +BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID NOT IN (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' +END + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@ShowPending is null) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + CONVERT(char(24), DateAdd(mi, 1, GetDate()), 126) + ''')' +END + +IF( @GroupBy = 'Month' ) +BEGIN +EXEC(' + select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate), Month(StartDate) + order by [Year] desc, [Month] desc') +END +ELSE +BEGIN +EXEC(' + select 1 as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate) + order by [Year] desc') +END +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics + @ModuleID int, + @CategoryID varchar(2000), + @CategoryIDExclude varchar(2000), + @AuthorID int, + @SortBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) +BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Articles.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END +END + +IF (@CategoryIDExclude is not null) +BEGIN + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID NOT IN (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' +END + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@ShowPending is null ) + SELECT @strWhere = @strWhere + ' AND (Articles.StartDate is null OR Articles.StartDate < ''' + CONVERT(char(24), DateAdd(mi, 1, GetDate()), 126) + ''')' + +EXEC(' +SELECT + UserID, UserName, DisplayName, FirstName, LastName, count(*) as ''ArticleCount'' +FROM + {databaseOwner}{objectQualifier}Users Users, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles +where Articles.IsApproved = 1 and Articles.IsDraft = 0 and Users.UserID = Articles.AuthorID ' + + @strWhere + ' +GROUP BY + UserID, UserName, DisplayName, FirstName, LastName +ORDER BY ' + + @SortBy) +GO diff --git a/SqlDataProvider/00.07.99.SqlDataProvider b/SqlDataProvider/00.07.99.SqlDataProvider new file mode 100644 index 0000000..e8b91a0 --- /dev/null +++ b/SqlDataProvider/00.07.99.SqlDataProvider @@ -0,0 +1,396 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetArticleListBySearchCriteria + @ModuleID int, + @CurrentDate datetime, + @AgedDate datetime, + @CategoryID varchar(2000), + @CategoryIDCount int, + @CategoryIDExclude varchar(2000), + @MaxCount int, + @PageNumber int, + @PageSize int, + @SortBy varchar(50), + @SortDirection varchar(50), + @IsApproved bit, + @IsDraft bit, + @KeyWords nvarchar(255), + @AuthorID int, + @ShowPending bit, + @ShowExpired bit, + @ShowFeaturedOnly bit, + @ShowNotFeaturedOnly bit, + @ShowSecuredOnly bit, + @ShowNotSecuredOnly bit, + @ArticleIDs varchar(255), + @TagID varchar(2000), + @TagIDCount int, + @RssGuid nvarchar(255), + @CustomFieldID int, + @CustomValue nvarchar(255), + @LinkFilter nvarchar(255) +AS + +-- Form Where Query + +DECLARE @strWhere nvarchar(4000) +SELECT @strWhere = 'Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF( @CurrentDate is null ) + SELECT @CurrentDate = GetDate() + +IF( @ShowPending is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null OR (Article.StartDate <= ''' + CONVERT(char(24), @CurrentDate, 126) + ''' AND Article.StartDate <= GetDate()))' + + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + CONVERT(char(24), @AgedDate, 126) + '''' +END +ELSE +BEGIN + IF( @AgedDate is not null ) + SELECT @strWhere = @strWhere + ' AND Article.StartDate >= ''' + CONVERT(char(24), @AgedDate, 126) + '''' +END + +IF( @ShowExpired is null ) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.EndDate is null OR Article.EndDate >= ''' + CONVERT(char(24), @CurrentDate, 126) + ''')' +END + +IF (@CategoryId is not null) +BEGIN + IF(@CategoryIDCount is not null) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ') group by articleID having count(*) > ' + convert(nvarchar, @CategoryIDCount) + ')' + END + ELSE + BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Article.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END + END +END + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@CategoryIDExclude is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID not in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@IsApproved = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 1' + +IF (@IsApproved = 0 ) + SELECT @strWhere = @strWhere + ' AND Article.IsApproved = 0' + +IF (@IsDraft = 0) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 0' + +IF (@IsDraft = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsDraft = 1' + +IF (@ShowFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 1' + +IF (@ShowNotFeaturedOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsFeatured = 0' + +IF (@ShowSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 1' + +IF (@ShowNotSecuredOnly = 1 ) + SELECT @strWhere = @strWhere + ' AND Article.IsSecure = 0' + +IF (@Keywords is not null) +BEGIN + IF( LEN(@Keywords) = 1 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''' + @Keywords + '%'')' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.Title LIKE N''%' + @Keywords + '%'' OR Article.Summary LIKE N''%' + @Keywords + '%'' OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = Article.ArticleID and Page.PageText LIKE N''%' + @Keywords + '%'') > 0) OR ((select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue cv where cv.ArticleID = Article.ArticleID and cv.CustomValue LIKE N''%' + @Keywords + '%'') > 0))' + END +END + +IF (@CustomFieldID is not null AND @CustomValue is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID IN (SELECT ArticleID FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_CustomValue cv WHERE cv.customFieldID = ' + convert(nvarchar, @CustomFieldID) + ' AND cv.CustomValue LIKE N''%' + @CustomValue + '%'')' + +IF (@ArticleIDs is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in (' + @ArticleIDs + ')' + +IF (@SortBy = 'Title') + SELECT @SortBy = 'Article.Title' + +IF (@SortBy = 'IsFeatured DESC, Title') + SELECT @SortBy = 'IsFeatured DESC, Article.Title' + +IF (@TagID is not null) + if(@TagIDCount is not null) + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + ') group by articleID having count(*) > ' + convert(nvarchar, @TagIDCount) + ')' + else + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag.TagID in (' + @TagID + '))' + +IF (@RssGuid is not null) + SELECT @strWhere = @strWhere + ' AND Article.RssGuid = N''' + @RssGuid + '''' + +IF (@LinkFilter is not null) + SELECT @strWhere = @strWhere + ' AND Article.Url = N''' + @LinkFilter + '''' + +-- Set Paging Options + +IF( @PageNumber is null ) + SET @PageNumber = 1 + +IF( @PageSize is null ) + SET @PageSize = 100 + +SET @PageNumber = @PageNumber - 1 + +DECLARE @startRowIndex int +SET @startRowIndex = (@PageNumber * @PageSize) + +DECLARE @maxRow int +SET @maxRow = (@startRowIndex + @PageSize) +IF( @MaxCount is not null ) +BEGIN + IF( @MaxCount < @MaxRow ) + BEGIN + SET ROWCOUNT @MaxCount + END + ELSE + BEGIN + SET ROWCOUNT @maxRow + END +END +ELSE +BEGIN + SET ROWCOUNT @maxRow +END + +-- Create Temporary Table + +CREATE TABLE #TempItems +( + ID int IDENTITY, + ArticleID int +) + +EXEC(' +INSERT INTO #TempItems (ArticleID) +SELECT + Article.[ArticleID] +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID +WHERE ' + + @strWhere + ' +ORDER BY + ' + @SortBy + ' ' + @SortDirection) + +SET ROWCOUNT 0 + +SELECT + Article.[ArticleID], + Article.[AuthorID], + Article.[ApproverID], + Article.[CreatedDate], + Article.[LastUpdate], + Article.[Title], + Article.[Summary], + Article.[IsApproved], + Article.[NumberOfViews], + Article.[StartDate], + Article.[EndDate], + Article.[ModuleID], + Article.[IsFeatured], + Article.[ImageUrl], + Article.[LastUpdateID], + Article.[IsSecure], + Article.[IsNewWindow], + Article.[ImageUrl], + Article.[Url], + Article.[PageCount], + Article.[CommentCount], + Article.[Rating], + Article.[RatingCount], + Article.[FileCount], + Article.[ImageCount], + Article.[MetaTitle], + Article.[MetaDescription], + Article.[MetaKeywords], + Article.[PageHeadText], + Article.[ShortUrl], + Article.[RssGuid], + Author.[Email] as AuthorEmail, + Author.[UserName] as AuthorUserName, + Author.[FirstName] as AuthorFirstName, + Author.[LastName] as AuthorLastName, + Author.[DisplayName] as AuthorDisplayName, + Updated.[Email] as LastUpdateEmail, + Updated.[UserName] as LastUpdateUserName, + Updated.[FirstName] as LastUpdateFirstName, + Updated.[LastName] as LastUpdateLastName, + Updated.[DisplayName] as LastUpdateDisplayName, + Page.PageText as 'Body', + {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags(Article.[ArticleID]) as 'Tags' + +FROM + #TempItems t INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article ON t.ArticleID = Article.ArticleID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page on Page.ArticleID = Article.ArticleID AND Page.SortOrder = 0 LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Author ON Article.AuthorID = Author.UserID LEFT OUTER JOIN + {databaseOwner}{objectQualifier}Users Updated ON Article.LastUpdateID = Updated.UserID + +WHERE + ID > @startRowIndex + +ORDER BY + ID + +DROP TABLE #TempItems + +EXEC(' +SELECT + COUNT(Article.ArticleID) as ''TotalRecords'' +FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Article +WHERE ' + + @strWhere ) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetNewsArchive + @ModuleID int, + @CategoryID varchar(2000), + @CategoryIDExclude varchar(2000), + @AuthorID int, + @GroupBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Article.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) +BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.ArticleID in ( select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories where {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.ArticleID = Article.ArticleID and {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Article.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END +END + +IF (@CategoryIDExclude is not null) +BEGIN + SELECT @strWhere = @strWhere + ' AND Article.ArticleID NOT IN (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' +END + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Article.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@ShowPending is null) +BEGIN + SELECT @strWhere = @strWhere + ' AND (Article.StartDate is null or Article.StartDate < ''' + CONVERT(char(24), DateAdd(mi, 1, GetDate()), 126) + ''')' +END + +IF( @GroupBy = 'Month' ) +BEGIN +EXEC(' + select Month(StartDate) as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate), Month(StartDate) + order by [Year] desc, [Month] desc') +END +ELSE +BEGIN +EXEC(' + select 1 as [Month], Year(StartDate) as [Year], 1 as Day, Count(*) as [Count] + from {databaseOwner}{objectQualifier}dnnforge_newsarticles_article Article + where IsApproved = 1 and IsDraft = 0 ' + + @strWhere + ' + group by Year(StartDate) + order by [Year] desc') +END +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetAuthorStatistics + @ModuleID int, + @CategoryID varchar(2000), + @CategoryIDExclude varchar(2000), + @AuthorID int, + @SortBy varchar(255), + @ShowPending bit +AS + +DECLARE @strTop nvarchar(2000) +DECLARE @strWhere nvarchar(2000) + +SELECT @strTop = '' +SELECT @strWhere = '' + +IF (@ModuleID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.ModuleID = ' + convert(nvarchar, @ModuleId) + +IF (@CategoryId is not null) +BEGIN + IF( CHARINDEX('-1', @CategoryID) = 0 ) + BEGIN + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + '))' + END + ELSE + BEGIN + SELECT @strWhere = @strWhere + ' AND (Articles.ArticleID in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryID + ')) OR Articles.ArticleID not in (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories))' + END +END + +IF (@CategoryIDExclude is not null) +BEGIN + SELECT @strWhere = @strWhere + ' AND Articles.ArticleID NOT IN (select ArticleID from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ArticleCategories where ArticleCategories.CategoryID in (' + @CategoryIDExclude + '))' +END + +IF (@AuthorID is not null) + SELECT @strWhere = @strWhere + ' AND Articles.AuthorID = ' + convert(nvarchar, @AuthorID) + +IF (@ShowPending is null ) + SELECT @strWhere = @strWhere + ' AND (Articles.StartDate is null OR Articles.StartDate < ''' + CONVERT(char(24), DateAdd(mi, 1, GetDate()), 126) + ''')' + +EXEC(' +SELECT + UserID, UserName, DisplayName, FirstName, LastName, count(*) as ''ArticleCount'' +FROM + {databaseOwner}{objectQualifier}Users Users, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article Articles +where Articles.IsApproved = 1 and Articles.IsDraft = 0 and Users.UserID = Articles.AuthorID ' + + @strWhere + ' +GROUP BY + UserID, UserName, DisplayName, FirstName, LastName +ORDER BY ' + + @SortBy) +GO diff --git a/SqlDataProvider/00.08.00.SqlDataProvider b/SqlDataProvider/00.08.00.SqlDataProvider new file mode 100644 index 0000000..aa20273 --- /dev/null +++ b/SqlDataProvider/00.08.00.SqlDataProvider @@ -0,0 +1,114 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @Current int, + @CategoryID varchar(255), + @AuthorID int, + @MaxDepth int, + @ShowPending bit, + @SortType int +AS + +SET NOCOUNT ON + +DECLARE @FilterID int +SET @FilterID = @Current + +DECLARE @level int, @line int + +CREATE TABLE #hierarchy(HierarchyID int IDENTITY (1,1), CategoryID int, level int) +CREATE TABLE #stack (StackID int IDENTITY (1,1), item int, level int) +INSERT INTO #stack VALUES (@current, 1) +SELECT @level = 1 + +WHILE @level > 0 +BEGIN + IF EXISTS (SELECT TOP 1 * FROM #stack WHERE level = @level ORDER BY StackID) + BEGIN + SELECT @current = item + FROM #stack + WHERE level = @level + + insert into #hierarchy(CategoryID, level) values(@current, @level) + + DELETE FROM #stack + WHERE level = @level + AND item = @current + + IF( @MaxDepth IS NULL OR @MaxDepth >= @level ) + BEGIN + IF( @SortType = 0 ) + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [SortOrder] DESC, [Name] DESC + END + ELSE + BEGIN + INSERT #stack + SELECT CategoryID, @level + 1 + FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE ParentID = @current and ModuleID = @ModuleID + ORDER BY [Name] DESC + END + IF @@ROWCOUNT > 0 + SELECT @level = @level + 1 + END + END + ELSE + SELECT @level = @level - 1 +END -- WHILE + +IF( @FilterID IS NOT NULL ) +BEGIN + DELETE FROM #hierarchy WHERE CategoryID = @FilterID +END + +DECLARE @strModuleID nvarchar(50) +SELECT @strModuleID = convert(varchar, @ModuleID) + +DECLARE @strCategoryId nvarchar(255) +IF (@CategoryId is not null) + SELECT @strCategoryId = ' AND c.CategoryID in (' + @CategoryID + ')' + +DECLARE @strAuthorId nvarchar(255) +IF (@authorId is not null) + SELECT @strAuthorId = ' AND a.AuthorID = ' + cast(@AuthorID as nvarchar) + +DECLARE @strPending nvarchar(2000) +IF (@ShowPending is null) + SELECT @strPending = ' AND (a.StartDate IS NULL OR a.StartDate < GetDate())' + +EXEC(' +SELECT + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE(''.'',(level-2)*2) + c.[Name] as ''NameIndented'', + c.[Image], + c.[Description], + c.[SortOrder], + c.[InheritSecurity], + c.[CategorySecurityType], + c.[MetaTitle], + c.[MetaDescription], + c.[MetaKeywords], + level-1 as ''Level'', + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 ' + @strAuthorId + @strPending + ') as ''NumberofArticles'', + (SELECT SUM(a.NumberOfViews) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac ON a.ArticleID = ac.ArticleID WHERE ac.CategoryID = c.CategoryID) as ''NumberofViews'' +FROM + #hierarchy h INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON h.CategoryID = c.CategoryID +WHERE + c.[ModuleID] = ' + @strModuleID + @strCategoryId + ' +ORDER BY + h.HierarchyID ASC') + +drop table #hierarchy +drop table #stack +GO diff --git a/SqlDataProvider/00.08.04.SqlDataProvider b/SqlDataProvider/00.08.04.SqlDataProvider new file mode 100644 index 0000000..be5a1be --- /dev/null +++ b/SqlDataProvider/00.08.04.SqlDataProvider @@ -0,0 +1,134 @@ +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdateArticleCount + @ArticleID int, + @NumberOfViews int +AS + UPDATE + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article + SET + [NumberOfViews] = @NumberOfViews + WHERE + [ArticleID] = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @AuthorID int, + @ShowPending bit, + @SortType int +AS + +;WITH CategoryHierarchy AS +( + SELECT + CategoryID, + ParentID, + CONVERT(nvarchar(max), Name) AS Path, + 1 as level, + SortOrder * (CONVERT(bigint, '1' + REPLICATE('0', 10))) AS 'SortOrderCount' + FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE + ParentID = -1 + AND + ModuleID = @ModuleID + + UNION ALL + + SELECT + TH.CategoryID, + TH.ParentID, + CONVERT(nvarchar(max), CategoryHierarchy.Path + ' \ ' + TH.Name) AS Path, + level = level + 1, + CategoryHierarchy.SortOrderCount + (CONVERT(bigint, CONVERT(varchar, TH.SortOrder) + REPLICATE('0', 10-level))) AS 'SortOrderCount' + FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category TH INNER JOIN + CategoryHierarchy ON CategoryHierarchy.CategoryID = TH.ParentID +) + +SELECT + SortOrderCount, + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE('.',(level-1)*2) + c.[Name] as 'NameIndented', + c.[Image], + c.[Description], + c.[SortOrder], + c.[InheritSecurity], + c.[CategorySecurityType], + c.[MetaTitle], + c.[MetaDescription], + c.[MetaKeywords], + ch.[level], + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 AND (@authorId IS NULL OR a.AuthorID = @authorID) AND (@ShowPending IS NOT NULL OR (a.StartDate IS NULL OR a.StartDate < GetDate()))) as 'NumberofArticles' +FROM + CategoryHierarchy ch INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON ch.CategoryID = c.CategoryID +ORDER BY + CASE WHEN @SortType = 0 THEN CAST(ch.SortOrderCount AS VARCHAR) ELSE ch.Path END +GO + +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page +ALTER COLUMN PageText nvarchar(max) +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddPage +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddPage + @ArticleID int, + @Title nvarchar(255), + @PageText nvarchar(max), + @SortOrder int +AS + +declare @count int + +select @count = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page where ArticleID = @ArticleID) + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page ( + [ArticleID], + [Title], + [PageText], + [SortOrder] +) VALUES ( + @ArticleID, + @Title, + @PageText, + @count +) + +select SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = @ArticleID +GO + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdatePage +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_UpdatePage + @PageID int, + @ArticleID int, + @Title nvarchar(255), + @PageText nvarchar(max), + @SortOrder int +AS + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page SET + [ArticleID] = @ArticleID, + [Title] = @Title, + [PageText] = @PageText, + [SortOrder] = @SortOrder +WHERE + [PageID] = @PageID + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = @ArticleID +GO diff --git a/SqlDataProvider/00.08.05.SqlDataProvider b/SqlDataProvider/00.08.05.SqlDataProvider new file mode 100644 index 0000000..02a5445 --- /dev/null +++ b/SqlDataProvider/00.08.05.SqlDataProvider @@ -0,0 +1,62 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @AuthorID int, + @ShowPending bit, + @SortType int +AS + +;WITH CategoryHierarchy AS +( + SELECT + CategoryID, + ParentID, + CONVERT(nvarchar(max), Name) AS Path, + 1 as level, + (SortOrder+1) * (CONVERT(bigint, '1' + REPLICATE('0', 10))) AS 'SortOrderCount' + FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE + ParentID = -1 + AND + ModuleID = @ModuleID + + UNION ALL + + SELECT + TH.CategoryID, + TH.ParentID, + CONVERT(nvarchar(max), CategoryHierarchy.Path + ' \ ' + TH.Name) AS Path, + level = level + 1, + CategoryHierarchy.SortOrderCount + (CONVERT(bigint, CONVERT(varchar, TH.SortOrder) + REPLICATE('0', 10-level))) AS 'SortOrderCount' + FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category TH INNER JOIN + CategoryHierarchy ON CategoryHierarchy.CategoryID = TH.ParentID +) + +SELECT + SortOrderCount, + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE('.',(level-1)*2) + c.[Name] as 'NameIndented', + c.[Image], + c.[Description], + c.[SortOrder], + c.[InheritSecurity], + c.[CategorySecurityType], + c.[MetaTitle], + c.[MetaDescription], + c.[MetaKeywords], + ch.[level], + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 AND (@authorId IS NULL OR a.AuthorID = @authorID) AND (@ShowPending IS NOT NULL OR (a.StartDate IS NULL OR a.StartDate < GetDate()))) as 'NumberofArticles' +FROM + CategoryHierarchy ch INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON ch.CategoryID = c.CategoryID +ORDER BY + CASE WHEN @SortType = 0 THEN CAST(ch.SortOrderCount AS VARCHAR) ELSE ch.Path END +GO + diff --git a/SqlDataProvider/00.08.06.SqlDataProvider b/SqlDataProvider/00.08.06.SqlDataProvider new file mode 100644 index 0000000..97665bb --- /dev/null +++ b/SqlDataProvider/00.08.06.SqlDataProvider @@ -0,0 +1,62 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @AuthorID int, + @ShowPending bit, + @SortType int +AS + +;WITH CategoryHierarchy AS +( + SELECT + CategoryID, + ParentID, + CONVERT(nvarchar(max), Name) AS Path, + 1 as level, + (SortOrder+1) * (CONVERT(bigint, '1' + REPLICATE('0', 10))) AS 'SortOrderCount' + FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE + ParentID = -1 + AND + ModuleID = @ModuleID + + UNION ALL + + SELECT + TH.CategoryID, + TH.ParentID, + CONVERT(nvarchar(max), CategoryHierarchy.Path + ' \ ' + TH.Name) AS Path, + level = level + 1, + CategoryHierarchy.SortOrderCount + (CONVERT(bigint, CONVERT(varchar, (TH.SortOrder+1)) + REPLICATE('0', 10-(level*2)))) AS 'SortOrderCount' + FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category TH INNER JOIN + CategoryHierarchy ON CategoryHierarchy.CategoryID = TH.ParentID +) + +SELECT + SortOrderCount, + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE('.',(level-1)*2) + c.[Name] as 'NameIndented', + c.[Image], + c.[Description], + c.[SortOrder], + c.[InheritSecurity], + c.[CategorySecurityType], + c.[MetaTitle], + c.[MetaDescription], + c.[MetaKeywords], + ch.[level], + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 AND (@authorId IS NULL OR a.AuthorID = @authorID) AND (@ShowPending IS NOT NULL OR (a.StartDate IS NULL OR a.StartDate < GetDate()))) as 'NumberofArticles' +FROM + CategoryHierarchy ch INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON ch.CategoryID = c.CategoryID +ORDER BY + CASE WHEN @SortType = 0 THEN CAST(ch.SortOrderCount AS VARCHAR) ELSE ch.Path END +GO + diff --git a/SqlDataProvider/00.09.02.SqlDataProvider b/SqlDataProvider/00.09.02.SqlDataProvider new file mode 100644 index 0000000..9ccaab6 --- /dev/null +++ b/SqlDataProvider/00.09.02.SqlDataProvider @@ -0,0 +1,109 @@ + +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddArticle + @AuthorID int, + @ApproverID int, + @CreatedDate datetime, + @LastUpdate datetime, + @Title nvarchar(255), + @Summary ntext, + @IsApproved bit, + @NumberOfViews int, + @IsDraft bit, + @StartDate DateTime, + @EndDate DateTime, + @ModuleID int, + @ImageUrl nvarchar(255), + @IsFeatured bit, + @LastUpdateID int, + @Url nvarchar(255), + @IsSecure bit, + @IsNewWindow bit, + @MetaTitle nvarchar(200), + @MetaDescription nvarchar(500), + @MetaKeywords nvarchar(500), + @PageHeadText nvarchar(500), + @ShortUrl nvarchar(50), + @RssGuid nvarchar(255) +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article ( + [AuthorID], + [ApproverID], + [CreatedDate], + [LastUpdate], + [Title], + [Summary], + [IsApproved], + [NumberOfViews], + [IsDraft], + [StartDate], + [EndDate], + [ModuleID], + [ImageUrl], + [IsFeatured], + [LastUpdateID], + [Url], + [IsSecure], + [IsNewWindow], + [MetaTitle], + [MetaDescription], + [MetaKeywords], + [PageHeadText], + [ShortUrl], + [RssGuid] +) VALUES ( + @AuthorID, + @ApproverID, + @CreatedDate, + @LastUpdate, + @Title, + @Summary, + @IsApproved, + @NumberOfViews, + @IsDraft, + @StartDate, + @EndDate, + @ModuleID, + @ImageUrl, + @IsFeatured, + @LastUpdateID, + @Url, + @IsSecure, + @IsNewWindow, + @MetaTitle, + @MetaDescription, + @MetaKeywords, + @PageHeadText, + @ShortUrl, + @RssGuid +) + +select SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [PageCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Page Page where Page.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [Rating] = (select AVG(rating) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [RatingCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Rating Rating where Rating.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [ImageCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Image i where i.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [FileCount] = (select COUNT(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_File f where f.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID) +WHERE [ArticleID] = SCOPE_IDENTITY() +GO \ No newline at end of file diff --git a/SqlDataProvider/00.09.05.SqlDataProvider b/SqlDataProvider/00.09.05.SqlDataProvider new file mode 100644 index 0000000..f4e9b2a --- /dev/null +++ b/SqlDataProvider/00.09.05.SqlDataProvider @@ -0,0 +1,71 @@ +ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_HandoutArticle ADD CONSTRAINT + PK_{objectQualifier}DnnForge_NewsArticles_HandoutArticle PRIMARY KEY CLUSTERED + ( + HandoutID, + ArticleID + ) ON [PRIMARY] + +GO + +ALTER PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_AddComment + @ArticleID int, + @CreatedDate datetime, + @UserID int, + @Comment ntext, + @RemoteAddress nvarchar(50) , + @Type int, + @TrackbackUrl nvarchar(255), + @TrackbackTitle nvarchar(255), + @TrackbackBlogName nvarchar(255), + @TrackbackExcerpt ntext, + @AnonymousName nvarchar(255), + @AnonymousEmail nvarchar(255), + @AnonymousURL nvarchar(255), + @NotifyMe bit, + @IsApproved bit, + @ApprovedBy int +AS + +INSERT INTO {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment ( + [ArticleID], + [CreatedDate], + [UserID], + [Comment], + [RemoteAddress], + [Type], + [TrackbackUrl], + [TrackbackTitle], + [TrackbackBlogName], + [TrackbackExcerpt], + [AnonymousName], + [AnonymousEmail], + [AnonymousURL], + [NotifyMe], + [IsApproved], + [ApprovedBy] +) VALUES ( + @ArticleID, + @CreatedDate, + @UserID, + @Comment, + @RemoteAddress, + @Type, + @TrackbackUrl, + @TrackbackTitle, + @TrackbackBlogName, + @TrackbackExcerpt, + @AnonymousName, + @AnonymousEmail, + @AnonymousURL, + @NotifyMe, + @IsApproved, + @ApprovedBy +) + +select SCOPE_IDENTITY() + +UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article +SET [CommentCount] = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Comment Comment where Comment.ArticleID = {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article.ArticleID and Comment.IsApproved = 1) +WHERE ArticleID = @ArticleID +GO + diff --git a/SqlDataProvider/00.09.06.SqlDataProvider b/SqlDataProvider/00.09.06.SqlDataProvider new file mode 100644 index 0000000..7fe888d --- /dev/null +++ b/SqlDataProvider/00.09.06.SqlDataProvider @@ -0,0 +1,62 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @AuthorID int, + @ShowPending bit, + @SortType int +AS + +;WITH CategoryHierarchy AS +( + SELECT + CategoryID, + ParentID, + CONVERT(nvarchar(max), Name) AS Path, + 1 as level, + SortOrder * (CONVERT(bigint, '1' + REPLICATE('0', 10))) AS 'SortOrderCount' + FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE + ParentID = -1 + AND + ModuleID = @ModuleID + + UNION ALL + + SELECT + TH.CategoryID, + TH.ParentID, + CONVERT(nvarchar(max), CategoryHierarchy.Path + ' \ ' + TH.Name) AS Path, + level = level + 1, + CategoryHierarchy.SortOrderCount + (CONVERT(bigint, CONVERT(varchar, TH.SortOrder) + REPLICATE('0', 10-level))) AS 'SortOrderCount' + FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category TH INNER JOIN + CategoryHierarchy ON CategoryHierarchy.CategoryID = TH.ParentID +) + +SELECT + SortOrderCount, + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE('.',(level-1)*2) + c.[Name] as 'NameIndented', + c.[Image], + c.[Description], + c.[SortOrder], + c.[InheritSecurity], + c.[CategorySecurityType], + c.[MetaTitle], + c.[MetaDescription], + c.[MetaKeywords], + ch.[level], + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 AND (@authorId IS NULL OR a.AuthorID = @authorID) AND (@ShowPending IS NOT NULL OR (a.StartDate IS NULL OR a.StartDate < GetDate()))) as 'NumberofArticles' +FROM + CategoryHierarchy ch INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON ch.CategoryID = c.CategoryID +ORDER BY + CASE WHEN @SortType = 0 THEN ch.SortOrderCount END, + CASE WHEN @SortType = 1 THEN CH.Path END +GO diff --git a/SqlDataProvider/00.09.11.SqlDataProvider b/SqlDataProvider/00.09.11.SqlDataProvider new file mode 100644 index 0000000..32f5608 --- /dev/null +++ b/SqlDataProvider/00.09.11.SqlDataProvider @@ -0,0 +1,61 @@ +DROP PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll +GO + +CREATE PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_GetCategoryListAll + @ModuleID int, + @AuthorID int, + @ShowPending bit, + @SortType int +AS + +;WITH CategoryHierarchy AS +( + SELECT + CategoryID, + ParentID, + CONVERT(nvarchar(max), Name) AS Path, + 1 as level, + (SortOrder+1) * (CONVERT(bigint, '1' + REPLICATE('0', 15))) AS 'SortOrderCount' + FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category + WHERE + ParentID = -1 + AND + ModuleID = @ModuleID + + UNION ALL + + SELECT + TH.CategoryID, + TH.ParentID, + CONVERT(nvarchar(max), CategoryHierarchy.Path + ' \ ' + TH.Name) AS Path, + level = level + 1, + CategoryHierarchy.SortOrderCount + 1 + (CONVERT(bigint, CONVERT(varchar, TH.SortOrder) + REPLICATE('0', 15-level*2))) AS 'SortOrderCount' + FROM + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category TH INNER JOIN + CategoryHierarchy ON CategoryHierarchy.CategoryID = TH.ParentID +) + +SELECT + SortOrderCount, + c.[CategoryID], + c.[ParentID], + c.[ModuleID], + c.[Name], + REPLICATE('.',(level-1)*2) + c.[Name] as 'NameIndented', + c.[Image], + c.[Description], + c.[SortOrder], + c.[InheritSecurity], + c.[CategorySecurityType], + c.[MetaTitle], + c.[MetaDescription], + c.[MetaKeywords], + ch.[level], + (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleCategories ac INNER JOIN {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Article a ON ac.ArticleID = a.ArticleID WHERE ac.CategoryID = c.CategoryID AND a.IsDraft = 0 AND a.IsApproved = 1 AND (@authorId IS NULL OR a.AuthorID = @authorID) AND (@ShowPending IS NOT NULL OR (a.StartDate IS NULL OR a.StartDate < GetDate()))) as 'NumberofArticles' +FROM + CategoryHierarchy ch INNER JOIN + {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Category c ON ch.CategoryID = c.CategoryID +ORDER BY + CASE WHEN @SortType = 0 THEN CAST(ch.SortOrderCount AS VARCHAR) ELSE ch.Path END +GO \ No newline at end of file diff --git a/SqlDataProvider/Uninstall.SqlDataProvider b/SqlDataProvider/Uninstall.SqlDataProvider new file mode 100644 index 0000000..34b48db Binary files /dev/null and b/SqlDataProvider/Uninstall.SqlDataProvider differ diff --git a/Ventrian.NewsArticles.vbproj b/Ventrian.NewsArticles.vbproj index 9fbfe53..f4bed11 100755 --- a/Ventrian.NewsArticles.vbproj +++ b/Ventrian.NewsArticles.vbproj @@ -18,13 +18,14 @@ 3.5 - v3.5 + v4.5 false + true @@ -36,6 +37,7 @@ 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42353,42354,42355 + false pdbonly @@ -47,6 +49,7 @@ 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42353,42354,42355 + false @@ -65,6 +68,9 @@ + + + @@ -153,7 +159,6 @@ - @@ -214,12 +219,8 @@ - - - SWFUploaderFiles.ashx - UploadFiles.ascx @@ -248,9 +249,6 @@ PostRating.ascx ASPXCodeBehind - - SWFUploader.ashx - UploadImages.ascx @@ -807,21 +805,9 @@ - - - - - - - - - - - - @@ -841,7 +827,6 @@ - @@ -884,11 +869,8 @@ - - - MyApplicationCodeGenerator Application.Designer.vb @@ -901,7 +883,6 @@ Designer - @@ -991,9 +972,9 @@ True 55764 / - http://localhost/DotNetNuke455 + http://europedirect.dnndev.me True - http://localhost/DotNetNuke455 + http://europedirect.dnndev.me False False diff --git a/Ventrian.NewsArticles.vbproj.user b/Ventrian.NewsArticles.vbproj.user index b8e4aa5..42f45b9 100755 --- a/Ventrian.NewsArticles.vbproj.user +++ b/Ventrian.NewsArticles.vbproj.user @@ -1,28 +1,6 @@  - - - - - - - - CurrentPage - True - False - False - False - - - - - - - - - False - True - - - - + + + Debug|Any CPU + \ No newline at end of file diff --git a/ViewArticle.ascx.vb b/ViewArticle.ascx.vb index ebb90ff..ed706e2 100755 --- a/ViewArticle.ascx.vb +++ b/ViewArticle.ascx.vb @@ -263,7 +263,43 @@ Namespace Ventrian.NewsArticles Me.BasePage.Header.Controls.Add(phPageHeaderTitle) End If - End Sub + + ' set metatags for sharing + Dim sb As New StringBuilder() + Dim desc As String = StripHtml(Server.HtmlDecode(objArticle.Summary.Trim()), True) + If String.IsNullOrEmpty(desc) Then + Dim pageController As New PageController + Dim pageList As ArrayList = pageController.GetPageList(objArticle.ArticleID) + If pageList.Count > 0 Then + Dim p As PageInfo = pageList(0) + desc = StripHtml(Server.HtmlDecode(p.PageText), True) + End If + End If + desc = desc.Substring(0, Math.Min(300, desc.Length)) + + Dim img As String = "" + If (objArticle.ImageUrl <> "") Then + img = FormatImageUrl(objArticle.ImageUrl) + Else + If (objArticle.ImageCount > 0) Then + Dim objImageController As New ImageController + Dim objImages As List(Of ImageInfo) = objImageController.GetImageList(objArticle.ArticleID, Null.NullString()) + If (objImages.Count > 0) Then + img = AddHTTP(System.Web.HttpContext.Current.Request.Url.Host & PortalSettings.HomeDirectory & objImages(0).Folder & objImages(0).FileName) + End If + End If + End If + + sb.AppendFormat("{1}", "article", System.Environment.NewLine) + sb.AppendFormat("{1}", objArticle.Title, System.Environment.NewLine) + sb.AppendFormat("{1}", desc, System.Environment.NewLine) + sb.AppendFormat("{1}", targetUrl, System.Environment.NewLine) + If (Not String.IsNullOrEmpty(img)) Then + sb.AppendFormat("{1}", img, System.Environment.NewLine) + End If + Me.Parent.Page.Header.Controls.Add(New LiteralControl(sb.ToString())) + + End Sub Private Sub ReadQueryString() diff --git a/Web References/wsStoryFeed/Reference.vb b/Web References/wsStoryFeed/Reference.vb index 4ad4606..7d13939 100755 --- a/Web References/wsStoryFeed/Reference.vb +++ b/Web References/wsStoryFeed/Reference.vb @@ -1,7 +1,7 @@ '------------------------------------------------------------------------------ ' ' This code was generated by a tool. -' Runtime Version:4.0.30319.17929 +' Runtime Version:4.0.30319.42000 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. @@ -19,12 +19,12 @@ Imports System.Web.Services.Protocols Imports System.Xml.Serialization ' -'This source code was auto-generated by Microsoft.VSDesigner, Version 4.0.30319.17929. +'This source code was auto-generated by Microsoft.VSDesigner, Version 4.0.30319.42000. ' Namespace wsStoryFeed ''' - _ @@ -153,11 +153,11 @@ Namespace wsStoryFeed End Class ''' - _ + _ Public Delegate Sub AddActionCompletedEventHandler(ByVal sender As Object, ByVal e As AddActionCompletedEventArgs) ''' - _ Partial Public Class AddActionCompletedEventArgs @@ -180,11 +180,11 @@ Namespace wsStoryFeed End Class ''' - _ + _ Public Delegate Sub AddActionIfNotExistsCompletedEventHandler(ByVal sender As Object, ByVal e As AddActionIfNotExistsCompletedEventArgs) ''' - _ Partial Public Class AddActionIfNotExistsCompletedEventArgs diff --git a/ucSubmitNews.ascx b/ucSubmitNews.ascx index b2dff06..148802b 100755 --- a/ucSubmitNews.ascx +++ b/ucSubmitNews.ascx @@ -12,9 +12,6 @@ - - -
diff --git a/ucViewOptions.ascx.vb b/ucViewOptions.ascx.vb index da726b2..d42ae33 100755 --- a/ucViewOptions.ascx.vb +++ b/ucViewOptions.ascx.vb @@ -1080,15 +1080,15 @@ Namespace Ventrian.NewsArticles End If End If Next - objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_CATEGORIES_SETTING, IIf(String.IsNullOrEmpty(categoriesRoles), ";", categoriesRoles)) - objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_EXCERPT_SETTING, IIf(String.IsNullOrEmpty(excerptRoles), ";", excerptRoles)) - objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_IMAGE_SETTING, IIf(String.IsNullOrEmpty(imageRoles), ";", imageRoles)) - objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_FILE_SETTING, IIf(String.IsNullOrEmpty(fileRoles), ";", fileRoles)) - objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_LINK_SETTING, IIf(String.IsNullOrEmpty(linkRoles), ";", linkRoles)) - objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_PUBLISH_SETTING, IIf(String.IsNullOrEmpty(publishRoles), ";", publishRoles)) - objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_EXPIRY_SETTING, IIf(String.IsNullOrEmpty(expiryRoles), ";", expiryRoles)) - objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_META_SETTING, IIf(String.IsNullOrEmpty(metaRoles), ";", metaRoles)) - objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_CUSTOM_SETTING, IIf(String.IsNullOrEmpty(customRoles), ";", customRoles)) + objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_CATEGORIES_SETTING, categoriesRoles) + objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_EXCERPT_SETTING, excerptRoles) + objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_IMAGE_SETTING, imageRoles) + objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_FILE_SETTING, fileRoles) + objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_LINK_SETTING, linkRoles) + objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_PUBLISH_SETTING, publishRoles) + objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_EXPIRY_SETTING, expiryRoles) + objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_META_SETTING, metaRoles) + objModules.UpdateModuleSetting(ModuleId, ArticleConstants.PERMISSION_CUSTOM_SETTING, customRoles) Dim siteTemplatesRoles As String = "" For Each item As DataGridItem In grdAdminPermissions.Items