-
Notifications
You must be signed in to change notification settings - Fork 24
/
Archives.ascx.vb
executable file
·310 lines (224 loc) · 13.8 KB
/
Archives.ascx.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
'
' News Articles for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2002-2007
' by Ventrian ( [email protected] ) ( http://www.ventrian.com )
'
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Security
Imports Ventrian.NewsArticles.Base
Namespace Ventrian.NewsArticles
Partial Public Class Archives
Inherits NewsArticleModuleBase
#Region " Protected Properties "
Protected ReadOnly Property AuthorID() As Integer
Get
Dim id As Integer = Null.NullInteger
If (ArticleSettings.AuthorUserIDFilter) Then
If (Request.QueryString(ArticleSettings.AuthorUserIDParam) <> "") Then
Try
id = Convert.ToInt32(Request.QueryString(ArticleSettings.AuthorUserIDParam))
Catch
End Try
End If
End If
If (ArticleSettings.AuthorUsernameFilter) Then
If (Request.QueryString(ArticleSettings.AuthorUsernameParam) <> "") Then
Try
Dim objUser As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetUserByName(Me.PortalId, Request.QueryString(ArticleSettings.AuthorUsernameParam))
If (objUser IsNot Nothing) Then
id = objUser.UserID
End If
Catch
End Try
End If
End If
If (ArticleSettings.AuthorLoggedInUserFilter) Then
If (Request.IsAuthenticated) Then
id = Me.UserId
Else
id = -100
End If
End If
If (ArticleSettings.Author <> Null.NullInteger) Then
id = ArticleSettings.Author
End If
Return id
End Get
End Property
Protected ReadOnly Property AuthorIDRSS() As String
Get
If (AuthorID <> Null.NullInteger) Then
Return "&AuthorID=" & AuthorID.ToString()
End If
Return ""
End Get
End Property
#End Region
#Region " Protected Methods "
Protected Function GetAuthorLink(ByVal authorID As Integer, ByVal username As String) As String
Return Common.GetAuthorLink(Me.TabId, Me.ModuleId, authorID, username, ArticleSettings.LaunchLinks, ArticleSettings)
End Function
Protected Function GetAuthorLinkRss(ByVal authorID As String) As String
Return Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/RSS.aspx?TabID=" & TabId.ToString() & "&ModuleID=" & ModuleId.ToString() & "&AuthorID=" & authorID)
End Function
Protected Function GetCategoryLink(ByVal categoryID As String, ByVal name As String) As String
Return Common.GetCategoryLink(Me.TabId, Me.ModuleId, categoryID, name, ArticleSettings.LaunchLinks, ArticleSettings)
End Function
Protected Function GetCategoryLinkRss(ByVal categoryID As String) As String
Return Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/RSS.aspx?TabID=" & TabId.ToString() & "&ModuleID=" & ModuleId.ToString() & "&CategoryID=" & categoryID & AuthorIDRSS)
End Function
Protected Function GetCurrentLinkRss() As String
Return Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/RSS.aspx?TabID=" & TabId.ToString() & "&ModuleID=" & ModuleId.ToString() & "&MaxCount=25" & AuthorIDRSS)
End Function
Protected Function GetCurrentLink() As String
Return Common.GetModuleLink(TabId, ModuleId, "", ArticleSettings)
End Function
Protected Function GetMonthLink(ByVal month As Integer, ByVal year As Integer) As String
Return Common.GetModuleLink(Me.TabId, Me.ModuleId, "ArchiveView", ArticleSettings, "month=" & month.ToString(), "year=" & year.ToString())
End Function
Protected Function GetMonthLinkRss(ByVal month As Integer, ByVal year As Integer) As String
Return Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/RSS.aspx?TabID=" & TabId.ToString() & "&ModuleID=" & ModuleId.ToString() & "&Month=" & month.ToString() & "&Year=" & year.ToString() & AuthorIDRSS)
End Function
Protected Function GetMonthName(ByVal month As Integer) As String
Dim dt As New DateTime(2008, month, 1)
Return dt.ToString("MMMM")
End Function
Protected Function GetRssPath() As String
Return Page.ResolveUrl(ArticleSettings.SyndicationImagePath)
End Function
Protected Function IsSyndicationEnabled() As Boolean
Return ArticleSettings.IsSyndicationEnabled
End Function
#End Region
#Region " Event Handlers "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim objCategoryController As New CategoryController
If (ArticleSettings.FilterSingleCategory <> Null.NullInteger) Then
Dim categoriesToDisplay(1) As Integer
categoriesToDisplay(1) = ArticleSettings.FilterSingleCategory
rptCategories.DataSource = objCategoryController.GetCategoriesAll(Me.ModuleId, Null.NullInteger, categoriesToDisplay, AuthorID, Null.NullInteger, ArticleSettings.ShowPending, ArticleSettings.CategorySortType)
rptCategories.DataBind()
Else
Dim objCategoriesSelected As New List(Of CategoryInfo)
Dim objCategoriesDisplay As List(Of CategoryInfo) = objCategoryController.GetCategoriesAll(Me.ModuleId, Null.NullInteger, ArticleSettings.FilterCategories, AuthorID, Null.NullInteger, ArticleSettings.ShowPending, ArticleSettings.CategorySortType)
For Each objCategory As CategoryInfo In objCategoriesDisplay
If (objCategory.InheritSecurity) Then
objCategoriesSelected.Add(objCategory)
Else
If (Request.IsAuthenticated) Then
If (Settings.Contains(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (PortalSecurity.IsInRoles(Settings(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING).ToString())) Then
objCategoriesSelected.Add(objCategory)
End If
End If
End If
End If
Next
rptCategories.DataSource = objCategoriesSelected
rptCategories.DataBind()
End If
Dim objCategories As List(Of CategoryInfo) = objCategoryController.GetCategoriesAll(ModuleId, Null.NullInteger)
Dim excludeCategoriesRestrictive As New List(Of Integer)
For Each objCategory As CategoryInfo In objCategories
If (objCategory.InheritSecurity = False And objCategory.CategorySecurityType = CategorySecurityType.Restrict) Then
If (Request.IsAuthenticated) Then
If (Settings.Contains(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (PortalSecurity.IsInRoles(Settings(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING).ToString()) = False) Then
excludeCategoriesRestrictive.Add(objCategory.CategoryID)
End If
End If
Else
excludeCategoriesRestrictive.Add(objCategory.CategoryID)
End If
End If
Next
Dim excludeCategories As New List(Of Integer)
For Each objCategory As CategoryInfo In objCategories
If (objCategory.InheritSecurity = False And objCategory.CategorySecurityType = CategorySecurityType.Loose) Then
If (Request.IsAuthenticated) Then
If (Settings.Contains(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (PortalSecurity.IsInRoles(Settings(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING).ToString()) = False) Then
excludeCategories.Add(objCategory.CategoryID)
End If
End If
Else
excludeCategories.Add(objCategory.CategoryID)
End If
End If
Next
Dim filterCategories As Integer() = ArticleSettings.FilterCategories
Dim includeCategories As New List(Of Integer)
If (excludeCategories.Count > 0) Then
For Each objCategoryToInclude As CategoryInfo In objCategories
Dim includeCategory As Boolean = True
For Each exclCategory As Integer In excludeCategories
If (exclCategory = objCategoryToInclude.CategoryID) Then
includeCategory = False
End If
Next
If (ArticleSettings.FilterCategories IsNot Nothing) Then
If (ArticleSettings.FilterCategories.Length > 0) Then
Dim filter As Boolean = False
For Each cat As Integer In ArticleSettings.FilterCategories
If (cat = objCategoryToInclude.CategoryID) Then
filter = True
End If
Next
If (filter = False) Then
includeCategory = False
End If
End If
End If
If (includeCategory) Then
includeCategories.Add(objCategoryToInclude.CategoryID)
End If
Next
If (includeCategories.Count > 0) Then
includeCategories.Add(-1)
End If
filterCategories = includeCategories.ToArray()
End If
If (ArticleSettings.FilterSingleCategory <> Null.NullInteger) Then
Dim categoriesToDisplay(1) As Integer
categoriesToDisplay(1) = ArticleSettings.FilterSingleCategory
Dim objAuthorController As New AuthorController
rptAuthors.DataSource = objAuthorController.GetAuthorStatistics(Me.ModuleId, categoriesToDisplay, excludeCategoriesRestrictive.ToArray(), AuthorID, "DisplayName", ArticleSettings.ShowPending)
rptAuthors.DataBind()
Else
Dim objAuthorController As New AuthorController
rptAuthors.DataSource = objAuthorController.GetAuthorStatistics(Me.ModuleId, filterCategories, excludeCategoriesRestrictive.ToArray(), AuthorID, "DisplayName", ArticleSettings.ShowPending)
rptAuthors.DataBind()
End If
If (ArticleSettings.FilterSingleCategory <> Null.NullInteger) Then
Dim categoriesToDisplay(1) As Integer
categoriesToDisplay(1) = ArticleSettings.FilterSingleCategory
Dim objArticleController As New ArticleController
rptMonth.DataSource = objArticleController.GetNewsArchive(Me.ModuleId, categoriesToDisplay, excludeCategoriesRestrictive.ToArray(), AuthorID, GroupByType.Month, ArticleSettings.ShowPending)
rptMonth.DataBind()
Else
Dim objArticleController As New ArticleController
rptMonth.DataSource = objArticleController.GetNewsArchive(Me.ModuleId, filterCategories, excludeCategoriesRestrictive.ToArray(), AuthorID, GroupByType.Month, ArticleSettings.ShowPending)
rptMonth.DataBind()
End If
Me.BasePage.Title = "Archives | " & Me.BasePage.Title
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
Try
LoadStyleSheet()
phCurrentArticles.Visible = ArticleSettings.ArchiveCurrentArticles
phCategory.Visible = ArticleSettings.ArchiveCategories
phAuthor.Visible = ArticleSettings.ArchiveAuthor
phMonth.Visible = ArticleSettings.ArchiveMonth
phArchives.Visible = IsSyndicationEnabled()
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace