From 19837ff4dd8b01cf1f0a458cafc02c56be48bf66 Mon Sep 17 00:00:00 2001 From: Snoopy Pfeffer Date: Tue, 27 Mar 2012 22:30:02 +0200 Subject: Two new scripting functions osInviteToGroup(userID) and osEjectFromGroup(userID) that invite/eject users to/from groups the object containing the script is set to. These functions also work for closed groups. --- .../Shared/Api/Implementation/OSSL_Api.cs | 69 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 3 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 10 ++++ 3 files changed, 82 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 2ecd890..a5dcba4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2980,5 +2980,74 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return String.Empty; } + + /// <summary> + /// Invite user to the group this object is set to + /// </summary> + /// <param name="agentId"></param> + /// <returns></returns> + public LSL_Integer osInviteToGroup(LSL_Key agentId) + { + CheckThreatLevel(ThreatLevel.VeryLow, "osInviteToGroup"); + m_host.AddScriptLPS(1); + + UUID agent = new UUID(agentId); + + // groups module is required + IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface<IGroupsModule>(); + if (groupsModule == null) return ScriptBaseClass.FALSE; + + // object has to be set to a group, but not group owned + if (m_host.GroupID == UUID.Zero || m_host.GroupID == m_host.OwnerID) return ScriptBaseClass.FALSE; + + // object owner has to be in that group and required permissions + GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID); + if (member == null || (member.GroupPowers & (ulong)GroupPowers.Invite) == 0) return ScriptBaseClass.FALSE; + + // check if agent is in that group already + //member = groupsModule.GetMembershipData(agent, m_host.GroupID, agent); + //if (member != null) return ScriptBaseClass.FALSE; + + // invited agent has to be present in this scene + if (World.GetScenePresence(agent) == null) return ScriptBaseClass.FALSE; + + groupsModule.InviteGroup(null, m_host.OwnerID, m_host.GroupID, agent, UUID.Zero); + + return ScriptBaseClass.TRUE; + } + + /// <summary> + /// Eject user from the group this object is set to + /// </summary> + /// <param name="agentId"></param> + /// <returns></returns> + public LSL_Integer osEjectFromGroup(LSL_Key agentId) + { + CheckThreatLevel(ThreatLevel.VeryLow, "osEjectFromGroup"); + m_host.AddScriptLPS(1); + + UUID agent = new UUID(agentId); + + // groups module is required + IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface<IGroupsModule>(); + if (groupsModule == null) return ScriptBaseClass.FALSE; + + // object has to be set to a group, but not group owned + if (m_host.GroupID == UUID.Zero || m_host.GroupID == m_host.OwnerID) return ScriptBaseClass.FALSE; + + // object owner has to be in that group and required permissions + GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID); + if (member == null || (member.GroupPowers & (ulong)GroupPowers.Eject) == 0) return ScriptBaseClass.FALSE; + + // agent has to be in that group + //member = groupsModule.GetMembershipData(agent, m_host.GroupID, agent); + //if (member == null) return ScriptBaseClass.FALSE; + + // ejectee can be offline + + groupsModule.EjectGroupMember(null, m_host.OwnerID, m_host.GroupID, agent); + + return ScriptBaseClass.TRUE; + } } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 8f9efc0..30bd3ef 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -231,5 +231,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_String osUnixTimeToTimestamp(long time); LSL_String osGetInventoryDesc(string item); + + LSL_Integer osInviteToGroup(LSL_Key agentId); + LSL_Integer osEjectFromGroup(LSL_Key agentId); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 09e5992..680cefb4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -868,5 +868,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osGetInventoryDesc(item); } + + public LSL_Integer osInviteToGroup(LSL_Key agentId) + { + return m_OSSL_Functions.osInviteToGroup(agentId); + } + + public LSL_Integer osEjectFromGroup(LSL_Key agentId) + { + return m_OSSL_Functions.osEjectFromGroup(agentId); + } } } -- cgit v1.1