Mantis#1587. Thank you kindly, Melanie for a patch that:

Add permissions magling to llGiveInventoryItem, 
correct some corner case functionality
0.6.0-stable
Charles Krinke 2008-06-24 23:55:33 +00:00
parent dc0d089bf5
commit f6bf4c39be
4 changed files with 77 additions and 17 deletions

View File

@ -882,12 +882,6 @@ namespace OpenSim.Region.Environment.Scenes
return; return;
} }
// Only owner can copy
if (remoteClient.AgentId != taskItem.OwnerID)
{
return;
}
InventoryItemBase agentItem = new InventoryItemBase(); InventoryItemBase agentItem = new InventoryItemBase();
agentItem.ID = LLUUID.Random(); agentItem.ID = LLUUID.Random();
@ -925,13 +919,13 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// <see>MoveTaskInventoryItem</see> /// <see>ClientMoveTaskInventoryItem</see>
/// </summary> /// </summary>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
/// <param name="folderID"></param> /// <param name="folderID"></param>
/// <param name="primLocalID"></param> /// <param name="primLocalID"></param>
/// <param name="itemID"></param> /// <param name="itemID"></param>
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); SceneObjectPart part = GetSceneObjectPart(primLocalId);
@ -944,6 +938,15 @@ namespace OpenSim.Region.Environment.Scenes
return; return;
} }
TaskInventoryItem taskItem = part.GetInventoryItem(itemId);
// Only owner can copy
if (remoteClient.AgentId != taskItem.OwnerID)
{
return;
}
MoveTaskInventoryItem(remoteClient, folderId, part, itemId); MoveTaskInventoryItem(remoteClient, folderId, part, itemId);
} }
@ -977,7 +980,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="destId"></param> /// <param name="destId"></param>
/// <param name="part"></param> /// <param name="part"></param>
/// <param name="itemId"></param> /// <param name="itemId"></param>
public void CopyTaskInventoryItem(LLUUID destId, SceneObjectPart part, LLUUID itemId) public void MoveTaskInventoryItem(LLUUID destId, SceneObjectPart part, LLUUID itemId)
{ {
TaskInventoryItem srcTaskItem = part.GetInventoryItem(itemId); TaskInventoryItem srcTaskItem = part.GetInventoryItem(itemId);
@ -1003,23 +1006,43 @@ namespace OpenSim.Region.Environment.Scenes
destTaskItem.ItemID = LLUUID.Random(); destTaskItem.ItemID = LLUUID.Random();
destTaskItem.CreatorID = srcTaskItem.CreatorID; destTaskItem.CreatorID = srcTaskItem.CreatorID;
destTaskItem.AssetID = srcTaskItem.AssetID; destTaskItem.AssetID = srcTaskItem.AssetID;
destTaskItem.GroupID = srcTaskItem.GroupID; destTaskItem.GroupID = destPart.GroupID;
destTaskItem.OwnerID = srcTaskItem.OwnerID; destTaskItem.OwnerID = destPart.OwnerID;
destTaskItem.ParentID = srcTaskItem.ParentID; destTaskItem.ParentID = destPart.UUID;
destTaskItem.ParentPartID = srcTaskItem.ParentPartID; destTaskItem.ParentPartID = destPart.UUID;
destTaskItem.BaseMask = srcTaskItem.BaseMask; destTaskItem.BaseMask = srcTaskItem.BaseMask;
destTaskItem.EveryoneMask = srcTaskItem.EveryoneMask; destTaskItem.EveryoneMask = srcTaskItem.EveryoneMask;
destTaskItem.GroupMask = srcTaskItem.GroupMask; destTaskItem.GroupMask = srcTaskItem.GroupMask;
destTaskItem.OwnerMask = srcTaskItem.OwnerMask; destTaskItem.OwnerMask = srcTaskItem.OwnerMask;
destTaskItem.NextOwnerMask = srcTaskItem.NextOwnerMask;
destTaskItem.Flags = srcTaskItem.Flags; 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.Description = srcTaskItem.Description;
destTaskItem.Name = srcTaskItem.Name; destTaskItem.Name = srcTaskItem.Name;
destTaskItem.InvType = srcTaskItem.InvType; destTaskItem.InvType = srcTaskItem.InvType;
destTaskItem.Type = srcTaskItem.Type; destTaskItem.Type = srcTaskItem.Type;
destPart.AddInventoryItem(destTaskItem); destPart.AddInventoryItem(destTaskItem);
if((srcTaskItem.OwnerMask & (uint)PermissionMask.Copy) == 0)
part.RemoveInventoryItem(itemId);
} }

View File

@ -2010,7 +2010,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnRequestTaskInventory += RequestTaskInventory; client.OnRequestTaskInventory += RequestTaskInventory;
client.OnRemoveTaskItem += RemoveTaskInventory; client.OnRemoveTaskItem += RemoveTaskInventory;
client.OnUpdateTaskInventory += UpdateTaskInventory; client.OnUpdateTaskInventory += UpdateTaskInventory;
client.OnMoveTaskItem += MoveTaskInventoryItem; client.OnMoveTaskItem += ClientMoveTaskInventoryItem;
client.OnGrabObject += ProcessObjectGrab; client.OnGrabObject += ProcessObjectGrab;
client.OnDeGrabObject += ProcessObjectDeGrab; client.OnDeGrabObject += ProcessObjectDeGrab;
client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
@ -3628,4 +3628,4 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }

View File

@ -2729,7 +2729,7 @@ namespace OpenSim.Region.ScriptEngine.Common
else else
{ {
// destination is an object // destination is an object
World.CopyTaskInventoryItem(destId, m_host, objId); World.MoveTaskInventoryItem(destId, m_host, objId);
} }
if (!found) if (!found)

View File

@ -36,6 +36,7 @@ using Axiom.Math;
using libsecondlife; using libsecondlife;
using OpenSim; using OpenSim;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Environment; using OpenSim.Region.Environment;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney; 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) public void llGiveInventory(string destination, string inventory)
{ {
m_host.AddScriptLPS(1); 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<LLUUID, TaskInventoryItem> 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) public void llRemoveInventory(string item)