private osGroupMemberInfo AddAgentToGroup(UUID AgentID, osGroup existingGroup) { if (existingGroup.Members.ContainsKey(AgentID)) { return(existingGroup.Members[AgentID]); } osGroupMemberInfo newMembership = new osGroupMemberInfo(); newMembership.AgentID = AgentID; newMembership.AcceptNotices = true; newMembership.Contribution = 0; newMembership.ListInProfile = true; newMembership.SelectedTitleRole = UUID.Zero; // Everyone Role newMembership.Roles.Add(UUID.Zero, existingGroup.Roles[UUID.Zero]); existingGroup.Roles[UUID.Zero].RoleMembers.Add(AgentID, newMembership); // Make sure the member is in the big Group Membership lookup dictionary if (!m_GroupMemberInfo.ContainsKey(AgentID)) { m_GroupMemberInfo.Add(AgentID, new Dictionary <UUID, osGroupMemberInfo>()); } // Add this particular membership to the lookup m_GroupMemberInfo[AgentID].Add(existingGroup.GroupID, newMembership); // Add member to group's local list of members existingGroup.Members.Add(AgentID, newMembership); return(newMembership); }
public void ActivateGroup(IClientAPI remoteClient, UUID groupID) { m_log.InfoFormat("[Groups] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); string Title = ""; if (groupID == UUID.Zero) { // Setting to no group active, "None" m_AgentActiveGroup[remoteClient.AgentId] = groupID; } else if (m_Groups.ContainsKey(groupID)) { osGroup group = m_Groups[groupID]; if (group.Members.ContainsKey(remoteClient.AgentId)) { m_AgentActiveGroup[remoteClient.AgentId] = groupID; osGroupMemberInfo member = group.Members[remoteClient.AgentId]; Title = group.Roles[member.SelectedTitleRole].Title; } } UpdateScenePresenceWithTitle(remoteClient.AgentId, Title); UpdateClientWithGroupInfo(remoteClient); }
public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) { m_log.InfoFormat("[Groups] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); foreach (osGroup existingGroup in m_Groups.Values) { if (existingGroup.Name.ToLower().Trim().Equals(name.ToLower().Trim())) { remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); return(UUID.Zero); } } osGroup newGroup = new osGroup(); newGroup.GroupID = UUID.Random(); newGroup.Name = name; newGroup.Charter = charter; newGroup.ShowInList = showInList; newGroup.InsigniaID = insigniaID; newGroup.MembershipFee = membershipFee; newGroup.OpenEnrollment = openEnrollment; newGroup.AllowPublish = allowPublish; newGroup.MaturePublish = maturePublish; newGroup.PowersMask = AllGroupPowers; newGroup.FounderID = remoteClient.AgentId; // Setup members role osgRole everyoneRole = AddRole2Group(newGroup, "Everyone", "Everyone in the group is in the everyone role.", "Everyone Title", m_DefaultEveryonePowers, UUID.Zero); // Setup owners role osgRole ownerRole = AddRole2Group(newGroup, "Owners", "Owners of " + newGroup.Name, "Owner of " + newGroup.Name, AllGroupPowers); osGroupMemberInfo Member = AddAgentToGroup(remoteClient.AgentId, newGroup); // Put the founder in the owner and everyone role Member.Roles.Add(ownerRole.RoleID, ownerRole); // Add founder to owner & everyone's local lists of members ownerRole.RoleMembers.Add(Member.AgentID, Member); // Add group to module m_Groups.Add(newGroup.GroupID, newGroup); remoteClient.SendCreateGroupReply(newGroup.GroupID, true, "Group created successfullly"); // Set this as the founder's active group ActivateGroup(remoteClient, newGroup.GroupID); // The above sends this out too as of 4/3/09 // UpdateClientWithGroupInfo(remoteClient); return(newGroup.GroupID); }
private osgRole AddRole2Group(osGroup group, string name, string description, string title, GroupPowers powers, UUID roleid) { osgRole newRole = new osgRole(); // everyoneRole.RoleID = UUID.Random(); newRole.RoleID = roleid; newRole.Name = name; newRole.Description = description; newRole.Powers = (GroupPowers)powers & group.PowersMask; newRole.Title = title; newRole.Group = group; group.Roles.Add(newRole.RoleID, newRole); return(newRole); }
private osgRole AddRole2Group(osGroup group, string name, string description, string title, GroupPowers powers) { return(AddRole2Group(group, name, description, title, powers, UUID.Random())); }
private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID AgentID, UUID SessionID) { m_log.InfoFormat("[Groups] {0} called with SessionID :: {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, SessionID); UUID ActiveGroupID; string ActiveGroupTitle = string.Empty; string ActiveGroupName = string.Empty; ulong ActiveGroupPowers = (ulong)GroupPowers.None; if (m_AgentActiveGroup.TryGetValue(AgentID, out ActiveGroupID)) { if ((ActiveGroupID != null) && (ActiveGroupID != UUID.Zero)) { osGroup group = m_Groups[ActiveGroupID]; osGroupMemberInfo membership = m_GroupMemberInfo[AgentID][ActiveGroupID]; ActiveGroupName = group.Name; if (membership.SelectedTitleRole != UUID.Zero) { ActiveGroupTitle = membership.Roles[membership.SelectedTitleRole].Title; } // Gather up all the powers from agent's roles, then mask them with group mask foreach (osgRole role in membership.Roles.Values) { ActiveGroupPowers |= (ulong)role.Powers; } ActiveGroupPowers &= (ulong)group.PowersMask; } else { ActiveGroupID = UUID.Zero; } } else { // I think this is needed bcasue the TryGetValue() will set this to null ActiveGroupID = UUID.Zero; } string firstname, lastname; IClientAPI agent; if (m_ActiveClients.TryGetValue(AgentID, out agent)) { firstname = agent.FirstName; lastname = agent.LastName; } else { firstname = "Unknown"; lastname = "Unknown"; } m_log.InfoFormat("[Groups] Active Powers {0}, Group {1}, Title {2}", ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle); remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle); }