protected List<ExtendedGroupRoleMembersData> _GetGroupRoleMembers(UUID GroupID, bool isInGroup) { List<ExtendedGroupRoleMembersData> rmembers = new List<ExtendedGroupRoleMembersData>(); RoleData[] rdata = new RoleData[0]; if (!isInGroup) { rdata = m_Database.RetrieveRoles(GroupID); if (rdata == null || (rdata != null && rdata.Length == 0)) return rmembers; } List<RoleData> rlist = new List<RoleData>(rdata); if (!isInGroup) rlist = rlist.FindAll(r => (UInt64.Parse(r.Data["Powers"]) & (ulong)GroupPowers.MemberVisible) != 0); RoleMembershipData[] data = m_Database.RetrieveRolesMembers(GroupID); if (data == null || (data != null && data.Length == 0)) return rmembers; foreach (RoleMembershipData d in data) { if (!isInGroup) { RoleData rd = rlist.Find(_r => _r.RoleID == d.RoleID); // visible role if (rd == null) continue; } ExtendedGroupRoleMembersData r = new ExtendedGroupRoleMembersData(); r.MemberID = d.PrincipalID; r.RoleID = d.RoleID; rmembers.Add(r); } return rmembers; }
protected bool _AddOrUpdateGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, bool add) { RoleData data = m_Database.RetrieveRole(groupID, roleID); if (add && data != null) // it already exists, can't create { m_log.DebugFormat("[Groups]: Group {0} already exists. Can't create it again", groupID); return false; } if (!add && data == null) // it deosn't exist, can't update { m_log.DebugFormat("[Groups]: Group {0} doesn't exist. Can't update it", groupID); return false; } if (add) data = new RoleData(); data.GroupID = groupID; data.RoleID = roleID; data.Data = new Dictionary<string, string>(); data.Data["Name"] = name; data.Data["Description"] = description; data.Data["Title"] = title; data.Data["Powers"] = powers.ToString(); return m_Database.StoreRole(data); }