Beispiel #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));
        }
        private void RegisterScripts()
        {
            if (MemberAddPageSetting != string.Empty)
            {
                StringBuilder sbGroupPath = new StringBuilder();
                sbGroupPath.Append(group.Title);
                GroupCluster gc = new GroupCluster(group.GroupClusterID);

                while (gc != null && gc.GroupClusterID != -1)
                {
                    sbGroupPath.Insert(0, gc.Title + " | ");
                    gc = new GroupCluster(gc.ParentClusterID);
                }

                StringBuilder sbScript = new StringBuilder();
                sbScript.Append("\n\n<script language=\"javascript\">\n");

                sbScript.Append("\tfunction openAddWindow()\n");
                sbScript.Append("\t{\n");

                sbScript.AppendFormat("\t\twindow.location.href='default.aspx?page={0}&group_id={1}&referral_url={2}&group_path={3}';\n",
                                      MemberAddPageSetting,
                                      group.GroupID.ToString(),
                                      HttpUtility.UrlEncode(Request.RawUrl).Replace("'", "\\'"),
                                      HttpUtility.UrlEncode(sbGroupPath.ToString()).Replace("'", "\\'"));

                sbScript.Append("\t}\n");

                sbScript.Append("</script>\n\n");

                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "openAddWindow", sbScript.ToString());
            }
        }
        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);
        }
Beispiel #4
0
        private void LoadChildClusterGroups(GroupCluster cluster, GroupCollection groups)
        {
            foreach (Group group in new GroupCollection(cluster.GroupClusterID))
            {
                groups.Add(group);
            }

            foreach (GroupCluster childCluster in cluster.ChildClusters)
            {
                LoadChildClusterGroups(childCluster, groups);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Load a list of person placemark objects from the given cluster ID. The
        /// list is constrained to the start and count parameters.
        /// </summary>
        /// <param name="clusterid">The Arena Cluster to generate a list of people from, only active members are returned.</param>
        /// <param name="start">The member index to start loading from.</param>
        /// <param name="count">The maximum number of people to load, pass Int32.MaxValue for complete load.</param>
        /// <returns>A list of PersonPlacemark objects.</returns>
        public List <PersonPlacemark> PersonPlacemarksInCluster(int clusterid, int start, int count)
        {
            List <PersonPlacemark> people    = new List <PersonPlacemark>();
            List <Int32>           peopleids = new List <Int32>();
            GroupCluster           cluster;
            int i;


            if (PermissionsOperationAllowed(new PermissionCollection(ObjectType.Group_Cluster, clusterid), OperationType.View) == false)
            {
                return(people);
            }

            cluster = new GroupCluster(clusterid);

            //
            // This is one ugly method, but someday God will grace us with his presence and
            // say "thou shalt not use thy Small Group Structure."
            //
            cluster.PopulateDescendents();
            Thread.Sleep(2000);
            while (cluster.WaitingForCount)
            {
                Thread.Sleep(50);
            }

            foreach (Person p in cluster.ActiveChildGroupLeaders)
            {
                if (peopleids.Contains(p.PersonID) == false)
                {
                    peopleids.Add(p.PersonID);
                }
            }
            foreach (GroupMember gm in cluster.ActiveChildGroupMembers)
            {
                if (peopleids.Contains(gm.PersonID) == false)
                {
                    peopleids.Add(gm.PersonID);
                }
            }

            for (i = start; i < peopleids.Count && people.Count < count; i++)
            {
                try
                {
                    people.Add(new PersonPlacemark(new Person(peopleids[i])));
                }
                catch { }
            }

            return(people);
        }
Beispiel #6
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)
            {
                throw new Exception("Access denied.");
            }

            return(mapper.FromArena(cluster));
        }
Beispiel #7
0
        /// <summary>
        /// Load a list of small group placemark objects from the given cluster ID. The
        /// list is constrained to the start and count parameters.
        /// </summary>
        /// <param name="clusterid">The Arena Cluster to generate a list of groups from, only active groups are returned.</param>
        /// <param name="start">The member index to start loading from.</param>
        /// <param name="count">The maximum number of groups to load, pass Int32.MaxValue for complete load.</param>
        /// <returns>A list of SmallGroupPlacemark objects.</returns>
        public List <SmallGroupPlacemark> SmallGroupPlacemarksInCluster(int clusterid, int start, int count)
        {
            List <SmallGroupPlacemark> groups = new List <SmallGroupPlacemark>();
            List <Int32> groupids             = new List <Int32>();
            GroupCluster cluster;


            if (PermissionsOperationAllowed(new PermissionCollection(ObjectType.Group_Cluster, clusterid), OperationType.View) == false)
            {
                return(groups);
            }

            cluster = new GroupCluster(clusterid);

            foreach (Group g in cluster.SmallGroups)
            {
                if (g.Active == true && g.Private == false)
                {
                    try
                    {
                        groups.Add(new SmallGroupPlacemark(g));
                    }
                    catch { }
                }
            }

            foreach (GroupCluster gc in cluster.ChildClusters)
            {
                groups.AddRange(SmallGroupPlacemarksInCluster(gc.GroupClusterID, 0, Int32.MaxValue));
            }

            if (start > groups.Count)
            {
                start = groups.Count;
            }
            if (count > (groups.Count - start))
            {
                count = (groups.Count - start);
            }
            return(groups.GetRange(start, count));
        }
Beispiel #8
0
        /// <summary>
        /// Process a single small group cluster. If the cluster has child-clusters then
        /// each child cluster is processed as well. If the cluster has small groups then
        /// pass along the small groups to the ProcessGroup method.
        /// </summary>
        /// <param name="cluster">The GroupCluster to be processed.</param>
        /// <returns>True/false status indicating if a fatal error occurred.</returns>
        Boolean ProcessCluster(GroupCluster cluster)
        {
            //
            // If they have limited the cluster types and this cluster type is not in
            // the list of valid cluster types, then skip it.
            //
            if (ClusterTypes.Length > 0 && ClusterTypes.Contains(cluster.ClusterTypeID) == false)
            {
                return(true);
            }

            if (Debug)
            {
                _message.AppendFormat("Processing cluster '{0}'<br />", cluster.Name);
            }

            //
            // Process each cluster level under this cluster.
            //
            foreach (GroupCluster child in cluster.ChildClusters)
            {
                if (ProcessCluster(child) == false)
                {
                    return(false);
                }
            }

            //
            // Process each small group under this cluster.
            //
            foreach (Group group in cluster.SmallGroups)
            {
                if (ProcessGroup(group) == false)
                {
                    return(false);
                }
            }

            return(true);
        }
        private void btnSend_Click(object sender, EventArgs e)
        {
            int    groupid               = -1;
            string strLeaderEmail        = "";
            string strClusterLeaderEmail = "";

            foreach (DataGridItem item in dgResults.Items)
            {
                RadioButton rb = (RadioButton)item.FindControl("rbSelect");
                if (rb.Checked)
                {
                    groupid = Int32.Parse(rb.Attributes["groupid"]);
                    break;
                }
            }

            bool  sendClusterLeaderEmail = bool.Parse(SendClusterLeaderEmailSetting);
            Group group = new Group(groupid);

            strLeaderEmail = group.Leader.Emails.FirstActive;
            if (strLeaderEmail.Length == 0 || sendClusterLeaderEmail)
            {
                GroupCluster parentCluster = group.GroupCluster;
                while (parentCluster.GroupClusterID != -1)
                {
                    if (parentCluster.Leader.Emails.FirstActive != string.Empty)
                    {
                        strLeaderEmail        = (!string.IsNullOrEmpty(strLeaderEmail) ? strLeaderEmail : parentCluster.Leader.Emails.FirstActive);
                        strClusterLeaderEmail = parentCluster.Leader.Emails.FirstActive;
                        break;
                    }
                    else if (parentCluster.Admin != null && parentCluster.Admin.PersonID != parentCluster.Leader.PersonID && parentCluster.Admin.Emails.FirstActive != string.Empty)
                    {
                        strLeaderEmail        = (!string.IsNullOrEmpty(strLeaderEmail) ? strLeaderEmail : parentCluster.Admin.Emails.FirstActive);
                        strClusterLeaderEmail = parentCluster.Admin.Emails.FirstActive;
                        break;
                    }
                    parentCluster = new GroupCluster(parentCluster.ParentClusterID);
                }
            }

            if (strLeaderEmail.Length == 0 && GroupLeaderEmailSetting != string.Empty)
            {
                strLeaderEmail = GroupLeaderEmailSetting;
            }
            else if (strLeaderEmail.Length == 0)
            {
                strLeaderEmail = CurrentOrganization.Settings["GroupLocatorEmail"];
            }

            SmallGroupLocator           smallGroupLocator = new SmallGroupLocator();
            Dictionary <string, string> fields            = new Dictionary <string, string>();

            fields.Add("##GroupName##", group.Title);
            fields.Add("##GroupID##", group.GroupID.ToString());
            fields.Add("##Name##", tbName.Text);
            fields.Add("##Phone##", tbPhone.PhoneNumber);
            fields.Add("##Email##", tbEmail.Text);
            fields.Add("##Notes##", tbNotes.Text);
            smallGroupLocator.Send(strLeaderEmail, fields);
            if (sendClusterLeaderEmail && strLeaderEmail != strClusterLeaderEmail)
            {
                smallGroupLocator.Send(strClusterLeaderEmail, fields);
            }

            //set pending registratant
            if (PendingRegistraintSetting.ToLower() == "true" && CurrentPerson != null && CurrentPerson.PersonID != -1)
            {
                Registration registration = new Registration();
                registration.OrganizationID = CurrentPortal.OrganizationID;

                if (_useGroupType)
                {
                    Lookup grpType = group.GroupType;
                    try
                    {
                        registration.ClusterType = new ClusterType(Int32.Parse(grpType.Qualifier));
                    }
                    catch
                    {
                        throw new ArenaApplicationException(string.Format("Invalid Cluster Type ID for Small Group Type '{0}'", grpType.Value));
                    }
                    registration.GroupType = grpType;
                }
                else
                {
                    registration.ClusterType = group.ClusterType;
                    registration.GroupType   = null;
                }
                if (group.GroupType.ToString() != string.Empty)
                {
                    registration.GroupType = group.GroupType;
                }

                registration.Notes = tbNotes.Text;
                registration.Persons.Add(CurrentPerson);
                registration.DayOfWeek.Add(group.MeetingDay);
                registration.AgeRange.Add(group.PrimaryAge);
                registration.MaritalPreference.Add(group.PrimaryMaritalStatus);
                registration.SetCluster();
                registration.GroupID = group.GroupID;

                registration.Save(CurrentPortal.OrganizationID, CurrentUser.Identity.Name);
            }

            Response.Redirect(string.Format("~/default.aspx?page={0}", RedirectPageIDSetting.ToString()), true);
        }
        private void btnSend_Click(object sender, EventArgs e)
        {
            int groupid = -1;
            string strLeaderEmail = "";
            string strClusterLeaderEmail = "";

            foreach (DataGridItem item in dgResults.Items)
            {
                RadioButton rb = (RadioButton)item.FindControl("rbSelect");
                if (rb.Checked)
                {
                    groupid = Int32.Parse(rb.Attributes["groupid"]);
                    break;
                }
            }

            bool sendClusterLeaderEmail = bool.Parse(SendClusterLeaderEmailSetting);
            Group group = new Group(groupid);
            strLeaderEmail = group.Leader.Emails.FirstActive;
            if (strLeaderEmail.Length == 0 || sendClusterLeaderEmail)
            {
                GroupCluster parentCluster = group.GroupCluster;
                while (parentCluster.GroupClusterID != -1)
                {
                    if (parentCluster.Leader.Emails.FirstActive != string.Empty)
                    {
                        strLeaderEmail = (!string.IsNullOrEmpty(strLeaderEmail) ? strLeaderEmail : parentCluster.Leader.Emails.FirstActive);
                        strClusterLeaderEmail = parentCluster.Leader.Emails.FirstActive;
                        break;
                    }
                    else if (parentCluster.Admin != null && parentCluster.Admin.PersonID != parentCluster.Leader.PersonID && parentCluster.Admin.Emails.FirstActive != string.Empty)
                    {
                        strLeaderEmail = (!string.IsNullOrEmpty(strLeaderEmail) ? strLeaderEmail : parentCluster.Admin.Emails.FirstActive);
                        strClusterLeaderEmail = parentCluster.Admin.Emails.FirstActive;
                        break;
                    }
                    parentCluster = new GroupCluster(parentCluster.ParentClusterID);
                }
            }

            if (strLeaderEmail.Length == 0 && GroupLeaderEmailSetting != string.Empty)
                strLeaderEmail = GroupLeaderEmailSetting;
            else if (strLeaderEmail.Length == 0)
                strLeaderEmail = CurrentOrganization.Settings["GroupLocatorEmail"];

            SmallGroupLocator smallGroupLocator = new SmallGroupLocator();
            Dictionary<string, string> fields = new Dictionary<string, string>();
            fields.Add("##GroupName##", group.Title);
            fields.Add("##GroupID##", group.GroupID.ToString());
            fields.Add("##Name##", tbName.Text);
            fields.Add("##Phone##", tbPhone.PhoneNumber);
            fields.Add("##Email##", tbEmail.Text);
            fields.Add("##Notes##", tbNotes.Text);
            smallGroupLocator.Send(strLeaderEmail, fields);
            if (sendClusterLeaderEmail && strLeaderEmail != strClusterLeaderEmail)
                smallGroupLocator.Send(strClusterLeaderEmail, fields);

            //set pending registratant
            if (PendingRegistraintSetting.ToLower() == "true" && CurrentPerson != null && CurrentPerson.PersonID != -1)
            {
                Registration registration = new Registration();
                registration.OrganizationID = CurrentPortal.OrganizationID;

                if (_useGroupType)
                {
                    Lookup grpType = group.GroupType;
                    try
                    {
                        registration.ClusterType = new ClusterType(Int32.Parse(grpType.Qualifier));
                    }
                    catch
                    {
                        throw new ArenaApplicationException(string.Format("Invalid Cluster Type ID for Small Group Type '{0}'", grpType.Value));
                    }
                    registration.GroupType = grpType;
                }
                else
                {
                    registration.ClusterType = group.ClusterType;
                    registration.GroupType = null;
                }
                if (group.GroupType.ToString() != string.Empty)
                    registration.GroupType = group.GroupType;

                registration.Notes = tbNotes.Text;
                registration.Persons.Add(CurrentPerson);
                registration.DayOfWeek.Add(group.MeetingDay);
                registration.AgeRange.Add(group.PrimaryAge);
                registration.MaritalPreference.Add(group.PrimaryMaritalStatus);
                registration.SetCluster();
                registration.GroupID = group.GroupID;

                registration.Save(CurrentPortal.OrganizationID, CurrentUser.Identity.Name);

            }

            Response.Redirect(string.Format("~/default.aspx?page={0}", RedirectPageIDSetting.ToString()), true);
        }
        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)
                throw new Exception("Access denied.");

            return mapper.FromArena(cluster);
        }
        public SmallGroupCluster FromArena(GroupCluster arena)
        {
            SmallGroupCluster cluster = new SmallGroupCluster();


            cluster.ClusterID = arena.GroupClusterID;
            if (cluster.ClusterID == -1)
            {
                return(cluster);
            }

            cluster.Active        = arena.Active;
            cluster.Admin         = new GenericReference(arena.Admin);
            cluster.AreaID        = arena.Area.AreaID;
            cluster.CategoryID    = arena.ClusterType.CategoryID;
            cluster.ClusterTypeID = arena.ClusterTypeID;
            cluster.CreatedBy     = arena.CreatedBy;
            cluster.DateCreated   = arena.DateCreated;
            cluster.DateModified  = arena.DateModified;
            cluster.Description   = arena.Description;
            if (arena.ImageBlob.BlobID != -1)
            {
                cluster.ImageUrl = this.BuildBlobUrl(arena.ImageBlob.GUID.ToString(), -1, Arena.Enums.Gender.Unknown);
            }
            cluster.Leader         = new GenericReference(arena.Leader);
            cluster.ClusterLevelID = arena.ClusterLevelID;
            cluster.ModifiedBy     = arena.ModifiedBy;
            cluster.Name           = arena.Name;
            if (String.IsNullOrEmpty(arena.NavigationUrl) == false)
            {
                cluster.NavigationUrl = arena.NavigationUrl;
            }
            if (String.IsNullOrEmpty(arena.Notes) == false)
            {
                cluster.Notes = arena.Notes;
            }
            cluster.ParentClusterID = arena.ParentClusterID;
            if (String.IsNullOrEmpty(arena.ClusterUrl) == false)
            {
                cluster.ClusterUrl = arena.ClusterUrl;
            }

            //
            // Get the counts from Arena.
            //
            SqlParameter groupCount, memberCount, unassignedRegCount, assignedRegCount;
            ArrayList    paramList = new ArrayList();

            groupCount                   = new SqlParameter("@GroupCount", SqlDbType.Int);
            groupCount.Direction         = ParameterDirection.Output;
            memberCount                  = new SqlParameter("@MemberCount", SqlDbType.Int);
            memberCount.Direction        = ParameterDirection.Output;
            unassignedRegCount           = new SqlParameter("@UnassignedRegCount", SqlDbType.Int);
            unassignedRegCount.Direction = ParameterDirection.Output;
            assignedRegCount             = new SqlParameter("@AssignedRegCount", SqlDbType.Int);
            assignedRegCount.Direction   = ParameterDirection.Output;

            paramList.Add(new SqlParameter("@ParentClusterID", arena.GroupClusterID));
            paramList.Add(new SqlParameter("@ActiveOnly", 1));
            paramList.Add(groupCount);
            paramList.Add(memberCount);
            paramList.Add(unassignedRegCount);
            paramList.Add(assignedRegCount);

            new Arena.DataLayer.Organization.OrganizationData().ExecuteNonQuery("smgp_sp_get_counts", paramList);
            cluster.GroupCount        = (int)groupCount.Value;
            cluster.MemberCount       = (int)memberCount.Value;
            cluster.RegistrationCount = (int)unassignedRegCount.Value;
            cluster.ClusterCount      = arena.ChildClusters.Count;

            return(cluster);
        }
