public List <ExtendedGroupMembersData> GetGroupMembers(string RequestingAgentID, UUID GroupID)
        {
            List <ExtendedGroupMembersData> members = new List <ExtendedGroupMembersData>();

            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["GroupID"]           = GroupID.ToString();
            sendData["RequestingAgentID"] = RequestingAgentID;

            Dictionary <string, object> ret = MakeRequest("GETGROUPMEMBERS", sendData);

            if (ret == null)
            {
                return(members);
            }

            if (!ret.ContainsKey("RESULT"))
            {
                return(members);
            }

            if (ret["RESULT"].ToString() == "NULL")
            {
                return(members);
            }

            foreach (object v in ((Dictionary <string, object>)ret["RESULT"]).Values)
            {
                ExtendedGroupMembersData m = GroupsDataUtils.GroupMembersData((Dictionary <string, object>)v);
                members.Add(m);
            }

            return(members);
        }
Example #2
0
        public GroupMembersData ConvertGroupMembersData(ExtendedGroupMembersData _m)
        {
            if (m_log.IsDebugEnabled)
            {
                m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
            }


            GroupMembersData m = new GroupMembersData();

            m.AcceptNotices = _m.AcceptNotices;
            m.AgentPowers   = _m.AgentPowers;
            m.Contribution  = _m.Contribution;
            m.IsOwner       = _m.IsOwner;
            m.ListInProfile = _m.ListInProfile;
            m.OnlineStatus  = _m.OnlineStatus;
            m.Title         = _m.Title;

            string url = string.Empty, first = string.Empty, last = string.Empty, tmp = string.Empty;

            Util.ParseUniversalUserIdentifier(_m.AgentID, out m.AgentID, out url, out first, out last, out tmp);
            if (url != string.Empty)
            {
                m_UserManagement.AddUser(m.AgentID, first, last, url);
            }

            return(m);
        }
        public static Dictionary <string, object> GroupMembersData(ExtendedGroupMembersData member)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            dict["AcceptNotices"] = member.AcceptNotices.ToString();
            dict["AccessToken"]   = Sanitize(member.AccessToken);
            dict["AgentID"]       = Sanitize(member.AgentID);
            dict["AgentPowers"]   = member.AgentPowers.ToString();
            dict["Contribution"]  = member.Contribution.ToString();
            dict["IsOwner"]       = member.IsOwner.ToString();
            dict["ListInProfile"] = member.ListInProfile.ToString();
            dict["OnlineStatus"]  = Sanitize(member.OnlineStatus);
            dict["Title"]         = Sanitize(member.Title);

            return(dict);
        }
Example #4
0
        public GroupMembersData ConvertGroupMembersData(ExtendedGroupMembersData _m)
        {
            GroupMembersData m = new GroupMembersData();
            m.AcceptNotices = _m.AcceptNotices;
            m.AgentPowers = _m.AgentPowers;
            m.Contribution = _m.Contribution;
            m.IsOwner = _m.IsOwner;
            m.ListInProfile = _m.ListInProfile;
            m.OnlineStatus = _m.OnlineStatus;
            m.Title = _m.Title;

            string url = string.Empty, first = string.Empty, last = string.Empty, tmp = string.Empty;
            Util.ParseUniversalUserIdentifier(_m.AgentID, out m.AgentID, out url, out first, out last, out tmp);
            if (url != string.Empty)
                m_UserManagement.AddUser(m.AgentID, first, last, url);

            return m;
        }
Example #5
0
        public GroupMembersData ConvertGroupMembersData(ExtendedGroupMembersData _m)
        {
            GroupMembersData m = new GroupMembersData();

            m.AcceptNotices = _m.AcceptNotices;
            m.AgentPowers   = _m.AgentPowers;
            m.Contribution  = _m.Contribution;
            m.IsOwner       = _m.IsOwner;
            m.ListInProfile = _m.ListInProfile;
            m.OnlineStatus  = _m.OnlineStatus;
            m.Title         = _m.Title;

            string url = string.Empty, first = string.Empty, last = string.Empty, tmp = string.Empty;

            Util.ParseUniversalUserIdentifier(_m.AgentID, out m.AgentID, out url, out first, out last, out tmp);
            if (url != string.Empty)
            {
                m_UserManagement.AddUser(m.AgentID, first, last, url);
            }

            return(m);
        }
Example #6
0
        public GroupMembersData ConvertGroupMembersData(ExtendedGroupMembersData _m)
        {
			if (m_log.IsDebugEnabled) {
				m_log.DebugFormat ("{0} called", System.Reflection.MethodBase.GetCurrentMethod ().Name);
			}


            GroupMembersData m = new GroupMembersData();
            m.AcceptNotices = _m.AcceptNotices;
            m.AgentPowers = _m.AgentPowers;
            m.Contribution = _m.Contribution;
            m.IsOwner = _m.IsOwner;
            m.ListInProfile = _m.ListInProfile;
            m.OnlineStatus = _m.OnlineStatus;
            m.Title = _m.Title;

            string url = string.Empty, first = string.Empty, last = string.Empty, tmp = string.Empty;
            Util.ParseUniversalUserIdentifier(_m.AgentID, out m.AgentID, out url, out first, out last, out tmp);
            if (url != string.Empty)
                m_UserManagement.AddUser(m.AgentID, first, last, url);

            return m;
        }
        public static ExtendedGroupMembersData GroupMembersData(Dictionary<string, object> dict)
        {
            ExtendedGroupMembersData member = new ExtendedGroupMembersData();

            if (dict == null)
                return member;

            if (dict.ContainsKey("AcceptNotices") && dict["AcceptNotices"] != null)
                member.AcceptNotices = bool.Parse(dict["AcceptNotices"].ToString());

            if (dict.ContainsKey("AccessToken") && dict["AccessToken"] != null)
                member.AccessToken = Sanitize(dict["AccessToken"].ToString());
            else
                member.AccessToken = string.Empty;

            if (dict.ContainsKey("AgentID") && dict["AgentID"] != null)
                member.AgentID = Sanitize(dict["AgentID"].ToString());
            else
                member.AgentID = UUID.Zero.ToString();

            if (dict.ContainsKey("AgentPowers") && dict["AgentPowers"] != null)
                member.AgentPowers = UInt64.Parse(dict["AgentPowers"].ToString());

            if (dict.ContainsKey("Contribution") && dict["Contribution"] != null)
                member.Contribution = Int32.Parse(dict["Contribution"].ToString());

            if (dict.ContainsKey("IsOwner") && dict["IsOwner"] != null)
                member.IsOwner = bool.Parse(dict["IsOwner"].ToString());

            if (dict.ContainsKey("ListInProfile") && dict["ListInProfile"] != null)
                member.ListInProfile = bool.Parse(dict["ListInProfile"].ToString());

            if (dict.ContainsKey("OnlineStatus") && dict["OnlineStatus"] != null)
                member.OnlineStatus = Sanitize(dict["OnlineStatus"].ToString());
            else
                member.OnlineStatus = string.Empty;

            if (dict.ContainsKey("Title") && dict["Title"] != null)
                member.Title = Sanitize(dict["Title"].ToString());
            else
                member.Title = string.Empty;

            return member;
        }
        public static Dictionary<string, object> GroupMembersData(ExtendedGroupMembersData member)
        {
            Dictionary<string, object> dict = new Dictionary<string, object>();

            dict["AcceptNotices"] = member.AcceptNotices.ToString();
            dict["AccessToken"] = Sanitize(member.AccessToken);
            dict["AgentID"] = Sanitize(member.AgentID);
            dict["AgentPowers"] = member.AgentPowers.ToString();
            dict["Contribution"] = member.Contribution.ToString();
            dict["IsOwner"] = member.IsOwner.ToString();
            dict["ListInProfile"] = member.ListInProfile.ToString();
            dict["OnlineStatus"] = Sanitize(member.OnlineStatus);
            dict["Title"] = Sanitize(member.Title);

            return dict;
        }
Example #9
0
        public List<ExtendedGroupMembersData> GetGroupMembers(string RequestingAgentID, UUID GroupID)
        {
            List<ExtendedGroupMembersData> members = new List<ExtendedGroupMembersData>();

            GroupData group = m_Database.RetrieveGroup(GroupID);
            if (group == null)
                return members;

            // Unfortunately this doesn't quite work on legacy group data because of a bug
            // that's also being fixed here on CreateGroup. The OwnerRoleID sent to the DB was wrong.
            // See how to find the ownerRoleID a few lines below.
            UUID ownerRoleID = new UUID(group.Data["OwnerRoleID"]);

            RoleData[] roles = m_Database.RetrieveRoles(GroupID);
            if (roles == null)
                // something wrong with this group
                return members;
            List<RoleData> rolesList = new List<RoleData>(roles);

            // Let's find the "real" ownerRoleID
            RoleData ownerRole = rolesList.Find(r => r.Data["Powers"] == ((long)OwnerPowers).ToString());
            if (ownerRole != null)
                ownerRoleID = ownerRole.RoleID;

            // Check visibility? 
            // When we don't want to check visibility, we pass it "all" as the requestingAgentID
            bool checkVisibility = !RequestingAgentID.Equals(UUID.Zero.ToString());

            if (checkVisibility)
            {
                // Is the requester a member of the group?
                bool isInGroup = false;
                if (m_Database.RetrieveMember(GroupID, RequestingAgentID) != null)
                    isInGroup = true;

                if (!isInGroup) // reduce the roles to the visible ones
                    rolesList = rolesList.FindAll(r => (UInt64.Parse(r.Data["Powers"]) & (ulong)GroupPowers.MemberVisible) != 0);
            }

            MembershipData[] datas = m_Database.RetrieveMembers(GroupID);
            if (datas == null || (datas != null && datas.Length == 0))
                return members;

            // OK, we have everything we need

            foreach (MembershipData d in datas)
            {
                RoleMembershipData[] rolememberships = m_Database.RetrieveMemberRoles(GroupID, d.PrincipalID);
                List<RoleMembershipData> rolemembershipsList = new List<RoleMembershipData>(rolememberships);

                ExtendedGroupMembersData m = new ExtendedGroupMembersData();

                // What's this person's current role in the group?
                UUID selectedRole = new UUID(d.Data["SelectedRoleID"]);
                RoleData selected = rolesList.Find(r => r.RoleID == selectedRole);

                if (selected != null)
                {
                    m.Title = selected.Data["Title"];
                    m.AgentPowers = UInt64.Parse(selected.Data["Powers"]);
                }

                m.AgentID = d.PrincipalID;
                m.AcceptNotices = d.Data["AcceptNotices"] == "1" ? true : false;
                m.Contribution = Int32.Parse(d.Data["Contribution"]);
                m.ListInProfile = d.Data["ListInProfile"] == "1" ? true : false;

                // Is this person an owner of the group?
                m.IsOwner = (rolemembershipsList.Find(r => r.RoleID == ownerRoleID) != null) ? true : false;

                members.Add(m);
            }

            return members;
        }
        public List <ExtendedGroupMembersData> GetGroupMembers(string RequestingAgentID, UUID GroupID)
        {
            List <ExtendedGroupMembersData> members = new List <ExtendedGroupMembersData>();

            GroupData group = m_Database.RetrieveGroup(GroupID);

            if (group == null)
            {
                return(members);
            }

            UUID ownerRoleID = new UUID(group.Data["OwnerRoleID"]);

            RoleData[] roles = m_Database.RetrieveRoles(GroupID);
            if (roles == null)
            {
                // something wrong with this group
                return(members);
            }
            List <RoleData> rolesList = new List <RoleData>(roles);

            // Check visibility?
            // When we don't want to check visibility, we pass it "all" as the requestingAgentID
            bool checkVisibility = !RequestingAgentID.Equals(UUID.Zero.ToString());

            if (checkVisibility)
            {
                // Is the requester a member of the group?
                bool isInGroup = false;
                if (m_Database.RetrieveMember(GroupID, RequestingAgentID) != null)
                {
                    isInGroup = true;
                }

                if (!isInGroup) // reduce the roles to the visible ones
                {
                    rolesList = rolesList.FindAll(r => (UInt64.Parse(r.Data["Powers"]) & (ulong)GroupPowers.MemberVisible) != 0);
                }
            }

            MembershipData[] datas = m_Database.RetrieveMembers(GroupID);
            if (datas == null || (datas != null && datas.Length == 0))
            {
                return(members);
            }

            // OK, we have everything we need

            foreach (MembershipData d in datas)
            {
                RoleMembershipData[]      rolememberships     = m_Database.RetrieveMemberRoles(GroupID, d.PrincipalID);
                List <RoleMembershipData> rolemembershipsList = new List <RoleMembershipData>(rolememberships);

                ExtendedGroupMembersData m = new ExtendedGroupMembersData();

                // What's this person's current role in the group?
                UUID     selectedRole = new UUID(d.Data["SelectedRoleID"]);
                RoleData selected     = rolesList.Find(r => r.RoleID == selectedRole);

                if (selected != null)
                {
                    m.Title       = selected.Data["Title"];
                    m.AgentPowers = UInt64.Parse(selected.Data["Powers"]);

                    m.AgentID       = d.PrincipalID;
                    m.AcceptNotices = d.Data["AcceptNotices"] == "1" ? true : false;
                    m.Contribution  = Int32.Parse(d.Data["Contribution"]);
                    m.ListInProfile = d.Data["ListInProfile"] == "1" ? true : false;

                    // Is this person an owner of the group?
                    m.IsOwner = (rolemembershipsList.Find(r => r.RoleID == ownerRoleID) != null) ? true : false;

                    members.Add(m);
                }
            }

            return(members);
        }
