forked from DNNCommunity/DNN.Links
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Links.ascx.vb
1290 lines (904 loc) · 48.5 KB
/
Links.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
'
' 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.
'
'Option Strict On
Imports System.Web.UI.WebControls
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Security.Roles
Imports System.IO
Imports DotNetNuke.Services.FileSystem
Imports System.Xml
Imports DotNetNuke.Entities.Users
Imports System.Collections.Generic
Imports DotNetNuke.Entities.Users.Social
Imports System.Linq
Imports System.Threading
Imports Telerik.Web.UI
Namespace DotNetNuke.Modules.Links
''' -----------------------------------------------------------------------------
''' <summary>
''' The Links Class provides the UI for displaying the Links
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/23/2004 Moved Links to a separate Project
''' [cnurse] 10/20/2004 Removed ViewOptions from Action menu
''' </history>
''' -----------------------------------------------------------------------------
Partial Class Links
Inherits Entities.Modules.PortalModuleBase
Implements Entities.Modules.IActionable
#Region " Properties "
Private _FileId As Integer = Null.NullInteger
Public Property FileId() As Integer
Get
Return _FileId
End Get
Set(ByVal value As Integer)
_FileId = value
End Set
End Property
Public ReadOnly Property ModuleContentType() As Enums.ModuleContentTypes
Get
Dim result As Enums.ModuleContentTypes = Enums.ModuleContentTypes.Links
If Settings(SettingName.ModuleContentType) IsNot Nothing Then
result = CType(Settings(SettingName.ModuleContentType), Enums.ModuleContentTypes)
End If
Return result
End Get
End Property
Public ReadOnly Property FolderId() As Integer
Get
Dim result As Integer = Null.NullInteger
If Settings(Consts.FolderId) IsNot Nothing Then
result = CType(Settings(Consts.FolderId), Integer)
End If
Return result
End Get
End Property
Public ReadOnly Property FolderInfo() As DotNetNuke.Services.FileSystem.FolderInfo
Get
Dim result As DotNetNuke.Services.FileSystem.IFolderInfo = Nothing
Dim cont As New DotNetNuke.Services.FileSystem.FolderController
If Me.FolderId <> Null.NullInteger Then
result = FolderManager.Instance.GetFolder(Me.FolderId)
End If
Return result
End Get
End Property
Public ReadOnly Property FolderPermissions() As DotNetNuke.Security.Permissions.FolderPermissionCollection
Get
Dim result As New DotNetNuke.Security.Permissions.FolderPermissionCollection
If FolderInfo IsNot Nothing Then
result = DotNetNuke.Security.Permissions.FolderPermissionController.GetFolderPermissionsCollectionByFolder(Me.PortalId, FolderInfo.FolderPath)
End If
Return result
End Get
End Property
Public Shadows Function IsEditable() As Boolean
Dim result As Boolean = False
Select Case Me.ModuleContentType
Case Enums.ModuleContentTypes.Links
If MyBase.IsEditable Then
Return True
End If
Case Enums.ModuleContentTypes.Menu
Case Enums.ModuleContentTypes.Folder
Case Enums.ModuleContentTypes.Friends
End Select
End Function
Public ReadOnly Property DisplayMode() As String
Get
Dim result As String = Consts.DisplayModeLink
If Settings(SettingName.DisplayMode) IsNot Nothing Then
result = Settings(SettingName.DisplayMode)
End If
Return result
End Get
End Property
' 2014 TODO: Menu
Public ReadOnly Property MenuAllUser() As String
Get
Dim result As String = Consts.MenuAllUser
If Settings(SettingName.MenuAllUsers) IsNot Nothing Then
result = Settings(SettingName.MenuAllUsers)
End If
Return result
End Get
End Property
Public ReadOnly Property LinkDescriptionMode() As String
Get
Dim result As String = Consts.ShowLinkDescriptionNo
If Settings(SettingName.LinkDescriptionMode) IsNot Nothing Then
result = Settings(SettingName.LinkDescriptionMode)
End If
Return result
End Get
End Property
Public ReadOnly Property UsePermissions() As Boolean
Get
Dim result As String = False
If Settings(SettingName.UsePermissions) IsNot Nothing Then
result = CBool(Settings(SettingName.UsePermissions))
End If
Return result
End Get
End Property
Protected ReadOnly Property ImageFileId As String
Get
Dim result As String = ""
If Settings(SettingName.Icon) IsNot Nothing Then
result = CStr(Settings(SettingName.Icon))
End If
Return result
End Get
End Property
#End Region
#Region " Public Methods "
''' -----------------------------------------------------------------------------
''' <summary>
''' DisplayInfo displays the description/info on the link
''' </summary>
''' <param name="strDescription"></param>
''' <returns>The description text</returns>
''' <history>
''' [cnurse] 9/23/2004 Moved Links to a separate Project
''' [erikvb] 5/29/2008 Added strDescription parameter, inorder to prevent displaying info when description is empty
''' </history>
''' -----------------------------------------------------------------------------
Public Function DisplayInfo(ByVal strDescription As String) As String
Dim result As String = "False"
Try
If (CType(Settings(SettingName.LinkDescriptionMode), String) = Consts.ShowLinkDescriptionYes) AndAlso (Not String.IsNullOrEmpty(strDescription)) Then
result = "True"
Else
result = "False"
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
Return result
End Function
''' -----------------------------------------------------------------------------
''' <summary>
''' DisplayToolTip gets the tooltip to display
''' </summary>
''' <remarks>
''' </remarks>
''' <param name="strDescription">The description</param>
''' <returns>The tooltip text</returns>
''' <history>
''' [cnurse] 9/23/2004 Moved Links to a separate Project
''' [bonosoft] 11/3/2004 Added default option, if option not set. (DNN-115)
''' </history>
''' -----------------------------------------------------------------------------
Public Function DisplayToolTip(ByVal strDescription As String) As String
Dim result As String = strDescription
If CType(Settings(SettingName.LinkDescriptionMode), String) <> Consts.ShowLinkDescriptionNo Then
result = String.Empty
End If
Return result
End Function
''' -----------------------------------------------------------------------------
''' <summary>
''' FormatURL correctly formats the links url
''' </summary>
''' <remarks>
''' </remarks>
''' <param name="Link">The link</param>
''' <returns>The correctly formatted url</returns>
''' <history>
''' [cnurse] 9/23/2004 Moved Links to a separate Project
''' </history>
''' -----------------------------------------------------------------------------
Public Function FormatURL(ByVal Link As String, ByVal TrackClicks As Boolean) As String
Return Common.Globals.LinkClick(Link, TabId, ModuleId, TrackClicks)
End Function
''' -----------------------------------------------------------------------------
''' <summary>
''' FormatIcon correctly formats the link icon
''' </summary>
''' <remarks>
''' </remarks>
''' <returns>The correctly formatted url</returns>
''' <history>
''' </history>
''' -----------------------------------------------------------------------------
Public Function FormatIcon(ByVal ImageURL As String) As String
Dim result As String = String.Empty
Select Case Me.ModuleContentType
Case Enums.ModuleContentTypes.Links
If CType(Settings(SettingName.Icon), String) <> String.Empty Then
result = Common.Globals.LinkClick(CType(Settings(SettingName.Icon), String), TabId, ModuleId, False)
End If
Case Enums.ModuleContentTypes.Folder
If Not String.IsNullOrEmpty(ImageURL) Then
result = ResolveUrl(ImageURL)
End If
End Select
Return result
End Function
''' -----------------------------------------------------------------------------
''' <summary>
''' DisplayIcon displays the icon
''' </summary>
''' <remarks>
''' </remarks>
''' <returns>true or false</returns>
''' <history>
''' </history>
''' -----------------------------------------------------------------------------
Public Function DisplayIcon() As String
Dim result As String = "False"
Try
Select Case Me.ModuleContentType
Case Enums.ModuleContentTypes.Links
If CType(Settings(SettingName.Icon), String) <> String.Empty Then
result = "True"
Else
result = "False"
End If
Case Enums.ModuleContentTypes.Folder
result = "True"
End Select
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
Return result
End Function
''' -----------------------------------------------------------------------------
''' <summary>
''' HtmlDecode decodes the html string
''' </summary>
''' <remarks>
''' </remarks>
''' <param name="strValue">The string to decode</param>
''' <returns>The decoded html</returns>
''' <history>
''' [cnurse] 9/23/2004 Moved Links to a separate Project
''' </history>
''' -----------------------------------------------------------------------------
Public Function HtmlDecode(ByVal strValue As String) As String
Dim result As String = String.Empty
Try
result = Server.HtmlDecode(strValue)
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
Return result
End Function
Public Function NoWrap() As String
If Not CType(Settings("nowrap"), String) = "W" Then
Return "style=""white-space: nowrap"""
End If
Return String.Empty
End Function
Public ReadOnly Property Horizontal() As String
Get
Dim result As String = String.Empty
If CType(Settings(SettingName.Direction), String) = Consts.DirectionHorizontal Then
result = "Horizontal"
End If
Return result
End Get
End Property
Public ReadOnly Property PopupTrigger() As String
Get
Dim result As String = String.Empty
If Me.LinkDescriptionMode = Consts.ShowLinkDescriptionJQuery Then
result = " trigger"
End If
Return result
End Get
End Property
Public ReadOnly Property ShowPopup() As String
Get
Dim result As String = "false"
If Me.LinkDescriptionMode = Consts.ShowLinkDescriptionJQuery Then
result = "true"
End If
Return result
End Get
End Property
#End Region
#Region " Event Handlers "
''' -----------------------------------------------------------------------------
''' <summary>
''' Page_Load runs when the control is loaded
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/23/2004 Moved Links to a separate Project
''' </history>
''' -----------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
If CStr(Me.Settings(SettingName.LinkDescriptionMode)) = Consts.ShowLinkDescriptionYes Then
If Not Me.Page.ClientScript.IsClientScriptIncludeRegistered(Consts.ToogleJS) Then
Dim jspath As String = Page.ResolveUrl("~/DesktopModules/Links/js/toggle.js")
Me.Page.ClientScript.RegisterClientScriptInclude(Consts.PopupJS, jspath)
End If
End If
If Me.ModuleContentType.Equals(Enums.ModuleContentTypes.Friends) AndAlso Me.Settings(Consts.ModuleContentItem).Equals("BusinessCardMode") Then
pnlList.Visible = False
pnlDropdown.Visible = False
Else
If CType(Settings(SettingName.DisplayMode), String) = Consts.DisplayModeDropdown Then
pnlList.Visible = False
pnlDropdown.Visible = True
Else
pnlList.Visible = True
pnlDropdown.Visible = False
End If
End If
If Not Page.IsPostBack Then
If Request.Params(Consts.FileId) IsNot Nothing Then
Me.FileId = CInt(Request.Params(Consts.FileId))
End If
If Me.FileId <> Null.NullInteger Then
Dim fileInfo As DotNetNuke.Services.FileSystem.IFileInfo = FileManager.Instance.GetFile(Me.FileId)
If fileInfo IsNot Nothing Then
Dim folderInfo As DotNetNuke.Services.FileSystem.IFolderInfo = FolderManager.Instance.GetFolder(fileInfo.FolderId)
If folderInfo IsNot Nothing Then
If DotNetNuke.Security.Permissions.FolderPermissionController.HasFolderPermission(Me.PortalId, folderInfo.FolderPath, "READ") Then
DownloadFile(GetFolderPortalID(PortalSettings), Me.FileId, False, True)
End If
End If
End If
End If
Dim roleController As New DotNetNuke.Security.Roles.RoleController
Dim objLinks As New LinkController
Dim roles = GetUserRoles(Me.PortalId, Me.UserId, True)
Dim isInARole As Boolean = False
Dim linksToShow As New ArrayList
Dim links As New List(Of LinkInfo)
Select Case Me.ModuleContentType
Case Enums.ModuleContentTypes.Links
links = objLinks.GetLinks(ModuleId).Cast(Of LinkInfo).ToList()
Dim imgUrl As String = DotNetNuke.Common.Globals.LinkClick(ImageFileId, TabId, ModuleId)
For Each link As LinkInfo In links
link.ImageURL = imgUrl
'pre alpha
'link.ImageURL = String.Format("~/DesktopModules/Links/WebThumbnail.ashx?url={0}&tw={1}&th={2}", Server.UrlEncode(link.Url), 300, 200)
Next
Case Enums.ModuleContentTypes.Menu
Dim tabsToShow As ArrayList = New ArrayList(TabController.GetTabsByParent(Int32.Parse(Settings(Consts.ModuleContentItem).ToString()), Me.PortalId))
For Each tabinfo As DotNetNuke.Entities.Tabs.TabInfo In tabsToShow
' 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))
Dim stream As New System.IO.StringWriter()
tabSerializer.Serialize(stream, tabinfo)
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
Dim link As New LinkInfo
link.NewWindow = False
link.Title = tabinfo.TabName
link.Url = NavigateURL(tabinfo.TabID)
link.GrantRoles = ";"
link.Description = tabinfo.Description
link.ItemId = tabinfo.TabID
' 2014 TODO: Menu
If MenuAllUser.Equals("No") Then
For Each role As Permissions.TabPermissionInfo In tabinfo.TabPermissions
link.GrantRoles += role.RoleID & ";"
Next
Else
' -2: All Users; -1: Unauthenticated Users
link.GrantRoles += "-2;"
End If
links.Add(link)
End If
Next
Case Enums.ModuleContentTypes.Folder
Dim folder As IFolderInfo = FolderManager.Instance.GetFolder(Me.FolderId)
Dim arrFiles As IList(Of IFileInfo) = FolderManager.Instance.GetFiles(folder).ToList()
For Each file As DotNetNuke.Services.FileSystem.FileInfo In arrFiles
Dim link As New LinkInfo
link.NewWindow = False
link.Title = file.FileName
link.ItemId = file.FileId
link.Url = NavigateURL(Me.TabId, String.Empty, "FileId=" & file.FileId.ToString())
link.GrantRoles = ";"
link.Description = Utils.GetFileSizeString(file.Size)
link.ImageURL = Utils.GetImageURL(file.Extension)
For Each permission As Permissions.FolderPermissionInfo In Me.FolderPermissions
If permission.AllowAccess = True AndAlso permission.PermissionKey = "READ" AndAlso permission.UserID = Null.NullInteger Then
link.GrantRoles += permission.RoleID & ";"
End If
Next
links.Add(link)
Next
Case Enums.ModuleContentTypes.Friends
If Me.Settings(Consts.ModuleContentItem).Equals("NormalMode") Then
pnlFriends.Visible = False
Else
pnlFriends.Visible = True
pnlDropdown.Visible = False
pnlList.Visible = False
End If
' list friends
Dim currentUser As UserInfo = UserController.GetCurrentUserInfo()
If currentUser IsNot Nothing And currentUser.UserID <> -1 Then
For Each lFriend As LinksFriend In GetFriendsSource(currentUser)
Dim link As New LinkInfo
link.NewWindow = False
Select Case Convert.ToInt16(Me.Settings(SettingName.DisplayAttribute))
Case Enums.DisplayAttribute.Username
link.Title = lFriend.UserName
Case Enums.DisplayAttribute.DisplayName
link.Title = lFriend.DisplayName
Case Enums.DisplayAttribute.FirstName
link.Title = lFriend.UserFirstName
Case Enums.DisplayAttribute.LastName
link.Title = lFriend.UserLastName
Case Enums.DisplayAttribute.FullName
link.Title = lFriend.UserFullName
End Select
'link.Title = lFriend.UserName
link.Url = DotNetNuke.Common.Globals.LinkClick("UserID=" & lFriend.UserID, Me.TabId, Me.ModuleId)
link.GrantRoles = ";"
link.ItemId = lFriend.UserID
link.Description = "Status: " & lFriend.Status & "<br />Username: " & lFriend.UserName & "<br />Displayname: " & lFriend.DisplayName & "<br />Full Name: " & lFriend.UserFullName
links.Add(link)
Next
lvFriends.DataSource = GetFriendsSource(currentUser)
lvFriends.DataBind()
End If
If Convert.ToInt16(Me.Settings(SettingName.DisplayOrder)) = Enums.DisplayOrder.ASC Then
links = links.OrderBy(Function(l) l.Title).ToList()
Else
links = links.OrderByDescending(Function(l) l.Title).ToList()
End If
End Select
If Me.DisplayMode = Consts.DisplayModeDropdown Then
If IsEditable() Then
cmdEdit.Visible = True
Else
cmdEdit.Visible = False
End If
cmdGo.ToolTip = Localization.GetString("cmdGo")
If Me.LinkDescriptionMode = Consts.ShowLinkDescriptionYes Then
cmdInfo.Visible = True
Else
cmdInfo.Visible = False
End If
cmdInfo.ToolTip = Localization.GetString("cmdInfo", Me.LocalResourceFile)
For Each link As LinkInfo In links
If Me.ModuleContentType = Enums.ModuleContentTypes.Links AndAlso Me.UsePermissions Then
link.GrantRoles += "-2;"
End If
isInARole = False
If link.RefreshContent Then
objLinks.RefreshLinkContent(link)
End If
For Each role As RoleInfo In roles
If link.GrantRoles.Contains(";" & role.RoleID & ";") Then
isInARole = True
End If
Next
'
If Me.ModuleContentType = Enums.ModuleContentTypes.Friends Then
isInARole = True
End If
If isInARole _
Or link.GrantRoles.Contains(";-2;") _
Or link.GrantRoles.Contains(";-1;") _
Or Me.UserInfo.IsSuperUser _
Or Me.UserInfo.IsInRole(Me.PortalSettings.AdministratorRoleName) Then
linksToShow.Add(link)
End If
Next
cboLinks.DataSource = linksToShow
Select Case Me.ModuleContentType
Case Enums.ModuleContentTypes.Menu
cboLinks.DataValueField = "ItemId"
Case Enums.ModuleContentTypes.Folder
cboLinks.DataValueField = "ItemId"
cboLinks.DataTextField = "Title"
Case Enums.ModuleContentTypes.Friends
cboLinks.DataValueField = "ItemId"
End Select
cboLinks.DataBind()
Else
For Each link As LinkInfo In links
If Me.ModuleContentType = Enums.ModuleContentTypes.Links Then
If Me.UsePermissions = False Then
link.GrantRoles += "-2;"
End If
End If
isInARole = False
If link.RefreshContent Then
objLinks.RefreshLinkContent(link)
End If
For Each role As RoleInfo In roles
If link.GrantRoles.Contains(";" & role.RoleID & ";") Then
isInARole = True
End If
Next
'
If Me.ModuleContentType = Enums.ModuleContentTypes.Friends Then
isInARole = True
End If
If isInARole _
Or link.GrantRoles.Contains("-2") _
Or link.GrantRoles.Contains("-1") _
Or Me.UserInfo.IsSuperUser _
Or Me.UserInfo.IsInRole(Me.PortalSettings.AdministratorRoleName) Then
linksToShow.Add(link)
End If
Next
lstLinks.DataSource = linksToShow
lstLinks.DataBind()
End If
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
''' -----------------------------------------------------------------------------
''' <summary>
''' cmdEdit_Click runs when the edit button is clciked
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/23/2004 Moved Links to a separate Project
''' </history>
''' -----------------------------------------------------------------------------
Private Sub cmdEdit_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles cmdEdit.Click
Try
If Not cboLinks.SelectedItem Is Nothing Then
Response.Redirect(EditUrl("ItemID", cboLinks.SelectedItem.Value), True)
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
''' -----------------------------------------------------------------------------
''' <summary>
''' cmdGo_Click runs when the Go Button is clicked
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/23/2004 Moved Links to a separate Project
''' </history>
''' -----------------------------------------------------------------------------
Private Sub cmdGo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdGo.Click
Try
If Not cboLinks.SelectedItem Is Nothing Then
Dim strURL As String = String.Empty
Dim objLinks As New LinkController
Dim objLink As New LinkInfo
Select Case Me.ModuleContentType
Case Enums.ModuleContentTypes.Links
objLink = objLinks.GetLink(Integer.Parse(cboLinks.SelectedValue), ModuleId)
strURL = FormatURL(objLink.Url.ToString, objLink.TrackClicks)
Case Enums.ModuleContentTypes.Menu
objLink = New LinkInfo()
Dim tabCont As New DotNetNuke.Entities.Tabs.TabController
Dim tabInfo As DotNetNuke.Entities.Tabs.TabInfo = tabCont.GetTab(Integer.Parse(cboLinks.SelectedItem.Value), Me.PortalId, False)
strURL = NavigateURL(tabInfo.TabID)
objLink.TrackClicks = False
Case Enums.ModuleContentTypes.Folder
objLink = New LinkInfo()
strURL = NavigateURL(Me.TabId, String.Empty, "FileId", cboLinks.SelectedValue)
Case Enums.ModuleContentTypes.Friends
objLink = New LinkInfo()
strURL = DotNetNuke.Common.Globals.LinkClick("UserID=" & Integer.Parse(cboLinks.SelectedItem.Value), Me.TabId, Me.ModuleId)
End Select
If Not objLink Is Nothing Then
If objLink.NewWindow = True Then
Page.ClientScript.RegisterClientScriptBlock(GetType(String), "OpenLink", "window.open('" + strURL + "','_blank')", True)
Else
Response.Redirect(strURL, True)
End If
End If
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
''' -----------------------------------------------------------------------------
''' <summary>
''' cmdInfo_Click runs when the Info (...) button is clicked
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/23/2004 Moved Links to a separate Project
''' </history>
''' -----------------------------------------------------------------------------
Private Sub cmdInfo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdInfo.Click
Try
If Not cboLinks.SelectedItem Is Nothing Then
Dim desc As String = String.Empty
Select Case Me.ModuleContentType
Case Enums.ModuleContentTypes.Links
Dim objLinks As New LinkController
Dim objLink As New LinkInfo
objLink = objLinks.GetLink(Integer.Parse(cboLinks.SelectedItem.Value), ModuleId)
If objLink Is Nothing Then
desc = HtmlDecode(objLink.Description.ToString)
End If
Case Enums.ModuleContentTypes.Menu
Dim tabCont As New DotNetNuke.Entities.Tabs.TabController
Dim tabInfo As DotNetNuke.Entities.Tabs.TabInfo = tabCont.GetTab(Integer.Parse(cboLinks.SelectedItem.Value), Me.PortalId, False)
If tabInfo IsNot Nothing Then
desc = tabInfo.Description
End If
Case Enums.ModuleContentTypes.Folder
Dim fileInfo As DotNetNuke.Services.FileSystem.IFileInfo
fileInfo = FileManager.Instance.GetFile(Integer.Parse(cboLinks.SelectedItem.Value))
If fileInfo IsNot Nothing Then
desc = Utils.GetFileSizeString(fileInfo.Size)
End If
Case Enums.ModuleContentTypes.Friends
Dim currentUser As UserInfo = UserController.GetCurrentUserInfo()
Dim friendUser As UserInfo = UserController.GetUserById(Me.PortalId, Integer.Parse(cboLinks.SelectedItem.Value))
Dim updatedRelation As UserRelationship = RelationshipController.Instance.GetFriendRelationship(currentUser, friendUser)
If updatedRelation.Status.ToString.Equals("Accepted") Then
desc = "Status: " & updatedRelation.Status.ToString()
Else
If currentUser.UserID <> updatedRelation.UserId Then
' current user not initialize
desc = "Status: " & "Receive Request from " & friendUser.Username
Else
desc = "Status: " & "Request " & updatedRelation.Status.ToString()