forked from DNNCommunity/DNN.Feedback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewComments.ascx.vb
211 lines (174 loc) · 8.79 KB
/
ViewComments.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
'
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2010
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'
Imports DotNetNuke.Security.Permissions
Namespace DotNetNuke.Modules.Feedback
Partial Class ViewComments
Inherits Entities.Modules.PortalModuleBase
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
#Region "Private Members"
Private _template As Template
Private _pageSize As Integer = 10
#End Region
#Region "Properties"
Protected ReadOnly Property Template() As Template
Get
If _template Is Nothing Then
_template = Template.LoadTemplate(ModuleId, TabModuleId, Settings)
End If
Return _template
End Get
End Property
Private Property CurrentPage() As Integer
Get
If ViewState("CurrentPage") Is Nothing Then
Return 1
Else
Return CType(ViewState("CurrentPage"), Integer)
End If
End Get
Set(ByVal value As Integer)
ViewState("CurrentPage") = value
End Set
End Property
#End Region
#Region "Private Methods"
Private Sub BindData()
Dim totalRecords As Integer = 0
With rptComments
.HeaderTemplate = Template.CreateTemplate(System.Web.UI.WebControls.ListItemType.Header)
.ItemTemplate = Template.CreateTemplate(System.Web.UI.WebControls.ListItemType.Item)
.AlternatingItemTemplate = Template.CreateTemplate(System.Web.UI.WebControls.ListItemType.AlternatingItem)
.SeparatorTemplate = Template.CreateTemplate(System.Web.UI.WebControls.ListItemType.Separator)
.FooterTemplate = Template.CreateTemplate(System.Web.UI.WebControls.ListItemType.Footer)
End With
Dim oFb As New FeedbackController
Dim cfgSettings As New ConfigurationView(ModuleId, TabModuleId)
Dim category As String = cfgSettings.ArrayToString(cfgSettings.ViewCategory)
Dim selectedModules As String() = cfgSettings.SelectedModules
Dim arr As New ArrayList
If selectedModules Is Nothing Then 'legacy behavior/portal scope
arr = oFb.GetCategoryFeedback(PortalId, -1, category, FeedbackInfo.FeedbackStatusType.StatusPublic, CurrentPage, _pageSize)
If arr.Count > 0 Then
totalRecords = CType(arr(0), FeedbackInfo).TotalRecords
End If
Else
For Each selectedModule As String In selectedModules
If IsNumeric(selectedModule) Then
Dim selectedModuleId As Integer = CType(selectedModule, Integer)
Dim mc As New Entities.Modules.ModuleController
Dim mi As Entities.Modules.ModuleInfo = mc.GetModule(selectedModuleId)
If ModulePermissionController.CanViewModule(mi) Then
Dim moduleItems As ArrayList = oFb.GetCategoryFeedback(PortalId, selectedModuleId, category, FeedbackInfo.FeedbackStatusType.StatusPublic, CurrentPage, _pageSize)
If moduleItems.Count > 0 Then
totalRecords += CType(moduleItems(0), FeedbackInfo).TotalRecords
arr.AddRange(moduleItems)
End If
End If
End If
Next
End If
If arr IsNot Nothing AndAlso arr.Count > 0 Then
rptComments.DataSource = arr
rptComments.DataBind()
With ctlPagingControl
.TotalRecords = totalRecords
.PageSize = _pageSize
.CurrentPage = CurrentPage
.TabID = TabId
.Visible = (totalRecords > _pageSize)
End With
Else
totalRecords = 0
End If
Dim pagingEnabled As Boolean = cfgSettings.EnablePager
If pagingEnabled AndAlso totalRecords > CInt(ddlPageSize.Items(0).Value) Then
trPager.Visible = True
litMessage.Visible = False
Else
trPager.Visible = False
If totalRecords = 0 Then
litMessage.Visible = True
litMessage.Text = Localization.GetString("NoFeedback", LocalResourceFile)
End If
End If
End Sub
#End Region
#Region "Event Handlers"
Public Sub Page_Load(ByVal source As System.Object, ByVal e As EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim cfgSettings As New ConfigurationView(ModuleId, TabModuleId)
trPager.Visible = cfgSettings.EnablePager
If trPager.Visible Then
_pageSize = cfgSettings.DefaultPageSize
Dim start As Integer = Math.Max(_pageSize - 25, 5)
Dim finish As Integer = Math.Min(_pageSize + 25, 50)
ddlPageSize.Items.Clear()
For i As Integer = start To finish Step 5
ddlPageSize.Items.Add(i.ToString)
Next
ddlPageSize.SelectedValue = _pageSize.ToString
Else
_pageSize = Integer.MaxValue
End If
BindData()
Else
If trPager.Visible Then
Integer.TryParse(ddlPageSize.SelectedValue, _pageSize)
Else
_pageSize = Integer.MaxValue
End If
End If
End Sub
Private Sub ddlRecordsPerPage_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As EventArgs) Handles ddlPageSize.SelectedIndexChanged
CurrentPage = 1
BindData()
End Sub
Private Sub ctlPagingControl_PageChanged(ByVal sender As System.Object, ByVal e As EventArgs) Handles ctlPagingControl.PageChanged
CurrentPage = ctlPagingControl.CurrentPage
BindData()
End Sub
Private Sub rptComments_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptComments.ItemDataBound
With e.Item
If .ItemType = System.Web.UI.WebControls.ListItemType.Item Or .ItemType = System.Web.UI.WebControls.ListItemType.AlternatingItem Then
If .HasControls Then
If .Controls(0).HasControls Then
Dim litControl As System.Web.UI.LiteralControl = CType(e.Item.Controls(0).Controls(0), System.Web.UI.LiteralControl)
Dim tr As New FeedbackTokenReplace(CType(e.Item.DataItem, FeedbackInfo), Configuration.SharedResources)
tr.AccessingUser = UserController.GetCurrentUserInfo
tr.DebugMessages = Not (PortalSettings.UserMode = Entities.Portals.PortalSettings.Mode.View)
tr.ModuleId = ModuleId
litControl.Text = tr.ReplaceFeedbackTokens(litControl.Text)
End If
End If
End If
End With
End Sub
#End Region
End Class
End Namespace