2021-12-15 11:47:45 +01:00
using System ;
using System.Collections.Generic ;
2017-09-12 16:22:16 +02:00
using System.ComponentModel.DataAnnotations ;
using System.Linq ;
using System.Runtime.Serialization ;
2021-02-18 11:06:02 +01:00
using Umbraco.Extensions ;
2017-09-12 16:22:16 +02:00
2021-02-18 11:06:02 +01:00
namespace Umbraco.Cms.Core.Models.ContentEditing
2017-09-12 16:22:16 +02:00
{
/// <summary>
/// Used to assign user group permissions to a content node
/// </summary>
[DataContract(Name = "contentPermission", Namespace = "")]
2021-11-18 11:20:49 +01:00
public class UserGroupPermissionsSave
2017-09-12 16:22:16 +02:00
{
public UserGroupPermissionsSave ( )
{
AssignedPermissions = new Dictionary < int , IEnumerable < string > > ( ) ;
}
2019-01-27 01:17:32 -05:00
// TODO: we should have an option to clear the permissions assigned to this node and instead just have them inherit - yes once we actually have inheritance!
2017-09-12 16:22:16 +02:00
[DataMember(Name = "contentId", IsRequired = true)]
[Required]
public int ContentId { get ; set ; }
/// <summary>
/// A dictionary of permissions to assign, the key is the user group id
/// </summary>
[DataMember(Name = "permissions")]
2017-09-23 10:08:18 +02:00
public IDictionary < int , IEnumerable < string > > AssignedPermissions { get ; set ; }
2021-12-15 11:47:45 +01:00
[Obsolete("This is not used and will be removed in Umbraco 10")]
public IEnumerable < ValidationResult > Validate ( ValidationContext validationContext )
{
if ( AssignedPermissions . SelectMany ( x = > x . Value ) . Any ( x = > x . IsNullOrWhiteSpace ( ) ) )
{
yield return new ValidationResult ( "A permission value cannot be null or empty" , new [ ] { "Permissions" } ) ;
}
}
2017-09-12 16:22:16 +02:00
}
2017-09-23 10:08:18 +02:00
}