forked from ventrian/News-Articles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathucEditPages.ascx.vb
executable file
·215 lines (139 loc) · 7.98 KB
/
ucEditPages.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
'
' 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.Services.Exceptions
Imports Ventrian.NewsArticles.Base
Namespace Ventrian.NewsArticles
Partial Public Class ucEditPages
Inherits NewsArticleModuleBase
#Region " Private Members "
Private _articleID As Integer
#End Region
#Region " Private Methods "
Private Sub ReadQueryString()
If (IsNumeric(Request("ArticleID"))) Then
_articleID = Convert.ToInt32(Request("ArticleID"))
End If
End Sub
Private Sub CheckSecurity()
If (HasEditRights(_articleID, Me.ModuleId, Me.TabId) = False) Then
Response.Redirect(Common.GetModuleLink(Me.TabId, Me.ModuleId, "NotAuthorized", ArticleSettings), True)
End If
End Sub
Private Sub BindArticle()
If (_articleID = Null.NullInteger) Then
Response.Redirect(Common.GetModuleLink(Me.TabId, Me.ModuleId, "NotAuthorized", ArticleSettings), True)
End If
Dim objArticleController As ArticleController = New ArticleController
Dim objArticle As ArticleInfo = objArticleController.GetArticle(_articleID)
If (objArticle Is Nothing) Then
Response.Redirect(Common.GetModuleLink(Me.TabId, Me.ModuleId, "NotAuthorized", ArticleSettings), True)
End If
lblTitle.Text = String.Format(DotNetNuke.Services.Localization.Localization.GetString("EditPages.Text", LocalResourceFile), objArticle.Title)
If (objArticle.IsDraft) Then
cmdSubmitApproval.Visible = True
cmdSubmitApproval.Attributes.Add("onClick", "javascript:return confirm('" & DotNetNuke.Services.Localization.Localization.GetString("SubmitApproval.Text", LocalResourceFile) & "');")
Else
cmdSubmitApproval.Visible = False
End If
End Sub
Private Sub BindPages()
Dim objPageController As PageController = New PageController
DotNetNuke.Services.Localization.Localization.LocalizeDataGrid(grdPages, Me.LocalResourceFile)
grdPages.DataSource = objPageController.GetPageList(_articleID)
grdPages.DataBind()
If (grdPages.Items.Count > 0) Then
grdPages.Visible = True
lblNoPages.Visible = False
Else
grdPages.Visible = False
lblNoPages.Visible = True
lblNoPages.Text = DotNetNuke.Services.Localization.Localization.GetString("NoPagesMessage.Text", LocalResourceFile)
End If
End Sub
#End Region
#Region " Protected Methods "
Protected Function GetEditPageUrl(ByVal articleID As String, ByVal pageID As String) As String
Return Common.GetModuleLink(TabId, ModuleId, "EditPage", ArticleSettings, "ArticleID=" & articleID, "PageID=" & pageID)
End Function
#End Region
#Region " Event Handlers "
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
Try
ReadQueryString()
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
CheckSecurity()
BindPages()
If (IsPostBack = False) Then
BindArticle()
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdAddPage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddPage.Click
Try
Response.Redirect(Common.GetModuleLink(TabId, ModuleId, "EditPage", ArticleSettings, "ArticleID=" & _articleID.ToString()), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdSortOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSortOrder.Click
Try
Response.Redirect(Common.GetModuleLink(TabId, ModuleId, "EditSortOrder", ArticleSettings, "ArticleID=" & _articleID.ToString()), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdSummary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSummary.Click
Try
Response.Redirect(Common.GetModuleLink(TabId, ModuleId, "SubmitNews", ArticleSettings, "ArticleID=" & _articleID.ToString()), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdSubmitApproval_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmitApproval.Click
Try
Dim objLogController As New DotNetNuke.Services.Log.EventLog.EventLogController
Dim objController As New ArticleController
Dim objArticle As ArticleInfo = objController.GetArticle(_articleID)
If Not (objArticle Is Nothing) Then
objArticle.Status = StatusType.AwaitingApproval
objController.UpdateArticle(objArticle)
If (Settings.Contains(ArticleConstants.NOTIFY_SUBMISSION_SETTING)) Then
If (Convert.ToBoolean(Settings(ArticleConstants.NOTIFY_SUBMISSION_SETTING)) = True) Then
Dim objEmailTemplateController As New EmailTemplateController
Dim emails As String = objEmailTemplateController.GetApproverDistributionList(ModuleId)
For Each email As String In emails.Split(Convert.ToChar(";"))
If (email <> "") Then
objEmailTemplateController.SendFormattedEmail(Me.ModuleId, Common.GetArticleLink(objArticle, PortalSettings.ActiveTab, ArticleSettings, False), objArticle, EmailTemplateType.ArticleSubmission, email, ArticleSettings)
End If
Next
End If
End If
If (Settings.Contains(ArticleConstants.NOTIFY_SUBMISSION_SETTING_EMAIL)) Then
If (Settings(ArticleConstants.NOTIFY_SUBMISSION_SETTING_EMAIL).ToString() <> "") Then
Dim objEmailTemplateController As New EmailTemplateController
objEmailTemplateController.SendFormattedEmail(Me.ModuleId, Common.GetArticleLink(objArticle, PortalSettings.ActiveTab, ArticleSettings, False), objArticle, EmailTemplateType.ArticleSubmission, Settings(ArticleConstants.NOTIFY_SUBMISSION_SETTING_EMAIL).ToString(), ArticleSettings)
End If
End If
Response.Redirect(Common.GetModuleLink(TabId, ModuleId, "SubmitNewsComplete", ArticleSettings, "ArticleID=" & _articleID.ToString()), True)
Else
ProcessModuleLoadException(Me, New Exception("Unable to Retrieve Article to Submit for Approval"))
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace