forked from DNN-Connect/UserAccountManagement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
View.ascx.vb
2726 lines (2018 loc) · 114 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
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'***********************************************************************************
' Connect UsersLibrary
'
' Copyright (C) 2013-2014 DNN-Connect Association, Philipp Becker
' http://dnn-connect.org
'
' This program is free software; you can redistribute it and/or
' modify it under the terms of the GNU General Public License
' as published by the Free Software Foundation; either version 2
' of the License, or (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
'
'***********************************************************************************
Imports DotNetNuke.Entities.Modules
Imports Connect.Libraries.UserManagement
Imports DotNetNuke.Entities.Users
Imports DotNetNuke.Security.Membership
Imports Telerik.Web.UI
Imports DotNetNuke.Security.Roles
Imports DotNetNuke.Entities.Profile
Imports DotNetNuke.Web.UI.WebControls
Imports DotNetNuke.Entities.Portals
Imports DotNetNuke.Common.Lists
Imports DotNetNuke.Framework.JavaScriptLibraries
Imports System.Linq
Namespace Connect.Modules.UserManagement.AccountManagement
Partial Class View
Inherits ConnectUsersModuleBase
Implements IActionable
#Region "Private Members"
Private _IsReportResult As Boolean = False
#End Region
#Region "Event Handlers"
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
If Request.QueryString("RoleId") Is Nothing Then
If Me.PreSelectRole <> Null.NullInteger Then
Response.Redirect(NavigateURL(TabId, "", "RoleId=" & Me.PreSelectRole.ToString), False)
Context.ApplicationInstance.CompleteRequest()
Else
Response.Redirect(NavigateURL(TabId, "", "RoleId=" & Me.PortalSettings.RegisteredRoleId.ToString.ToString), False)
Context.ApplicationInstance.CompleteRequest()
End If
End If
ProcessQuerystring() 'watch out for querystring actions
JavaScript.RequestRegistration(CommonJs.DnnPlugins)
JavaScript.RequestRegistration(CommonJs.jQueryUI)
InitializeForm()
ProcessFormTemplate(plhUser, GetTemplate(ModuleTheme, Constants.TemplateName_AccountForm, CurrentLocale, False), User)
ProcessFormTemplate(plhProfile, GetTemplate(ModuleTheme, Constants.TemplateName_ProfileForm, CurrentLocale, False), User)
ProcessFormTemplate(plhCreate, GetTemplate(ModuleTheme, Constants.TemplateName_CreateForm, CurrentLocale, False), Nothing)
End Sub
Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
'make sure txtSearch is empty on non-postback requests
txtSearch.Text = ""
BindRoles()
BindSearchColOptions()
PersonalizeOptions()
BindReports()
pnlBackToList.Visible = False
If Not Request.QueryString("uid") Is Nothing Then
If IsNumeric(Request.QueryString("uid")) Then
BindUser(Convert.ToInt32(Request.QueryString("uid")))
End If
End If
If Not Request.QueryString("Action") Is Nothing Then
If Request.QueryString("Action") = "Messaging" Then
pnlGrid.Visible = False
pnlCreate.Visible = False
pnlUser.Visible = False
pnlRoleMessaging.Visible = True
End If
End If
End If
End Sub
Private Sub grdUsers_PreRender(sender As Object, e As EventArgs) Handles grdUsers.PreRender
grdUsers.ClientSettings.Scrolling.AllowScroll = False
End Sub
Private Sub btnReport_Click(sender As Object, e As EventArgs) Handles btnReport.Click
_IsReportResult = True
If drpReports.SelectedIndex > 0 Then
ctlRoles.UnselectAllNodes()
grdUsers.Rebind()
End If
Session("UserReportsId") = drpReports.SelectedValue
pnlGrid.Visible = True
pnlUser.Visible = False
pnlCreate.Visible = False
End Sub
Private Sub grdUsers_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles grdUsers.NeedDataSource
BindUsers()
End Sub
Public Function GetStatusText(strStatus As Object) As String
Select Case strStatus.ToString
Case "1"
Return Localization.GetString("RoleStatusApproved", LocalResourceFile)
Case "0"
Return Localization.GetString("RoleStatusNoStatus", LocalResourceFile)
Case "-1"
Return Localization.GetString("RoleStatusPending", LocalResourceFile)
End Select
Return Localization.GetString("RoleStatusUnknown", LocalResourceFile)
End Function
Protected Sub grdUsers_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles grdUsers.ItemDataBound
If e.Item.ItemType = GridItemType.AlternatingItem Or e.Item.ItemType = GridItemType.Item Then
Try
Dim dataBoundItem As GridDataItem = e.Item
Dim row As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim intUser As String = Convert.ToInt32(row("UserID"))
Dim intRole As Integer = Convert.ToInt32(ctlRoles.SelectedNode.Value)
Dim btnHardDelete As HtmlGenericControl = CType(e.Item.FindControl("btnHardDelete"), HtmlGenericControl)
If Not btnHardDelete Is Nothing Then
btnHardDelete.Visible = False
If intRole = -2 Then
btnHardDelete.Visible = True
End If
End If
Dim btnRemove As HtmlGenericControl = CType(e.Item.FindControl("btnRemove"), HtmlGenericControl)
If Not btnRemove Is Nothing Then
btnRemove.Visible = False
If intRole <> -2 AndAlso intRole <> PortalSettings.RegisteredRoleId Then
btnRemove.Visible = True
End If
End If
Dim btnSetStatus As HtmlGenericControl = CType(e.Item.FindControl("btnSetStatus"), HtmlGenericControl)
If Not btnSetStatus Is Nothing Then
btnSetStatus.Visible = False
If intRole <> -2 AndAlso intRole <> PortalSettings.RegisteredRoleId Then
'If intRole <> -2 Then
btnSetStatus.Visible = True
End If
End If
Dim btnSetDeleted As HtmlGenericControl = CType(e.Item.FindControl("btnSetDeleted"), HtmlGenericControl)
If Not btnSetDeleted Is Nothing Then
btnSetDeleted.Visible = False
If AllowDelete AndAlso intUser <> PortalSettings.AdministratorId AndAlso intUser <> UserInfo.UserID AndAlso (Not ctlRoles.SelectedNode Is Nothing AndAlso ctlRoles.SelectedNode.Value <> "-2") Then
btnSetDeleted.Visible = True
End If
End If
Dim btnRestore As HtmlGenericControl = CType(e.Item.FindControl("btnRestore"), HtmlGenericControl)
If Not btnRestore Is Nothing Then
btnRestore.Visible = False
If (Not ctlRoles.SelectedNode Is Nothing AndAlso ctlRoles.SelectedNode.Value = "-2") Then
btnRestore.Visible = True
End If
End If
Catch ex As Exception
End Try
End If
End Sub
Private Sub btnCancelMessaging_Click(sender As Object, e As EventArgs) Handles btnCancelMessaging.Click
Response.Redirect(NavigateURL(TabId, "", "RoleId=" & Request.QueryString("RoleId")), False)
Context.ApplicationInstance.CompleteRequest()
End Sub
Private Sub btnApplyOptions_Click(sender As Object, e As EventArgs) Handles btnApplyOptions.Click
SaveGridOptions()
SaveSearchOptions()
If Not Request.QueryString("RoleId") Is Nothing Then
Response.Redirect(NavigateURL(TabId, "", "RoleId=" & Request.QueryString("RoleId")), False)
Context.ApplicationInstance.CompleteRequest()
Else
Response.Redirect(NavigateURL(TabId), False)
Context.ApplicationInstance.CompleteRequest()
End If
End Sub
Private Sub cmdBack_Click(sender As Object, e As EventArgs) Handles cmdBack.Click
Dim url As String = NavigateURL(TabId)
If Not Request.QueryString("RoleId") Is Nothing Then
url = NavigateURL(TabId, "", "RoleId=" & Request.QueryString("RoleId"))
End If
Response.Redirect(url, False)
Context.ApplicationInstance.CompleteRequest()
End Sub
Protected Sub grdUserRoles_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdUserRoles.NeedDataSource
Dim roleController As New RoleController
Dim userRoles As IList = roleController.GetUserRoles(PortalId, User.Username, "")
grdUserRoles.DataSource = userRoles
End Sub
Protected Sub grdUserRoles_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles grdUserRoles.ItemDataBound
If e.Item.ItemType = GridItemType.AlternatingItem Or e.Item.ItemType = GridItemType.Item Then
Dim dataBoundItem As GridDataItem = CType(e.Item, GridDataItem)
Dim expiryDate As Date = Date.Parse(dataBoundItem("col_ExpiryDate").Text)
If expiryDate = Null.NullDate Then
dataBoundItem("col_ExpiryDate").Text = "-"
Else
dataBoundItem("col_ExpiryDate").Text = expiryDate.ToShortDateString
End If
Dim effectiveDate As Date = Date.Parse(dataBoundItem("col_EffectiveDate").Text)
If effectiveDate = Null.NullDate Then
dataBoundItem("col_EffectiveDate").Text = User.Membership.CreatedDate.ToShortDateString
Else
dataBoundItem("col_EffectiveDate").Text = effectiveDate.ToShortDateString
End If
Dim btnApprove As ImageButton = CType(dataBoundItem("statusCol").FindControl("btnApproveUserRole"), ImageButton)
btnApprove.ImageUrl = ResolveUrl("~/images/grant.gif")
Dim currentRoleId As Integer = CType(btnApprove.CommandArgument, Integer)
Dim roleController As New RoleController
Dim userRoles As IList = roleController.GetUserRoles(PortalId, User.Username, "")
For Each userRole As UserRoleInfo In userRoles
If userRole.RoleID = currentRoleId Then
If userRole.Status = RoleStatus.Approved Then
btnApprove.Visible = False
End If
End If
Next
Dim btn As ImageButton = CType(dataBoundItem("removeCol").FindControl("btnDeleteUserRole"), ImageButton)
btn.ImageUrl = ResolveUrl("~/images/delete.gif")
If btn.CommandArgument = PortalSettings.RegisteredRoleId.ToString Then
btn.Visible = False
End If
If btn.CommandArgument = PortalSettings.AdministratorRoleId.ToString Then
btn.Visible = (User.UserID <> PortalSettings.AdministratorId)
End If
End If
End Sub
Private Sub btnAddToRole_Click(sender As Object, e As EventArgs) Handles btnAddToRole.Click
Dim roleController As New RoleController
Dim effectiveDate As Date = Date.Now
If Not ctlRoleDatFrom.DbSelectedDate Is Nothing Then
effectiveDate = ctlRoleDatFrom.DbSelectedDate
End If
Dim expiryDate As Date = Null.NullDate
If Not ctlRoleDateTo.DbSelectedDate Is Nothing Then
expiryDate = ctlRoleDateTo.DbSelectedDate
End If
Dim roleId As Integer = Null.NullInteger
If drpRoles.SelectedItem.Value <> "-1" Then
roleId = Convert.ToInt32(drpRoles.SelectedItem.Value)
End If
If roleId <> Null.NullInteger Then
roleController.AddUserRole(PortalId, User.UserID, roleId, effectiveDate, expiryDate)
lblRolesNote.Text = Localization.GetString("lblNotificationNote_Roles", LocalResourceFile)
BindRoleMembershipChangedNotification(drpRoles.SelectedItem.Text, Constants.TemplateName_EmailAddedToRole, effectiveDate, expiryDate)
DataCache.RemoveCache("DNNWERK_USERLIST_ROLEID" & roleId.ToString)
pnlRoleChange_Step1.Visible = False
pnlRoleChange_Step2.Visible = True
btnNotifyRole.CommandArgument = "add"
btnNotifyRoleSkip.CommandArgument = "add"
End If
End Sub
Protected Sub btnDeleteUserRole_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Dim roleId As Integer = Convert.ToInt32(CType(sender, ImageButton).CommandArgument)
Dim roleController As New RoleController
Dim role As RoleInfo = roleController.GetRole(roleId, PortalId)
roleController.DeleteUserRole(User, role, PortalSettings, False)
DataCache.RemoveCache("DNNWERK_USERLIST_ROLEID" & roleId.ToString)
Dim strRole As String = roleController.GetRole(roleId, PortalId).RoleName
lblRolesNote.Text = Localization.GetString("lblNotificationNote_Roles", LocalResourceFile)
BindRoleMembershipChangedNotification(role.RoleName, Constants.TemplateName_EmailRemovedFromRole, Null.NullDate, Null.NullDate)
pnlRoleChange_Step1.Visible = False
pnlRoleChange_Step2.Visible = True
btnNotifyRole.CommandArgument = "remove"
btnNotifyRoleSkip.CommandArgument = "remove"
End Sub
Protected Sub btnApproveUserRole_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Dim roleId As Integer = Convert.ToInt32(CType(sender, ImageButton).CommandArgument)
Dim roleController As New RoleController
Dim role As RoleInfo = roleController.GetRole(roleId, PortalId)
roleController.UpdateUserRole(PortalId, User.UserID, roleId, RoleStatus.Approved, False, False)
DataCache.RemoveCache("DNNWERK_USERLIST_ROLEID" & roleId.ToString)
Dim strRole As String = roleController.GetRole(roleId, PortalId).RoleName
lblRolesNote.Text = Localization.GetString("lblNotificationNote_Roles", LocalResourceFile)
BindRoleMembershipChangedNotification(role.RoleName, Constants.TemplateName_EmailRoleStatusChanged, Date.Now, Null.NullDate)
pnlRoleChange_Step1.Visible = False
pnlRoleChange_Step2.Visible = True
btnNotifyRole.CommandArgument = "approve"
btnNotifyRoleSkip.CommandArgument = "approve"
End Sub
Private Sub btnNotifyRoleSkip_Click(sender As Object, e As EventArgs) Handles btnNotifyRoleSkip.Click
lblRolesNote.Text = Localization.GetString("lblRolesChanged", LocalResourceFile)
grdUserRoles.Rebind()
pnlRoleChange_Step1.Visible = True
pnlRoleChange_Step2.Visible = False
End Sub
Private Sub btnNotifyRole_Click(sender As Object, e As EventArgs) Handles btnNotifyRole.Click
Dim strPassword As String = Localization.GetString("HiddenPassword", LocalResourceFile)
If MembershipProvider.Instance.PasswordRetrievalEnabled Then
strPassword = MembershipProvider.Instance().GetPassword(User, "")
End If
Dim strBody As String = txtNotifyRoleBody.Content.Replace(Localization.GetString("HiddenPassword", LocalResourceFile), strPassword)
Dim strSubject As String = txtNotifyRoleSubject.Text
If strSubject = "" Then
strSubject = Localization.GetString("txtNotifyRoleSubject", LocalResourceFile)
End If
DotNetNuke.Services.Mail.Mail.SendEmail(PortalSettings.Email, User.Email, strSubject, strBody)
lblRolesNote.Text = Localization.GetString("lblRolesChanged", LocalResourceFile)
grdUserRoles.Rebind()
pnlRoleChange_Step1.Visible = True
pnlRoleChange_Step2.Visible = False
End Sub
Private Sub cmdUpdateAccount_Click(sender As Object, e As EventArgs) Handles cmdUpdateAccount.Click
UpdateAccount()
ProcessFormTemplate(plhUser, GetTemplate(ModuleTheme, Constants.TemplateName_AccountForm, CurrentLocale, False), User)
End Sub
Private Sub cmdUpdateProfile_Click(sender As Object, e As EventArgs) Handles cmdUpdateProfile.Click
UpdateProfile()
ProcessFormTemplate(plhProfile, GetTemplate(ModuleTheme, Constants.TemplateName_ProfileForm, CurrentLocale, False), User)
End Sub
Private Sub cmdUpdateSites_Click(sender As Object, e As EventArgs) Handles cmdUpdateSites.Click
Dim uid As Integer = Convert.ToInt32(Request.QueryString("uid"))
Dim objCurrentUser As UserInfo = UserController.GetUserById(PortalId, uid)
Dim blnErrorOccured As Boolean = False
For Each cItem As ListItem In chkUserSites.Items
Dim pCtrl As New PortalController
Dim objPortal As PortalInfo = pCtrl.GetPortal(Convert.ToInt32(cItem.Value))
If Not objPortal Is Nothing Then
Dim objPortalUser As UserInfo = UserController.GetUserById(objPortal.PortalID, uid)
Try
If cItem.Selected Then
If cItem.Enabled Then
If objPortalUser Is Nothing Then
UserController.CopyUserToPortal(objCurrentUser, objPortal, False, False)
End If
End If
Else
If Not objPortalUser Is Nothing Then
UserController.RemoveUser(objPortalUser)
End If
End If
Catch ex As Exception
blnErrorOccured = True
End Try
End If
Next
If blnErrorOccured Then
lblSitesNote.Text = Localization.GetString("SitesError", LocalResourceFile)
Else
lblSitesNote.Text = Localization.GetString("SitesSuccess", LocalResourceFile)
End If
BindUserSites(uid)
End Sub
Private Sub cmdForcePasswordChange_Click(sender As Object, e As EventArgs) Handles cmdForcePasswordChange.Click
Dim oUser As UserInfo = User
oUser.Membership.UpdatePassword = True
UserController.UpdateUser(PortalId, oUser)
BindUser(oUser.UserID)
End Sub
Private Sub cmdUnlockAccount_Click(sender As Object, e As EventArgs) Handles cmdUnlockAccount.Click
Dim oUser As UserInfo = User
oUser.Membership.LockedOut = False
UserController.UpdateUser(PortalId, oUser)
BindUser(oUser.UserID)
End Sub
Private Sub cmdAuthorizeAccount_Click(sender As Object, e As EventArgs) Handles cmdAuthorizeAccount.Click
Dim oUser As UserInfo = User
oUser.Membership.Approved = True
UserController.UpdateUser(PortalId, oUser)
BindUser(oUser.UserID)
End Sub
Private Sub cmdRestoreAccount_Click(sender As Object, e As EventArgs) Handles cmdRestoreAccount.Click
If Request.IsAuthenticated = False Then
Exit Sub
End If
Dim TargetUserId As Integer = Null.NullInteger
If Request.QueryString("uid") Is Nothing Then
Exit Sub
Else
If IsNumeric(Request.QueryString("uid")) Then
TargetUserId = Convert.ToInt32(Request.QueryString("uid"))
End If
End If
If TargetUserId = Null.NullInteger Then
Exit Sub
End If
Dim TargetRoleId As Integer = Null.NullInteger
If Request.QueryString("RoleId") Is Nothing Then
Exit Sub
Else
If IsNumeric(Request.QueryString("RoleId")) Then
TargetRoleId = Convert.ToInt32(Request.QueryString("RoleId"))
End If
End If
Dim oUser As UserInfo = UserController.GetUserById(PortalId, TargetUserId)
If oUser Is Nothing Then
Exit Sub
End If
Try
UserController.RestoreUser(oUser)
Catch
End Try
ClearCache()
Response.Redirect(NavigateURL(TabId, "", "uid=" & oUser.UserID.ToString, "RoleId=" & TargetRoleId.ToString, "Action=Edit"), False)
Context.ApplicationInstance.CompleteRequest()
End Sub
Private Sub cmdDeleteAccount_Click(sender As Object, e As EventArgs) Handles cmdDeleteAccount.Click
If Request.IsAuthenticated = False Then
Exit Sub
End If
Dim TargetUserId As Integer = Null.NullInteger
If Request.QueryString("uid") Is Nothing Then
Exit Sub
Else
If IsNumeric(Request.QueryString("uid")) Then
TargetUserId = Convert.ToInt32(Request.QueryString("uid"))
End If
End If
If TargetUserId = Null.NullInteger Then
Exit Sub
End If
Dim TargetRoleId As Integer = Null.NullInteger
If Request.QueryString("RoleId") Is Nothing Then
Exit Sub
Else
If IsNumeric(Request.QueryString("RoleId")) Then
TargetRoleId = Convert.ToInt32(Request.QueryString("RoleId"))
End If
End If
Dim oUser As UserInfo = UserController.GetUserById(PortalId, TargetUserId)
If oUser Is Nothing Then
Exit Sub
End If
If oUser.IsDeleted Then
UserController.RemoveUser(oUser)
Else
UserController.DeleteUser(oUser, False, False)
End If
ClearCache()
Response.Redirect(NavigateURL(TabId, "", "RoleId=" & TargetRoleId.ToString), False)
Context.ApplicationInstance.CompleteRequest()
End Sub
Private Sub cmdCreateAccount_Click(sender As Object, e As EventArgs) Handles cmdCreateAccount.Click
BindUserCreateForm()
pnlCreateAccount.Visible = False
pnlBackToList.Visible = True
End Sub
Private Sub cmdAddAccount_Click(sender As Object, e As EventArgs) Handles cmdAddAccount.Click
AddAccount()
End Sub
Private Sub btnHardDelete_Click(sender As Object, e As EventArgs) Handles btnHardDelete.Click
UserController.RemoveDeletedUsers(PortalId)
ClearCache()
grdUsers.Rebind()
End Sub
Private Sub btnExport_Click(sender As Object, e As EventArgs) Handles btnExport.Click
Export()
End Sub
Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
If txtSearch.Text.Length > 0 Then
'Session("Connect_UserSearchTerm") = txtSearch.Text
SaveSearchOptions()
pnlGrid.Visible = True
pnlUser.Visible = False
pnlCreate.Visible = False
grdUsers.Rebind()
End If
End Sub
Private Sub cmdCancelCreate_Click(sender As Object, e As EventArgs) Handles cmdCancelCreate.Click
Response.Redirect(NavigateURL(TabId, "", "RoleId=" & Request.QueryString("RoleId")), False)
Context.ApplicationInstance.CompleteRequest()
End Sub
Private Sub cmdBulkDelete_Click(sender As Object, e As EventArgs) Handles cmdBulkDelete.Click
If AllowDelete Then
For i As Integer = 0 To grdUsers.SelectedItems.Count - 1
Dim intUser As Integer = Null.NullInteger
Try
Dim selecteditem As GridItem = grdUsers.SelectedItems(i)
Dim selectedvalue As String = selecteditem.OwnerTableView.DataKeyValues(selecteditem.ItemIndex)("UserId")
intUser = Convert.ToInt32(selectedvalue)
If intUser <> Null.NullInteger Then
Dim oUser As UserInfo = UserController.GetUserById(PortalId, intUser)
If Not oUser Is Nothing AndAlso Not oUser.IsSuperUser AndAlso Not oUser.UserID = PortalSettings.AdministratorId Then
UserController.DeleteUser(oUser, False, False)
End If
End If
Catch
End Try
Next
ClearCache()
grdUsers.Rebind()
End If
End Sub
Private Sub cmdHardDeleteSelected_Click(sender As Object, e As EventArgs) Handles cmdHardDeleteSelected.Click
For i As Integer = 0 To grdUsers.SelectedItems.Count - 1
Dim intUser As Integer = Null.NullInteger
Try
Dim selecteditem As GridItem = grdUsers.SelectedItems(i)
Dim selectedvalue As String = selecteditem.OwnerTableView.DataKeyValues(selecteditem.ItemIndex)("UserId")
intUser = Convert.ToInt32(selectedvalue)
If intUser <> Null.NullInteger Then
Dim oUser As UserInfo = UserController.GetUserById(PortalId, intUser)
UserController.RemoveUser(oUser)
End If
Catch
End Try
Next
ClearCache()
grdUsers.Rebind()
End Sub
Private Sub cmdBulkRemove_Click(sender As Object, e As EventArgs) Handles cmdBulkRemove.Click
Dim rc As New RoleController
Dim intRole As Integer = Convert.ToInt32(Request.QueryString("RoleId"))
Dim role As RoleInfo = rc.GetRole(intRole, PortalId)
For i As Integer = 0 To grdUsers.SelectedItems.Count - 1
Dim intUser As Integer = Null.NullInteger
Try
Dim selecteditem As GridItem = grdUsers.SelectedItems(i)
Dim selectedvalue As String = selecteditem.OwnerTableView.DataKeyValues(selecteditem.ItemIndex)("UserId")
intUser = Convert.ToInt32(selectedvalue)
If intUser <> Null.NullInteger Then
Dim oUser As UserInfo = UserController.GetUserById(PortalId, intUser)
If Not oUser Is Nothing AndAlso Not oUser.IsSuperUser AndAlso Not (oUser.UserID = PortalSettings.AdministratorId And intRole = PortalSettings.AdministratorRoleId) Then
RoleController.DeleteUserRole(oUser, role, PortalSettings, False)
End If
End If
Catch
End Try
Next
ClearCache()
grdUsers.Rebind()
End Sub
#End Region
#Region "Account E-Mail Event handlers"
Private Sub btnNotifyUser_Click(sender As Object, e As EventArgs) Handles btnNotifyUser.Click
Try
DotNetNuke.Services.Mail.Mail.SendEmail(PortalSettings.Email, User.Email, txtEmailSubjectAll.Text, txtEmailBodyAll.Content)
lblEmailNote.Text = Localization.GetString("MessageSent", LocalResourceFile)
Catch ex As Exception
lblEmailNote.Text = String.Format(Localization.GetString("MessageNotSent", LocalResourceFile), ex.Message)
End Try
End Sub
''' <summary>
''' Sends an email to a users
''' </summary>
''' <param name="user"></param>
''' <remarks></remarks>
Private Sub SendEmail(user As UserInfo, subject As String, body As String)
Dim strPassword As String = Localization.GetString("HiddenPassword", LocalResourceFile)
If MembershipProvider.Instance.PasswordRetrievalEnabled Then
strPassword = MembershipProvider.Instance().GetPassword(user, "")
End If
Dim strBody As String = body.Replace(Localization.GetString("HiddenPassword", LocalResourceFile), strPassword)
Dim strSubject As String = subject
DotNetNuke.Services.Mail.Mail.SendEmail(PortalSettings.Email, user.Email, strSubject, strBody)
End Sub
#End Region
#Region "Account Message Event handlers"
Private Sub btnSendMessage_Click(sender As Object, e As EventArgs) Handles btnSendMessage.Click
Try
Dim users As New List(Of UserInfo)
users.Add(User)
SendMessage(users, txtMessageSubject.Text, txtMessageBody.Text)
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, Localization.GetString("InternalMessagesSent", LocalResourceFile), Skins.Controls.ModuleMessage.ModuleMessageType.GreenSuccess)
Catch ex As Exception
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, String.Format(Localization.GetString("InternalMessagesNotSent", LocalResourceFile), ex.Message), Skins.Controls.ModuleMessage.ModuleMessageType.RedError)
End Try
End Sub
Private Sub btnSendMessages_Click(sender As Object, e As EventArgs) Handles btnSendMessages.Click
Dim recipients As New List(Of UserInfo)
Dim ds As DataSet = Nothing
Dim strError As String = ""
If ctlRoles.SelectedNode Is Nothing Then
_IsReportResult = True
End If
If _IsReportResult Then
ds = GetReportResult(strError)
Else
ds = GetUserList()
End If
Select Case rblMessagingMode.SelectedValue
Case "e"
Dim resultMsg As String = ""
For Each row As DataRow In ds.Tables(0).Rows
Try
DotNetNuke.Services.Mail.Mail.SendEmail(PortalSettings.Email, row("EMail"), txtEmailSubjectAll.Text, txtEmailBodyAll.Content)
Catch ex As Exception
resultMsg += ex.Message + "<br/>"
End Try
Next
If resultMsg = "" Then
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, Localization.GetString("MessagesSent", LocalResourceFile), Skins.Controls.ModuleMessage.ModuleMessageType.GreenSuccess)
Else
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, String.Format(Localization.GetString("MessagesNotSent", LocalResourceFile), resultMsg), Skins.Controls.ModuleMessage.ModuleMessageType.RedError)
End If
Case "m"
For Each row As DataRow In ds.Tables(0).Rows
Dim oUser As UserInfo = UserController.GetUserById(PortalId, row("UserId"))
If Not oUser Is Nothing Then
recipients.Add(oUser)
End If
Next
Try
SendMessage(recipients, txtEmailSubjectAll.Text, txtEmailBodyAll.Content)
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, Localization.GetString("InternalMessageSent", LocalResourceFile), Skins.Controls.ModuleMessage.ModuleMessageType.GreenSuccess)
Catch ex As Exception
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, String.Format(Localization.GetString("InternalMessageNotSent", LocalResourceFile), ex.Message), Skins.Controls.ModuleMessage.ModuleMessageType.RedError)
End Try
End Select
End Sub
''' <summary>
''' Sends a message to a list of users
''' </summary>
''' <param name="users"></param>
''' <remarks></remarks>
Private Sub SendMessage(users As List(Of UserInfo), subject As String, body As String)
Dim strPassword As String = Localization.GetString("HiddenPassword", LocalResourceFile)
If MembershipProvider.Instance.PasswordRetrievalEnabled Then
strPassword = MembershipProvider.Instance().GetPassword(User, "")
End If
Dim strBody As String = body.Replace(Localization.GetString("HiddenPassword", LocalResourceFile), strPassword)
Dim strSubject As String = subject
Dim message As New DotNetNuke.Services.Social.Messaging.Message()
message.Subject = strSubject
message.Body = strBody
DotNetNuke.Services.Social.Messaging.MessagingController.Instance.SendMessage(message, Nothing, users, Nothing)
End Sub
#End Region
#Region "Password Update Event Handlers"
Private Sub cmdResetPasswordLink_Click(sender As Object, e As EventArgs) Handles cmdResetPasswordLink.Click
pnlResetButton.Visible = False
pnlPassword_Step1.Visible = False
pnlPassword_Step2.Visible = True
BindPasswordNotification()
End Sub
Private Sub cmdUpdatePassword_Click(sender As Object, e As EventArgs) Handles cmdUpdatePassword.Click
Dim blnProceed As Boolean = True
'verifiy passwords have been entered and both passwords match
If txtPassword1.Text = txtPassword2.Text Then
If UserController.ValidatePassword(txtPassword1.Text) Then
blnProceed = True
Else
Me.lblPasswordNote.Text = Localization.GetString("PasswordPoliciesError", LocalResourceFile)
blnProceed = False
End If
Else
Me.lblPasswordNote.Text = Localization.GetString("PasswordMatchError", LocalResourceFile)
blnProceed = False
End If
If blnProceed Then
Dim strPassword As String = ""
strPassword = txtPassword1.Text
Try
If UserController.ChangePassword(User, "", strPassword) Then
lblPasswordNote.Text = Localization.GetString("PasswordSetNotifyQuestion", LocalResourceFile)
pnlPassword_Step1.Visible = False
pnlPassword_Step2.Visible = True
BindPasswordNotification()
Else
Me.lblPasswordNote.Text = Localization.GetString("PasswordResetError", LocalResourceFile)
End If
Catch ex As Exception
Me.lblPasswordNote.Text = Localization.GetString("CannotUsePassword", LocalResourceFile)
End Try
End If
End Sub
Private Sub btnNotifyPassword_Click(sender As Object, e As EventArgs) Handles btnNotifyPassword.Click
Dim strPassword As String = Localization.GetString("HiddenPassword", LocalResourceFile)
If MembershipProvider.Instance.PasswordRetrievalEnabled Then
strPassword = MembershipProvider.Instance().GetPassword(User, "")
End If
Dim strBody As String = txtNotifyPasswordBody.Content.Replace(Localization.GetString("HiddenPassword", LocalResourceFile), strPassword)
Dim strSubject As String = txtNotifyPasswordSubject.Text
If strSubject = "" Then
strSubject = Localization.GetString("txtNotifyPasswordSubject", LocalResourceFile)
End If
Try
DotNetNuke.Services.Mail.Mail.SendEmail(PortalSettings.Email, User.Email, strSubject, strBody)
Me.lblPasswordNote.Text = Localization.GetString("UserNotifiedPassword", LocalResourceFile)
If MembershipProvider.Instance.PasswordRetrievalEnabled = False AndAlso MembershipProvider.Instance.PasswordResetEnabled = True Then
Me.lblPasswordNote.Text = Localization.GetString("UserNotifiedReset", LocalResourceFile)
End If
Catch ex As Exception
Me.lblPasswordNote.Text = String.Format(Localization.GetString("MessageNotSent.Text", LocalResourceFile), ex.Message)
End Try
If MembershipProvider.Instance.PasswordRetrievalEnabled = False AndAlso MembershipProvider.Instance.PasswordResetEnabled = True Then
pnlResetButton.Visible = True
pnlPassword_Step1.Visible = False
pnlPassword_Step2.Visible = False
txtPassword1.Text = ""
txtPassword2.Text = ""
Else
If MembershipProvider.Instance.PasswordRetrievalEnabled = True Then
pnlResetButton.Visible = False
pnlPassword_Step1.Visible = True
pnlPassword_Step2.Visible = False
txtPassword1.Text = ""
txtPassword2.Text = ""
End If
End If
End Sub
Private Sub btnNotifyPasswordSkip_Click(sender As Object, e As EventArgs) Handles btnNotifyPasswordSkip.Click
Me.lblPasswordNote.Text = Localization.GetString("PasswordSet", LocalResourceFile)
pnlPassword_Step1.Visible = True
pnlPassword_Step2.Visible = False
txtPassword1.Text = ""
txtPassword2.Text = ""
End Sub
Private Sub BindPasswordNotification()
Dim Locale As String = CurrentLocale
If Not String.IsNullOrEmpty(User.Profile.PreferredLocale) Then
Locale = User.Profile.PreferredLocale
End If
UserController.ResetPasswordToken(User, 1440)