forked from ventrian/News-Articles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathucApproveArticles.ascx.vb
executable file
·365 lines (253 loc) · 16.2 KB
/
ucApproveArticles.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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
'
' News Articles for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2002-2007
' by Ventrian ( [email protected] ) ( http://www.ventrian.com )
'
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Users
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Security.Roles
Imports Ventrian.NewsArticles.Components.Social
Imports Ventrian.NewsArticles.Base
Namespace Ventrian.NewsArticles
Partial Public Class ucApproveArticles
Inherits NewsArticleModuleBase
#Region " Private Properties "
Private ReadOnly Property CurrentPage() As Integer
Get
If (Request("Page") = Null.NullString And Request("CurrentPage") = Null.NullString) Then
Return 1
Else
Try
If (Request("Page") <> Null.NullString) Then
Return Convert.ToInt32(Request("Page"))
Else
Return Convert.ToInt32(Request("CurrentPage"))
End If
Catch
Return 1
End Try
End If
End Get
End Property
#End Region
#Region " Private Methods "
Private Function IsInRole(ByVal roleName As String, ByVal roles As String()) As Boolean
For Each role As String In roles
If (roleName = role) Then
Return True
End If
Next
Return False
End Function
Private Sub BindArticles()
Dim count As Integer = 0
Dim objArticleController As New ArticleController
DotNetNuke.Services.Localization.Localization.LocalizeDataGrid(grdArticles, Me.LocalResourceFile)
grdArticles.DataSource = objArticleController.GetArticleList(Me.ModuleId, Null.NullDate, Null.NullDate, Nothing, Null.NullBoolean, Nothing, Null.NullInteger, CurrentPage, 20, "StartDate", "DESC", False, Null.NullBoolean, Null.NullString, Null.NullInteger, True, True, Null.NullBoolean, Null.NullBoolean, False, False, Null.NullString, Nothing, False, Null.NullString, Null.NullInteger, Null.NullString, Null.NullString, count)
grdArticles.DataBind()
If (grdArticles.Items.Count = 0) Then
lblNoArticles.Visible = True
lblNoArticles.Text = DotNetNuke.Services.Localization.Localization.GetString("NoArticlesMessage.Text", LocalResourceFile)
grdArticles.Visible = False
ctlPagingControl.Visible = False
Else
lblNoArticles.Visible = False
grdArticles.Visible = True
ctlPagingControl.Visible = True
ctlPagingControl.TotalRecords = count
ctlPagingControl.PageSize = 20
ctlPagingControl.CurrentPage = CurrentPage
ctlPagingControl.QuerystringParams = GetParams()
ctlPagingControl.TabID = TabId
ctlPagingControl.EnableViewState = False
End If
End Sub
Private Function GetParams() As String
Dim params As String = ""
If (Request("ctl") <> "") Then
If (Request("ctl").ToLower = "approvearticles") Then
params += "ctl=" & Request("ctl") & "&mid=" & ModuleId.ToString()
End If
End If
If (Request("articleType") <> "") Then
If (Request("articleType").ToString().ToLower = "approvearticles") Then
params += "articleType=" & Request("articleType")
End If
End If
Return params
End Function
Private Sub NotifyAuthor(ByVal objArticle As ArticleInfo)
If (Settings.Contains(ArticleConstants.NOTIFY_APPROVAL_SETTING)) Then
If (Convert.ToBoolean(Settings(ArticleConstants.NOTIFY_APPROVAL_SETTING))) Then
Dim objUserController As New UserController
Dim objUser As UserInfo = objUserController.GetUser(Me.PortalId, objArticle.AuthorID)
Dim objEmailTemplateController As New EmailTemplateController
If Not (objUser Is Nothing) Then
objEmailTemplateController.SendFormattedEmail(Me.ModuleId, Common.GetArticleLink(objArticle, PortalSettings.ActiveTab, ArticleSettings, False), objArticle, EmailTemplateType.ArticleApproved, objUser.Email, ArticleSettings)
End If
End If
End If
End Sub
Private Sub CheckSecurity()
If (Request.IsAuthenticated = False) Then
Response.Redirect(Common.GetModuleLink(Me.TabId, Me.ModuleId, "NotAuthenticated", ArticleSettings), True)
End If
If (ArticleSettings.IsApprover) Then
Return
End If
Response.Redirect(Common.GetModuleLink(Me.TabId, Me.ModuleId, "NotAuthorized", ArticleSettings), True)
End Sub
#End Region
#Region " Protected Methods "
Protected Function GetAdjustedCreateDate(ByVal objItem As Object) As String
Dim objArticle As ArticleInfo = CType(objItem, ArticleInfo)
Return objArticle.CreatedDate.ToString("d") & " " & objArticle.CreatedDate.ToString("t")
End Function
Protected Function GetAdjustedPublishDate(ByVal objItem As Object) As String
Dim objArticle As ArticleInfo = CType(objItem, ArticleInfo)
Return objArticle.StartDate.ToString("d") & " " & objArticle.StartDate.ToString("t")
End Function
Protected Function GetArticleLink(ByVal objItem As Object) As String
Dim objArticle As ArticleInfo = CType(objItem, ArticleInfo)
Return Common.GetArticleLink(objArticle, PortalSettings.ActiveTab, ArticleSettings, False)
End Function
Protected Function GetEditUrl(ByVal articleID As String) As String
If (ArticleSettings.LaunchLinks) Then
Return Common.GetModuleLink(Me.TabId, Me.ModuleId, "Edit", ArticleSettings, "ArticleID=" & articleID, "returnurl=" & Server.UrlEncode(Request.Url.ToString()))
Else
Return Common.GetModuleLink(Me.TabId, Me.ModuleId, "SubmitNews", ArticleSettings, "ArticleID=" & articleID, "returnurl=" & Server.UrlEncode(Request.Url.ToString()))
End If
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
CheckSecurity()
If IsPostBack = False Then
BindArticles()
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdApproveSelected_OnClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdApproveSelected.Click
Try
Dim objArticleController As New ArticleController
For i As Integer = 0 To grdArticles.Items.Count - 1
Dim currentItem As DataGridItem = grdArticles.Items(i)
If Not (currentItem.FindControl("chkArticle") Is Nothing) Then
Dim chkArticle As CheckBox = CType(currentItem.FindControl("chkArticle"), CheckBox)
If (chkArticle.Checked) Then
Dim objArticle As ArticleInfo = objArticleController.GetArticle(Convert.ToInt32(grdArticles.DataKeys(i)))
objArticle.Status = StatusType.Published
objArticleController.UpdateArticle(objArticle)
NotifyAuthor(objArticle)
If (ArticleSettings.EnableAutoTrackback) Then
Dim objNotifications As New Tracking.Notification
objNotifications.NotifyExternalSites(objArticle, Common.GetArticleLink(objArticle, PortalSettings.ActiveTab, ArticleSettings, False), Me.PortalSettings.PortalName)
End If
If (ArticleSettings.EnableNotificationPing) Then
Dim objNotifications As New Tracking.Notification
objNotifications.NotifyWeblogs(AddHTTP(NavigateURL()), Me.PortalSettings.PortalName)
End If
If (ArticleSettings.JournalIntegration) Then
Dim objJournal As New Journal
objJournal.AddArticleToJournal(objArticle, PortalId, TabId, Me.UserId, Null.NullInteger, Common.GetArticleLink(objArticle, PortalSettings.ActiveTab, ArticleSettings, False))
End If
If (ArticleSettings.JournalIntegrationGroups) Then
Dim objCategories As ArrayList = objArticleController.GetArticleCategories(objArticle.ArticleID)
If (objCategories.Count > 0) Then
Dim objRoleController As New RoleController()
Dim objRoles As IList(Of RoleInfo) = objRoleController.GetRoles(PortalId)
For Each objRole As RoleInfo In objRoles
Dim roleAccess As Boolean = False
If (objRole.SecurityMode = SecurityMode.SocialGroup Or objRole.SecurityMode = SecurityMode.Both) Then
For Each objCategory As CategoryInfo In objCategories
If (objCategory.InheritSecurity = False) Then
If (objCategory.CategorySecurityType = CategorySecurityType.Loose) Then
roleAccess = False
Exit For
Else
If (Settings.Contains(objCategory.CategoryID.ToString() & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (IsInRole(objRole.RoleName, Settings(objCategory.CategoryID.ToString() & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING).ToString().Split(";"c))) Then
roleAccess = True
End If
End If
End If
End If
Next
End If
If (roleAccess) Then
Dim objJournal As New Journal
objJournal.AddArticleToJournal(objArticle, PortalId, TabId, Me.UserId, objRole.RoleID, Common.GetArticleLink(objArticle, PortalSettings.ActiveTab, ArticleSettings, False))
End If
Next
End If
End If
If (ArticleSettings.EnableSmartThinkerStoryFeed) Then
Dim objStoryFeed As New wsStoryFeed.StoryFeedWS
objStoryFeed.Url = DotNetNuke.Common.Globals.AddHTTP(Request.ServerVariables("HTTP_HOST") & Me.ResolveUrl("~/DesktopModules/Smart-Thinker%20-%20UserProfile/StoryFeed.asmx"))
Dim val As String = GetSharedResource("StoryFeed-AddArticle")
val = val.Replace("[AUTHOR]", objArticle.AuthorDisplayName)
val = val.Replace("[AUTHORID]", objArticle.AuthorID.ToString())
val = val.Replace("[ARTICLELINK]", Common.GetArticleLink(objArticle, Me.PortalSettings.ActiveTab, ArticleSettings, False))
val = val.Replace("[ARTICLETITLE]", objArticle.Title)
Try
objStoryFeed.AddAction(80, objArticle.ArticleID, val, objArticle.AuthorID, "VE6457624576460436531768")
Catch
End Try
End If
If (ArticleSettings.EnableActiveSocialFeed) Then
If (ArticleSettings.ActiveSocialSubmitKey <> "") Then
If IO.File.Exists(HttpContext.Current.Server.MapPath("~/bin/active.modules.social.dll")) Then
Dim ai As Object = Nothing
Dim asm As System.Reflection.Assembly
Dim ac As Object = Nothing
Try
asm = System.Reflection.Assembly.Load("Active.Modules.Social")
ac = asm.CreateInstance("Active.Modules.Social.API.Journal")
If Not ac Is Nothing Then
ac.AddProfileItem(New Guid(ArticleSettings.ActiveSocialSubmitKey), objArticle.AuthorID, Common.GetArticleLink(objArticle, Me.PortalSettings.ActiveTab, ArticleSettings, False), objArticle.Title, objArticle.Summary, objArticle.Body, 1, "")
End If
Catch ex As Exception
End Try
End If
End If
End If
End If
End If
Next
Response.Redirect(Common.GetModuleLink(TabId, ModuleId, "ApproveArticles", ArticleSettings), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdApproveAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdApproveAll.Click
Try
Dim objArticleController As New ArticleController
For i As Integer = 0 To grdArticles.Items.Count - 1
Dim currentItem As DataGridItem = grdArticles.Items(i)
Dim objArticle As ArticleInfo = objArticleController.GetArticle(Convert.ToInt32(grdArticles.DataKeys(i)))
objArticle.Status = StatusType.Published
objArticleController.UpdateArticle(objArticle)
NotifyAuthor(objArticle)
If (ArticleSettings.EnableAutoTrackback) Then
Dim objNotifications As New Tracking.Notification
objNotifications.NotifyExternalSites(objArticle, Common.GetArticleLink(objArticle, PortalSettings.ActiveTab, ArticleSettings, False), Me.PortalSettings.PortalName)
End If
If (ArticleSettings.EnableNotificationPing) Then
Dim objNotifications As New Tracking.Notification
objNotifications.NotifyWeblogs(AddHTTP(NavigateURL()), Me.PortalSettings.PortalName)
End If
Next
Response.Redirect(Common.GetModuleLink(TabId, ModuleId, "ApproveArticles", ArticleSettings), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace