U4-10437 Listview children not showing after upgrade to 7.7
This commit is contained in:
@@ -17,7 +17,30 @@ namespace Umbraco.Core.Models.Membership
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the aggregate permissions in the permission set
|
||||
/// Returns the aggregate permissions in the permission set for a single node
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// This value is only calculated once per node
|
||||
/// </remarks>
|
||||
public IEnumerable<string> GetAllPermissions(int entityId)
|
||||
{
|
||||
if (_aggregateNodePermissions == null)
|
||||
_aggregateNodePermissions = new Dictionary<int, string[]>();
|
||||
|
||||
string[] entityPermissions;
|
||||
if (_aggregateNodePermissions.TryGetValue(entityId, out entityPermissions) == false)
|
||||
{
|
||||
entityPermissions = this.Where(x => x.EntityId == entityId).SelectMany(x => x.AssignedPermissions).Distinct().ToArray();
|
||||
_aggregateNodePermissions[entityId] = entityPermissions;
|
||||
}
|
||||
return entityPermissions;
|
||||
}
|
||||
|
||||
private Dictionary<int, string[]> _aggregateNodePermissions;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the aggregate permissions in the permission set for all nodes
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
|
||||
@@ -101,30 +101,19 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
ids.Add(((dynamic)items[i]).Id);
|
||||
}
|
||||
//get all the permissions for these nodes in one call
|
||||
var permissions = _userService.GetPermissions(user, ids.ToArray()).ToArray();
|
||||
var permissions = _userService.GetPermissions(user, ids.ToArray());
|
||||
var toRemove = new List<dynamic>();
|
||||
foreach (dynamic item in items)
|
||||
{
|
||||
var nodePermission = permissions.Where(x => x.EntityId == Convert.ToInt32(item.Id)).ToArray();
|
||||
//if there are no permissions for this id then we need to check what the user's default
|
||||
// permissions are.
|
||||
if (nodePermission.Length == 0)
|
||||
{
|
||||
//get the combined permission set across all user groups for this node
|
||||
//we're in the world of dynamics here so we need to cast
|
||||
var nodePermission = ((IEnumerable<string>)permissions.GetAllPermissions(item.Id)).ToArray();
|
||||
|
||||
//if the permission being checked doesn't exist then remove the item
|
||||
if (nodePermission.Contains(_permissionToCheck.ToString(CultureInfo.InvariantCulture)) == false)
|
||||
{
|
||||
//var defaultP = user.DefaultPermissions
|
||||
|
||||
toRemove.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var n in nodePermission)
|
||||
{
|
||||
//if the permission being checked doesn't exist then remove the item
|
||||
if (n.AssignedPermissions.Contains(_permissionToCheck.ToString(CultureInfo.InvariantCulture)) == false)
|
||||
{
|
||||
toRemove.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var item in toRemove)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user