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 {
2010-10-08 02:47:09 +08:00
public static readonly Permission PublishContent = new Permission { Description = "Publish or unpublish content for others" , Name = "PublishContent" } ;
public static readonly Permission PublishOwnContent = new Permission { Description = "Publish or unpublish content" , Name = "PublishOwnContent" , ImpliedBy = new [ ] { PublishContent } } ;
public static readonly Permission EditContent = new Permission { Description = "Edit content for others" , Name = "EditContent" , ImpliedBy = new [ ] { PublishContent } } ;
public static readonly Permission EditOwnContent = new Permission { Description = "Edit content" , Name = "EditOwnContent" , ImpliedBy = new [ ] { EditContent , PublishOwnContent } } ;
public static readonly Permission DeleteContent = new Permission { Description = "Delete content for others" , Name = "DeleteContent" } ;
public static readonly Permission DeleteOwnContent = new Permission { Description = "Delete content" , Name = "DeleteOwnContent" , ImpliedBy = new [ ] { DeleteContent } } ;
2010-07-16 15:49:24 +08:00
2010-10-08 02:47:09 +08:00
public static readonly Permission MetaListContent = new Permission { ImpliedBy = new [ ] { EditOwnContent , PublishOwnContent , DeleteOwnContent } } ;
2010-07-16 15:49:24 +08:00
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-10-08 02:47:09 +08:00
EditOwnContent ,
2010-07-16 15:49:24 +08:00
EditContent ,
2010-10-08 02:47:09 +08:00
PublishOwnContent ,
2010-07-16 15:49:24 +08:00
PublishContent ,
2010-10-08 02:47:09 +08:00
DeleteOwnContent ,
2010-07-16 15:49:24 +08:00
DeleteContent ,
} ;
}
public IEnumerable < PermissionStereotype > GetDefaultStereotypes ( ) {
return new [ ] {
new PermissionStereotype {
Name = "Administrator" ,
2010-10-08 02:47:09 +08:00
Permissions = new [ ] { PublishContent , EditContent , DeleteContent }
2010-07-16 15:49:24 +08:00
} ,
new PermissionStereotype {
Name = "Editor" ,
2010-10-08 02:47:09 +08:00
Permissions = new [ ] { PublishContent , EditContent , DeleteContent }
2010-07-16 15:49:24 +08:00
} ,
new PermissionStereotype {
Name = "Moderator" ,
//Permissions = new[] {}
} ,
new PermissionStereotype {
Name = "Author" ,
2010-10-08 02:47:09 +08:00
Permissions = new [ ] { PublishOwnContent , EditOwnContent , DeleteOwnContent }
2010-07-16 15:49:24 +08:00
} ,
new PermissionStereotype {
Name = "Contributor" ,
2010-10-08 02:47:09 +08:00
Permissions = new [ ] { EditOwnContent }
2010-07-16 15:49:24 +08:00
} ,
} ;
}
}
}