/// <summary> /// Checks the PermissionCollection class to determine if the /// indicated operation is allowed for the current user. /// </summary> /// <param name="permissions">The collection of permissions to check. These should be object permissions.</param> /// <param name="operation">The type of access the user needs to proceed.</param> /// <returns>true/false indicating if the operation is allowed.</returns> public bool PermissionsOperationAllowed(PermissionCollection permissions, OperationType operation) { return(permissions.Allowed(operation, _User)); }
private bool ShouldShow(Arena.Core.Person arena, string name) { // First we check to see if this is yourself if (Arena.Core.ArenaContext.Current.Person.PersonID == arena.PersonID) { return true; } // Next we check to see if this is a family member if (Arena.Core.ArenaContext.Current.Person.FamilyId == arena.FamilyId) { return true; } // Group Leader Check - If the person they are fetching is one of their // small group members, go ahead and provide visibility Arena.Custom.SECC.Data.SmallGroup.GroupCollection gc = new Arena.Custom.SECC.Data.SmallGroup.GroupCollection(); gc.LoadByLeaderPersonID(Arena.Core.ArenaContext.Current.Person.PersonID); foreach (Arena.SmallGroup.Group g in gc) { foreach (Arena.Core.Person groupMember in g.Members) { if (groupMember.PersonID == arena.PersonID) { return true; } } Arena.SmallGroup.GroupCluster cluster = g.GroupCluster; while (cluster != null) { // If this is the current group's cluster leader or admin if (cluster.LeaderID == arena.PersonID || cluster.AdminID == arena.PersonID) { return true; } if (cluster.ParentClusterID > 0) { cluster = new Arena.SmallGroup.GroupCluster(cluster.ParentClusterID); } else { cluster = null; } } } if (!PersonMapper._fieldSecurityMap.ContainsKey(name.ToUpperInvariant())) { return false; } PermissionCollection permissionCollection = new PermissionCollection(ObjectType.PersonField, PersonMapper._fieldSecurityMap[name.ToUpperInvariant()]); if (!permissionCollection.Allowed(OperationType.View, Arena.Core.ArenaContext.Current.User)) { return false; } if (this._includeFields == null) { return true; } return this._includeFields.Contains(name.ToUpperInvariant()); }
private bool ShouldShow(Arena.Core.Person arena, string name) { // First we check to see if this is yourself if (Arena.Core.ArenaContext.Current.Person.PersonID == arena.PersonID) { return(true); } // Next we check to see if this is a family member if (Arena.Core.ArenaContext.Current.Person.FamilyId == arena.FamilyId) { return(true); } // Group Leader Check - If the person they are fetching is one of their // small group members, go ahead and provide visibility Arena.Custom.SECC.Data.SmallGroup.GroupCollection gc = new Arena.Custom.SECC.Data.SmallGroup.GroupCollection(); gc.LoadByLeaderPersonID(Arena.Core.ArenaContext.Current.Person.PersonID); foreach (Arena.SmallGroup.Group g in gc) { foreach (Arena.Core.Person groupMember in g.Members) { if (groupMember.PersonID == arena.PersonID) { return(true); } } Arena.SmallGroup.GroupCluster cluster = g.GroupCluster; while (cluster != null) { // If this is the current group's cluster leader or admin if (cluster.LeaderID == arena.PersonID || cluster.AdminID == arena.PersonID) { return(true); } if (cluster.ParentClusterID > 0) { cluster = new Arena.SmallGroup.GroupCluster(cluster.ParentClusterID); } else { cluster = null; } } } if (!PersonMapper._fieldSecurityMap.ContainsKey(name.ToUpperInvariant())) { return(false); } PermissionCollection permissionCollection = new PermissionCollection(ObjectType.PersonField, PersonMapper._fieldSecurityMap[name.ToUpperInvariant()]); if (!permissionCollection.Allowed(OperationType.View, Arena.Core.ArenaContext.Current.User)) { return(false); } if (this._includeFields == null) { return(true); } return(this._includeFields.Contains(name.ToUpperInvariant())); }