Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/// <summary>
/// Gets the access control type for an item from its ancestors.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="account">The account.</param>
/// <param name="accessRight">The desired access right.</param>
/// <param name="propagationType">Type of propagation.</param>
/// <returns></returns>
protected virtual AccessResult GetAncestorAccess(
Item item,
Account account,
AccessRight accessRight,
PropagationType propagationType)
{
Assert.ArgumentNotNull((object) item, nameof (item));
Assert.ArgumentNotNull((object) account, nameof (account));
Assert.ArgumentNotNull((object) accessRight, nameof (accessRight));
if (propagationType == PropagationType.Entity && propagationType != PropagationType.Descendants)
propagationType = PropagationType.Descendants;
if (propagationType != PropagationType.Descendants)
return AccessResult.NotSet;
Item parent = ItemManager.GetParent(item, SecurityCheck.Disable);
if (parent == null)
return AccessResult.NotSet;
AccessResultCache accessResultCache = CacheManager.GetAccessResultCache();
AccessResultCacheRecord record = accessResultCache.GetRecord((ISecurable) item, account, accessRight, propagationType);
if (record != null)
return record.Value;
AccessResult itemAccess = this.GetItemAccess(parent, account, accessRight, propagationType);
accessResultCache.AddRecord((ISecurable) item, account, accessRight, propagationType, itemAccess);
return itemAccess;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment