forked from DNNCommunity/DNN.Links
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.ascx.vb
554 lines (421 loc) · 23.3 KB
/
Settings.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
'
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2008
' by DotNetNuke Corporation
'
' 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.Web.UI.WebControls
Imports DotNetNuke
Imports DotNetNuke.Entities.Modules
Imports System.Collections.Generic
Imports DotNetNuke.Security.Permissions
Imports System.Xml
Imports System.Linq
Imports DotNetNuke.Application
Imports DotNetNuke.Services.FileSystem
Namespace DotNetNuke.Modules.Links
''' -----------------------------------------------------------------------------
''' <summary>
''' The Settings ModuleSettingsBase is used to manage the
''' settings for the Links Module
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/23/2004 Moved Links to a separate Project
''' [cnurse] 9/23/2004 Updated to reflect design changes for Help, 508 support
''' and localisation
''' [cnurse] 10/20/2004 Converted to a ModuleSettingsBase class
''' </history>
''' -----------------------------------------------------------------------------
Partial Class Settings
Inherits Entities.Modules.ModuleSettingsBase
Public Const BUSINESSCARDMODE As String = "BusinessCardMode"
Public Const NORMALMODE As String = "NormalMode"
#Region " Base Method Implementations "
''' -----------------------------------------------------------------------------
''' <summary>
''' LoadSettings loads the settings from the Databas and displays them
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 10/20/2004 created
''' </history>
''' -----------------------------------------------------------------------------
Public Overrides Sub LoadSettings()
Try
If (Page.IsPostBack = False) Then
' 2014 TODO: Menu
If CType(ModuleSettings(SettingName.MenuAllUsers), String) <> String.Empty Then
Dim item As ListItem = optMenuAllUsers.Items.FindByValue(CType(ModuleSettings(SettingName.MenuAllUsers), String))
If item IsNot Nothing Then
item.Selected = True
End If
Else
optMenuAllUsers.SelectedIndex = 0
End If
If CType(ModuleSettings(SettingName.DisplayMode), String) <> String.Empty Then
optControl.Items.FindByValue(CType(ModuleSettings(SettingName.DisplayMode), String)).Selected = True
pnlWrap.Visible = ShowWrapPanel
Else
optControl.SelectedIndex = 0 ' list
End If
If CType(ModuleSettings(SettingName.Direction), String) <> String.Empty Then
optView.Items.FindByValue(CType(ModuleSettings(SettingName.Direction), String)).Selected = True
Else
optView.SelectedIndex = 0 ' vertical
End If
If CType(ModuleSettings(SettingName.LinkDescriptionMode), String) <> "" Then
optInfo.Items.FindByValue(CType(ModuleSettings(SettingName.LinkDescriptionMode), String)).Selected = True
Else
optInfo.SelectedIndex = 1
End If
trOptView.Visible = Not optControl.SelectedValue = Consts.DisplayModeDropdown
Dim version As String = DotNetNukeContext.Current.Application.Version.ToString(3)
If Not String.IsNullOrEmpty(version) _
AndAlso Convert.ToInt16(version.Substring(0, 1)) > 5 Then
optInfo.Items(2).Enabled = True
Else
optInfo.Items(2).Enabled = False
End If
If CType(ModuleSettings(SettingName.Icon), String) <> String.Empty Then
ctlIcon.Url = CType(ModuleSettings(SettingName.Icon), String)
End If
If CType(ModuleSettings("nowrap"), String) <> String.Empty Then
optNoWrap.Items.FindByValue(CType(ModuleSettings("nowrap"), String)).Selected = True
Else
optNoWrap.SelectedIndex = 1
End If
If CType(ModuleSettings(SettingName.UsePermissions), String) <> String.Empty Then
optUsePermissions.Items.FindByValue(CType(ModuleSettings(SettingName.UsePermissions), String)).Selected = True
Else
optUsePermissions.SelectedIndex = 0
End If
If CType(ModuleSettings(SettingName.ModuleContentType), String) <> String.Empty Then
optLinkModuleType.Items.FindByValue(CType(ModuleSettings(SettingName.ModuleContentType), String)).Selected = True
pnlIcon.Visible = ShowIconPanel
End If
LoadContentData(CType(ModuleSettings(SettingName.ModuleContentType), String))
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Public Sub LoadContentData(ByVal pContentType As String)
'optTypeContentSelection.Visible = True
plControl.Visible = True
optControl.Visible = True
ploptView.Visible = True
optView.Visible = True
plInfo.Visible = True
optInfo.Visible = True
plNoWrap.Visible = True
optNoWrap.Visible = True
plUsePermissions.Visible = True
optUsePermissions.Visible = True
plIcon.Visible = True
ctlIcon.Visible = True
plDisplayAttribute.Visible = False
optDisplayAttribute.Visible = False
optDisplayOrder.Visible = False
' 2014 TODO: Menu
plMenuAllUsers.Visible = False
optMenuAllUsers.Visible = False
Select Case CType(pContentType, Enums.ModuleContentTypes)
Case Enums.ModuleContentTypes.Links
optUsePermissions.Visible = True
plUsePermissions.Visible = True
optTypeContentSelection.Visible = False
Case Enums.ModuleContentTypes.Menu
optTypeContentSelection.Visible = True
Dim dnnTabController As New TabController
Dim portalTabs As TabCollection = dnnTabController.GetTabsByPortal(PortalId)
Dim hostTabs As TabCollection = dnnTabController.GetTabsByPortal(-1)
Dim tabs As New TabCollection
AddTabsToCollection(portalTabs, tabs)
AddTabsToCollection(hostTabs, tabs)
Dim listTabs As New List(Of DotNetNuke.Entities.Tabs.TabInfo)
For Each kvp As Generic.KeyValuePair(Of Integer, DotNetNuke.Entities.Tabs.TabInfo) In tabs
listTabs.Add(kvp.Value)
Next
optTypeContentSelection.DataSource = listTabs
optTypeContentSelection.DataValueField = "TabID"
optTypeContentSelection.DataTextField = "TabPath"
optTypeContentSelection.DataBind()
If CType(ModuleSettings(Consts.ModuleContentItem), String) <> String.Empty Then
Dim item As ListItem = optTypeContentSelection.Items.FindByValue(CType(ModuleSettings(Consts.ModuleContentItem), String))
If item IsNot Nothing Then
item.Selected = True
End If
End If
optUsePermissions.Visible = False
plUsePermissions.Visible = False
' 2014 TODO: Menu
plMenuAllUsers.Visible = True
optMenuAllUsers.Visible = True
Case Enums.ModuleContentTypes.Folder
Dim folderCont As New DotNetNuke.Services.FileSystem.FolderController
Dim dic As Generic.List(Of DotNetNuke.Services.FileSystem.IFolderInfo) = FolderManager.Instance.GetFolders(Me.PortalId).ToList()
Dim folders As New Generic.List(Of DotNetNuke.Services.FileSystem.IFolderInfo)
Dim folderPermissionsController As New FolderPermissionController
For Each folder In dic
If FolderPermissionController.HasFolderPermission(Me.PortalId, folder.FolderPath, "READ") Then
folders.Add(folder)
End If
Next
optTypeContentSelection.DataSource = folders
optTypeContentSelection.DataValueField = "FolderID"
optTypeContentSelection.DataTextField = "FolderPath"
optTypeContentSelection.DataBind()
For Each item As ListItem In optTypeContentSelection.Items
If String.IsNullOrEmpty(item.Text) Then
item.Text = "Root"
End If
Next
optTypeContentSelection.Visible = True
optUsePermissions.Visible = False
plUsePermissions.Visible = False
If Not String.IsNullOrEmpty(ModuleSettings(Consts.ModuleContentItem)) Then
Dim moduleContentItem As String = ModuleSettings(Consts.ModuleContentItem)
Dim hasItem As Boolean = False
For Each item As ListItem In optTypeContentSelection.Items
If item.Value = moduleContentItem Then
hasItem = True
Exit For
End If
Next
If hasItem Then
optTypeContentSelection.SelectedValue = ModuleSettings(Consts.ModuleContentItem)
End If
End If
Case Enums.ModuleContentTypes.Friends
optTypeContentSelection.Visible = True
plControl.Visible = True
optControl.Visible = True
ploptView.Visible = True
optView.Visible = True
plInfo.Visible = True
optInfo.Visible = True
plNoWrap.Visible = True
optNoWrap.Visible = True
plDisplayAttribute.Visible = True
optDisplayAttribute.Visible = True
optDisplayOrder.Visible = True
plUsePermissions.Visible = False
optUsePermissions.Visible = False
plIcon.Visible = False
ctlIcon.Visible = False
optTypeContentSelection.Items.Clear()
optTypeContentSelection.ClearSelection()
optDisplayAttribute.ClearSelection()
optDisplayOrder.ClearSelection()
' normal und business card
Dim modeList As ArrayList = New ArrayList
Dim modeNormal As Object = New With {.ModeID = "NormalMode", .Mode = "Normal"}
Dim modeBusinessCard As Object = New With {.ModeID = "BusinessCardMode", .Mode = "Business Card"}
modeList.Add(modeNormal)
modeList.Add(modeBusinessCard)
optTypeContentSelection.DataSource = modeList
optTypeContentSelection.DataValueField = "ModeID"
optTypeContentSelection.DataTextField = "Mode"
optTypeContentSelection.DataBind()
If CType(ModuleSettings(Consts.ModuleContentItem), String) <> String.Empty Then
Dim item As ListItem = optTypeContentSelection.Items.FindByValue(CType(ModuleSettings(Consts.ModuleContentItem), String))
If item IsNot Nothing Then
item.Selected = True
If item.Value.Equals(BUSINESSCARDMODE) Then
plControl.Visible = False
optControl.Visible = False
ploptView.Visible = False
optView.Visible = False
plInfo.Visible = False
optInfo.Visible = False
plNoWrap.Visible = False
optNoWrap.Visible = False
plDisplayAttribute.Visible = False
optDisplayAttribute.Visible = False
optDisplayOrder.Visible = False
End If
End If
End If
If CType(ModuleSettings(SettingName.DisplayAttribute), String) <> String.Empty Then
Dim item As ListItem = optDisplayAttribute.Items.FindByValue(CType(ModuleSettings(SettingName.DisplayAttribute), String))
If item IsNot Nothing Then
item.Selected = True
End If
End If
If CType(ModuleSettings(SettingName.DisplayAttribute), String) <> String.Empty Then
Dim item As ListItem = optDisplayOrder.Items.FindByValue(CType(ModuleSettings(SettingName.DisplayOrder), String))
If item IsNot Nothing Then
item.Selected = True
End If
End If
End Select
End Sub
Private Sub AddTabsToCollection(ByVal inTabs As TabCollection, ByVal outtabs As TabCollection)
' 1.0.2 - Workaround for dnn powered content localization - [alexander.zimmer] & [simon.meraner]
' serialize tab object in order to be able to identify whether the content localization is active.
Dim tabSerializer As New System.Xml.Serialization.XmlSerializer(GetType(DotNetNuke.Entities.Tabs.TabInfo))
For Each kvp As Generic.KeyValuePair(Of Integer, DotNetNuke.Entities.Tabs.TabInfo) In inTabs
If Not outtabs.ContainsKey(kvp.Key) Then
Dim stream As New System.IO.StringWriter()
tabSerializer.Serialize(stream, kvp.Value)
Dim sr As System.IO.StringReader = New System.IO.StringReader(stream.ToString)
Dim xmlDoc As New XmlDocument
xmlDoc.Load(sr)
stream.Close()
Dim tabCulture As XmlElement = xmlDoc.SelectSingleNode("/tab/cultureCode")
Dim showCulture As Boolean = True
If tabCulture IsNot Nothing Then
Dim cultureNode As XmlNode = tabCulture.FirstChild
' dnn 5.5.x detected ... exclude tabs where the cultures doesn`t matcj the current culture
If cultureNode IsNot Nothing AndAlso cultureNode.Value <> System.Threading.Thread.CurrentThread.CurrentCulture.Name Then
showCulture = False
End If
End If
' -------------------------------------------------------------------------------------------------------
If showCulture Then
outtabs.Add(kvp.Key, kvp.Value)
End If
End If
Next
End Sub
''' -----------------------------------------------------------------------------
''' <summary>
''' UpdateSettings saves the modified settings to the Database
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 10/20/2004 created
''' [cnurse] 10/25/2004 upated to use TabModuleId rather than TabId/ModuleId
''' </history>
''' -----------------------------------------------------------------------------
Public Overrides Sub UpdateSettings()
Try
Dim objModules As New Entities.Modules.ModuleController
' 2014 TODO: Menu
objModules.UpdateModuleSetting(ModuleId, SettingName.DisplayMode, optControl.SelectedItem.Value)
objModules.UpdateModuleSetting(ModuleId, SettingName.Direction, optView.SelectedItem.Value)
objModules.UpdateModuleSetting(ModuleId, SettingName.LinkDescriptionMode, optInfo.SelectedItem.Value)
objModules.UpdateModuleSetting(ModuleId, SettingName.Icon, ctlIcon.Url)
objModules.UpdateModuleSetting(ModuleId, "nowrap", optNoWrap.SelectedItem.Value)
objModules.UpdateModuleSetting(ModuleId, SettingName.ModuleContentType, optLinkModuleType.SelectedValue)
objModules.UpdateModuleSetting(ModuleId, SettingName.UsePermissions, optUsePermissions.SelectedValue)
'objModules.UpdateModuleSetting(ModuleId, "usepopup", optUsePopup.SelectedValue)
objModules.UpdateModuleSetting(ModuleId, SettingName.DisplayAttribute, optDisplayAttribute.SelectedValue)
objModules.UpdateModuleSetting(ModuleId, SettingName.DisplayOrder, optDisplayOrder.SelectedValue)
' 2014 TODO
objModules.UpdateModuleSetting(ModuleId, SettingName.MenuAllUsers, optMenuAllUsers.SelectedValue)
Select Case CType(optLinkModuleType.SelectedValue, Enums.ModuleContentTypes)
Case Enums.ModuleContentTypes.Menu
objModules.UpdateModuleSetting(ModuleId, Consts.ModuleContentItem, optTypeContentSelection.SelectedValue)
Case Enums.ModuleContentTypes.Folder
objModules.UpdateModuleSetting(ModuleId, Consts.ModuleContentItem, optTypeContentSelection.SelectedValue)
objModules.UpdateModuleSetting(ModuleId, Consts.FolderId, optTypeContentSelection.SelectedValue)
Case Enums.ModuleContentTypes.Friends
objModules.UpdateModuleSetting(ModuleId, Consts.ModuleContentItem, optTypeContentSelection.SelectedValue)
Case Else
End Select
Dim allowCaching As Boolean = True
If optControl.SelectedItem.Value = Consts.DisplayModeDropdown Then
allowCaching = False
End If
If optInfo.SelectedItem.Value = "Y" Then
allowCaching = False
End If
If Not allowCaching Then
Dim objModule As DotNetNuke.Entities.Modules.ModuleInfo = objModules.GetModule(ModuleId, TabId, False)
If objModule.CacheTime > 0 Then
objModule.CacheTime = 0
objModules.UpdateModule(objModule)
End If
End If
ModuleController.SynchronizeModule(ModuleId)
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
#Region " Event Handlers "
Protected Sub optLinkModuleType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles optLinkModuleType.SelectedIndexChanged
Try
pnlIcon.Visible = ShowIconPanel
LoadContentData(optLinkModuleType.SelectedValue)
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Sub
Protected Sub optControl_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles optControl.SelectedIndexChanged
pnlWrap.Visible = ShowWrapPanel
If ShowWrapPanel Then
optNoWrap.SelectedValue = "NW"
End If
trOptView.Visible = Not optControl.SelectedValue = Consts.DisplayModeDropdown
End Sub
Protected Sub optTypeContentSelection_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles optTypeContentSelection.SelectedIndexChanged
If CType(optLinkModuleType.SelectedValue, Enums.ModuleContentTypes).Equals(Enums.ModuleContentTypes.Friends) Then
If optTypeContentSelection.Text.Equals(BUSINESSCARDMODE) Then
plControl.Visible = False
optControl.Visible = False
ploptView.Visible = False
optView.Visible = False
plInfo.Visible = False
optInfo.Visible = False
plNoWrap.Visible = False
optNoWrap.Visible = False
plDisplayAttribute.Visible = False
optDisplayAttribute.Visible = False
optDisplayOrder.Visible = False
Else
plControl.Visible = True
optControl.Visible = True
ploptView.Visible = True
optView.Visible = True
plInfo.Visible = True
optInfo.Visible = True
plNoWrap.Visible = True
optNoWrap.Visible = True
plDisplayAttribute.Visible = True
optDisplayAttribute.Visible = True
optDisplayOrder.Visible = True
End If
End If
End Sub
#End Region
#Region " Properties "
Public ReadOnly Property ShowIconPanel() As Boolean
Get
Dim result As Boolean = False
If optLinkModuleType.SelectedValue = 1 Then
result = True
End If
Return result
End Get
End Property
Public ReadOnly Property ShowWrapPanel() As String
Get
Dim result As Boolean = False
If optControl.SelectedValue <> Consts.DisplayModeDropdown Then
result = True
End If
Return result
End Get
End Property
#End Region
End Class
End Namespace