Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7.1.0 - CheckRolesMatch update #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 79 additions & 84 deletions Source/DnnDocuments/EditDocs.ascx.vb
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
'
' DotNetNuke� - http://www.dotnetnuke.com
' Copyright (c) 2002-2011
' 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.
'

'
' DotNetNuke� - http://www.dotnetnuke.com
' Copyright (c) 2002-2011
' 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.IO
Imports System.Linq
Imports System.Web
Expand All @@ -40,10 +40,10 @@ Namespace DotNetNuke.Modules.Documents
''' </history>
''' -----------------------------------------------------------------------------
Public MustInherit Class EditDocs
Inherits Entities.Modules.PortalModuleBase

Inherits Entities.Modules.PortalModuleBase
#Region "Controls"

Protected WithEvents plName As UI.UserControls.LabelControl
Protected WithEvents txtName As System.Web.UI.WebControls.TextBox
Protected WithEvents valName As System.Web.UI.WebControls.RequiredFieldValidator
Expand All @@ -69,29 +69,29 @@ Namespace DotNetNuke.Modules.Documents
Protected WithEvents valSortIndex As System.Web.UI.WebControls.RangeValidator
Protected WithEvents lblOwner As System.Web.UI.WebControls.Label
Protected WithEvents lnkChange As System.Web.UI.WebControls.LinkButton
Protected WithEvents lblAudit As System.Web.UI.WebControls.Label

Protected WithEvents lblAudit As System.Web.UI.WebControls.Label
#End Region

#Region "Private Members"

Private mintItemId As Integer

Private mintItemId As Integer
#End Region

#Region "Event Handlers"

''' -----------------------------------------------------------------------------
''' <summary>
''' Page_Load runs when the control is loaded
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/22/2004 Updated to reflect design changes for Help, 508 support
''' and localisation
''' </history>
''' -----------------------------------------------------------------------------
''' -----------------------------------------------------------------------------
''' <summary>
''' Page_Load runs when the control is loaded
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [cnurse] 9/22/2004 Updated to reflect design changes for Help, 508 support
''' and localisation
''' </history>
''' -----------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objDocumentsSettings As DocumentsSettingsInfo

Expand Down Expand Up @@ -246,8 +246,8 @@ Namespace DotNetNuke.Modules.Documents
If Not objFile Is Nothing Then
' Get file's folder security
Dim moduleRoles As ModulePermissionCollection = ModulePermissionController.GetModulePermissions(ModuleId, TabId)
Dim fileRoles As FolderPermissionCollection = Security.Permissions.FolderPermissionController.GetFolderPermissionsCollectionByFolder(PortalId, objFile.Folder)
Return CheckRolesMatch(moduleRoles, fileRoles)
Dim fileRoles As FolderPermissionCollection = Security.Permissions.FolderPermissionController.GetFolderPermissionsCollectionByFolder(PortalId, objFile.Folder)
Return CheckRolesMatch(moduleRoles, fileRoles)
End If
End Select
Return True
Expand All @@ -272,9 +272,11 @@ Namespace DotNetNuke.Modules.Documents
Dim fileRolesList As List(Of PermissionInfoBase) = FileRoles.ToList()
Dim fileReadRoles As IEnumerable(Of PermissionInfoBase) = From fileRole In fileRolesList Where fileRole.PermissionKey = "READ"
For Each fileRole As FolderPermissionInfo In fileReadRoles
objFileRoles.Add(fileRole.RoleName, fileRole.RoleName)
If fileRole.RoleName = DotNetNuke.Common.Globals.glbRoleAllUsersName Then
Return True
If Not fileRole.RoleName = "" Then
objFileRoles.Add(fileRole.RoleName, fileRole.RoleName)
If fileRole.RoleName = DotNetNuke.Common.Globals.glbRoleAllUsersName Then
Return True
End If
End If
Next

Expand All @@ -292,13 +294,13 @@ Namespace DotNetNuke.Modules.Documents
Next
If blnNotMatching Then
' Warn user that roles do not match
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, _
DotNetNuke.Services.Localization.Localization.GetString("msgFileSecurityWarning.Text", Me.LocalResourceFile).Replace("[$ROLELIST]", IIf(strRolesForMessage.IndexOf(",") >= 0, "s", "").ToString & "'" & strRolesForMessage & "'"), _
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me,
DotNetNuke.Services.Localization.Localization.GetString("msgFileSecurityWarning.Text", Me.LocalResourceFile).Replace("[$ROLELIST]", IIf(strRolesForMessage.IndexOf(",") >= 0, "s", "").ToString & "'" & strRolesForMessage & "'"),
DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning)
Return False
Else
Return True
End If
End If
End Function

