diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 200 |
1 files changed, 97 insertions, 103 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 29666d5..7377e6d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -1645,76 +1645,78 @@ namespace OpenSim.Region.Framework.Scenes | |||
1645 | uint primLocalID) | 1645 | uint primLocalID) |
1646 | { | 1646 | { |
1647 | UUID itemID = itemInfo.ItemID; | 1647 | UUID itemID = itemInfo.ItemID; |
1648 | if (itemID == UUID.Zero) | ||
1649 | { | ||
1650 | m_log.ErrorFormat( | ||
1651 | "[PRIM INVENTORY]: UpdateTaskInventory called with item ID Zero to update for {1}!", | ||
1652 | remoteClient.Name); | ||
1653 | return; | ||
1654 | } | ||
1648 | 1655 | ||
1649 | // Find the prim we're dealing with | 1656 | // Find the prim we're dealing with |
1650 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | 1657 | SceneObjectPart part = GetSceneObjectPart(primLocalID); |
1658 | if(part == null) | ||
1659 | { | ||
1660 | m_log.WarnFormat( | ||
1661 | "[PRIM INVENTORY]: " + | ||
1662 | "Update with item {0} requested of prim {1} for {2} but this prim does not exist", | ||
1663 | itemID, primLocalID, remoteClient.Name); | ||
1664 | return; | ||
1665 | } | ||
1651 | 1666 | ||
1652 | if (part != null) | 1667 | TaskInventoryItem currentItem = part.Inventory.GetInventoryItem(itemID); |
1668 | |||
1669 | if (currentItem == null) | ||
1653 | { | 1670 | { |
1654 | TaskInventoryItem currentItem = part.Inventory.GetInventoryItem(itemID); | 1671 | InventoryItemBase item = InventoryService.GetItem(remoteClient.AgentId, itemID); |
1655 | bool allowInventoryDrop = (part.GetEffectiveObjectFlags() | ||
1656 | & (uint)PrimFlags.AllowInventoryDrop) != 0; | ||
1657 | 1672 | ||
1658 | // Explicity allow anyone to add to the inventory if the | 1673 | // if not found Try library |
1659 | // AllowInventoryDrop flag has been set. Don't however let | 1674 | if (item == null && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1660 | // them update an item unless they pass the external checks | 1675 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1661 | // | ||
1662 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId) | ||
1663 | && (currentItem != null || !allowInventoryDrop)) | ||
1664 | return; | ||
1665 | 1676 | ||
1666 | if (currentItem == null) | 1677 | if(item == null) |
1667 | { | 1678 | { |
1668 | UUID copyID = UUID.Random(); | 1679 | m_log.ErrorFormat( |
1669 | if (itemID != UUID.Zero) | 1680 | "[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!", |
1670 | { | 1681 | itemID, remoteClient.Name); |
1671 | InventoryItemBase item = InventoryService.GetItem(remoteClient.AgentId, itemID); | 1682 | return; |
1683 | } | ||
1672 | 1684 | ||
1673 | // Try library | 1685 | if (!Permissions.CanDropInObjectInv(item, remoteClient, part)) |
1674 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) | 1686 | return; |
1675 | { | ||
1676 | item = LibraryService.LibraryRootFolder.FindItem(itemID); | ||
1677 | } | ||
1678 | 1687 | ||
1679 | // If we've found the item in the user's inventory or in the library | 1688 | UUID copyID = UUID.Random(); |
1680 | if (item != null) | 1689 | part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID); |
1681 | { | 1690 | m_log.InfoFormat( |
1682 | part.ParentGroup.AddInventoryItem(remoteClient.AgentId, primLocalID, item, copyID); | 1691 | "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", |
1683 | m_log.InfoFormat( | 1692 | item.Name, primLocalID, remoteClient.Name); |
1684 | "[PRIM INVENTORY]: Update with item {0} requested of prim {1} for {2}", | 1693 | part.SendPropertiesToClient(remoteClient); |
1685 | item.Name, primLocalID, remoteClient.Name); | 1694 | if (!Permissions.BypassPermissions()) |
1686 | part.SendPropertiesToClient(remoteClient); | 1695 | { |
1687 | if (!Permissions.BypassPermissions()) | 1696 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) |
1688 | { | 1697 | { |
1689 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | 1698 | List<UUID> uuids = new List<UUID>(); |
1690 | { | 1699 | uuids.Add(itemID); |
1691 | List<UUID> uuids = new List<UUID>(); | 1700 | RemoveInventoryItem(remoteClient, uuids); |
1692 | uuids.Add(itemID); | ||
1693 | RemoveInventoryItem(remoteClient, uuids); | ||
1694 | } | ||
1695 | } | ||
1696 | } | ||
1697 | else | ||
1698 | { | ||
1699 | m_log.ErrorFormat( | ||
1700 | "[PRIM INVENTORY]: Could not find inventory item {0} to update for {1}!", | ||
1701 | itemID, remoteClient.Name); | ||
1702 | } | ||
1703 | } | 1701 | } |
1704 | } | 1702 | } |
1705 | else // Updating existing item with new perms etc | 1703 | } |
1706 | { | 1704 | else // Updating existing item with new perms etc |
1705 | { | ||
1707 | // m_log.DebugFormat( | 1706 | // m_log.DebugFormat( |
1708 | // "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", | 1707 | // "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", |
1709 | // currentItem.Name, part.Name); | 1708 | // currentItem.Name, part.Name); |
1710 | 1709 | ||
1711 | // Only look for an uploaded updated asset if we are passed a transaction ID. This is only the | 1710 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) |
1712 | // case for updates uploded through UDP. Updates uploaded via a capability (e.g. a script update) | 1711 | return; |
1713 | // will not pass in a transaction ID in the update message. | 1712 | |
1714 | if (transactionID != UUID.Zero && AgentTransactionsModule != null) | 1713 | // Only look for an uploaded updated asset if we are passed a transaction ID. This is only the |
1715 | { | 1714 | // case for updates uploded through UDP. Updates uploaded via a capability (e.g. a script update) |
1716 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( | 1715 | // will not pass in a transaction ID in the update message. |
1717 | remoteClient, part, transactionID, currentItem); | 1716 | if (transactionID != UUID.Zero && AgentTransactionsModule != null) |
1717 | { | ||
1718 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( | ||
1719 | remoteClient, part, transactionID, currentItem); | ||
1718 | 1720 | ||
1719 | // if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | 1721 | // if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) |
1720 | // remoteClient.SendAgentAlertMessage("Notecard saved", false); | 1722 | // remoteClient.SendAgentAlertMessage("Notecard saved", false); |
@@ -1722,49 +1724,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1722 | // remoteClient.SendAgentAlertMessage("Script saved", false); | 1724 | // remoteClient.SendAgentAlertMessage("Script saved", false); |
1723 | // else | 1725 | // else |
1724 | // remoteClient.SendAgentAlertMessage("Item saved", false); | 1726 | // remoteClient.SendAgentAlertMessage("Item saved", false); |
1725 | } | 1727 | } |
1726 | 1728 | ||
1727 | // Base ALWAYS has move | 1729 | // Base ALWAYS has move |
1728 | currentItem.BasePermissions |= (uint)PermissionMask.Move; | 1730 | currentItem.BasePermissions |= (uint)PermissionMask.Move; |
1729 | 1731 | ||
1730 | itemInfo.Flags = currentItem.Flags; | 1732 | itemInfo.Flags = currentItem.Flags; |
1731 | 1733 | ||
1732 | // Check if we're allowed to mess with permissions | 1734 | // Check if we're allowed to mess with permissions |
1733 | if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god | 1735 | if (!Permissions.IsGod(remoteClient.AgentId)) // Not a god |
1736 | { | ||
1737 | if (remoteClient.AgentId != part.OwnerID) // Not owner | ||
1734 | { | 1738 | { |
1735 | if (remoteClient.AgentId != part.OwnerID) // Not owner | 1739 | // Friends and group members can't change any perms |
1736 | { | 1740 | itemInfo.BasePermissions = currentItem.BasePermissions; |
1737 | // Friends and group members can't change any perms | 1741 | itemInfo.EveryonePermissions = currentItem.EveryonePermissions; |
1738 | itemInfo.BasePermissions = currentItem.BasePermissions; | 1742 | itemInfo.GroupPermissions = currentItem.GroupPermissions; |
1739 | itemInfo.EveryonePermissions = currentItem.EveryonePermissions; | 1743 | itemInfo.NextPermissions = currentItem.NextPermissions; |
1740 | itemInfo.GroupPermissions = currentItem.GroupPermissions; | 1744 | itemInfo.CurrentPermissions = currentItem.CurrentPermissions; |
1741 | itemInfo.NextPermissions = currentItem.NextPermissions; | ||
1742 | itemInfo.CurrentPermissions = currentItem.CurrentPermissions; | ||
1743 | } | ||
1744 | else | ||
1745 | { | ||
1746 | // Owner can't change base, and can change other | ||
1747 | // only up to base | ||
1748 | itemInfo.BasePermissions = currentItem.BasePermissions; | ||
1749 | if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions) | ||
1750 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; | ||
1751 | if (itemInfo.GroupPermissions != currentItem.GroupPermissions) | ||
1752 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup; | ||
1753 | if (itemInfo.CurrentPermissions != currentItem.CurrentPermissions) | ||
1754 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner; | ||
1755 | if (itemInfo.NextPermissions != currentItem.NextPermissions) | ||
1756 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; | ||
1757 | itemInfo.EveryonePermissions &= currentItem.BasePermissions; | ||
1758 | itemInfo.GroupPermissions &= currentItem.BasePermissions; | ||
1759 | itemInfo.CurrentPermissions &= currentItem.BasePermissions; | ||
1760 | itemInfo.NextPermissions &= currentItem.BasePermissions; | ||
1761 | } | ||
1762 | |||
1763 | } | 1745 | } |
1764 | else | 1746 | else |
1765 | { | 1747 | { |
1766 | if (itemInfo.BasePermissions != currentItem.BasePermissions) | 1748 | // Owner can't change base, and can change other |
1767 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteBase; | 1749 | // only up to base |
1750 | itemInfo.BasePermissions = currentItem.BasePermissions; | ||
1768 | if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions) | 1751 | if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions) |
1769 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; | 1752 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; |
1770 | if (itemInfo.GroupPermissions != currentItem.GroupPermissions) | 1753 | if (itemInfo.GroupPermissions != currentItem.GroupPermissions) |
@@ -1773,24 +1756,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
1773 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner; | 1756 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner; |
1774 | if (itemInfo.NextPermissions != currentItem.NextPermissions) | 1757 | if (itemInfo.NextPermissions != currentItem.NextPermissions) |
1775 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; | 1758 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; |
1759 | itemInfo.EveryonePermissions &= currentItem.BasePermissions; | ||
1760 | itemInfo.GroupPermissions &= currentItem.BasePermissions; | ||
1761 | itemInfo.CurrentPermissions &= currentItem.BasePermissions; | ||
1762 | itemInfo.NextPermissions &= currentItem.BasePermissions; | ||
1776 | } | 1763 | } |
1777 | 1764 | ||
1778 | // Next ALWAYS has move | 1765 | } |
1779 | itemInfo.NextPermissions |= (uint)PermissionMask.Move; | 1766 | else |
1767 | { | ||
1768 | if (itemInfo.BasePermissions != currentItem.BasePermissions) | ||
1769 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteBase; | ||
1770 | if (itemInfo.EveryonePermissions != currentItem.EveryonePermissions) | ||
1771 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteEveryone; | ||
1772 | if (itemInfo.GroupPermissions != currentItem.GroupPermissions) | ||
1773 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup; | ||
1774 | if (itemInfo.CurrentPermissions != currentItem.CurrentPermissions) | ||
1775 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteOwner; | ||
1776 | if (itemInfo.NextPermissions != currentItem.NextPermissions) | ||
1777 | itemInfo.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner; | ||
1778 | } | ||
1779 | |||
1780 | // Next ALWAYS has move | ||
1781 | itemInfo.NextPermissions |= (uint)PermissionMask.Move; | ||
1780 | 1782 | ||
1781 | if (part.Inventory.UpdateInventoryItem(itemInfo)) | 1783 | if (part.Inventory.UpdateInventoryItem(itemInfo)) |
1782 | { | 1784 | { |
1783 | part.SendPropertiesToClient(remoteClient); | 1785 | part.SendPropertiesToClient(remoteClient); |
1784 | } | ||
1785 | } | 1786 | } |
1786 | } | 1787 | } |
1787 | else | ||
1788 | { | ||
1789 | m_log.WarnFormat( | ||
1790 | "[PRIM INVENTORY]: " + | ||
1791 | "Update with item {0} requested of prim {1} for {2} but this prim does not exist", | ||
1792 | itemID, primLocalID, remoteClient.Name); | ||
1793 | } | ||
1794 | } | 1788 | } |
1795 | 1789 | ||
1796 | /// <summary> | 1790 | /// <summary> |