-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditFeedback.ascx.vb
executable file
·2045 lines (1599 loc) · 118 KB
/
EditFeedback.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
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'
' Feedback Center for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2002-2005
' by Scott McCulloch ( [email protected] ) ( http://www.smcculloch.net )
'
Imports System.IO
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports DotNetNuke
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Users
Imports DotNetNuke.Security
Imports DotNetNuke.Security.Roles
Imports DotNetNuke.Services.Localization
Imports Ventrian.FeedbackCenter.Entities
Imports Ventrian.FeedbackCenter.Entities.CustomFields
Imports DotNetNuke.UI.UserControls
Imports Ventrian.FeedbackCenter.Entities.Emails
Imports Ventrian.FeedbackCenter.Entities.Layout
Namespace Ventrian.FeedbackCenter
Partial Public Class EditFeedback
Inherits FeedbackCenterBase
#Region " Private Members "
Private _feedbackID As Integer = Null.NullInteger
Private _productID As Integer = Null.NullInteger
Private _richTextValues As New NameValueCollection
#End Region
#Region " Private Methods "
Private Sub BindCustomFields()
Dim objCustomFieldController As New CustomFieldController()
Dim objCustomFields As ArrayList = objCustomFieldController.List(Me.ModuleId)
If (objCustomFields.Count = 0) Then
rptCustomFields.Visible = False
Else
rptCustomFields.DataSource = objCustomFields
rptCustomFields.DataBind()
End If
End Sub
Private Sub CheckSecurity()
If (Settings.Contains(Constants.PERMISSION_SUBMIT_SETTING)) Then
If (PortalSecurity.IsInRoles(FeedbackSettings.PermissionSubmit) = False) Then
If (FeedbackSettings.PermissionSubmit.ToLower().Contains(glbRoleUnauthUserName.ToLower()) = False) Then
Response.Redirect(NavigateURL(Me.TabId, "", "fbType=NotAuthorized"), True)
End If
End If
Else
If (Request.IsAuthenticated = False) Then
Response.Redirect(NavigateURL(Me.TabId, "", "fbType=NotAuthorized"), True)
End If
End If
End Sub
Private Sub ReadQueryString()
If Not (Request("FeedbackID") Is Nothing) Then
_feedbackID = Convert.ToInt32(Request("FeedbackID"))
End If
If Not (Request("ProductID") Is Nothing) Then
_productID = Convert.ToInt32(Request("ProductID"))
End If
End Sub
Private Sub SetVisibility()
trStatus.Visible = HasEditPermissions()
trImplemented.Visible = HasEditPermissions()
trCaptcha.Visible = FeedbackSettings.EnableCaptcha
If (_feedbackID <> Null.NullInteger) Then
trCaptcha.Visible = False
End If
cmdEditProducts.Visible = HasEditPermissions()
End Sub
Private Sub BindTypes()
Dim objTypeController As New TypeController
lstTypes.DataSource = objTypeController.List()
lstTypes.DataBind()
If (lstTypes.Items.Count > 0) Then
lstTypes.Items(0).Selected = True
End If
End Sub
Private Sub BindProducts(ByRef drpProductsList As DropDownList)
Dim objProductController As New ProductController
Dim objProducts As ArrayList = objProductController.ListAll(Me.ModuleId)
Dim objProductsToSelect As New ArrayList
For Each objProduct As ProductInfo In objProducts
If (objProduct.InheritSecurity) Then
objProductsToSelect.Add(objProduct)
Else
If (Settings.Contains(objProduct.ProductID.ToString() & "-" & Constants.PERMISSION_CATEGORY_SUBMIT_SETTING)) Then
If (PortalSecurity.IsInRoles(Settings(objProduct.ProductID.ToString() & "-" & Constants.PERMISSION_CATEGORY_SUBMIT_SETTING).ToString())) Then
objProductsToSelect.Add(objProduct)
End If
End If
End If
Next
drpProductsList.DataSource = objProductsToSelect
drpProductsList.DataBind()
If (_productID <> Null.NullInteger) Then
If Not (drpProducts.Items.FindByValue(_productID.ToString) Is Nothing) Then
drpProductsList.SelectedValue = _productID.ToString
End If
Else
If (drpProductsList.Items.Count = 1) Then
drpProductsList.SelectedIndex = 0
End If
End If
drpProductsList.Items.Insert(0, New ListItem(Localization.GetString("AllProducts", LocalResourceFile), Null.NullInteger.ToString()))
End Sub
Private Sub BindFeedback()
If (IsEditable Or PortalSecurity.IsInRoles(FeedbackSettings.PermissionApprove)) Then
trIsApproved.Visible = True
Else
trIsApproved.Visible = False
End If
If (_feedbackID = Null.NullInteger) Then
If (Settings.Contains(Constants.PERMISSION_AUTO_APPROVE_SETTING)) Then
If (IsEditable Or PortalSecurity.IsInRoles(FeedbackSettings.PermissionApprove) Or PortalSecurity.IsInRoles(FeedbackSettings.PermissionAutoApprove)) Then
chkIsApproved.Checked = True
Else
If (FeedbackSettings.PermissionAutoApprove.ToLower().Contains(glbRoleUnauthUserName.ToLower()) = False) Then
chkIsApproved.Checked = False
Else
chkIsApproved.Checked = True
End If
End If
Else
' Auto-Approve
chkIsApproved.Checked = True
End If
phUser.Visible = Not Request.IsAuthenticated
cmdDelete.Visible = False
cmdUpdate.Text = Localization.GetString("Submit", LocalResourceFile)
Else
cmdDelete.Visible = True
cmdDelete.Attributes.Add("onClick", "javascript:return confirm('Are You Sure You Wish To Delete This Item ?');")
cmdUpdate.Text = Localization.GetString("cmdUpdate")
Dim objFeedbackController As New FeedbackController
Dim objFeedback As FeedbackInfo = objFeedbackController.Get(_feedbackID)
If Not (objFeedback Is Nothing) Then
If (IsEditable = False) Then
If (PortalSecurity.IsInRoles(FeedbackSettings.PermissionApprove) = False) Then
If (FeedbackSettings.PermissionApprove.ToLower().Contains(glbRoleUnauthUserName.ToLower()) = False) Then
Response.Redirect(NavigateURL(Me.TabId, "", "fbType=NotAuthorized"), True)
End If
End If
End If
If (objFeedback.UserID = Null.NullInteger) Then
phUser.Visible = True
End If
If Not (lstTypes.Items.FindByValue(objFeedback.TypeID) Is Nothing) Then
lstTypes.Items.FindByValue(objFeedback.TypeID).Selected = True
End If
If Not (drpProducts.Items.FindByValue(objFeedback.ProductID) Is Nothing) Then
drpProducts.Items.FindByValue(objFeedback.ProductID).Selected = True
End If
txtTitle.Text = objFeedback.Title
txtDescription.Text = objFeedback.Details.Replace("<br />", vbCrLf)
txtDescription.Text = objFeedback.Details.Replace("<br>", vbCrLf)
If (objFeedback.IsClosed) Then
lstStatus.SelectedValue = "Closed"
Else
lstStatus.SelectedValue = "Open"
End If
chkImplemented.Checked = objFeedback.IsResolved
chkIsApproved.Checked = objFeedback.IsApproved
txtName.Text = objFeedback.AnonymousName
txtEmail.Text = objFeedback.AnonymousEmail
txtURL.Text = objFeedback.AnonymousUrl
End If
End If
End Sub
Private Function FormatEmail(ByVal template As String, ByVal link As String, ByVal objFeedback As FeedbackInfo) As String
Dim formatted As String = template
formatted = formatted.Replace("[PORTALNAME]", PortalSettings.PortalName)
formatted = formatted.Replace("[POSTDATE]", DateTime.Now.ToShortDateString & " " & DateTime.Now.ToShortTimeString)
formatted = formatted.Replace("[TITLE]", objFeedback.Title)
formatted = formatted.Replace("[LINK]", link)
Return formatted
End Function
Private Function GetApproverDistributionList() As String
Dim distributionList As String = ""
If (Settings.Contains(Constants.PERMISSION_APPROVE_SETTING)) Then
Dim roles As String = Settings(Constants.PERMISSION_APPROVE_SETTING).ToString()
Dim rolesArray() As String = roles.Split(Convert.ToChar(";"))
Dim userList As Hashtable = New Hashtable
For Each role As String In rolesArray
If (role.Length > 0) Then
Dim objRoleController As RoleController = New RoleController
Dim objRole As RoleInfo = objRoleController.GetRoleByName(PortalId, role)
If Not (objRole Is Nothing) Then
Dim objUsers As ArrayList = objRoleController.GetUserRolesByRoleName(PortalId, objRole.RoleName)
For Each objUser As UserRoleInfo In objUsers
Dim objUserController As UserController = New UserController
Dim objSelectedUser As UserInfo = objUserController.GetUser(PortalId, objUser.UserID)
If Not (objSelectedUser Is Nothing) Then
If (objSelectedUser.Membership.Email.Length > 0) Then
If (userList.Contains(objSelectedUser.Membership.Email) = False) Then
userList.Add(objSelectedUser.Membership.Email, objSelectedUser.Membership.Email)
End If
End If
End If
Next
End If
End If
Next
For Each email As DictionaryEntry In userList
If (distributionList.Length > 0) Then
distributionList += ";"
End If
distributionList += email.Value.ToString()
Next
Else
distributionList = PortalSettings.Email
End If
Return distributionList
End Function
Private Sub BindCrumbs()
Dim crumbs As New ArrayList
Dim crumbAllAlbums As New CrumbInfo
crumbAllAlbums.Caption = Localization.GetString("AllFeedback", LocalResourceFile)
crumbAllAlbums.Url = NavigateURL()
crumbs.Add(crumbAllAlbums)
Dim currentCrumb As New CrumbInfo
If (_feedbackID = Null.NullInteger) Then
currentCrumb.Caption = Localization.GetString("AddNewFeedback", LocalResourceFile)
Else
currentCrumb.Caption = Localization.GetString("EditFeedback", LocalResourceFile)
End If
currentCrumb.Url = Request.Url.ToString()
crumbs.Add(currentCrumb)
rptBreadCrumbs.DataSource = crumbs
rptBreadCrumbs.DataBind()
End Sub
'set focus to any control
Public Sub SetFormFocus(ByVal control As Control)
Page.SetFocus(control)
End Sub
Private Sub LocalizeTitles()
If (lstStatus.Items.Count = 2) Then
lstStatus.Items(0).Text = Localization.GetString("Open", LocalResourceFile)
lstStatus.Items(1).Text = Localization.GetString("Closed", LocalResourceFile)
End If
End Sub
Private Sub GetCookie()
If (Request.IsAuthenticated = False) Then
Dim cookie As HttpCookie = Request.Cookies("comment")
If (cookie IsNot Nothing) Then
txtName.Text = cookie.Values("name")
txtEmail.Text = cookie.Values("email")
txtURL.Text = cookie.Values("url")
End If
End If
End Sub
Private Sub SetCookie()
If (Request.IsAuthenticated = False) Then
Dim objCookie As New HttpCookie("comment")
objCookie.Expires = DateTime.Now.AddMonths(24)
objCookie.Values.Add("name", txtName.Text)
objCookie.Values.Add("email", txtEmail.Text)
objCookie.Values.Add("url", txtURL.Text)
Response.Cookies.Add(objCookie)
End If
End Sub
Private Sub SaveCustomFields(ByVal feedbackID As Integer)
Dim fieldsToUpdate As New Hashtable
Dim objCustomFieldController As New CustomFieldController()
Dim objCustomFields As ArrayList = objCustomFieldController.List(Me.ModuleId)
If (phForm.Visible) Then
If (rptCustomFields.Visible) Then
For Each item As RepeaterItem In rptCustomFields.Items
Dim phValue As PlaceHolder = CType(item.FindControl("phValue"), PlaceHolder)
If Not (phValue Is Nothing) Then
If (phValue.Controls.Count > 0) Then
Dim objControl As System.Web.UI.Control = phValue.Controls(0)
Dim customFieldID As Integer = Convert.ToInt32(objControl.ID)
For Each objCustomField As CustomFieldInfo In objCustomFields
If (objCustomField.CustomFieldID = customFieldID) Then
Select Case objCustomField.FieldType
Case CustomFieldType.OneLineTextBox
Dim objTextBox As TextBox = CType(objControl, TextBox)
fieldsToUpdate.Add(customFieldID.ToString(), objTextBox.Text)
Case CustomFieldType.MultiLineTextBox
Dim objTextBox As TextBox = CType(objControl, TextBox)
fieldsToUpdate.Add(customFieldID.ToString(), objTextBox.Text)
Case CustomFieldType.RichTextBox
Dim objTextBox As TextEditor = CType(objControl, TextEditor)
fieldsToUpdate.Add(customFieldID.ToString(), objTextBox.Text)
Case CustomFieldType.DropDownList
Dim objDropDownList As DropDownList = CType(objControl, DropDownList)
If (objDropDownList.SelectedValue = "-1") Then
fieldsToUpdate.Add(customFieldID.ToString(), "")
Else
fieldsToUpdate.Add(customFieldID.ToString(), objDropDownList.SelectedValue)
End If
Case CustomFieldType.CheckBox
Dim objCheckBox As CheckBox = CType(objControl, CheckBox)
fieldsToUpdate.Add(customFieldID.ToString(), objCheckBox.Checked.ToString())
Case CustomFieldType.MultiCheckBox
Dim objCheckBoxList As CheckBoxList = CType(objControl, CheckBoxList)
Dim values As String = ""
For Each objCheckBox As ListItem In objCheckBoxList.Items
If (objCheckBox.Selected) Then
If (values = "") Then
values = objCheckBox.Value
Else
values = values & "|" & objCheckBox.Value
End If
End If
Next
fieldsToUpdate.Add(customFieldID.ToString(), values)
Case CustomFieldType.RadioButton
Dim objRadioButtonList As RadioButtonList = CType(objControl, RadioButtonList)
fieldsToUpdate.Add(customFieldID.ToString(), objRadioButtonList.SelectedValue)
Case CustomFieldType.FileUpload
Dim objFileUpload As HtmlInputFile = CType(objControl, HtmlInputFile)
If Not (objFileUpload.PostedFile Is Nothing) Then
' Delete old one
Dim objPropertyValueController As New CustomValueController
Dim objPropertyValue As CustomValueInfo = objPropertyValueController.GetByCustomField(feedbackID, Convert.ToInt32(customFieldID.ToString()))
If Not (objPropertyValue Is Nothing) Then
Dim fileToDelete = PortalSettings.HomeDirectoryMapPath & objPropertyValue.CustomValue
If (File.Exists(fileToDelete)) Then
File.Delete(fileToDelete)
End If
objPropertyValueController.Delete(feedbackID, objPropertyValue.CustomValueID)
End If
If (objFileUpload.PostedFile.ContentLength > 0) Then
' Upload new one
Dim filePath As String = PortalSettings.HomeDirectoryMapPath & "FeedbackCenter\" & ModuleId.ToString() & "\Files\" & feedbackID.ToString() & "\"
Dim fileName As String = Path.GetFileName(objFileUpload.PostedFile.FileName)
Dim relativePath As String = "FeedbackCenter\" & ModuleId.ToString() & "\Files\" & feedbackID.ToString() & "\" & fileName
If (Directory.Exists(filePath) = False) Then
Directory.CreateDirectory(filePath)
End If
objFileUpload.PostedFile.SaveAs(filePath & fileName)
fieldsToUpdate.Add(customFieldID.ToString(), relativePath)
End If
End If
End Select
Exit For
End If
Next
End If
End If
Next
End If
Else
For Each objControl As Control In phFormTemplate.Controls
If (IsNumeric(objControl.ID)) Then
Dim customFieldID As Integer = Convert.ToInt32(objControl.ID)
For Each objCustomField As CustomFieldInfo In objCustomFields
If (objCustomField.CustomFieldID = customFieldID) Then
Select Case objCustomField.FieldType
Case CustomFieldType.OneLineTextBox
Dim objTextBox As TextBox = CType(objControl, TextBox)
fieldsToUpdate.Add(customFieldID.ToString(), objTextBox.Text)
Case CustomFieldType.MultiLineTextBox
Dim objTextBox As TextBox = CType(objControl, TextBox)
fieldsToUpdate.Add(customFieldID.ToString(), objTextBox.Text)
Case CustomFieldType.RichTextBox
Dim objTextBox As TextEditor = CType(objControl, TextEditor)
fieldsToUpdate.Add(customFieldID.ToString(), objTextBox.Text)
Case CustomFieldType.DropDownList
Dim objDropDownList As DropDownList = CType(objControl, DropDownList)
If (objDropDownList.SelectedValue = "-1") Then
fieldsToUpdate.Add(customFieldID.ToString(), "")
Else
fieldsToUpdate.Add(customFieldID.ToString(), objDropDownList.SelectedValue)
End If
Case CustomFieldType.CheckBox
Dim objCheckBox As CheckBox = CType(objControl, CheckBox)
fieldsToUpdate.Add(customFieldID.ToString(), objCheckBox.Checked.ToString())
Case CustomFieldType.MultiCheckBox
Dim objCheckBoxList As CheckBoxList = CType(objControl, CheckBoxList)
Dim values As String = ""
For Each objCheckBox As ListItem In objCheckBoxList.Items
If (objCheckBox.Selected) Then
If (values = "") Then
values = objCheckBox.Value
Else
values = values & "|" & objCheckBox.Value
End If
End If
Next
fieldsToUpdate.Add(customFieldID.ToString(), values)
Case CustomFieldType.RadioButton
Dim objRadioButtonList As RadioButtonList = CType(objControl, RadioButtonList)
fieldsToUpdate.Add(customFieldID.ToString(), objRadioButtonList.SelectedValue)
Case CustomFieldType.FileUpload
Dim objFileUpload As HtmlInputFile = CType(objControl, HtmlInputFile)
If Not (objFileUpload.PostedFile Is Nothing) Then
' Delete old one
Dim objPropertyValueController As New CustomValueController
Dim objPropertyValue As CustomValueInfo = objPropertyValueController.GetByCustomField(feedbackID, Convert.ToInt32(customFieldID.ToString()))
If Not (objPropertyValue Is Nothing) Then
Dim fileToDelete = PortalSettings.HomeDirectoryMapPath & objPropertyValue.CustomValue
If (File.Exists(fileToDelete)) Then
File.Delete(fileToDelete)
End If
objPropertyValueController.Delete(feedbackID, objPropertyValue.CustomValueID)
End If
If (objFileUpload.PostedFile.ContentLength > 0) Then
' Upload new one
Dim filePath As String = PortalSettings.HomeDirectoryMapPath & "FeedbackCenter\" & ModuleId.ToString() & "\Files\" & feedbackID.ToString() & "\"
Dim fileName As String = Path.GetFileName(objFileUpload.PostedFile.FileName)
Dim relativePath As String = "FeedbackCenter\" & ModuleId.ToString() & "\Files\" & feedbackID.ToString() & "\" & fileName
If (Directory.Exists(filePath) = False) Then
Directory.CreateDirectory(filePath)
End If
objFileUpload.PostedFile.SaveAs(filePath & fileName)
fieldsToUpdate.Add(customFieldID.ToString(), relativePath)
End If
End If
End Select
Exit For
End If
Next
End If
Next
End If
For Each key As String In fieldsToUpdate.Keys
Dim val As String = fieldsToUpdate(key).ToString()
Dim objCustomValueController As New CustomValueController
Dim objCustomValue As CustomValueInfo = objCustomValueController.GetByCustomField(feedbackID, Convert.ToInt32(key))
If (objCustomValue IsNot Nothing) Then
objCustomValueController.Delete(feedbackID, Convert.ToInt32(key))
End If
objCustomValue = New CustomValueInfo
objCustomValue.CustomFieldID = Convert.ToInt32(key)
objCustomValue.CustomValue = val
objCustomValue.FeedbackID = feedbackID
objCustomValueController.Add(objCustomValue)
Next
End Sub
Protected Sub ProcessEdiTemplate(ByRef controls As ControlCollection, ByVal layoutArray As String())
Dim objFeedback As FeedbackInfo
Dim objFeedbackController As New FeedbackController()
objFeedback = objFeedbackController.Get(_feedbackID)
Dim objCustomFieldController As New CustomFieldController()
Dim objCustomFields As ArrayList = objCustomFieldController.List(Me.ModuleId)
For iPtr As Integer = 0 To layoutArray.Length - 1 Step 2
controls.Add(New LiteralControl(layoutArray(iPtr).ToString()))
If iPtr < layoutArray.Length - 1 Then
Select Case layoutArray(iPtr + 1)
Case "APPROVED"
Dim objApproved As New CheckBox
objApproved.EnableViewState = False
objApproved.ID = "Approved"
If (Settings.Contains(Constants.PERMISSION_AUTO_APPROVE_SETTING)) Then
If (IsEditable Or PortalSecurity.IsInRoles(FeedbackSettings.PermissionApprove) Or PortalSecurity.IsInRoles(FeedbackSettings.PermissionAutoApprove)) Then
objApproved.Checked = True
Else
If (FeedbackSettings.PermissionAutoApprove.ToLower().Contains(glbRoleUnauthUserName.ToLower()) = False) Then
objApproved.Checked = False
Else
objApproved.Checked = True
End If
End If
Else
' Auto-Approve
objApproved.Checked = True
End If
If (IsEditable Or PortalSecurity.IsInRoles(FeedbackSettings.PermissionApprove)) Then
objApproved.Visible = True
Else
objApproved.Visible = False
End If
If (objFeedback IsNot Nothing) Then
objApproved.Checked = objFeedback.IsApproved
End If
controls.Add(objApproved)
Case "DESCRIPTION"
Dim objDescription As New TextBox
objDescription.EnableViewState = False
objDescription.ID = "Description"
objDescription.CssClass = "NormalTextBox"
objDescription.TextMode = TextBoxMode.MultiLine
objDescription.Rows = 10
If (objFeedback IsNot Nothing) Then
objDescription.Text = objFeedback.Details
End If
controls.Add(objDescription)
Dim objRequired As New RequiredFieldValidator
objRequired.CssClass = "NormalRed"
objRequired.ErrorMessage = Localization.GetString("valDescription.ErrorMessage", Me.LocalResourceFile)
objRequired.ControlToValidate = objDescription.ID
objRequired.Display = ValidatorDisplay.Dynamic
controls.Add(objRequired)
Case "EMAIL"
If (Request.IsAuthenticated = False) Then
Dim objEmail As New TextBox
objEmail.EnableViewState = False
objEmail.ID = "Email"
objEmail.CssClass = "NormalTextBox"
If (objFeedback IsNot Nothing) Then
objEmail.Text = objFeedback.Details
End If
controls.Add(objEmail)
Dim objRequired As New RequiredFieldValidator
objRequired.CssClass = "NormalRed"
objRequired.ErrorMessage = Localization.GetString("valEmail.ErrorMessage", Me.LocalResourceFile)
objRequired.ControlToValidate = objEmail.ID
objRequired.Display = ValidatorDisplay.Dynamic
controls.Add(objRequired)
Dim objRegEx As New RegularExpressionValidator
objRegEx.CssClass = "NormalRed"
objRegEx.ErrorMessage = Localization.GetString("valEmailIsValid.ErrorMessage", Me.LocalResourceFile)
objRegEx.ControlToValidate = objEmail.ID
objRegEx.Display = ValidatorDisplay.Dynamic
objRegEx.ValidationExpression = "^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"
controls.Add(objRegEx)
End If
Case "IMPLEMENTED"
Dim objImplemented As New CheckBox
objImplemented.EnableViewState = False
objImplemented.ID = "Implemented"
If (objFeedback IsNot Nothing) Then
objImplemented.Checked = objFeedback.IsResolved
End If
controls.Add(objImplemented)
Case "ISANONYMOUS"
If (Request.IsAuthenticated) Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/ISANONYMOUS") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/ISANONYMOUS"
' Do Nothing
Case "ISAPPROVER"
If ((IsEditable Or PortalSecurity.IsInRoles(FeedbackSettings.PermissionApprove)) = False) Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/ISAPPROVER") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/ISAPPROVER"
' Do Nothing
Case "NAME"
If (Request.IsAuthenticated = False) Then
Dim objName As New TextBox
objName.EnableViewState = False
objName.ID = "Name"
objName.CssClass = "NormalTextBox"
If (objFeedback IsNot Nothing) Then
objName.Text = objFeedback.AnonymousEmail
End If
controls.Add(objName)
Dim objRequired As New RequiredFieldValidator
objRequired.CssClass = "NormalRed"
objRequired.ErrorMessage = Localization.GetString("valName.ErrorMessage", Me.LocalResourceFile)
objRequired.ControlToValidate = objName.ID
objRequired.Display = ValidatorDisplay.Dynamic
controls.Add(objRequired)
End If
Case "PRODUCTS"
Dim objDropDownList As New DropDownList
objDropDownList.EnableViewState = False
objDropDownList.ID = "Products"
objDropDownList.DataTextField = "Name"
objDropDownList.DataValueField = "ProductID"
BindProducts(objDropDownList)
If (objFeedback IsNot Nothing) Then
If (objDropDownList.Items.FindByValue(objFeedback.ProductID.ToString()) IsNot Nothing) Then
objDropDownList.SelectedValue = objFeedback.ProductID
End If
End If
controls.Add(objDropDownList)
Dim objRequired As New RequiredFieldValidator
objRequired.CssClass = "NormalRed"
objRequired.ErrorMessage = Localization.GetString("valProducts.ErrorMessage", Me.LocalResourceFile)
objRequired.ControlToValidate = objDropDownList.ID
objRequired.Display = ValidatorDisplay.Dynamic
objRequired.InitialValue = "-1"
controls.Add(objRequired)
Case "STATUS"
Dim rdoStatus As New RadioButtonList
rdoStatus.ID = "Status"
rdoStatus.Items.Add(New ListItem(Localization.GetString("Open", Me.LocalResourceFile), "Open"))
rdoStatus.Items.Add(New ListItem(Localization.GetString("Closed", Me.LocalResourceFile), "Closed"))
rdoStatus.RepeatDirection = RepeatDirection.Horizontal
rdoStatus.RepeatLayout = RepeatLayout.Flow
rdoStatus.CssClass = "NormalTextBox"
rdoStatus.SelectedIndex = 0
If (objFeedback IsNot Nothing) Then
If (objFeedback.IsClosed) Then
rdoStatus.SelectedValue = "Closed"
Else
rdoStatus.SelectedValue = "Open"
End If
End If
controls.Add(rdoStatus)
Case "TITLE"
Dim objTitle As New TextBox
objTitle.EnableViewState = False
objTitle.ID = "Title"
objTitle.MaxLength = 100
objTitle.CssClass = "NormalTextBox"
If (objFeedback IsNot Nothing) Then
objTitle.Text = objFeedback.Title
End If
controls.Add(objTitle)
Dim objRequired As New RequiredFieldValidator
objRequired.CssClass = "NormalRed"
objRequired.ErrorMessage = Localization.GetString("valTitle.ErrorMessage", Me.LocalResourceFile)
objRequired.ControlToValidate = objTitle.ID
objRequired.Display = ValidatorDisplay.Dynamic
controls.Add(objRequired)
Case "URL"
If (Request.IsAuthenticated = False) Then
Dim objUrl As New TextBox
objUrl.EnableViewState = False
objUrl.ID = "Url"
objUrl.CssClass = "NormalTextBox"
If (objFeedback IsNot Nothing) Then
objUrl.Text = objFeedback.AnonymousUrl
End If
controls.Add(objUrl)
End If
Case Else
Dim rendered As Boolean = False
If (layoutArray(iPtr + 1).ToUpper().StartsWith("CUSTOM:")) Then
Dim field As String = layoutArray(iPtr + 1).Substring(7, layoutArray(iPtr + 1).Length - 7).ToLower()
Dim customFieldID As Integer = Null.NullInteger
For Each objCustomField As CustomFieldInfo In objCustomFields
If (objCustomField.Name.ToLower() = field.ToLower()) Then
Select (objCustomField.FieldType)
Case CustomFieldType.OneLineTextBox
Dim objTextBox As New TextBox
objTextBox.CssClass = "NormalTextBox"
objTextBox.ID = objCustomField.CustomFieldID.ToString()
If (objCustomField.Length <> Null.NullInteger AndAlso objCustomField.Length > 0) Then
objTextBox.MaxLength = objCustomField.Length
End If
If (objCustomField.DefaultValue <> "") Then
objTextBox.Text = objCustomField.DefaultValue
End If
If Not (objFeedback Is Nothing) Then
If (objFeedback.CustomList.Contains(objCustomField.CustomFieldID) And (Page.IsPostBack = False Or objTextBox.Enabled = False)) Then
objTextBox.Text = objFeedback.CustomList(objCustomField.CustomFieldID).ToString()
End If
End If
controls.Add(objTextBox)
rendered = True
If (objCustomField.IsRequired) Then
Dim valRequired As New RequiredFieldValidator
valRequired.ControlToValidate = objTextBox.ID
valRequired.ErrorMessage = Localization.GetString("valFieldRequired", Me.LocalResourceFile).Replace("[CUSTOMFIELD]", objCustomField.Name)
valRequired.CssClass = "NormalRed"
valRequired.Display = ValidatorDisplay.Dynamic
valRequired.SetFocusOnError = True
controls.Add(valRequired)
End If
If (objCustomField.ValidationType <> CustomFieldValidationType.None) Then
Dim valCompare As New CompareValidator
valCompare.ControlToValidate = objTextBox.ID
valCompare.CssClass = "NormalRed"
valCompare.Display = ValidatorDisplay.Dynamic
valCompare.SetFocusOnError = True
Select Case objCustomField.ValidationType
Case CustomFieldValidationType.Currency
valCompare.Type = ValidationDataType.Double
valCompare.Operator = ValidationCompareOperator.DataTypeCheck
valCompare.ErrorMessage = Localization.GetString("valFieldCurrency", Me.LocalResourceFile).Replace("[CUSTOMFIELD]", objCustomField.Name)
controls.Add(valCompare)
Case CustomFieldValidationType.Date
valCompare.Type = ValidationDataType.Date
valCompare.Operator = ValidationCompareOperator.DataTypeCheck
valCompare.ErrorMessage = Localization.GetString("valFieldDate", Me.LocalResourceFile).Replace("[CUSTOMFIELD]", objCustomField.Name)
controls.Add(valCompare)
Dim objCalendar As New HyperLink
objCalendar.CssClass = "CommandButton"
objCalendar.Text = Localization.GetString("Calendar", Me.LocalResourceFile)
objCalendar.NavigateUrl = DotNetNuke.Common.Utilities.Calendar.InvokePopupCal(objTextBox)
controls.Add(objCalendar)
Case CustomFieldValidationType.Double
valCompare.Type = ValidationDataType.Double
valCompare.Operator = ValidationCompareOperator.DataTypeCheck
valCompare.ErrorMessage = Localization.GetString("valFieldDecimal", Me.LocalResourceFile).Replace("[CUSTOMFIELD]", objCustomField.Name)
controls.Add(valCompare)
Case CustomFieldValidationType.Integer
valCompare.Type = ValidationDataType.Integer
valCompare.Operator = ValidationCompareOperator.DataTypeCheck
valCompare.ErrorMessage = Localization.GetString("valFieldNumber", Me.LocalResourceFile).Replace("[CUSTOMFIELD]", objCustomField.Name)
controls.Add(valCompare)
Case CustomFieldValidationType.Email
Dim valRegular As New RegularExpressionValidator
valRegular.ControlToValidate = objTextBox.ID
valRegular.ValidationExpression = "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
valRegular.ErrorMessage = Localization.GetString("valFieldEmail", Me.LocalResourceFile).Replace("[CUSTOMFIELD]", objCustomField.Name)
valRegular.CssClass = "NormalRed"
valRegular.Display = ValidatorDisplay.Dynamic
controls.Add(valRegular)
Case CustomFieldValidationType.Regex
If (objCustomField.RegularExpression <> "") Then
Dim valRegular As New RegularExpressionValidator
valRegular.ControlToValidate = objTextBox.ID
valRegular.ValidationExpression = objCustomField.RegularExpression
valRegular.ErrorMessage = Localization.GetString("valFieldRegex", Me.LocalResourceFile).Replace("[CUSTOMFIELD]", objCustomField.Name)
valRegular.CssClass = "NormalRed"
valRegular.Display = ValidatorDisplay.Dynamic
controls.Add(valRegular)
End If
End Select
End If
Case CustomFieldType.MultiLineTextBox
Dim objTextBox As New TextBox
objTextBox.TextMode = TextBoxMode.MultiLine
objTextBox.CssClass = "NormalTextBox"
objTextBox.ID = objCustomField.CustomFieldID.ToString()
objTextBox.Rows = 4
If (objCustomField.Length <> Null.NullInteger AndAlso objCustomField.Length > 0) Then
objTextBox.MaxLength = objCustomField.Length
End If
If (objCustomField.DefaultValue <> "") Then
objTextBox.Text = objCustomField.DefaultValue
End If
If Not (objFeedback Is Nothing) Then
If (objFeedback.CustomList.Contains(objCustomField.CustomFieldID) And (Page.IsPostBack = False Or objTextBox.Enabled = False)) Then
objTextBox.Text = objFeedback.CustomList(objCustomField.CustomFieldID).ToString()
End If
End If
controls.Add(objTextBox)
rendered = True
If (objCustomField.IsRequired) Then
Dim valRequired As New RequiredFieldValidator
valRequired.ControlToValidate = objTextBox.ID
valRequired.ErrorMessage = Localization.GetString("valFieldRequired", Me.LocalResourceFile).Replace("[CUSTOMFIELD]", objCustomField.Name)
valRequired.CssClass = "NormalRed"
valRequired.Display = ValidatorDisplay.None
valRequired.SetFocusOnError = True
controls.Add(valRequired)
End If
Case CustomFieldType.RichTextBox
Dim objTextBox As TextEditor = CType(Me.LoadControl("~/controls/TextEditor.ascx"), TextEditor)
objTextBox.ID = objCustomField.CustomFieldID.ToString()
If (objCustomField.DefaultValue <> "") Then
' objTextBox.Text = objCustomField.DefaultValue
End If
If Not (objFeedback Is Nothing) Then
If (objFeedback.CustomList.Contains(objCustomField.CustomFieldID) And Page.IsPostBack = False) Then
' There is a problem assigned values at init with the RTE, using ArrayList to assign later.
_richTextValues.Add(objCustomField.CustomFieldID.ToString(), objFeedback.CustomList(objCustomField.CustomFieldID).ToString())
End If
End If
objTextBox.Width = Unit.Pixel(300)
objTextBox.Height = Unit.Pixel(400)
controls.Add(objTextBox)
rendered = True
If (objCustomField.IsRequired) Then
Dim valRequired As New RequiredFieldValidator
valRequired.ControlToValidate = objTextBox.ID
valRequired.ErrorMessage = Localization.GetString("valFieldRequired", Me.LocalResourceFile).Replace("[CUSTOMFIELD]", objCustomField.Name)
valRequired.CssClass = "NormalRed"
valRequired.SetFocusOnError = True
controls.Add(valRequired)
End If
Case CustomFieldType.DropDownList
Dim objDropDownList As New DropDownList
objDropDownList.CssClass = "NormalTextBox"
objDropDownList.ID = objCustomField.CustomFieldID.ToString()
Dim values As String() = objCustomField.FieldElements.Split(Convert.ToChar("|"))
For Each value As String In values
If (value <> "") Then
objDropDownList.Items.Add(value)
End If
Next
Dim selectText As String = Localization.GetString("SelectValue", Me.LocalResourceFile)
selectText = selectText.Replace("[VALUE]", objCustomField.Caption)
objDropDownList.Items.Insert(0, New ListItem(selectText, "-1"))
If (objCustomField.DefaultValue <> "") Then
If Not (objDropDownList.Items.FindByValue(objCustomField.DefaultValue) Is Nothing) Then
objDropDownList.SelectedValue = objCustomField.DefaultValue
End If
End If
If Not (objFeedback Is Nothing) Then
If (objFeedback.CustomList.Contains(objCustomField.CustomFieldID) And (Page.IsPostBack = False Or objDropDownList.Enabled = False)) Then
If Not (objDropDownList.Items.FindByValue(objFeedback.CustomList(objCustomField.CustomFieldID).ToString()) Is Nothing) Then