mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#17795 Adding a ViewContentTypes Permission
--HG-- branch : 1.x extra : source : 5d7754f28609ac7ae688b44abbd666608b03225b
This commit is contained in:
@@ -12,8 +12,8 @@ namespace Orchard.ContentTypes {
|
||||
builder.Add(T("Content Definition"), "1.4.1", menu => {
|
||||
menu.LinkToFirstChild(true);
|
||||
|
||||
menu.Add(T("Content Types"), "1", item => item.Action("Index", "Admin", new { area = "Orchard.ContentTypes" }).LocalNav());
|
||||
menu.Add(T("Content Parts"), "2", item => item.Action("ListParts", "Admin", new { area = "Orchard.ContentTypes" }).LocalNav());
|
||||
menu.Add(T("Content Types"), "1", item => item.Action("Index", "Admin", new { area = "Orchard.ContentTypes" }).Permission(Permissions.ViewContentTypes).LocalNav());
|
||||
menu.Add(T("Content Parts"), "2", item => item.Action("ListParts", "Admin", new { area = "Orchard.ContentTypes" }).Permission(Permissions.ViewContentTypes).LocalNav());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,9 @@ namespace Orchard.ContentTypes.Controllers {
|
||||
#region Types
|
||||
|
||||
public ActionResult List() {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ViewContentTypes, T("Not allowed to view content types.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
return View("List", new ListContentTypesViewModel {
|
||||
Types = _contentDefinitionService.GetTypes()
|
||||
});
|
||||
|
||||
@@ -4,13 +4,15 @@ using Orchard.Security.Permissions;
|
||||
|
||||
namespace Orchard.ContentTypes {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ViewContentTypes = new Permission { Name = "ViewContentTypes", Description = "View content types." };
|
||||
public static readonly Permission EditContentTypes = new Permission { Name = "EditContentTypes", Description = "Edit content types." };
|
||||
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new [] {
|
||||
EditContentTypes,
|
||||
ViewContentTypes,
|
||||
EditContentTypes
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user