public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
        {
            object remoteValue = DoRemote(requestingAgentID, GroupID, AgentID);
            if (remoteValue != null || m_doRemoteOnly)
                return (GroupProfileData) remoteValue;

            if (!CheckGroupPermissions(requestingAgentID, GroupID, (ulong) GroupPowers.MemberVisible))
                return new GroupProfileData();

            GroupProfileData GPD = new GroupProfileData();
            GroupRecord record = GetGroupRecord(requestingAgentID, GroupID, null);

            QueryFilter filter1 = new QueryFilter();
            filter1.andFilters["GroupID"] = AgentID; // yes these look the wrong way around
            filter1.andFilters["AgentID"] = GroupID; // but they were like that when I got here! ~ SignpostMarv

            QueryFilter filter2 = new QueryFilter();
            filter2.andFilters["GroupID"] = GroupID;

            List<string> Membership = data.Query(new[]
                                                     {
                                                         "Contribution",
                                                         "ListInProfile",
                                                         "SelectedRoleID"
                                                     }, "osgroupmembership", filter1, null, null, null);

            int GroupMemCount =
                int.Parse(data.Query(new[] {"COUNT(AgentID)"}, "osgroupmembership", filter2, null, null, null)[0]);

            int GroupRoleCount = int.Parse(data.Query(new[] {"COUNT(RoleID)"}, "osrole", filter2, null, null, null)[0]);

            QueryFilter filter3 = new QueryFilter();
            filter3.andFilters["RoleID"] = Membership[2];
            List<string> GroupRole = data.Query(new[]
                                                    {
                                                        "Name",
                                                        "Powers"
                                                    }, "osrole", filter3, null, null, null);

            GPD.AllowPublish = record.AllowPublish;
            GPD.Charter = record.Charter;
            GPD.FounderID = record.FounderID;
            GPD.GroupID = record.GroupID;
            GPD.GroupMembershipCount = GroupMemCount;
            GPD.GroupRolesCount = GroupRoleCount;
            GPD.InsigniaID = record.GroupPicture;
            GPD.MaturePublish = record.MaturePublish;
            GPD.MembershipFee = record.MembershipFee;
            GPD.MemberTitle = GroupRole[0];
            GPD.Money = 0;

            GPD.Name = record.GroupName;
            GPD.OpenEnrollment = record.OpenEnrollment;
            GPD.OwnerRole = record.OwnerRoleID;
            GPD.PowersMask = ulong.Parse(GroupRole[1]);
            GPD.ShowInList = int.Parse(Membership[2]) == 1;

            return GPD;
        }
        public GroupProfileData GetGroupProfile(UUID requestingAgentID, UUID GroupID)
        {
            object remoteValue = DoRemote(requestingAgentID, GroupID);
            if (remoteValue != null || m_doRemoteOnly)
                return (GroupProfileData) remoteValue;

            GroupProfileData profile = new GroupProfileData();

            GroupRecord groupInfo = GetGroupRecord(requestingAgentID, GroupID, null);
            if (groupInfo != null)
            {
                profile.AllowPublish = groupInfo.AllowPublish;
                profile.Charter = groupInfo.Charter;
                profile.FounderID = groupInfo.FounderID;
                profile.GroupID = GroupID;
                profile.GroupMembershipCount =
                    GetGroupMembers(requestingAgentID, GroupID).Count;
                profile.GroupRolesCount = GetGroupRoles(requestingAgentID, GroupID).Count;
                profile.InsigniaID = groupInfo.GroupPicture;
                profile.MaturePublish = groupInfo.MaturePublish;
                profile.MembershipFee = groupInfo.MembershipFee;
                profile.Money = 0; // TODO: Get this from the currency server?
                profile.Name = groupInfo.GroupName;
                profile.OpenEnrollment = groupInfo.OpenEnrollment;
                profile.OwnerRole = groupInfo.OwnerRoleID;
                profile.ShowInList = groupInfo.ShowInList;
            }

            GroupMembershipData memberInfo = GetGroupMembershipData(requestingAgentID,
                                                                    GroupID,
                                                                    requestingAgentID);
            if (memberInfo != null)
            {
                profile.MemberTitle = memberInfo.GroupTitle;
                profile.PowersMask = memberInfo.GroupPowers;
            }

            return profile;
        }