Beispiel #13
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string[] keys;
            keys = Request.QueryString.AllKeys;
            foreach (string key in keys)
            {
                switch (key.ToUpper())
                {
                case "GROUP":
                    try { group = new Group(Int32.Parse(Request.QueryString.Get(key))); }
                    catch { }
                    break;

                case "PERSON":
                    try { person = new Person(new Guid(Request.QueryString.Get(key))); }
                    catch { }
                    break;

                case "SPOUSE":
                    try { spouse = new Person(new Guid(Request.QueryString.Get(key))); }
                    catch { }
                    break;
                }
            }

            if (group != null && group.GroupID != -1 && person != null && person.PersonID != -1)
            {
                GroupMember gMember = new GroupMember(group.GroupID, person.PersonID);
                if (gMember.GroupID == -1)
                {
                    bool exists       = false;
                    bool spouseExists = false;
                    foreach (Registration registration in group.Registrations)
                    {
                        foreach (Person registrant in registration.Persons)
                        {
                            if (registrant.PersonID == person.PersonID)
                            {
                                exists = true;
                            }
                            if (spouse != null && registrant.PersonID == spouse.PersonID)
                            {
                                spouseExists = true;
                            }
                        }
                    }

                    if (!exists)
                    {
                        Registration registration = new Registration();
                        registration.OrganizationID = CurrentOrganization.OrganizationID;
                        registration.ClusterType    = group.ClusterType;
                        registration.GroupID        = group.GroupID;
                        registration.GroupType      = group.GroupType;
                        registration.Notes          = "User-Entered Registration";
                        registration.ClusterID      = group.GroupClusterID;

                        if (group.ClusterType.UnassignedRegistrationLevel >= 0)
                        {
                            GroupCluster gc = group.GroupCluster;
                            while (gc != null && gc.ParentClusterID != -1 && gc.ClusterLevel.Level > group.ClusterType.UnassignedRegistrationLevel)
                            {
                                gc = new GroupCluster(gc.ParentClusterID);
                            }
                            if (gc.ClusterLevel.Level == group.ClusterType.UnassignedRegistrationLevel)
                            {
                                registration.ClusterID = gc.GroupClusterID;
                            }
                        }

                        registration.Persons.Add(person);

                        // Add Spouse if specified
                        if (spouse != null && !spouseExists)
                        {
                            registration.Persons.Add(spouse);
                        }

                        registration.Save(CurrentOrganization.OrganizationID, CurrentUser.Identity.Name);

                        foreach (Person rPerson in registration.Persons)
                        {
                            PersonHistory history = new PersonHistory();
                            history.PersonID           = rPerson.PersonID;
                            history.HistoryType        = new Lookup(SystemLookup.PersonHistoryType_SmallGroupRegistration);
                            history.HistoryQualifierID = registration.RegistrationID;
                            history.Text = "User registered for group: " + group.Title;
                            history.Save(CurrentOrganization.OrganizationID);
                        }
                    }
                }
            }
            //else
            //{
            //    throw new ModuleException(CurrentPortalPage, CurrentModule, "The GroupRegistrationAdd module requires a valid Group and Person!");
            //}
        }