From f6bf4c39be634bb8d1a03de5fd048edc54b7df50 Mon Sep 17 00:00:00 2001
From: Charles Krinke
Date: Tue, 24 Jun 2008 23:55:33 +0000
Subject: Mantis#1587. Thank you kindly, Melanie for a patch that: Add
permissions magling to llGiveInventoryItem, correct some corner case
functionality
---
.../Region/Environment/Scenes/Scene.Inventory.cs | 49 ++++++++++++++++------
OpenSim/Region/Environment/Scenes/Scene.cs | 4 +-
.../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 2 +-
.../Shared/Api/Implementation/LSL_Api.cs | 39 ++++++++++++++++-
4 files changed, 77 insertions(+), 17 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 3580b99..517066d 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -882,12 +882,6 @@ namespace OpenSim.Region.Environment.Scenes
return;
}
- // Only owner can copy
- if (remoteClient.AgentId != taskItem.OwnerID)
- {
- return;
- }
-
InventoryItemBase agentItem = new InventoryItemBase();
agentItem.ID = LLUUID.Random();
@@ -925,13 +919,13 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- /// MoveTaskInventoryItem
+ /// ClientMoveTaskInventoryItem
///
///
///
///
///
- public void MoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, uint primLocalId, LLUUID itemId)
+ public void ClientMoveTaskInventoryItem(IClientAPI remoteClient, LLUUID folderId, uint primLocalId, LLUUID itemId)
{
SceneObjectPart part = GetSceneObjectPart(primLocalId);
@@ -944,6 +938,15 @@ namespace OpenSim.Region.Environment.Scenes
return;
}
+
+ TaskInventoryItem taskItem = part.GetInventoryItem(itemId);
+
+ // Only owner can copy
+ if (remoteClient.AgentId != taskItem.OwnerID)
+ {
+ return;
+ }
+
MoveTaskInventoryItem(remoteClient, folderId, part, itemId);
}
@@ -977,7 +980,7 @@ namespace OpenSim.Region.Environment.Scenes
///
///
///
- public void CopyTaskInventoryItem(LLUUID destId, SceneObjectPart part, LLUUID itemId)
+ public void MoveTaskInventoryItem(LLUUID destId, SceneObjectPart part, LLUUID itemId)
{
TaskInventoryItem srcTaskItem = part.GetInventoryItem(itemId);
@@ -1003,23 +1006,43 @@ namespace OpenSim.Region.Environment.Scenes
destTaskItem.ItemID = LLUUID.Random();
destTaskItem.CreatorID = srcTaskItem.CreatorID;
destTaskItem.AssetID = srcTaskItem.AssetID;
- destTaskItem.GroupID = srcTaskItem.GroupID;
- destTaskItem.OwnerID = srcTaskItem.OwnerID;
- destTaskItem.ParentID = srcTaskItem.ParentID;
- destTaskItem.ParentPartID = srcTaskItem.ParentPartID;
+ destTaskItem.GroupID = destPart.GroupID;
+ destTaskItem.OwnerID = destPart.OwnerID;
+ destTaskItem.ParentID = destPart.UUID;
+ destTaskItem.ParentPartID = destPart.UUID;
destTaskItem.BaseMask = srcTaskItem.BaseMask;
destTaskItem.EveryoneMask = srcTaskItem.EveryoneMask;
destTaskItem.GroupMask = srcTaskItem.GroupMask;
destTaskItem.OwnerMask = srcTaskItem.OwnerMask;
+ destTaskItem.NextOwnerMask = srcTaskItem.NextOwnerMask;
destTaskItem.Flags = srcTaskItem.Flags;
+ if(destPart.OwnerID != part.OwnerID)
+ {
+ if (ExternalChecks.ExternalChecksPropagatePermissions())
+ {
+ destTaskItem.OwnerMask = srcTaskItem.OwnerMask &
+ srcTaskItem.NextOwnerMask;
+ destTaskItem.GroupMask = srcTaskItem.GroupMask &
+ srcTaskItem.NextOwnerMask;
+ destTaskItem.EveryoneMask = srcTaskItem.EveryoneMask &
+ srcTaskItem.NextOwnerMask;
+ destTaskItem.BaseMask = srcTaskItem.BaseMask &
+ srcTaskItem.NextOwnerMask;
+ destTaskItem.OwnerMask |= 8; // Slam!
+ }
+ }
+
destTaskItem.Description = srcTaskItem.Description;
destTaskItem.Name = srcTaskItem.Name;
destTaskItem.InvType = srcTaskItem.InvType;
destTaskItem.Type = srcTaskItem.Type;
destPart.AddInventoryItem(destTaskItem);
+
+ if((srcTaskItem.OwnerMask & (uint)PermissionMask.Copy) == 0)
+ part.RemoveInventoryItem(itemId);
}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 69981e2..bbef28f 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -2010,7 +2010,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnRequestTaskInventory += RequestTaskInventory;
client.OnRemoveTaskItem += RemoveTaskInventory;
client.OnUpdateTaskInventory += UpdateTaskInventory;
- client.OnMoveTaskItem += MoveTaskInventoryItem;
+ client.OnMoveTaskItem += ClientMoveTaskInventoryItem;
client.OnGrabObject += ProcessObjectGrab;
client.OnDeGrabObject += ProcessObjectDeGrab;
client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
@@ -3628,4 +3628,4 @@ namespace OpenSim.Region.Environment.Scenes
}
}
-
\ No newline at end of file
+
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index a4e473d..6d40dff 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -2729,7 +2729,7 @@ namespace OpenSim.Region.ScriptEngine.Common
else
{
// destination is an object
- World.CopyTaskInventoryItem(destId, m_host, objId);
+ World.MoveTaskInventoryItem(destId, m_host, objId);
}
if (!found)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 7832633..7c6bcf7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -36,6 +36,7 @@ using Axiom.Math;
using libsecondlife;
using OpenSim;
using OpenSim.Framework;
+using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Environment;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney;
@@ -2549,7 +2550,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llGiveInventory(string destination, string inventory)
{
m_host.AddScriptLPS(1);
- NotImplemented("llGiveInventory");
+ bool found = false;
+ LLUUID destId = LLUUID.Zero;
+ LLUUID objId = LLUUID.Zero;
+
+ if(!LLUUID.TryParse(destination, out destId))
+ {
+ llSay(0, "Could not parse key " + destination);
+ return;
+ }
+
+ // move the first object found with this inventory name
+ foreach (KeyValuePair inv in m_host.TaskInventory)
+ {
+ if (inv.Value.Name == inventory)
+ {
+ found = true;
+ objId = inv.Key;
+ break;
+ }
+ }
+
+ // check if destination is an avatar
+ if (World.GetScenePresence(destId) != null)
+ {
+ // destination is an avatar
+ CachedUserInfo userInfo =
+ World.CommsManager.UserProfileCacheService.GetUserDetails(destId);
+ World.MoveTaskInventoryItem(destId,userInfo.RootFolder.ID, m_host, objId);
+ }
+ else
+ {
+ // destination is an object
+ World.MoveTaskInventoryItem(destId, m_host, objId);
+ }
+
+ if (!found)
+ llSay(0, "Could not find object " + inventory);
}
public void llRemoveInventory(string item)
--
cgit v1.1