//private void ResetPermissions(CFAggregation agregation) //{ // List<CFAccessGroup> accessGroups = agregation.AccessGroups.ToList(); // accessGroups.RemoveAll(x => x.IsInherited == true); // agregation.AccessGroups = accessGroups; // foreach (CFAggregation parent in agregation.ParentMembers) // { // if (parent != this && parent != agregation) // { // foreach (CFAccessGroup accessGroup in parent.AccessGroups) // { // agregation.SetAccess(accessGroup.AccessGuid, // accessGroup.AccessDefinition.AccessModes, // true); // } // } // } // foreach (CFAggregation child in agregation.ChildMembers) // { // if (child != this && child != agregation) // { // ResetPermissions(child); // } // } //} private void ResetPermissions() { List <CFAccessGroup> accessGroups = AccessGroups.ToList(); accessGroups.RemoveAll(x => x.IsInherited == true); AccessGroups = accessGroups; foreach (CFAggregation parent in ParentMembers) { if (parent != this) { foreach (CFAccessGroup accessGroup in parent.AccessGroups) { SetAccess(accessGroup.AccessGuid, accessGroup.AccessDefinition.AccessModes, true); } } } foreach (CFAggregation child in ChildMembers) { if (child != this) { child.ResetPermissions(); } } }
public new void SetAccess(Guid guid, AccessMode accessMode, bool isInherited = false) { //XXX Check control permission //User.Identity.IsAuthenticated CFAccessGroup accessGroup = GetAccessGroup(guid); if (accessGroup == null) { base.SetAccess(guid, accessMode, isInherited); } else if (accessGroup.IsInherited == false && isInherited == true) { return; } else { List <CFAccessGroup> accessGroups = AccessGroups.ToList(); accessGroups.Remove(accessGroup); CFAccessGroup newAccessGroup = new CFAccessGroup(); newAccessGroup.IsInherited = isInherited; newAccessGroup.Guid = guid.ToString(); newAccessGroup.AccessDefinition.AccessModes = accessMode; if (accessGroup.IsInherited == true && isInherited == true) { AccessMode inheritedAccessMode = RecalculateInheritedPermissions(guid); newAccessGroup.AccessDefinition.AccessModes |= inheritedAccessMode; } accessGroups.Add(newAccessGroup); AccessGroups = accessGroups; } }
public CFAccessGroup GetOrCreateAccess(Guid guid) { CFAccessGroup accessGroup = GetAccessGroup(guid); if (accessGroup == null) { accessGroup = new CFAccessGroup(); List <CFAccessGroup> accessGroups = AccessGroups.ToList(); accessGroups.Add(accessGroup); AccessGroups = accessGroups; } return(accessGroup); }