This repository has been archived by the owner on Feb 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
View.ascx.vb
984 lines (760 loc) · 39.8 KB
/
View.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
' Copyright (c) 2014 Philipp Becker
' All rights reserved.
'
' 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
Imports DotNetNuke.Entities.Modules.Actions
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports PerceptiveMCAPI
Imports PerceptiveMCAPI.Types
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Common.Globals
Imports PerceptiveMCAPI.Methods
Imports DotNetNuke.Web.UI.WebControls
Public Class View
Inherits ModuleBase
Implements IActionable
#Region "Private Members"
Private _apikey As String = Null.NullString
Private _listid As String = Null.NullString
Private _mergefields As List(Of listMergeVarsResults)
Private _listmember As listMemberInfoResults
Private ReadOnly Property UseDoubleOptIn() As Boolean
Get
If Not Settings("Mailchimp_UseDoubleOptIn") Is Nothing Then
Try
Return Boolean.Parse(CType(Settings("Mailchimp_UseDoubleOptIn"), String))
Catch
End Try
End If
Return False
End Get
End Property
Private ReadOnly Property SendWelcomeEmailOnSubscribe() As Boolean
Get
If Not Settings("Mailchimp_SendWelcomeEmailOnSubscribe") Is Nothing Then
Try
Return Boolean.Parse(CType(Settings("Mailchimp_SendWelcomeEmailOnSubscribe"), String))
Catch
End Try
End If
Return False
End Get
End Property
Private ReadOnly Property DeleteMemberOnUnsubscribe() As Boolean
Get
If Not Settings("Mailchimp_DeleteMemberOnUnsubscribe") Is Nothing Then
Try
Return Boolean.Parse(CType(Settings("Mailchimp_DeleteMemberOnUnsubscribe"), String))
Catch
End Try
End If
Return False
End Get
End Property
Private ReadOnly Property SendGoodbyEmailOnUnSubscribe() As Boolean
Get
If Not Settings("Mailchimp_SendGoodbyEmailOnUnSubscribe") Is Nothing Then
Try
Return Boolean.Parse(CType(Settings("Mailchimp_SendGoodbyEmailOnUnSubscribe"), String))
Catch
End Try
End If
Return True
End Get
End Property
Private ReadOnly Property SendAdminNotificationOnUnsubscribe() As Boolean
Get
If Not Settings("Mailchimp_SendAdminNotificationOnUnsubscribe") Is Nothing Then
Try
Return Boolean.Parse(CType(Settings("Mailchimp_SendAdminNotificationOnUnsubscribe"), String))
Catch
End Try
End If
Return True
End Get
End Property
#End Region
#Region "Event Handlers"
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
DotNetNuke.Framework.AJAX.RegisterScriptManager()
LoadList()
End Sub
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub cmdShowUnSubscribe_Click(ByVal sender As Object, ByVal e As System.EventArgs)
pnlSettings.Visible = False
pnlSettingsResult.Visible = False
pnlSubscribe.Visible = False
pnlSubscribeResult.Visible = False
pnlUnSubscribe.Visible = True
pnlUnSubscribeResult.Visible = False
pnlError.Visible = False
End Sub
Protected Sub cmdUnSubscribe_Click(ByVal sender As Object, ByVal e As System.EventArgs)
pnlSettings.Visible = False
pnlSettingsResult.Visible = False
pnlSubscribe.Visible = False
pnlUnSubscribe.Visible = False
pnlUnSubscribeResult.Visible = False
pnlError.Visible = False
If UnSubscribe() Then
pnlUnSubscribeResult.Visible = True
pnlUnSubscribe.Visible = False
Else
pnlUnSubscribeResult.Visible = False
pnlUnSubscribe.Visible = True
End If
End Sub
Protected Sub cmdSubscribe_Click(ByVal sender As Object, ByVal e As System.EventArgs)
pnlSettings.Visible = False
pnlSettingsResult.Visible = False
pnlSubscribe.Visible = False
pnlUnSubscribe.Visible = False
pnlUnSubscribeResult.Visible = False
pnlError.Visible = False
If Subscribe() Then
pnlSubscribeResult.Visible = True
pnlSubscribe.Visible = False
Else
pnlSubscribeResult.Visible = False
pnlSubscribe.Visible = True
End If
End Sub
Protected Sub cmdUpdateSettings_Click(ByVal sender As Object, ByVal e As System.EventArgs)
pnlSubscribe.Visible = False
pnlUnSubscribe.Visible = False
pnlUnSubscribeResult.Visible = False
pnlSubscribeResult.Visible = False
pnlSubscribe.Visible = False
pnlError.Visible = False
If UpdateSubscription() Then
pnlSettings.Visible = False
pnlSettingsResult.Visible = True
Else
pnlSettings.Visible = True
pnlSettingsResult.Visible = False
End If
End Sub
#End Region
#Region "Private Methods"
Private Function UpdateSubscription() As Boolean
Dim strEmail As String = Null.NullString
Dim merges As New Dictionary(Of String, Object)
Dim subscriptionType As EnumValues.emailType = EnumValues.emailType.html
ParseForm(pnlSettings, merges, strEmail, subscriptionType)
'add to list
If strEmail <> Null.NullString Then
Dim input As New listUpdateMemberInput(_apikey, _listid, strEmail, merges, subscriptionType, True)
Dim cmd As New listUpdateMember
Dim output As listUpdateMemberOutput = cmd.Execute(input)
If Not output Is Nothing Then
Return output.result
End If
End If
Return False
End Function
Private Function Subscribe() As Boolean
Dim strEmail As String = Null.NullString
Dim merges As New Dictionary(Of String, Object)
Dim subscriptionType As EnumValues.emailType = EnumValues.emailType.html
ParseForm(pnlSubscribe, merges, strEmail, subscriptionType)
'add to list
If strEmail <> Null.NullString Then
Dim input As New listSubscribeInput(_apikey, _listid, strEmail, merges, subscriptionType, UseDoubleOptIn, True, True, SendWelcomeEmailOnSubscribe)
Dim cmd As New listSubscribe
Dim output As listSubscribeOutput = cmd.Execute(input)
If Not output Is Nothing Then
Return output.result
End If
End If
Return False
End Function
Private Function UnSubscribe() As Boolean
Dim strEmail As String = Null.NullString
Dim txtEmail As TextBox = FindControlRecursive(pnlUnSubscribe, pnlUnSubscribe.ID & "_txtEMAIL")
If Not txtEmail Is Nothing Then
If txtEmail.Text.Length > 0 Then
strEmail = txtEmail.Text
Else
ShowErrorDialog(Localization.GetString("FillInAllFields", LocalResourceFile))
Return False
End If
Else
If Request.IsAuthenticated Then
strEmail = UserInfo.Email
Else
ShowErrorDialog(Localization.GetString("FormSetupError", LocalResourceFile))
Return False
End If
End If
'add to list
If strEmail <> Null.NullString Then
Dim input As New listUnsubscribeInput(_apikey, _listid, strEmail, DeleteMemberOnUnsubscribe, SendGoodbyEmailOnUnSubscribe, SendAdminNotificationOnUnsubscribe)
Dim cmd As New listUnsubscribe
Dim output As listUnsubscribeOutput = cmd.Execute(input)
If Not output Is Nothing Then
Return output.result
End If
End If
Return False
End Function
Private Sub ParseForm(ByVal Container As Control, ByRef merges As Dictionary(Of String, Object), ByRef strEmail As String, ByRef subscriptionType As EnumValues.emailType)
Dim txtEmail As TextBox = FindControlRecursive(Container, Container.ID & "_txtEMAIL")
If Not txtEmail Is Nothing Then
If txtEmail.Text.Length > 0 Then
strEmail = txtEmail.Text
Else
ShowErrorDialog(Localization.GetString("FillInAllFields", LocalResourceFile))
Exit Sub
End If
Else
If Request.IsAuthenticated Then
strEmail = UserInfo.Email
Else
ShowErrorDialog(Localization.GetString("FormSetupError", LocalResourceFile))
Exit Sub
End If
End If
Dim rblOptions As RadioButtonList = FindControlRecursive(Container, Container.ID & "_rblOPTIONS")
If Not rblOptions Is Nothing Then
If rblOptions.SelectedValue = "html" Then
subscriptionType = EnumValues.emailType.html
ElseIf rblOptions.SelectedValue = "text" Then
subscriptionType = EnumValues.emailType.text
ElseIf rblOptions.SelectedValue = "mobile" Then
subscriptionType = EnumValues.emailType.mobile
Else
subscriptionType = EnumValues.emailType.NotSpecified
End If
End If
For Each fieldItem As listMergeVarsResults In _mergefields
Dim strKey As String = fieldItem.tag
Dim obj As Object = Nothing
Select Case fieldItem.field_type.ToLower
Case "radio"
Dim rbl As RadioButtonList = FindControlRecursive(Container, Container.ID & "_rbl" & fieldItem.tag)
If Not rbl Is Nothing Then
obj = rbl.SelectedValue
Else
If Request.IsAuthenticated Then
Try
obj = UserInfo.Profile.GetPropertyValue(fieldItem.tag)
Catch
End Try
End If
If fieldItem.req AndAlso obj Is Nothing Then
ShowErrorDialog(Localization.GetString("FormSetupError", LocalResourceFile))
Exit Sub
End If
End If
Case "dropdown"
Dim drp As DropDownList = FindControlRecursive(Container, Container.ID & "_drp" & fieldItem.tag)
If Not drp Is Nothing Then
obj = drp.SelectedValue
Else
If Request.IsAuthenticated Then
Try
obj = UserInfo.Profile.GetPropertyValue(fieldItem.tag)
Catch
End Try
End If
If fieldItem.req AndAlso obj Is Nothing Then
ShowErrorDialog(Localization.GetString("FormSetupError", LocalResourceFile))
Exit Sub
End If
End If
Case "date"
Dim ctl As DnnDatePicker = FindControlRecursive(Container, Container.ID & "_ctl" & fieldItem.tag)
If Not ctl Is Nothing Then
If Not ctl.SelectedDate Is Nothing Then
If Not ctl.DbSelectedDate Is Nothing Then
obj = ctl.DbSelectedDate
Else
If fieldItem.req Then
ShowErrorDialog(Localization.GetString("FillInAllFields", LocalResourceFile))
Exit Sub
End If
End If
Else
If Request.IsAuthenticated Then
Try
obj = UserInfo.Profile.GetPropertyValue(fieldItem.tag)
Catch
End Try
End If
If fieldItem.req AndAlso obj Is Nothing Then
ShowErrorDialog(Localization.GetString("FillInAllFields", LocalResourceFile))
Exit Sub
End If
End If
Else
If fieldItem.req Then
ShowErrorDialog(Localization.GetString("FormSetupError", LocalResourceFile))
Exit Sub
End If
End If
Case "number"
Dim txt As DnnNumericTextBox = FindControlRecursive(Container, Container.ID & "_txt" & fieldItem.tag)
If Not txt Is Nothing Then
If Not txt.Value Is Nothing Then
If txt.Value > CDec(0) Then
obj = Convert.ToInt32(txt.Value)
Else
If Request.IsAuthenticated Then
Try
obj = UserInfo.Profile.GetPropertyValue(fieldItem.tag)
Catch
End Try
End If
If fieldItem.req AndAlso obj Is Nothing Then
ShowErrorDialog(Localization.GetString("FillInAllFields", LocalResourceFile))
Exit Sub
End If
End If
Else
If Request.IsAuthenticated Then
Try
obj = UserInfo.Profile.GetPropertyValue(fieldItem.tag)
Catch
End Try
End If
If fieldItem.req AndAlso obj Is Nothing Then
ShowErrorDialog(Localization.GetString("FillInAllFields", LocalResourceFile))
Exit Sub
End If
End If
Else
If Request.IsAuthenticated Then
Try
obj = UserInfo.Profile.GetPropertyValue(fieldItem.tag)
Catch
End Try
End If
If fieldItem.req AndAlso obj Is Nothing Then
ShowErrorDialog(Localization.GetString("FormSetupError", LocalResourceFile))
Exit Sub
End If
End If
Case Else
Dim txt As TextBox = FindControlRecursive(Container, Container.ID & "_txt" & fieldItem.tag)
If Not txt Is Nothing Then
If txt.Text.Length > 0 Then
obj = txt.Text
Else
If Request.IsAuthenticated Then
Try
obj = UserInfo.Profile.GetPropertyValue(fieldItem.tag)
Catch
End Try
End If
If fieldItem.req AndAlso obj Is Nothing Then
ShowErrorDialog(Localization.GetString("FillInAllFields", LocalResourceFile))
Exit Sub
End If
End If
Else
If Request.IsAuthenticated Then
If fieldItem.tag.ToLower = "lname" Then
obj = UserInfo.LastName
ElseIf fieldItem.tag.ToLower = "fname" Then
obj = UserInfo.FirstName
Else
If Not String.IsNullOrEmpty(UserInfo.Profile.GetPropertyValue(fieldItem.tag)) Then
obj = UserInfo.Profile.GetPropertyValue(fieldItem.tag)
End If
End If
End If
End If
End Select
If strKey <> "" AndAlso Not obj Is Nothing Then
merges.Add(strKey, obj)
End If
Next
End Sub
Public Function FindControlRecursive(ByVal objRoot As Control, ByVal id As String) As Control
If objRoot.ID = id Then
Return objRoot
End If
For Each c As Control In objRoot.Controls
Dim t As Control = FindControlRecursive(c, id)
If Not t Is Nothing Then
Return t
End If
Next
Return Nothing
End Function
Private Sub LoadList()
If Settings.Contains("Mailchimp_ApiKey") Then
_apikey = CType(Settings("Mailchimp_ApiKey"), String)
End If
If Settings.Contains("Mailchimp_ListId") Then
_listid = CType(Settings("Mailchimp_ListId"), String)
End If
If _apikey = Null.NullString Or _listid = Null.NullString Then
ShowModuleSettingsNote()
Exit Sub
End If
Dim input As New listMergeVarsInput(_apikey, _listid)
Dim cmd As New listMergeVars
Dim output As listMergeVarsOutput = cmd.Execute(input)
If Not output Is Nothing Then
If output.result.Count > 0 Then
_mergefields = output.result
Else
ShowModuleSettingsNote()
Exit Sub
End If
Else
ShowModuleSettingsNote()
Exit Sub
End If
If Not Page.IsPostBack Then
If IsSubscribed() Then
pnlSettings.Visible = True
pnlSettingsResult.Visible = False
pnlSubscribe.Visible = False
pnlSubscribeResult.Visible = False
pnlUnSubscribe.Visible = False
pnlUnSubscribeResult.Visible = False
pnlError.Visible = False
Else
pnlSettings.Visible = False
pnlSettingsResult.Visible = False
pnlSubscribe.Visible = True
pnlSubscribeResult.Visible = False
pnlUnSubscribe.Visible = False
pnlUnSubscribeResult.Visible = False
pnlError.Visible = False
End If
End If
ProcessTemplates()
End Sub
Private Sub ShowModuleSettingsNote()
lblConfigure.Text = Localization.GetString("lblConfigure", LocalResourceFile)
pnlModuleSettings.Visible = True
pnlSettings.Visible = False
pnlSettingsResult.Visible = False
pnlSubscribe.Visible = False
pnlSubscribeResult.Visible = False
pnlUnSubscribe.Visible = False
pnlUnSubscribeResult.Visible = False
End Sub
Private Sub ProcessTemplates()
Dim strTemplate As String = GetTemplate(ModuleTheme, Constants.TemplateName_SubscribeForm, CurrentLocale, False)
ParseTemplate(strTemplate, pnlSubscribe)
strTemplate = GetTemplate(ModuleTheme, Constants.TemplateName_SubscribeResult, CurrentLocale, False)
ParseTemplate(strTemplate, pnlSubscribeResult)
strTemplate = GetTemplate(ModuleTheme, Constants.TemplateName_UnsubscribeForm, CurrentLocale, False)
ParseTemplate(strTemplate, pnlUnSubscribe)
strTemplate = GetTemplate(ModuleTheme, Constants.TemplateName_UnsubscribeResult, CurrentLocale, False)
ParseTemplate(strTemplate, pnlUnSubscribeResult)
strTemplate = GetTemplate(ModuleTheme, Constants.TemplateName_SettingsForm, CurrentLocale, False)
ParseTemplate(strTemplate, pnlSettings)
strTemplate = GetTemplate(ModuleTheme, Constants.TemplateName_SettingsResult, CurrentLocale, False)
ParseTemplate(strTemplate, pnlSettingsResult)
End Sub
Private Sub ParseTemplate(strTemplate As String, Target As Panel)
Dim literal As New Literal
Dim delimStr As String = "[]"
Dim delimiter As Char() = delimStr.ToCharArray()
Dim templateArray As String()
templateArray = strTemplate.Split(delimiter)
For iPtr As Integer = 0 To templateArray.Length - 1 Step 2
Dim strHTML As String = templateArray(iPtr).ToString()
Target.Controls.Add(New LiteralControl(strHTML))
If iPtr < templateArray.Length - 1 Then
Dim strToken As String = templateArray(iPtr + 1)
If strToken.StartsWith("MERGE:") Then
Dim strKey As String = strToken.Split(Char.Parse(":"))(1)
Dim strType As String = strToken.Split(Char.Parse(":"))(2)
Select Case strKey.ToLower
Case "email"
If strType.ToLower = "label" Then
Dim strLabelText As String = ""
Dim strHelpText As String = ""
If Not String.IsNullOrEmpty(Localization.GetString("Label_" & strKey, LocalResourceFile)) Then
strLabelText = Localization.GetString("Label_" & strKey, LocalResourceFile)
Else
strLabelText = strKey
End If
If Not String.IsNullOrEmpty(Localization.GetString("Label_" & strKey & ".Help", LocalResourceFile)) Then
strHelpText = Localization.GetString("Label_" & strKey & ".Help", LocalResourceFile)
Else
strHelpText = strKey
End If
Dim oControl As New System.Web.UI.Control
oControl = CType(LoadControl("~/controls/LabelControl.ascx"), DotNetNuke.UI.UserControls.LabelControl)
Dim dnnLabel As DotNetNuke.UI.UserControls.LabelControl = CType(oControl, DotNetNuke.UI.UserControls.LabelControl)
dnnLabel.Text = strLabelText
dnnLabel.HelpText = strHelpText
dnnLabel.ID = Target.ID & "_RESX_" & strKey
Target.Controls.Add(dnnLabel)
ElseIf strType.ToLower = "required" Then
Dim objLiteral As New Literal
objLiteral.ID = Target.ID & "_" & strKey & "_Required"
objLiteral.EnableViewState = False
If String.IsNullOrEmpty(Localization.GetString("Label_Required", LocalResourceFile)) Then
objLiteral.Text = "*"
Else
objLiteral.Text = Localization.GetString("Label_Required", LocalResourceFile)
End If
Target.Controls.Add(objLiteral)
Else
Dim objTextBox As New TextBox
objTextBox.ID = Target.ID & "_txt" & strKey
objTextBox.EnableViewState = True
If Request.IsAuthenticated Then
objTextBox.Text = UserInfo.Email
End If
Target.Controls.Add(objTextBox)
End If
Case "options"
If strType.ToLower = "label" Then
Dim objLiteral As New Literal
objLiteral.ID = Target.ID & "_" & strKey
objLiteral.EnableViewState = False
If String.IsNullOrEmpty(Localization.GetString("Label_" & strKey, LocalResourceFile)) Then
objLiteral.Text = strKey
Else
objLiteral.Text = Localization.GetString("Label_" & strKey, LocalResourceFile)
End If
Target.Controls.Add(objLiteral)
Else
Dim objRadio As New RadioButtonList
objRadio.ID = Target.ID & "_rbl" & strKey
objRadio.EnableViewState = True
objRadio.Items.Add(New ListItem("HTML", "html"))
objRadio.Items.Add(New ListItem("Text", "text"))
objRadio.Items.Add(New ListItem("Mobile", "mobile"))
objRadio.SelectedValue = "html"
Target.Controls.Add(objRadio)
End If
Case Else
For Each item As listMergeVarsResults In _mergefields
If item.tag.ToLower = strKey.ToLower Then
If strType.ToLower = "label" Then
Dim strLabelText As String = ""
Dim strHelpText As String = ""
If Not String.IsNullOrEmpty(Localization.GetString("Label_" & item.tag, LocalResourceFile)) Then
strLabelText = Localization.GetString("Label_" & item.tag, LocalResourceFile)
Else
strLabelText = item.name
End If
If Not String.IsNullOrEmpty(Localization.GetString("Label_" & item.tag & ".Help", LocalResourceFile)) Then
strHelpText = Localization.GetString("Label_" & item.tag & ".Help", LocalResourceFile)
Else
strHelpText = item.name
End If
Dim oControl As New System.Web.UI.Control
oControl = CType(LoadControl("~/controls/LabelControl.ascx"), DotNetNuke.UI.UserControls.LabelControl)
Dim dnnLabel As DotNetNuke.UI.UserControls.LabelControl = CType(oControl, DotNetNuke.UI.UserControls.LabelControl)
dnnLabel.Text = strLabelText
dnnLabel.HelpText = strHelpText
dnnLabel.ID = Target.ID & "_RESX_" & item.tag
Target.Controls.Add(dnnLabel)
ElseIf strType.ToLower = "required" Then
If item.req Then
Dim objLiteral As New Literal
objLiteral.ID = Target.ID & "_" & item.tag & "_Required"
objLiteral.EnableViewState = False
If String.IsNullOrEmpty(Localization.GetString("Label_Required", LocalResourceFile)) Then
objLiteral.Text = "*"
Else
objLiteral.Text = Localization.GetString("Label_Required", LocalResourceFile)
End If
Target.Controls.Add(objLiteral)
End If
Else
Select Case item.field_type.ToLower
Case "date"
Dim objDate As New DnnDatePicker
objDate.ID = Target.ID & "_ctl" & item.tag
objDate.EnableViewState = True
If Request.IsAuthenticated Then
Try
objDate.SelectedDate = Date.Parse(UserInfo.Profile.GetPropertyValue(strKey))
Catch
End Try
End If
Target.Controls.Add(objDate)
Case "dropdown"
Dim objCombo As New DropDownList
objCombo.ID = Target.ID & "_drp" & item.tag
objCombo.EnableViewState = True
For Each strValue As String In item.choices
objCombo.Items.Add(New ListItem(strValue, strValue))
Next
If Request.IsAuthenticated Then
Try
objCombo.SelectedValue = UserInfo.Profile.GetPropertyValue(strKey)
Catch
End Try
End If
Target.Controls.Add(objCombo)
Case "radio"
Dim objRadio As New RadioButtonList
objRadio.ID = Target.ID & "_rbl" & item.tag
objRadio.EnableViewState = True
For Each strValue As String In item.choices
objRadio.Items.Add(New ListItem(strValue, strValue))
Next
If Request.IsAuthenticated Then
Try
objRadio.SelectedValue = UserInfo.Profile.GetPropertyValue(strKey)
Catch
End Try
End If
Target.Controls.Add(objRadio)
Case "number"
Dim objTextBox As New DnnNumericTextBox
objTextBox.ID = Target.ID & "_txt" & item.tag
objTextBox.EnableViewState = True
objTextBox.NumberFormat.DecimalDigits = 0
objTextBox.ShowSpinButtons = True
If Request.IsAuthenticated Then
Try
objTextBox.Value = Integer.Parse(UserInfo.Profile.GetPropertyValue(strKey))
Catch
End Try
End If
Target.Controls.Add(objTextBox)
Case Else
Dim objTextBox As New TextBox
objTextBox.ID = Target.ID & "_txt" & item.tag
objTextBox.EnableViewState = True
If Request.IsAuthenticated Then
If strKey.ToLower = "lname" Then
If Not _listmember Is Nothing Then
Try
objTextBox.Text = _listmember.merges("LNAME")
Catch
End Try
Else
objTextBox.Text = UserInfo.LastName
End If
ElseIf strKey.ToLower = "fname" Then
If Not _listmember Is Nothing Then
Try
objTextBox.Text = _listmember.merges("FNAME")
Catch
End Try
Else
objTextBox.Text = UserInfo.FirstName
End If
Else
Try
objTextBox.Text = UserInfo.Profile.GetPropertyValue(strKey)
Catch
End Try
End If
End If
Target.Controls.Add(objTextBox)
End Select
End If
End If
Next
End Select
ElseIf strToken.StartsWith("BUTTON:") Then
Dim strKey As String = strToken.Split(Char.Parse(":"))(1)
Dim strText As String = ""
If String.IsNullOrEmpty(Localization.GetString(strKey, LocalResourceFile)) Then
strText = strKey
Else
strText = Localization.GetString(strKey, LocalResourceFile)
End If
Dim cmd As New LinkButton
cmd.ID = Target.ID & "_" & strKey
cmd.Text = strText
cmd.CssClass = strKey
Select Case strKey.ToLower
Case "showunsubscribe"
AddHandler cmd.Click, AddressOf cmdShowUnSubscribe_Click
cmd.CssClass += " dnnSecondaryAction"
Case "subscribe"
AddHandler cmd.Click, AddressOf cmdSubscribe_Click
cmd.CssClass += " dnnPrimaryAction"
Case "unsubscribe"
AddHandler cmd.Click, AddressOf cmdUnSubscribe_Click
cmd.CssClass += " dnnSecondaryAction"
Case "updatesettings"
AddHandler cmd.Click, AddressOf cmdUpdateSettings_Click
cmd.CssClass += " dnnPrimaryAction"
End Select
Target.Controls.Add(cmd)
ElseIf strToken.StartsWith("LABEL:") Then
Dim strKey As String = strToken.Split(Char.Parse(":"))(1)
Dim objLiteral As New Literal
objLiteral.ID = Target.ID & "_" & strKey
objLiteral.EnableViewState = False
If String.IsNullOrEmpty(Localization.GetString(strKey, LocalResourceFile)) Then
objLiteral.Text = strKey
Else
objLiteral.Text = Localization.GetString(strKey, LocalResourceFile)
End If
Target.Controls.Add(objLiteral)
ElseIf strToken.StartsWith("LNK:") Then
Dim strKey As String = strToken.Split(Char.Parse(":"))(1)
Dim strText As String = Localization.GetString(strKey, LocalResourceFile)
Dim lnk As New HyperLink
lnk.ID = strKey
lnk.Text = strText
If strKey.ToLower = "lnkregister" Then
lnk.NavigateUrl = NavigateURL(PortalSettings.RegisterTabId)
ElseIf strKey.ToLower = "myprofile" Then
lnk.NavigateUrl = NavigateURL(PortalSettings.UserTabId)
ElseIf strKey.ToLower = "signout" Then
lnk.NavigateUrl = NavigateURL(TabId, "", "ctl=logoff")
End If
Target.Controls.Add(lnk)
End If
End If
Next
End Sub
Private Function IsSubscribed() As Boolean
If Request.IsAuthenticated = False Then
Return False
End If
Dim input As listsForEmailInput = New listsForEmailInput(_apikey, UserInfo.Email)
Dim cmd As New PerceptiveMCAPI.Methods.listsForEmail
Dim output As listsForEmailOutput = cmd.Execute(input)
If output.result.Count > 0 Then
For Each objList As String In output.result
If objList = _listid Then
Dim inputMember As listMemberInfoInput = New listMemberInfoInput(_apikey, _listid, UserInfo.Email)
Dim cmdMember As New listMemberInfo
Dim outputMember As listMemberInfoOutput = cmdMember.Execute(inputMember)
If Not outputMember Is Nothing Then
Try
_listmember = outputMember.result
Catch
End Try
End If
Return True
End If
Next
End If
Return False
End Function
Private Sub ShowErrorDialog(strText As String)
pnlError.Visible = True
lblError.Text = strText
End Sub
#End Region
#Region "Optional Interfaces"
Public ReadOnly Property ModuleActions() As Entities.Modules.Actions.ModuleActionCollection Implements Entities.Modules.IActionable.ModuleActions
Get
Dim Actions As New Entities.Modules.Actions.ModuleActionCollection
Actions.Add(GetNextActionID, Localization.GetString("ManageTemplates.Action", LocalResourceFile), Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl("ManageTemplates"), False, DotNetNuke.Security.SecurityAccessLevel.Edit, True, False)
Return Actions
End Get
End Property
#End Region
End Class