/// <summary> /// Gets the Roles that have a particualr Permission for a Folder /// </summary> /// <param name="Folder">The Folder</param> /// <param name="PortalId">The Id of the Portal</param> /// <param name="Permission">The Permissions to find</param> /// <remarks> /// </remarks> public static string GetRoles( string Folder, int PortalId, string Permission ) { StringBuilder Roles = new StringBuilder(); FolderPermissionController objFolderPermissionController = new FolderPermissionController(); FolderPermissionCollection objCurrentFolderPermissions; objCurrentFolderPermissions = objFolderPermissionController.GetFolderPermissionsCollectionByFolderPath( PortalId, Folder ); foreach( FolderPermissionInfo tempLoopVar_objFolderPermission in objCurrentFolderPermissions ) { FolderPermissionInfo objFolderPermission = tempLoopVar_objFolderPermission; if( objFolderPermission.AllowAccess && objFolderPermission.PermissionKey == Permission ) { Roles.Append( objFolderPermission.RoleName ); Roles.Append( ";" ); } } return Roles.ToString(); }
/// <summary> /// Sets a Folder Permission /// </summary> /// <param name="PortalId">The Id of the Portal</param> /// <param name="FolderId">The Id of the Folder</param> /// <param name="PermissionId">The Id of the Permission</param> /// <param name="RoleId">The Id of the Role</param> /// <param name="relativePath">The folder's Relative Path</param> /// <remarks> /// </remarks> public static void SetFolderPermission( int PortalId, int FolderId, int PermissionId, int RoleId, string relativePath ) { FolderPermissionController objFolderPermissionController = new FolderPermissionController(); FolderPermissionCollection objCurrentFolderPermissions; FolderPermissionInfo objFolderPermissionInfo = new FolderPermissionInfo(); objCurrentFolderPermissions = objFolderPermissionController.GetFolderPermissionsCollectionByFolderPath( PortalId, relativePath ); //Iterate current permissions to see if permisison has already been added foreach( FolderPermissionInfo tempLoopVar_objFolderPermissionInfo in objCurrentFolderPermissions ) { objFolderPermissionInfo = tempLoopVar_objFolderPermissionInfo; if( objFolderPermissionInfo.FolderID == FolderId && objFolderPermissionInfo.PermissionID == PermissionId && objFolderPermissionInfo.RoleID == RoleId && objFolderPermissionInfo.AllowAccess ) { return; } } //Permission not found so Add objFolderPermissionInfo = (FolderPermissionInfo)CBO.InitializeObject( objFolderPermissionInfo, typeof( FolderPermissionInfo ) ); objFolderPermissionInfo.FolderID = FolderId; objFolderPermissionInfo.PermissionID = PermissionId; objFolderPermissionInfo.RoleID = RoleId; objFolderPermissionInfo.AllowAccess = true; objFolderPermissionController.AddFolderPermission( objFolderPermissionInfo ); }
/// <summary> /// Sets a Folders Permissions the same as the Folders parent folder /// </summary> /// <param name="PortalId">The Id of the Portal</param> /// <param name="FolderId">The Id of the Folder</param> /// <param name="relativePath">The folder's Relative Path</param> /// <remarks> /// </remarks> /// <history> /// [cnurse] 08/01/2006 Created /// </history> public static void SetFolderPermissions( int PortalId, int FolderId, string relativePath ) { if( !String.IsNullOrEmpty( relativePath ) ) { string parentFolderPath = relativePath.Substring( 0, relativePath.Substring( 0, relativePath.Length - 1 ).LastIndexOf( "/" ) + 1 ); //Get Parents permissions FolderPermissionController objFolderPermissionController = new FolderPermissionController(); FolderPermissionCollection objFolderPermissions = objFolderPermissionController.GetFolderPermissionsCollectionByFolderPath( PortalId, parentFolderPath ); //Iterate parent permissions to see if permisison has already been added foreach( FolderPermissionInfo objPermission in objFolderPermissions ) { SetFolderPermission( PortalId, FolderId, objPermission.PermissionID, objPermission.RoleID, relativePath ); } } }
/// <summary> /// The cmdUpdate_Click server event handler on this user control runs when the /// Update button is clicked /// </summary> /// <history> /// [DYNST] 2/1/2004 Created /// [Jon Henning] 11/1/2004 Updated to use ClientAPI/DNNTree /// [Jon Henning] 4/21/2004 Rebind grid after update to reflect update - DNN-178 /// </history> protected void cmdUpdate_Click( Object sender, EventArgs e ) { string strFolderPath = FileSystemUtils.StripFolderPath( this.LastFolderPath ).Replace( "\\", "/" ); FolderController objFolderController = new FolderController(); FolderInfo objFolderInfo = objFolderController.GetFolder( FolderPortalID, strFolderPath ); if( objFolderInfo == null ) { //file system needs synchronizing //with database...this folder is new. Synchronize(); objFolderInfo = objFolderController.GetFolder( FolderPortalID, strFolderPath ); } FolderPermissionController objFolderPermissionController = new FolderPermissionController(); FolderPermissionCollection objCurrentFolderPermissions; objCurrentFolderPermissions = objFolderPermissionController.GetFolderPermissionsCollectionByFolderPath( FolderPortalID, strFolderPath ); if( ! objCurrentFolderPermissions.CompareTo( dgPermissions.Permissions ) ) { objFolderPermissionController.DeleteFolderPermissionsByFolder( FolderPortalID, strFolderPath ); foreach (FolderPermissionInfo objFolderPermission in dgPermissions.Permissions) { objFolderPermission.FolderID = objFolderInfo.FolderID; if( objFolderPermission.AllowAccess ) { objFolderPermissionController.AddFolderPermission( objFolderPermission ); } } GeneratePermissionsGrid(); //rebind the grid to reflect updated values - it is possible for the grid controls and the database to become out of sync } }