forked from DNNCommunity/DNN.Feedback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Feedback.ascx.vb
822 lines (708 loc) · 46.3 KB
/
Feedback.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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
'
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2016
' 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 System.Web
Imports DotNetNuke.Security
Namespace DotNetNuke.Modules.Feedback
''' -----------------------------------------------------------------------------
''' <summary>
''' The Feedback Class provides the UI for displaying the Feedback
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/22/2004 Moved Feedback to a separate Project
''' </history>
''' -----------------------------------------------------------------------------
Partial Public Class Feedback
Inherits FeedbackBase
Implements Entities.Modules.IActionable
'Implements Entities.Modules.IPortable
#Region "Private Members"
Private _isAdministrator As Integer = -2
Private _validationGroup As String
Private Enum MessageLevel As Integer
DNNSuccess = 1
DNNInformation
DNNWarning
DNNError
End Enum
#End Region
#Region "Public Properties"
'Uses a tri-state check to avoid repeated calls to IsInRoles
Public ReadOnly Property IsAdministrator() As Boolean
Get
If _isAdministrator = -1 Then
_isAdministrator = CType(Permissions.ModulePermissionController.HasModuleAccess(SecurityAccessLevel.Admin, "", ModuleConfiguration), Integer)
End If
Return CType(_isAdministrator, Boolean)
End Get
End Property
#End Region
#Region "Public Methods"
Public Shadows Function LocalizeString(keyName As String) As String
Return MyBase.LocalizeString(keyName)
End Function
#End Region
#Region "Private Methods"
''' -----------------------------------------------------------------------------
''' <summary>
''' GetUser fills the Email/Name fields if a user is logged in
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/22/2004 Moved Feedback to a separate Project
''' </history>
''' -----------------------------------------------------------------------------
Private Sub GetUser()
If Request.IsAuthenticated AndAlso UserId <> -1 Then
With UserInfo
txtEmail.Text = .Email
txtEmailConfirm.Text = .Email
txtName.Text = .Profile.FullName
txtStreet.Text = .Profile.Street
txtCity.Text = .Profile.City
txtRegion.Text = .Profile.Region
txtCountry.Text = .Profile.Country
txtPostalCode.Text = .Profile.PostalCode
txtTelephone.Text = .Profile.Telephone
End With
Else
txtEmail.Text = ""
txtName.Text = ""
txtStreet.Text = ""
txtCity.Text = ""
txtRegion.Text = ""
txtCountry.Text = ""
txtPostalCode.Text = ""
txtTelephone.Text = ""
End If
End Sub
''' -----------------------------------------------------------------------------
''' <summary>
''' InitializeForm sets the form up
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/22/2004 Moved Feedback to a separate Project
''' </history>
''' -----------------------------------------------------------------------------
Private Sub InitializeForm()
Try
GetUser()
txtSubject2.Text = ""
txtBody.Text = ""
chkCopy.Checked = True
divFeedbackFormContent.Visible = True
_validationGroup = "FeedbackForm_" & ModuleId.ToString
cmdSend.ValidationGroup = _validationGroup
valSummary.ValidationGroup = _validationGroup
SetValidationGroup(Me)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub SetValidationGroup(ByVal parentControl As System.Web.UI.Control)
For Each ctl As System.Web.UI.Control In parentControl.Controls
If TypeOf ctl Is System.Web.UI.WebControls.BaseValidator Then
CType(ctl, System.Web.UI.WebControls.BaseValidator).ValidationGroup = _validationGroup
ElseIf TypeOf ctl Is System.Web.UI.WebControls.CustomValidator Then
CType(ctl, System.Web.UI.WebControls.CustomValidator).ValidationGroup = _validationGroup
ElseIf ctl.HasControls() And ctl.Visible = True Then
SetValidationGroup(ctl)
End If
Next
End Sub
Private Sub SetRequiredVisibility(ByVal div As System.Web.UI.HtmlControls.HtmlGenericControl, _
ByVal ctl As Object, _
ByVal ctlLabel As UserControls.LabelControl, _
ByVal requiredValidator As System.Web.UI.WebControls.RequiredFieldValidator, _
ByVal visibility As Configuration.FieldVisibility)
div.Visible = visibility <> 3
If TypeOf ctl Is System.Web.UI.WebControls.TextBox Then
Dim ctlText As System.Web.UI.WebControls.TextBox = CType(ctl, System.Web.UI.WebControls.TextBox)
If visibility = 1 Then
requiredValidator.Enabled = True
ctlText.Attributes.Add("class", "dnnFormRequired NormalTextBox Feedback_ControlWidth2")
SetSpanVisibility(ctlLabel)
Else
ctlText.Attributes.Add("class", "NormalTextBox Feedback_ControlWidth")
End If
ElseIf TypeOf ctl Is System.Web.UI.WebControls.DropDownList Then
Dim ctlDDL As System.Web.UI.WebControls.DropDownList = CType(ctl, System.Web.UI.WebControls.DropDownList)
If visibility = 1 Then
requiredValidator.Enabled = True
ctlDDL.CssClass = "dnnFormRequired NormalTextBox Feedback_ControlWidth2"
SetSpanVisibility(ctlLabel)
Else
ctlDDL.CssClass = "NormalTextBox Feedback_ControlWidth"
End If
End If
End Sub
Private Sub SetRequiredVisibility2(ByVal div As System.Web.UI.HtmlControls.HtmlGenericControl, _
ByVal ctl As Object, _
ByVal ctlLabel As UserControls.LabelControl, _
ByVal requiredValidator As System.Web.UI.WebControls.RequiredFieldValidator, _
ByVal visibility As Configuration.FieldVisibility2)
div.Visible = visibility <> 2
If TypeOf ctl Is System.Web.UI.WebControls.TextBox Then
Dim ctlText As System.Web.UI.WebControls.TextBox = CType(ctl, System.Web.UI.WebControls.TextBox)
If visibility = 1 Then
requiredValidator.Enabled = True
ctlText.Attributes.Add("class", "dnnFormRequired NormalTextBox Feedback_ControlWidth2")
SetSpanVisibility(ctlLabel)
End If
ElseIf TypeOf ctl Is System.Web.UI.WebControls.DropDownList Then
Dim ctlDDL As System.Web.UI.WebControls.DropDownList = CType(ctl, System.Web.UI.WebControls.DropDownList)
If visibility = 1 Then
requiredValidator.Enabled = True
ctlDDL.CssClass = "dnnFormRequired NormalTextBox Feedback_ControlWidth2"
SetSpanVisibility(ctlLabel)
End If
End If
End Sub
Private Sub SetSpanVisibility(ByVal ctlLabel As UserControls.LabelControl)
ctlLabel.CssClass = "dnnFormRequired"
End Sub
Private Sub ShowMessage(ByVal msg As String, ByVal messageLevel As MessageLevel)
lblMessage.Text = msg
'Hide the rest of the form fields.
InitializeForm()
divFeedbackFormContent.Visible = False
divConfirmation.Visible = True
Select Case messageLevel
Case messageLevel.DNNSuccess
divResponseMessage.Attributes.Add("class", "dnnFormMessage dnnFormSuccess")
Case messageLevel.DNNInformation
divResponseMessage.Attributes.Add("class", "dnnFormMessage dnnFormInfo")
Case messageLevel.DNNWarning
divResponseMessage.Attributes.Add("class", "dnnFormMessage dnnFormWarning")
Case messageLevel.DNNError
divResponseMessage.Attributes.Add("class", "dnnFormMessage dnnFormValidationSummary")
End Select
End Sub
#End Region
#Region "Event Handlers"
''' -----------------------------------------------------------------------------
''' <summary>
''' Page_Load runs when the control is loaded
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/22/2004 Moved Feedback to a separate Project
''' </history>
''' -----------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.Load
Try
'Set validation regular expressions for Postal Code and Telephone fields
If String.IsNullOrEmpty(MyConfiguration.EmailRegex) Then
valEmail2.Enabled = False
Else
valEmail2.ValidationExpression = MyConfiguration.EmailRegex
End If
If String.IsNullOrEmpty(MyConfiguration.PostalCodeRegex) Then
valPostalCode2.Enabled = False
Else
valPostalCode2.ValidationExpression = MyConfiguration.PostalCodeRegex
End If
If String.IsNullOrEmpty(MyConfiguration.TelephoneRegex) Then
valTelephone2.Enabled = False
Else
valTelephone2.ValidationExpression = MyConfiguration.TelephoneRegex
End If
'Show / Hide fields and enable required field validators, set localized AlternateText and Title for required image
If MyConfiguration.SendCopy And Not MyConfiguration.OptOut Then
SetRequiredVisibility(divEmail, txtEmail, CType(plEmail, UserControls.LabelControl), valEmail1, Configuration.FieldVisibility.Required)
Else
SetRequiredVisibility(divEmail, txtEmail, CType(plEmail, UserControls.LabelControl), valEmail1, MyConfiguration.EmailFieldVisibility)
End If
SetRequiredVisibility2(divEmailConfirm, txtEmailConfirm, CType(plEmailConfirm, UserControls.LabelControl), valEmailConfirm, MyConfiguration.EmailConfirmFieldVisibility)
SetRequiredVisibility(divName, txtName, CType(plName, UserControls.LabelControl), valName, MyConfiguration.NameFieldVisibility)
SetRequiredVisibility(divStreet, txtStreet, CType(plStreet, UserControls.LabelControl), valStreet, MyConfiguration.StreetFieldVisibility)
SetRequiredVisibility(divCity, txtCity, CType(plCity, UserControls.LabelControl), valCity, MyConfiguration.CityFieldVisibility)
SetRequiredVisibility(divRegion, txtRegion, CType(plRegion, UserControls.LabelControl), valRegion, MyConfiguration.RegionFieldVisibility)
SetRequiredVisibility(divCountry, txtCountry, CType(plCountry, UserControls.LabelControl), valCountry, MyConfiguration.CountryFieldVisibility)
SetRequiredVisibility(divPostalCode, txtPostalCode, CType(plPostalCode, UserControls.LabelControl), valPostalCode, MyConfiguration.PostalCodeFieldVisibility)
SetRequiredVisibility(divTelephone, txtTelephone, CType(plTelephone, UserControls.LabelControl), valTelephone, MyConfiguration.TelephoneFieldVisibility)
SetRequiredVisibility(divMessage, txtBody, CType(plMessage, UserControls.LabelControl), valMessage, MyConfiguration.MessageFieldVisibility)
If MyConfiguration.CaptchaVisibility = Configuration.CaptchaVisibilities.AllUsers _
OrElse (MyConfiguration.CaptchaVisibility = Configuration.CaptchaVisibilities.AnonymousUsers AndAlso UserId = -1) Then
divCaptcha.Visible = True
ctlCaptcha.ErrorMessage = Localization.GetString("InvalidCaptcha", LocalResourceFile)
ctlCaptcha.CaptchaTextBoxLabel = Localization.GetString("CaptchaText", LocalResourceFile)
ctlCaptcha.CaptchaLinkButtonText = Localization.GetString("RefreshCaptcha", LocalResourceFile)
ctlCaptcha.CaptchaAudioLinkButtonText = Localization.GetString("CaptchaAudioText", LocalResourceFile)
ctlCaptcha.CaptchaImage.EnableCaptchaAudio = MyConfiguration.CaptchaAudio
ctlCaptcha.IgnoreCase = MyConfiguration.CaptchaCase
ctlCaptcha.CaptchaImage.LineNoise = MyConfiguration.CaptchaLineNoise
ctlCaptcha.CaptchaImage.BackgroundNoise = MyConfiguration.CaptchaBackgroundNoise
_validationGroup = "FeedbackForm_" & ModuleId.ToString
ctlCaptcha.ValidationGroup = _validationGroup
Else
divCaptcha.Visible = False
End If
Dim cssClass As String = "dnnForm FeedbackForm dnnClear"
Select Case MyConfiguration.LabelDisplayPosition
Case Configuration.LabelDisplayPositions.AboveField
cssClass = "dnnForm NarrowFeedbackForm dnnClear"
Case Configuration.LabelDisplayPositions.SameLineAsField
cssClass = "dnnForm FeedbackForm dnnClear"
End Select
divFeedbackForm.Attributes.Add("class", cssClass)
divFeedbackForm.Style.Add("width", MyConfiguration.Width.ToString)
If Not Page.IsPostBack Then
InitializeForm()
txtBody.Rows = MyConfiguration.Rows
valMessageLength.ValidationExpression = "^[\s\S]{0," + MyConfiguration.MaxMessage.ToString & "}$"
valMessageLength.Text = String.Format(Localization.GetString("valMessageLength.Error", LocalResourceFile), MyConfiguration.MaxMessage.ToString)
'Bind the categories from the Feedback Lists table
Dim oLists As New FeedbackController
Dim aList As ArrayList = oLists.GetFeedbackList(False, PortalId, -1, FeedbackList.Type.Category, True, ModuleId, False)
With cboCategory
.DataSource = aList
.DataTextField = "Name"
.DataValueField = "ListID"
.DataBind()
End With
Dim category As String = MyConfiguration.Category
' CategoryID is entered via querystring, use that
If HttpContext.Current.Request.QueryString("CategoryID") <> "" And MyConfiguration.CategorySelect Then
Dim tmpCategory As String = HttpContext.Current.Request.QueryString("CategoryID")
Dim selectedCategory As System.Web.UI.WebControls.ListItem = cboCategory.Items.FindByValue(tmpCategory)
If selectedCategory IsNot Nothing Then category = tmpCategory
End If
If MyConfiguration.CategorySelect AndAlso String.IsNullOrEmpty(category) Then
cboCategory.Items.Insert(0, New System.Web.UI.WebControls.ListItem(Localization.GetString("PleaseSelect", Configuration.SharedResources), ""))
cboCategory.SelectedIndex = 0
Else
Dim selectedCategory As System.Web.UI.WebControls.ListItem = cboCategory.Items.FindByValue(category)
If selectedCategory IsNot Nothing Then cboCategory.SelectedValue = category
End If
divCategory.Visible = MyConfiguration.CategorySelect AndAlso (aList.Count > 0)
If divCategory.Visible And MyConfiguration.CategoryRequired Then
SetRequiredVisibility(divCategory, cboCategory, CType(plCategory, UserControls.LabelControl), valCategory, Configuration.FieldVisibility.Required)
End If
Dim subject As String = MyConfiguration.Subject
'Set both rows to false and then show one based on whether the values from the settings are correct.
divSubject.Visible = False
divSubject2.Visible = False
Select Case MyConfiguration.SubjectFieldType
Case Configuration.SubjectFieldTypes.List
Dim subjectList As ArrayList = oLists.GetFeedbackList(False, PortalId, -1, FeedbackList.Type.Subject, True, ModuleId, False)
If subjectList.Count > 0 Then
cboSubject.DataSource = subjectList
cboSubject.DataTextField = "Name"
cboSubject.DataValueField = "ListID"
cboSubject.DataBind()
If String.IsNullOrEmpty(subject) Then
cboSubject.Items.Insert(0, New System.Web.UI.WebControls.ListItem(Localization.GetString("PleaseSelect", Configuration.SharedResources), ""))
cboSubject.SelectedIndex = 0
Else
Dim selectedSubject As System.Web.UI.WebControls.ListItem = cboSubject.Items.FindByValue(subject)
If selectedSubject IsNot Nothing Then cboSubject.SelectedValue = subject
End If
SetRequiredVisibility(divSubject, cboSubject, CType(plSubject, UserControls.LabelControl), valSubject, Configuration.FieldVisibility.Required)
Else
SetRequiredVisibility(divSubject2, txtSubject2, CType(plSubject2, UserControls.LabelControl), valSubject2, Configuration.FieldVisibility.Required)
End If
Case Configuration.SubjectFieldTypes.Textbox
SetRequiredVisibility(divSubject2, txtSubject2, CType(plSubject2, UserControls.LabelControl), valSubject2, Configuration.FieldVisibility.Required)
Case Configuration.SubjectFieldTypes.Hidden
'Hide the subject rows - already set to Visibility=False above
End Select
If Not divCategory.Visible And Not divSubject.Visible And Not divSubject2.Visible And Not divMessage.Visible Then
hContactInfo.Visible = False
hFeedback.Visible = False
End If
'If the administrator has chosen to allow the user to optout then make the trCopy row visible
chkCopy.Checked = MyConfiguration.SendCopy
divCopy.Visible = MyConfiguration.OptOut
End If
txtBody.Attributes.Add("onkeyup", "javascript:showchars('" + txtBody.ClientID + "','" + CharCount.ClientID + "'," + MyConfiguration.MaxMessage.ToString + ")")
CharCount.Text = (MyConfiguration.MaxMessage - txtBody.Text.Length).ToString
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
''' -----------------------------------------------------------------------------
''' <summary>
''' cmdCancel_Click runs when the cancel button is clicked
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/22/2004 Updated to reflect design changes for Help, 508 support
''' and localisation
''' </history>
''' -----------------------------------------------------------------------------
Private Sub cmdCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdCancel.Click
Try
Response.Redirect(NavigateURL(TabId))
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
''' -----------------------------------------------------------------------------
''' <summary>
''' cmdSend_Click runs when the send button is clicked
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/22/2004 Updated to reflect design changes for Help, 508 support
''' and localisation
''' </history>
''' -----------------------------------------------------------------------------
Private Sub cmdSend_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdSend.Click
If Not Page.IsValid Then Exit Sub
If Not divCaptcha.Visible OrElse ctlCaptcha.IsValid Then
Try
Dim objPortalSecurity As New PortalSecurity
Dim objFeedbackController As New FeedbackController()
'Get the senders IP Address and Email Address
Dim remoteAddr As String = objPortalSecurity.InputFilter(Security.ModuleSecurity.GetUserIPAddress(), _
PortalSecurity.FilterFlag.NoScripting Or PortalSecurity.FilterFlag.NoMarkup)
Dim senderEmail As String = objPortalSecurity.InputFilter(txtEmail.Text, _
PortalSecurity.FilterFlag.NoScripting Or PortalSecurity.FilterFlag.NoMarkup)
Dim repeatSubmission As Boolean = False
If MyConfiguration.RepeatSubmissionInteval > 0 Then
'This assumes that the web server time and database time are the same - not always the case, though
Dim repeatWhenAfter As DateTime = DateTime.UtcNow.AddMinutes(-CDbl(MyConfiguration.RepeatSubmissionInteval))
Select Case MyConfiguration.RepeatSubmissionFilter
Case Configuration.RepeatSubmissionFilters.None
' Do nothing as repeatSubmission is False
Case Configuration.RepeatSubmissionFilters.UserID
If UserId > 0 Then
repeatSubmission = objFeedbackController.GetLastSubmissionDateForUserId(PortalId, UserId) > repeatWhenAfter
End If
Case Configuration.RepeatSubmissionFilters.UserIP
If remoteAddr <> "[]" Then
repeatSubmission = objFeedbackController.GetLastSubmissionDateForUserIP(PortalId, remoteAddr) > repeatWhenAfter
End If
Case Configuration.RepeatSubmissionFilters.UserEMail
repeatSubmission = objFeedbackController.GetLastSubmissionDateForUserEmail(PortalId, senderEmail) > repeatWhenAfter
End Select
End If
If repeatSubmission Then
ShowMessage(Localization.GetString("SubmissionTooSoon", LocalResourceFile), MessageLevel.DNNWarning)
Exit Sub
End If
Dim categoryID As String = MyConfiguration.Category
Dim categoryText As String = ""
If (MyConfiguration.CategorySelect AndAlso cboCategory.SelectedValue <> "") Then
categoryID = cboCategory.SelectedItem.Value
categoryText = cboCategory.SelectedItem.Text
ElseIf categoryID <> "" Then
Dim li As System.Web.UI.WebControls.ListItem = cboCategory.Items.FindByValue(categoryID)
If li IsNot Nothing Then categoryText = li.Text
End If
Dim oFeedback As New FeedbackInfo
With oFeedback
.ModuleID = ModuleId
.PortalID = PortalId
.CategoryID = categoryID
'NOTE: v 4.4.3 opened major security hole for HTML injection attack
' by And'ing instead of Or'ing filter flags rendering InputFilter ineffective!
.SenderName = objPortalSecurity.InputFilter(txtName.Text, _
PortalSecurity.FilterFlag.NoScripting Or _
PortalSecurity.FilterFlag.NoMarkup)
.SenderEmail = senderEmail
.SenderStreet = objPortalSecurity.InputFilter(txtStreet.Text, _
PortalSecurity.FilterFlag.NoScripting Or _
PortalSecurity.FilterFlag.NoMarkup)
.SenderCity = objPortalSecurity.InputFilter(txtCity.Text, _
PortalSecurity.FilterFlag.NoScripting Or _
PortalSecurity.FilterFlag.NoMarkup)
.SenderRegion = objPortalSecurity.InputFilter(txtRegion.Text, _
PortalSecurity.FilterFlag.NoScripting Or _
PortalSecurity.FilterFlag.NoMarkup)
.SenderCountry = objPortalSecurity.InputFilter(txtCountry.Text, _
PortalSecurity.FilterFlag.NoScripting Or _
PortalSecurity.FilterFlag.NoMarkup)
.SenderPostalCode = objPortalSecurity.InputFilter(txtPostalCode.Text, _
PortalSecurity.FilterFlag.NoScripting Or _
PortalSecurity.FilterFlag.NoMarkup)
.SenderTelephone = objPortalSecurity.InputFilter(txtTelephone.Text, _
PortalSecurity.FilterFlag.NoScripting Or _
PortalSecurity.FilterFlag.NoMarkup)
.SenderRemoteAddr = remoteAddr
End With
Const allowHTML As Boolean = False
Dim filterFlags As PortalSecurity.FilterFlag = PortalSecurity.FilterFlag.NoScripting
If Not allowHTML Then
filterFlags = filterFlags Or PortalSecurity.FilterFlag.NoMarkup
End If
Dim msgText As String = ""
If MyConfiguration.MessageFieldVisibility = Configuration.FieldVisibility.Required Or Not txtBody.Text Is Nothing Then
msgText = objPortalSecurity.InputFilter(txtBody.Text, filterFlags)
End If
oFeedback.Message = msgText
'Check whether we're getting the subject from the dropdownlist or the text box.
If divSubject.Visible Then
'grab it from the drop down list.
If cboSubject.SelectedValue = "" Then
oFeedback.Subject = ""
Else
oFeedback.Subject = cboSubject.SelectedItem.Text
End If
ElseIf divSubject2.Visible Then
'grab it from the text box.
oFeedback.Subject = objPortalSecurity.InputFilter(txtSubject2.Text, _
PortalSecurity.FilterFlag.NoScripting Or _
PortalSecurity.FilterFlag.NoMarkup)
Else
'The admin might have chosen a subject but not made it visible.
If Not String.IsNullOrEmpty(MyConfiguration.Subject) Then
If IsNumeric(MyConfiguration.Subject) Then
'Grab the subject value and not the id.
Dim arryFeedbackItem As ArrayList = objFeedbackController.GetFeedbackList(True, PortalId, Convert.ToInt32(MyConfiguration.Subject), FeedbackList.Type.Subject, False, ModuleId, False)
If (arryFeedbackItem.Count > 0) Then
Dim objFeedbackSubjectItem As FeedbackList = CType(arryFeedbackItem(0), FeedbackList)
oFeedback.Subject = objFeedbackSubjectItem.Name
End If
Else
oFeedback.Subject = MyConfiguration.Subject
End If
Else
oFeedback.Subject = String.Empty
End If
End If
'If the Module is moderated and the category is one that is to be moderated then flag it appropriately
'other wise it will have StatusPublic and may appear immediately in the guest book.
Dim blModerated As Boolean = False
Dim status As FeedbackInfo.FeedbackStatusType = MyConfiguration.UnmoderatedStatus
If MyConfiguration.Moderated Then
' ReSharper disable LoopCanBeConvertedToQuery
For Each moderatedCategory As String In MyConfiguration.ModeratedCategories.Split(";"c)
' ReSharper restore LoopCanBeConvertedToQuery
If categoryID.Equals(moderatedCategory.Trim(), StringComparison.InvariantCultureIgnoreCase) Then
blModerated = True
status = FeedbackInfo.FeedbackStatusType.StatusPending
Exit For
End If
Next
End If
oFeedback.Referrer = Request.UserAgent
oFeedback.UserAgent = Request.UrlReferrer.ToString
oFeedback.Status = status
'Akisemet spam check if required
If MyConfiguration.AkismetEnable Then
Dim akismetApi As New Akismet(MyConfiguration.AkismetKey, NavigateURL())
If akismetApi.VerifyKey() Then
Dim comment As AkismetComment = akismetApi.CreateComment(oFeedback)
If akismetApi.CommentCheck(comment) Then
oFeedback.Status = FeedbackInfo.FeedbackStatusType.StatusSpam
End If
End If
End If
'Now we try to save the feedback in the feedback table.
'If the status is pending then send an email to the Administrator asking him to log in and
'approve the message. In all other cases send the email directly to user if requested.
Try
'Only do this if there is an email address that the user has entered - this is to prevent
'users from clicking on the Send button repeatedly.
If senderEmail <> "" Or MyConfiguration.EmailFieldVisibility <> Configuration.FieldVisibility.Required Then
' Admin has option of not saving unmoderated feedback categories to the database - only send emails in such case
If status <> FeedbackInfo.FeedbackStatusType.StatusDelete Then
' Check to see if this is a duplicate submission if required before saving
If MyConfiguration.DuplicateSubmission Then
If Not objFeedbackController.GetDuplicateSubmissionForUserEmail(PortalId, senderEmail, oFeedback.Message) = Nothing Then
ShowMessage(Localization.GetString("DuplicateSubmission", LocalResourceFile), MessageLevel.DNNWarning)
Exit Sub
End If
End If
' If email only, feedback is added to DB then deleted by scheduled process
If MyConfiguration.EmailOnly Then
oFeedback.Status = FeedbackInfo.FeedbackStatusType.StatusDelete
End If
objFeedbackController.CreateFeedback(oFeedback, UserId)
End If
'If sendCopy is checked then assume that we have to send a copy to the user.
'If the user opts out then don't send.
'Create a copy of the email object
Dim objFeedbackEmail As New FeedbackEmail
Dim sendFromEmail As String
If String.IsNullOrEmpty(MyConfiguration.SendFrom) Then
sendFromEmail = PortalSettings.Email
Else
sendFromEmail = MyConfiguration.SendFrom
End If
objFeedbackEmail.SendFromEmail = sendFromEmail
objFeedbackEmail.SendToEmail = senderEmail
Dim emailSubject As String
If String.IsNullOrEmpty(oFeedback.Subject) Then
emailSubject = ModuleConfiguration.ModuleTitle
Else
emailSubject = oFeedback.Subject
End If
objFeedbackEmail.Subject = emailSubject
objFeedbackEmail.Message = oFeedback.Message
Dim errorMsg As String = String.Empty
Try
If MyConfiguration.SendCopy Then
'Check whether the user has checked or unchecked the option.
If chkCopy.Checked OrElse Not MyConfiguration.OptOut Then
'User wants a copy of the feedback that was just submitted - Send it as an email from the site to the user.
If MyConfiguration.SendAsync Then
Dim objThread As New Threading.Thread(AddressOf objFeedbackEmail.SendEmail)
objThread.Start()
Else
errorMsg = objFeedbackEmail.SendEmail()
End If
End If
Else
'the admin may have chosen not to choose sendcopy but due to optout the chkCopy is visible
If MyConfiguration.OptOut And chkCopy.Checked Then
'User wants a copy of the feedback that was just submitted. - Send it as an email from the site to the user.
If MyConfiguration.SendAsync Then
Dim objThread As New Threading.Thread(AddressOf objFeedbackEmail.SendEmail)
objThread.Start()
Else
errorMsg = objFeedbackEmail.SendEmail()
End If
End If
End If
Catch ex As Exception
errorMsg &= ex.Message
End Try
'Send a copy of the feedback to whatever addresses are in the SendTo or users in roles in SendToRole
If MyConfiguration.SendWhenPublished And blModerated _
And (oFeedback.Status = FeedbackInfo.FeedbackStatusType.StatusPending Or oFeedback.Status = FeedbackInfo.FeedbackStatusType.StatusSpam) Then
'do nothing
Else
Dim objFeedbackUpdateController As New FeedbackUpdateController(ModuleId, MyConfiguration, PortalSettings, LocalResourceFile, UserId)
objFeedbackEmail = New FeedbackEmail
objFeedbackEmail.ReplyToEmail = senderEmail
objFeedbackEmail.SendFromEmail = objFeedbackUpdateController.GetSendFromEmail(senderEmail)
Dim objFeedbackCategoryItem As FeedbackList = objFeedbackUpdateController.GetCategory(categoryID)
objFeedbackEmail.SendToEmail = objFeedbackUpdateController.GetSendToEmail(objFeedbackCategoryItem.ListValue)
objFeedbackEmail.SendToRoles = MyConfiguration.SendToRoles
objFeedbackEmail.Subject = emailSubject
objFeedbackEmail.Message = objFeedbackUpdateController.CreateMsg(oFeedback, categoryText)
Try
If MyConfiguration.SendAsync Then
Dim objThread As New Threading.Thread(AddressOf objFeedbackEmail.SendEmail)
objThread.Start()
Else
errorMsg &= objFeedbackEmail.SendEmail()
End If
Catch ex As Exception
errorMsg &= ex.Message
End Try
End If
'Send a message to those in roles having moderate permissions if this is a moderated Feedback Module and there are posts that need to be moderated.
If oFeedback.Status = FeedbackInfo.FeedbackStatusType.StatusPending _
Or (oFeedback.Status = FeedbackInfo.FeedbackStatusType.StatusSpam And MyConfiguration.AkismetSendModerator) _
Or (oFeedback.Status = FeedbackInfo.FeedbackStatusType.StatusSpam And blModerated) Then
Dim moderationLink As String = "<a href='" & NavigateURL(TabId, "Moderation", "mid=" & ModuleId.ToString) & "'>" & Localization.GetString("Moderate", LocalResourceFile) & "</a>"
Dim moderationMessage As String
If oFeedback.Status = FeedbackInfo.FeedbackStatusType.StatusPending Then
moderationMessage = String.Format(Localization.GetString("MessagePending", LocalResourceFile), PortalSettings.PortalName, moderationLink)
Else
moderationMessage = String.Format(Localization.GetString("MessageSpam", LocalResourceFile), PortalSettings.PortalName, moderationLink)
End If
Dim sendToRoles As String = Security.ModuleSecurity.ModeratorRoles(ModuleConfiguration.ModulePermissions)
If Not MyConfiguration.ModerationEmailsToAdmins Then
sendToRoles = sendToRoles.Replace(PortalSettings.AdministratorRoleName & ";", "")
End If
If Right(sendToRoles, 1) = ";" Then
sendToRoles = Left(sendToRoles, Len(sendToRoles) - 1)
End If
Try
Dim contextkey As String
Dim objNotification As New Components.Integration.Notifications
contextkey = objNotification.SendFeedbackModerationNotification(sendToRoles.Split(";"c), PortalSettings.AdministratorId, emailSubject, moderationMessage, PortalId, TabId, ModuleId, oFeedback.FeedbackID)
objFeedbackController.UpdateContextKey(ModuleId, oFeedback.FeedbackID, contextkey, UserId)
Catch ex As Exception
errorMsg &= ex.Message
End Try
End If
If MyConfiguration.RedirectTabOnSubmission <> -1 Then
Response.Redirect(NavigateURL(MyConfiguration.RedirectTabOnSubmission), True)
Else
If errorMsg.Length > 0 Then
'Only show detailed email send error messages when Admin user is testing
If Not IsAdministrator Then
errorMsg = String.Empty
End If
ShowMessage(Localization.GetString("SendMessageError", LocalResourceFile) & errorMsg, MessageLevel.DNNError)
Else
If oFeedback.Status <> FeedbackInfo.FeedbackStatusType.StatusSpam Then
ShowMessage(Localization.GetString("MessageSent", LocalResourceFile), MessageLevel.DNNSuccess)
Else
ShowMessage(Localization.GetString("SendMessageSpam", LocalResourceFile), MessageLevel.DNNWarning)
End If
End If
End If
End If
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End If
End Sub
Private Sub valCopy_ServerValidate(source As Object, args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles valCopy.ServerValidate
If MyConfiguration.SendCopy And MyConfiguration.OptOut And chkCopy.Checked And txtEmail.Text = "" Then
args.IsValid = False
End If
End Sub
#End Region
#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()
' base module properties
HelpURL = "http://www.dotnetnuke.com/" & glbDefaultPage & "?tabid=787"
End Sub
#End Region
#Region "Optional Interfaces"
Public ReadOnly Property ModuleActions() As Entities.Modules.Actions.ModuleActionCollection Implements Entities.Modules.IActionable.ModuleActions
Get
' ReSharper disable InconsistentNaming
' ReSharper disable LocalVariableHidesMember
Dim Actions As New Entities.Modules.Actions.ModuleActionCollection
' ReSharper restore LocalVariableHidesMember
' ReSharper restore InconsistentNaming
Dim modSecurity As New Security.ModuleSecurity(ModuleId, TabId)
'check whether we have permission to moderate posts.
Try
If modSecurity.IsAllowedToModeratePosts Then 'user is allowed to moderate posts
Actions.Add(GetNextActionID, Localization.GetString("MenuModeration", LocalResourceFile), Entities.Modules.Actions.ModuleActionType.ContentOptions, "", "", EditUrl("", "", "Moderation"), False, SecurityAccessLevel.View, True, False)
End If
If modSecurity.IsAllowedToManageLists Then
Actions.Add(GetNextActionID, Localization.GetString("MenuEditLists", LocalResourceFile), Entities.Modules.Actions.ModuleActionType.EditContent, "", "", EditUrl("", "", "EditLists"), False, SecurityAccessLevel.View, True, False)
End If
Catch
' This try/catch is to avoid loosing control about your current Feedback module
End Try
Return Actions
End Get
End Property
#End Region
End Class
End Namespace