Example #11
0
        public List<ExtendedGroupMembersData> GetGroupMembers(string RequestingAgentID, UUID GroupID)
        {
            List<ExtendedGroupMembersData> members = new List<ExtendedGroupMembersData>();

            GroupData group = m_Database.RetrieveGroup(GroupID);
            if (group == null)
                return members;

            UUID ownerRoleID = new UUID(group.Data["OwnerRoleID"]);

            RoleData[] roles = m_Database.RetrieveRoles(GroupID);
            if (roles == null)
                // something wrong with this group
                return members;
            List<RoleData> rolesList = new List<RoleData>(roles);

            // Is the requester a member of the group?
            bool isInGroup = false;
            if (m_Database.RetrieveMember(GroupID, RequestingAgentID) != null)
                isInGroup = true;

            if (!isInGroup) // reduce the roles to the visible ones
                rolesList = rolesList.FindAll(r => (UInt64.Parse(r.Data["Powers"]) & (ulong)GroupPowers.MemberVisible) != 0);

            MembershipData[] datas = m_Database.RetrieveMembers(GroupID);
            if (datas == null || (datas != null && datas.Length == 0))
                return members;

            // OK, we have everything we need

            foreach (MembershipData d in datas)
            {
                RoleMembershipData[] rolememberships = m_Database.RetrieveMemberRoles(GroupID, d.PrincipalID);
                List<RoleMembershipData> rolemembershipsList = new List<RoleMembershipData>(rolememberships);

                ExtendedGroupMembersData m = new ExtendedGroupMembersData();

                // What's this person's current role in the group?
                UUID selectedRole = new UUID(d.Data["SelectedRoleID"]);
                RoleData selected = rolesList.Find(r => r.RoleID == selectedRole);

                if (selected != null)
                {
                    m.Title = selected.Data["Title"];
                    m.AgentPowers = UInt64.Parse(selected.Data["Powers"]);

                    m.AgentID = d.PrincipalID;
                    m.AcceptNotices = d.Data["AcceptNotices"] == "1" ? true : false;
                    m.Contribution = Int32.Parse(d.Data["Contribution"]);
                    m.ListInProfile = d.Data["ListInProfile"] == "1" ? true : false;

                    // Is this person an owner of the group?
                    m.IsOwner = (rolemembershipsList.Find(r => r.RoleID == ownerRoleID) != null) ? true : false;

                    members.Add(m);
                }
            }

            return members;
        }
Example #12
0
        public List <ExtendedGroupMembersData> GetGroupMembers(string RequestingAgentID, UUID GroupID)
        {
            List <ExtendedGroupMembersData> members = new List <ExtendedGroupMembersData>();

            GroupData group = m_Database.RetrieveGroup(GroupID);

            if (group == null)
            {
                return(members);
            }

            // Unfortunately this doesn't quite work on legacy group data because of a bug
            // that's also being fixed here on CreateGroup. The OwnerRoleID sent to the DB was wrong.
            // See how to find the ownerRoleID a few lines below.
            UUID ownerRoleID = new UUID(group.Data["OwnerRoleID"]);

            RoleData[] roles = m_Database.RetrieveRoles(GroupID);
            if (roles == null)
            {
                // something wrong with this group
                return(members);
            }
            List <RoleData> rolesList = new List <RoleData>(roles);

            // Let's find the "real" ownerRoleID
            RoleData ownerRole = rolesList.Find(r => r.Data["Powers"] == ((long)OwnerPowers).ToString());

            if (ownerRole != null)
            {
                ownerRoleID = ownerRole.RoleID;
            }

            // Check visibility?
            // When we don't want to check visibility, we pass it "all" as the requestingAgentID
            bool checkVisibility = !RequestingAgentID.Equals(UUID.Zero.ToString());

            if (checkVisibility)
            {
                // Is the requester a member of the group?
                bool isInGroup = false;
                if (m_Database.RetrieveMember(GroupID, RequestingAgentID) != null)
                {
                    isInGroup = true;
                }

                if (!isInGroup) // reduce the roles to the visible ones
                {
                    rolesList = rolesList.FindAll(r => (UInt64.Parse(r.Data["Powers"]) & (ulong)GroupPowers.MemberVisible) != 0);
                }
            }

            MembershipData[] datas = m_Database.RetrieveMembers(GroupID);
            if (datas == null || (datas != null && datas.Length == 0))
            {
                return(members);
            }

            // OK, we have everything we need

            foreach (MembershipData d in datas)
            {
                RoleMembershipData[]      rolememberships     = m_Database.RetrieveMemberRoles(GroupID, d.PrincipalID);
                List <RoleMembershipData> rolemembershipsList = new List <RoleMembershipData>(rolememberships);

                ExtendedGroupMembersData m = new ExtendedGroupMembersData();

                // What's this person's current role in the group?
                UUID     selectedRole = new UUID(d.Data["SelectedRoleID"]);
                RoleData selected     = rolesList.Find(r => r.RoleID == selectedRole);

                if (selected != null)
                {
                    m.Title       = selected.Data["Title"];
                    m.AgentPowers = UInt64.Parse(selected.Data["Powers"]);
                }

                m.AgentID       = d.PrincipalID;
                m.AcceptNotices = d.Data["AcceptNotices"] == "1" ? true : false;
                m.Contribution  = Int32.Parse(d.Data["Contribution"]);
                m.ListInProfile = d.Data["ListInProfile"] == "1" ? true : false;

                GridUserData gud = m_GridUserService.Get(d.PrincipalID);
                if (gud != null)
                {
                    if (bool.Parse(gud.Data["Online"]))
                    {
                        m.OnlineStatus = @"Online";
                    }
                    else
                    {
                        int unixtime = int.Parse(gud.Data["Login"]);
                        // The viewer is very picky about how these strings are formed. Eg. it will crash on malformed dates!
                        m.OnlineStatus = (unixtime == 0) ? @"unknown" : Util.ToDateTime(unixtime).ToString("MM/dd/yyyy");
                    }
                }

                // Is this person an owner of the group?
                m.IsOwner = (rolemembershipsList.Find(r => r.RoleID == ownerRoleID) != null) ? true : false;

                members.Add(m);
            }

            return(members);
        }
        public static ExtendedGroupMembersData GroupMembersData(Dictionary <string, object> dict)
        {
            ExtendedGroupMembersData member = new ExtendedGroupMembersData();

            if (dict == null)
            {
                return(member);
            }

            if (dict.ContainsKey("AcceptNotices") && dict["AcceptNotices"] != null)
            {
                member.AcceptNotices = bool.Parse(dict["AcceptNotices"].ToString());
            }

            if (dict.ContainsKey("AccessToken") && dict["AccessToken"] != null)
            {
                member.AccessToken = Sanitize(dict["AccessToken"].ToString());
            }
            else
            {
                member.AccessToken = string.Empty;
            }

            if (dict.ContainsKey("AgentID") && dict["AgentID"] != null)
            {
                member.AgentID = Sanitize(dict["AgentID"].ToString());
            }
            else
            {
                member.AgentID = UUID.Zero.ToString();
            }

            if (dict.ContainsKey("AgentPowers") && dict["AgentPowers"] != null)
            {
                member.AgentPowers = UInt64.Parse(dict["AgentPowers"].ToString());
            }

            if (dict.ContainsKey("Contribution") && dict["Contribution"] != null)
            {
                member.Contribution = Int32.Parse(dict["Contribution"].ToString());
            }

            if (dict.ContainsKey("IsOwner") && dict["IsOwner"] != null)
            {
                member.IsOwner = bool.Parse(dict["IsOwner"].ToString());
            }

            if (dict.ContainsKey("ListInProfile") && dict["ListInProfile"] != null)
            {
                member.ListInProfile = bool.Parse(dict["ListInProfile"].ToString());
            }

            if (dict.ContainsKey("OnlineStatus") && dict["OnlineStatus"] != null)
            {
                member.OnlineStatus = Sanitize(dict["OnlineStatus"].ToString());
            }
            else
            {
                member.OnlineStatus = string.Empty;
            }

            if (dict.ContainsKey("Title") && dict["Title"] != null)
            {
                member.Title = Sanitize(dict["Title"].ToString());
            }
            else
            {
                member.Title = string.Empty;
            }

            return(member);
        }