-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEditPartner.ascx.vb
168 lines (149 loc) · 5.86 KB
/
EditPartner.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
'
' Copyright (c) 2004-2011 DNN-Europe, http://www.dnn-europe.net
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this
' software and associated documentation files (the "Software"), to deal in the Software
' without restriction, including without limitation the rights to use, copy, modify, merge,
' publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
' to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or
' substantial portions of the Software.
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
' INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
' PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
' FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
' ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'
Imports System
Imports System.Web.UI
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Common
Imports DNNEurope.Modules.LocalizationEditor.Entities.Partners
Imports DNNEurope.Modules.LocalizationEditor.Services.DataExchange
Public Class EditPartner
Inherits ModuleBase
#Region " Controls "
#End Region
#Region " Variables "
Dim _partnerId As Int32 = -1
Dim _partner As PartnerInfo = Nothing
Dim _dl As Boolean = False
Dim _override As Boolean = False
#End Region
#Region " Event Handlers "
Private Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
Globals.ReadValue(Request.Params, "PartnerId", _partnerId)
Globals.ReadValue(Request.Params, "dl", _dl)
Globals.ReadValue(Request.Params, "o", _override)
If _partnerId <> -1 Then
_partner = PartnersController.GetPartner(_partnerId)
If _partner IsNot Nothing AndAlso _partner.ModuleId <> ModuleId Then
_partner = Nothing
Response.Redirect(AccessDeniedURL(), True)
End If
End If
If _partnerId = -1 Then
cmdUpdate.Enabled = False
cmdDelete.Enabled = False
End If
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
DotNetNuke.UI.Utilities.ClientAPI.AddButtonConfirm(cmdDelete, DotNetNuke.Services.Localization.Localization.GetString("Delete.Confirm", Me.LocalResourceFile))
If _partnerId <> -1 Then
pnlDetails.Visible = True
'tblCubeUrl.Visible = False
txtCubeUrl.Enabled = False
If Not _partner Is Nothing Then
'set screen
With _partner
chkAllowDirectDownload.Checked = .AllowDirectDownload
chkAllowRedistribute.Checked = .AllowRedistribute
txtCubeUrl.Text = .CubeUrl
chkDownloadAffiliates.Checked = .DownloadAffiliates
txtPackUrl.Text = .PackUrl
txtPartnerName.Text = .PartnerName
txtPartnerUrl.Text = .PartnerUrl
txtPartnerUsername.Text = .PartnerUsername
End With
Else ' security violation attempt to access item not related to this Module
Response.Redirect(AccessDeniedURL(), True)
End If
Else
'Initialize New Record
pnlDetails.Visible = False
tblCubeUrl.Visible = True
End If
Else
'its a postback
End If
End Sub
Private Sub cmdUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdUpdate.Click
Try
' Only Update if the Entered Data is Valid
If Page.IsValid = True Then
'bind text values to object
With _partner
'set values
.AllowRedistribute = chkAllowRedistribute.Checked
.DownloadAffiliates = chkDownloadAffiliates.Checked
.PartnerUsername = txtPartnerUsername.Text
End With
PartnersController.UpdatePartner(_partner)
Response.Redirect(EditUrl("Partners"), False)
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdCancel.Click
Try
Response.Redirect(EditUrl("Partners"), False)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdDelete_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdDelete.Click
Try
If Not _partnerId = -1 Then
PartnersController.DeletePartner(_partnerId)
End If
Response.Redirect(EditUrl("Partners"), False)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdDownload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdDownload.Click
Dim reload As Boolean = False
If _partner Is Nothing Then
_partner = New PartnerInfo
With _partner
.PartnerName = "New Partner"
.CubeUrl = txtCubeUrl.Text
.ModuleId = ModuleId
_partnerId = PartnersController.AddPartner(_partner)
.PartnerId = _partnerId
End With
cmdDownload.Enabled = False
txtCubeUrl.Enabled = False
cmdUpdate.Enabled = True
reload = True
End If
With _partner
'set values
.AllowRedistribute = chkAllowRedistribute.Checked
.DownloadAffiliates = chkDownloadAffiliates.Checked
.PartnerUsername = txtPartnerUsername.Text
End With
Dim fImport As New FeedImporter(_partner)
fImport.ImportFeed(chkImportOverride.Checked)
_partner = PartnersController.GetPartner(_partnerId)
txtPartnerName.Text = _partner.PartnerName
txtPartnerUrl.Text = _partner.PartnerUrl
txtPackUrl.Text = _partner.PartnerUrl
plhDownload.Controls.Add(New LiteralControl(fImport.Log.ToString))
If reload Then Response.Redirect(EditUrl("PartnerId", _partnerId.ToString, "EditPartner"), False)
End Sub
#End Region
End Class