-
Notifications
You must be signed in to change notification settings - Fork 2
/
AddFolder.ascx.vb
executable file
·220 lines (159 loc) · 7.75 KB
/
AddFolder.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
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Modules.Actions
Imports DotNetNuke.Security
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.FileSystem
Imports DotNetNuke.Services.Localization
Imports Ventrian.FileLinks.Entities
Imports Ventrian.FileLinks.Base
Imports System.IO
Namespace Ventrian.FileLinks
Partial Public Class AddFolder
Inherits FileLinksBase
#Region " Private Members "
Private _folderID As Integer = Null.NullInteger
Private _editFolderID As Integer = Null.NullInteger
#End Region
#Region " Private Methods "
Private Sub BindCrumbs()
Dim objCrumbs As New List(Of CrumbInfo)
Dim objCrumbHome As New CrumbInfo
objCrumbHome.Url = NavigateURL()
objCrumbHome.Caption = Localization.GetString("Home", Me.LocalResourceFile)
objCrumbs.Add(objCrumbHome)
Dim objCrumb As New CrumbInfo
objCrumb.Url = Request.RawUrl
objCrumb.Caption = Localization.GetString("AddFolder", Me.LocalResourceFile)
objCrumbs.Add(objCrumb)
rptBreadCrumbs.DataSource = objCrumbs
rptBreadCrumbs.DataBind()
End Sub
Private Sub BindFolders()
Dim folderPath As String = Null.NullString()
If (LinkSettings.FolderID <> Null.NullInteger) Then
Dim folderIDs As ArrayList = FileSystemUtils.GetFolders(Me.PortalId)
For Each folder As FolderInfo In folderIDs
If (folder.FolderID = LinkSettings.FolderID) Then
folderPath = folder.FolderPath
End If
Next
End If
Dim folders As ArrayList = FileSystemUtils.GetFolders(PortalId)
For Each folder As FolderInfo In folders
If (folderPath = Null.NullString Or folder.FolderPath.StartsWith(folderPath)) Then
Dim FolderItem As New ListItem
If folder.FolderPath = Null.NullString Then
FolderItem.Text = Localization.GetString("Root", Me.LocalResourceFile)
Else
FolderItem.Text = folder.FolderPath
End If
FolderItem.Value = folder.FolderID
If (_folderID <> Null.NullInteger) Then
If (_folderID = folder.FolderID) Then
FolderItem.Selected = True
End If
Else
If (LinkSettings.FolderID <> Null.NullInteger) Then
If (LinkSettings.FolderID = folder.FolderID) Then
FolderItem.Selected = True
End If
End If
End If
drpFolders.Items.Add(FolderItem)
End If
Next
End Sub
Private Sub CheckSecurity()
Dim objModuleSecurity As New ModuleSecurity(ModuleConfiguration, Settings)
If (IsEditable = False And objModuleSecurity.AddFolderPermission = False) Then
Response.Redirect(NavigateURL(), True)
End If
End Sub
Private Sub ReadQueryString()
If (Request("FolderID") <> "" AndAlso IsNumeric(Request("FolderID"))) Then
_folderID = Convert.ToInt32(Request("FolderID"))
End If
If (Request("EditFolderID") <> "" AndAlso IsNumeric(Request("EditFolderID"))) Then
_folderID = Convert.ToInt32(Request("EditFolderID"))
End If
End Sub
#End Region
#Region " Event Handlers "
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
CheckSecurity()
ReadQueryString()
BindCrumbs()
If (Page.IsPostBack = False) Then
BindFolders()
txtFolder.Focus()
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Protected Sub drpFolders_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles drpFolders.SelectedIndexChanged
Try
Response.Redirect(EditUrl("FolderID", drpFolders.SelectedValue, "AddFolder"), True)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Protected Sub cmdUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdUpdate.Click
Try
If (Page.IsValid) Then
Dim folders As ArrayList = FileSystemUtils.GetFolders(PortalSettings.PortalId)
For Each folder As FolderInfo In folders
If (folder.FolderID = Convert.ToInt32(drpFolders.SelectedValue)) Then
FileSystemUtils.AddFolder(PortalSettings, folder.PhysicalPath, txtFolder.Text)
If (Convert.ToInt32(drpFolders.SelectedValue) <> LinkSettings.FolderID) Then
Response.Redirect(NavigateURL(Me.TabId, "", "FolderID=" & _folderID.ToString()), True)
Else
Response.Redirect(NavigateURL(), True)
End If
Exit For
End If
Next
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Protected Sub cmdCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdCancel.Click
Try
If (_folderID <> Null.NullInteger) Then
Response.Redirect(NavigateURL(Me.TabId, "", "FolderID=" & _folderID.ToString()), True)
Else
Response.Redirect(NavigateURL(), True)
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
'Protected Sub cmdDelete_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdDelete.Click
' Try
' Dim folders As ArrayList = FileSystemUtils.GetFolders(PortalSettings.PortalId)
' For Each folder As FolderInfo In folders
' If (folder.FolderID = Convert.ToInt32(drpFolders.SelectedValue)) Then
' Dim objDirectory As New DirectoryInfo(folder.PhysicalPath)
' If (objDirectory.Exists) Then
' objDirectory.Delete(True)
' End If
' If (Convert.ToInt32(drpFolders.SelectedValue) <> LinkSettings.FolderID) Then
' Response.Redirect(NavigateURL(Me.TabId, "", "FolderID=" & _folderID.ToString()), True)
' Else
' Response.Redirect(NavigateURL(), True)
' End If
' Exit For
' End If
' Next
' FileSystemUtils.DeleteFolder(Me.PortalId,
' Catch exc As Exception 'Module failed to load
' ProcessModuleLoadException(Me, exc)
' End Try
'End Sub
#End Region
End Class
End Namespace