Ejemplo n.º 1
0
        public Contracts.SmallGroupCluster GetSmallGroupCluster(int clusterID)
        {
            Contracts.SmallGroupClusterMapper mapper = new Contracts.SmallGroupClusterMapper();
            GroupCluster cluster = new GroupCluster(clusterID);


            if (cluster.GroupClusterID == -1)
            {
                throw new Arena.Services.Exceptions.ResourceNotFoundException("Invalid cluster ID");
            }

            if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, cluster.GroupClusterID, OperationType.View) == false)
            {
                bool groupLeader = false;
                // Check to see if they are a leader within this cluster
                Arena.Custom.SECC.Data.SmallGroup.GroupCollection gc = new Arena.Custom.SECC.Data.SmallGroup.GroupCollection();
                gc.LoadByLeaderPersonID(ArenaContext.Current.Person.PersonID);

                foreach (Group group in gc)
                {
                    if (group.Active && group.GroupClusterID == clusterID)
                    {
                        groupLeader = true;
                        break;
                    }
                }

                if (!groupLeader)
                {
                    throw new Exception("Access denied.");
                }
            }

            return(mapper.FromArena(cluster));
        }
Ejemplo n.º 2
0
        public Contracts.SmallGroupCluster GetSmallGroupCluster(int clusterID)
        {
            Contracts.SmallGroupClusterMapper mapper = new Contracts.SmallGroupClusterMapper();
            GroupCluster cluster = new GroupCluster(clusterID);

            if (cluster.GroupClusterID == -1)
                throw new Arena.Services.Exceptions.ResourceNotFoundException("Invalid cluster ID");

            if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, cluster.GroupClusterID, OperationType.View) == false)
            {
                bool groupLeader = false;
                // Check to see if they are a leader within this cluster
                Arena.Custom.SECC.Data.SmallGroup.GroupCollection gc = new Arena.Custom.SECC.Data.SmallGroup.GroupCollection();
                gc.LoadByLeaderPersonID(ArenaContext.Current.Person.PersonID);

                foreach (Group group in gc)
                {
                    if (group.Active && group.GroupClusterID == clusterID)
                    {
                        groupLeader = true;
                        break;
                    }
                }

                if (!groupLeader) {
                    throw new Exception("Access denied.");
                }
            }

            return mapper.FromArena(cluster);
        }
Ejemplo n.º 3
0
        public Contracts.GenericListResult <Contracts.SmallGroup> GetPersonSmallGroupLeadership(int id, int clusterTypeId, int start, int max)
        {
            Contracts.GenericListResult <Contracts.SmallGroup> list = new Contracts.GenericListResult <Contracts.SmallGroup>();
            list.Items = new List <Contracts.SmallGroup>();
            list.Start = start;


            // Instantiate the mapper
            Contracts.SmallGroupMapper sgm = new Contracts.SmallGroupMapper();

            Arena.Custom.SECC.Data.SmallGroup.GroupCollection gc = new Arena.Custom.SECC.Data.SmallGroup.GroupCollection();
            gc.LoadByLeaderPersonID(ArenaContext.Current.Person.PersonID);

            foreach (Arena.SmallGroup.Group g in gc)
            {
                if (clusterTypeId > 0 && g.ClusterTypeID != clusterTypeId)
                {
                    continue;
                }

                // Make sure they have group cluster info if they aren't querying for themselves.
                if (ArenaContext.Current.Person.PersonID != id)
                {
                    if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, g.GroupClusterID, OperationType.View) == false)
                    {
                        continue;
                    }
                }

                // Make sure this person is an active member of the group
                bool active = true;
                foreach (Arena.SmallGroup.GroupMember gm in g.Members)
                {
                    if (!gm.Active && gm.PersonID == ArenaContext.Current.Person.PersonID)
                    {
                        active = false;
                    }
                }
                if (!active)
                {
                    continue;
                }

                if (list.Total >= start && (list.Items.Count < max || max <= 0))
                {
                    list.Items.Add(sgm.FromArena(g));
                }
            }
            list.Max = list.Total = list.Items.Count;

            return(list);
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        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()));
        }