mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Addin new Category property to Permission
- Automatically creates a Category if non is provided, using the previous text pattern --HG-- branch : dev
This commit is contained in:
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Roles.Models;
|
||||
using Orchard.Security.Permissions;
|
||||
@@ -22,8 +22,10 @@ namespace Orchard.Roles.Services {
|
||||
_permissionRepository = permissionRepository;
|
||||
_permissionProviders = permissionProviders;
|
||||
Logger = NullLogger.Instance;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public IEnumerable<RoleRecord> GetRoles() {
|
||||
@@ -105,11 +107,16 @@ namespace Orchard.Roles.Services {
|
||||
foreach (var permissionProvider in _permissionProviders) {
|
||||
var featureName = permissionProvider.Feature.Descriptor.Name;
|
||||
var permissions = permissionProvider.GetPermissions();
|
||||
foreach(var permission in permissions) {
|
||||
var category = permission.Category;
|
||||
|
||||
if (installedPermissions.ContainsKey(featureName))
|
||||
installedPermissions[featureName] = installedPermissions[featureName].Concat(permissions);
|
||||
else
|
||||
installedPermissions.Add(featureName, permissions);
|
||||
string title = String.IsNullOrWhiteSpace(category) ? T("{0} Feature", featureName).Text : T(category).Text;
|
||||
|
||||
if ( installedPermissions.ContainsKey(title) )
|
||||
installedPermissions[title] = installedPermissions[title].Concat( new [] {permission});
|
||||
else
|
||||
installedPermissions.Add(title, permissions);
|
||||
}
|
||||
}
|
||||
|
||||
return installedPermissions;
|
||||
|
@@ -11,9 +11,9 @@
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>@T("Permissions")</legend>
|
||||
@foreach (var featureName in Model.FeaturePermissions.Keys) {
|
||||
@foreach (var category in Model.FeaturePermissions.Keys) {
|
||||
<fieldset>
|
||||
<legend>@T("{0} Feature", featureName)</legend>
|
||||
<legend>@category</legend>
|
||||
<table class="items">
|
||||
<colgroup>
|
||||
<col id="Col1" />
|
||||
@@ -26,7 +26,7 @@
|
||||
<th scope="col">@T("Effective")</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@foreach (var permission in Model.FeaturePermissions[featureName]) {
|
||||
@foreach (var permission in Model.FeaturePermissions[category]) {
|
||||
<tr>
|
||||
<td>@permission.Description</td>
|
||||
<td style="width:60px;">
|
||||
|
@@ -4,6 +4,7 @@ namespace Orchard.Security.Permissions {
|
||||
public class Permission {
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Category { get; set; }
|
||||
|
||||
public IEnumerable<Permission> ImpliedBy { get; set; }
|
||||
public bool RequiresOwnership { get; set; }
|
||||
|
Reference in New Issue
Block a user