2010-07-16 15:49:24 +08:00
using System.Collections.Generic ;
2010-07-28 06:59:38 +08:00
using Orchard.Environment.Extensions.Models ;
2010-07-16 15:49:24 +08:00
using Orchard.Security.Permissions ;
namespace Orchard.Core.Contents {
public class Permissions : IPermissionProvider {
public static readonly Permission PublishOthersContent = new Permission { Description = "Publish or unpublish content for others" , Name = "PublishOthersContent" } ;
public static readonly Permission PublishContent = new Permission { Description = "Publish or unpublish content" , Name = "PublishContent" , ImpliedBy = new [ ] { PublishOthersContent } } ;
public static readonly Permission EditOthersContent = new Permission { Description = "Edit content for others" , Name = "EditOthersContent" , ImpliedBy = new [ ] { PublishOthersContent } } ;
public static readonly Permission EditContent = new Permission { Description = "Edit content" , Name = "EditContent" , ImpliedBy = new [ ] { EditOthersContent , PublishContent } } ;
public static readonly Permission DeleteOthersContent = new Permission { Description = "Delete content for others" , Name = "DeleteOthersContent" } ;
public static readonly Permission DeleteContent = new Permission { Description = "Delete content" , Name = "DeleteContent" , ImpliedBy = new [ ] { DeleteOthersContent } } ;
public static readonly Permission MetaListContent = new Permission { ImpliedBy = new [ ] { EditContent , PublishContent , DeleteContent } } ;
2010-07-28 06:59:38 +08:00
public virtual Feature Feature { get ; set ; }
2010-07-16 15:49:24 +08:00
public IEnumerable < Permission > GetPermissions ( ) {
2010-07-23 06:40:27 +08:00
return new [ ] {
2010-07-16 15:49:24 +08:00
EditContent ,
EditOthersContent ,
PublishContent ,
PublishOthersContent ,
DeleteContent ,
DeleteOthersContent ,
} ;
}
public IEnumerable < PermissionStereotype > GetDefaultStereotypes ( ) {
return new [ ] {
new PermissionStereotype {
Name = "Administrator" ,
Permissions = new [ ] { PublishOthersContent , EditOthersContent , DeleteOthersContent }
} ,
new PermissionStereotype {
Name = "Editor" ,
Permissions = new [ ] { PublishOthersContent , EditOthersContent , DeleteOthersContent }
} ,
new PermissionStereotype {
Name = "Moderator" ,
//Permissions = new[] {}
} ,
new PermissionStereotype {
Name = "Author" ,
Permissions = new [ ] { PublishContent , EditContent , DeleteContent }
} ,
new PermissionStereotype {
Name = "Contributor" ,
Permissions = new [ ] { EditContent }
} ,
} ;
}
}
}