mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Added ManageForms Permission
--HG-- branch : 1.x extra : source : e56047c49121177ab4828fdcc5660643911eec9f
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Orchard.CustomForms {
|
||||
builder.Add(T("Forms"), "4",
|
||||
menu => menu
|
||||
.Add(T("Manage Forms"), "1.0",
|
||||
item => item.Action("Index", "Admin", new { area = "Orchard.CustomForms" }).Permission(StandardPermissions.SiteOwner))
|
||||
item => item.Action("Index", "Admin", new { area = "Orchard.CustomForms" }).Permission(Permissions.ManageForms))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Orchard.CustomForms.Controllers {
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ActionResult Index(CustomFormIndexOptions options, PagerParameters pagerParameters) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to list custom forms")))
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageForms, T("Not authorized to list custom forms")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
|
||||
@@ -82,7 +82,7 @@ namespace Orchard.CustomForms.Controllers {
|
||||
[HttpPost]
|
||||
[Core.Contents.Controllers.FormValueRequired("submit.BulkEdit")]
|
||||
public ActionResult Index(FormCollection input) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage customForm")))
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageForms, T("Not authorized to manage customForm")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var viewModel = new CustomFormIndexViewModel { CustomForms = new List<CustomFormEntry>(), Options = new CustomFormIndexOptions() };
|
||||
@@ -113,7 +113,7 @@ namespace Orchard.CustomForms.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult Item(int id, PagerParameters pagerParameters) {
|
||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage customForm")))
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageForms, T("Not authorized to manage customForm")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Orchard.CustomForms {
|
||||
public class Permissions : IPermissionProvider {
|
||||
private static readonly Permission SubmitAnyForm = new Permission { Description = "Submit any forms", Name = "Submit" };
|
||||
private static readonly Permission SubmitForm = new Permission { Description = "Submit {0} forms", Name = "Submit_{0}", ImpliedBy = new[] { SubmitAnyForm } };
|
||||
public static readonly Permission ManageForms = new Permission { Description = "Manage custom forms", Name = "ManageForms" };
|
||||
|
||||
private readonly IContentDefinitionManager _contentDefinitionManager;
|
||||
private readonly IContentManager _contentManager;
|
||||
@@ -37,13 +38,14 @@ namespace Orchard.CustomForms {
|
||||
}
|
||||
|
||||
yield return SubmitAnyForm;
|
||||
yield return ManageForms;
|
||||
}
|
||||
|
||||
public IEnumerable<PermissionStereotype> GetDefaultStereotypes() {
|
||||
return new[] {
|
||||
new PermissionStereotype {
|
||||
Name = "Administrator",
|
||||
Permissions = new[] { SubmitAnyForm }
|
||||
Permissions = new[] { SubmitAnyForm, ManageForms }
|
||||
},
|
||||
new PermissionStereotype {
|
||||
Name = "Editor",
|
||||
|
||||
Reference in New Issue
Block a user