Created
October 16, 2020 17:15
-
-
Save martinrayenglish/d283805fbf25351f0675f433fc5fcb99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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