''' -----------------------------------------------------------------------------
Expand All @@ -312,14 +314,14 @@ Namespace DotNetNuke.Modules.Documents
''' </history>
''' -----------------------------------------------------------------------------
Private Function CheckFileExists(ByVal Url As String) As Boolean
Dim intFileId As Integer
Dim intFileId As Integer
Dim objFile As New DotNetNuke.Services.FileSystem.FileInfo
Dim blnAddWarning As Boolean

If Url = String.Empty Then
' File not selected
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, _
DotNetNuke.Services.Localization.Localization.GetString("msgNoFileSelected.Text", Me.LocalResourceFile), _
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me,
DotNetNuke.Services.Localization.Localization.GetString("msgNoFileSelected.Text", Me.LocalResourceFile),
DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning)
Return False
Else
Expand Down Expand Up @@ -350,8 +352,8 @@ Namespace DotNetNuke.Modules.Documents

If blnAddWarning Then
' Display a "file not found" warning
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me, _
DotNetNuke.Services.Localization.Localization.GetString("msgFileDeleted.Text", Me.LocalResourceFile), _
DotNetNuke.UI.Skins.Skin.AddModuleMessage(Me,
DotNetNuke.Services.Localization.Localization.GetString("msgFileDeleted.Text", Me.LocalResourceFile),
DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning)
Return False
End If
Expand Down Expand Up @@ -455,10 +457,10 @@ Namespace DotNetNuke.Modules.Documents
Me.cmdUpdate.Visible = False

' '' Display page-level warning instructing users to click update again if they want to ignore the warning
DotNetNuke.UI.Skins.Skin.AddPageMessage( _
Me.Page, _
DotNetNuke.Services.Localization.Localization.GetString("msgFileWarningHeading.Text", Me.LocalResourceFile), _
DotNetNuke.Services.Localization.Localization.GetString("msgFileWarning.Text", Me.LocalResourceFile), _
DotNetNuke.UI.Skins.Skin.AddPageMessage(
Me.Page,
DotNetNuke.Services.Localization.Localization.GetString("msgFileWarningHeading.Text", Me.LocalResourceFile),
DotNetNuke.Services.Localization.Localization.GetString("msgFileWarning.Text", Me.LocalResourceFile),
Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning)
Exit Sub
End If
Expand Down Expand Up @@ -537,10 +539,10 @@ Namespace DotNetNuke.Modules.Documents
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub

End Sub
#End Region

#Region "Private methods"
Private Property ItemID() As Integer
Get
Expand All @@ -564,12 +566,12 @@ Namespace DotNetNuke.Modules.Documents
End If

Return objDocumentsSettings
End Function
End Function
#End Region

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Expand All @@ -578,10 +580,10 @@ Namespace DotNetNuke.Modules.Documents
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

End Sub
#End Region

Private Sub lnkChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkChange.Click
lblOwner.Visible = False
lnkChange.Visible = False
Expand Down Expand Up @@ -612,21 +614,14 @@ Namespace DotNetNuke.Modules.Documents
End Sub

Private Sub PopulateOwnerList()
' populate owner list
lstOwner.DataSource = UserController.GetUsers(False, False, PortalId).Cast(Of UserInfo).OrderBy(Function(i As UserInfo) i.DisplayName)

lstOwner.DataTextField = "DisplayName"
lstOwner.DataValueField = "UserId"

lstOwner.DataBind()

' .GetUsers doesn't return super-users, but they can own documents
' so add them to the list
Dim objSuperUser As DotNetNuke.Entities.Users.UserInfo
For Each objSuperUser In UserController.GetUsers(Null.NullInteger)
lstOwner.Items.Insert(0, New System.Web.UI.WebControls.ListItem(objSuperUser.DisplayName, objSuperUser.UserID.ToString))
Next

' populate owner list
lstOwner.DataSource = UserController.GetUsers(PortalId).Cast(Of UserInfo).Distinct().OrderBy(Function(i As UserInfo) i.DisplayName)

lstOwner.DataTextField = "DisplayName"
lstOwner.DataValueField = "UserId"

lstOwner.DataBind()

lstOwner.Items.Insert(0, New System.Web.UI.WebControls.ListItem(Services.Localization.Localization.GetString("None_Specified"), "-1"))
'' End With
End Sub
Expand Down