DD-20 : Prevent pasting incompatible items in stock folders
parent
65e53b70f2
commit
545b408618
|
|
@ -4350,23 +4350,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item,
|
|||
}
|
||||
else if (move_is_into_marketplacelistings)
|
||||
{
|
||||
// If destination folder type is stock, check perm and type of item, if not compatible -> FALSE
|
||||
if (getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK)
|
||||
{
|
||||
// If the item is copyable (i.e. non stock) do not accept the drop in a stock folder
|
||||
if (inv_item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID(), gAgent.getGroupID()))
|
||||
{
|
||||
accept = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
LLInventoryModel::cat_array_t* cat_array;
|
||||
LLInventoryModel::item_array_t* item_array;
|
||||
gInventory.getDirectDescendentsOf(mUUID,cat_array,item_array);
|
||||
// Destination stock folder must be empty OR types must be identical
|
||||
accept = (!item_array->count() || (item_array->get(0)->getInventoryType() == inv_item->getInventoryType()));
|
||||
}
|
||||
}
|
||||
accept = (getCategory() && getCategory()->acceptItem(inv_item));
|
||||
}
|
||||
|
||||
LLInventoryPanel* active_panel = LLInventoryPanel::getActiveInventoryPanel(FALSE);
|
||||
|
|
|
|||
|
|
@ -913,6 +913,13 @@ void move_item_to_marketplacelistings(LLInventoryItem* inv_item, LLUUID dest_fol
|
|||
}
|
||||
LLViewerInventoryCategory* dest_cat = gInventory.getCategory(dest_folder);
|
||||
|
||||
// Verify we can have this item in that destination category
|
||||
if (!dest_cat->acceptItem(viewer_inv_item))
|
||||
{
|
||||
llinfos << "Merov : Marketplace error : Cannot move item in that stock folder -> move aborted!" << llendl;
|
||||
return;
|
||||
}
|
||||
|
||||
// When moving a no copy item into a first level listing folder, we create a stock folder for it
|
||||
if (!viewer_inv_item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID(), gAgent.getGroupID()) && (dest_cat->getParentUUID() == marketplace_listings_uuid))
|
||||
{
|
||||
|
|
@ -961,9 +968,15 @@ void move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUU
|
|||
if (has_correct_permissions_for_sale(inv_cat))
|
||||
{
|
||||
// Get the destination folder
|
||||
// *TODO : check that this folder is not full of no-copy items under its root...
|
||||
LLViewerInventoryCategory* dest_cat = gInventory.getCategory(dest_folder);
|
||||
|
||||
// Check it's not a stock folder
|
||||
if (dest_cat->getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK)
|
||||
{
|
||||
llinfos << "Merov : Marketplace error : Cannot move folder in stock folder -> move aborted!" << llendl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the parent folder of the moved item : we may have to update it
|
||||
LLUUID src_folder = inv_cat->getParentUUID();
|
||||
|
||||
|
|
|
|||
|
|
@ -816,6 +816,29 @@ bool LLViewerInventoryCategory::exportFileLocal(LLFILE* fp) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool LLViewerInventoryCategory::acceptItem(LLInventoryItem* inv_item)
|
||||
{
|
||||
bool accept = true;
|
||||
// Only stock folders have limitation on which item they will accept
|
||||
if (getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK)
|
||||
{
|
||||
// If the item is copyable (i.e. non stock) do not accept the drop in a stock folder
|
||||
if (inv_item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID(), gAgent.getGroupID()))
|
||||
{
|
||||
accept = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LLInventoryModel::cat_array_t* cat_array;
|
||||
LLInventoryModel::item_array_t* item_array;
|
||||
gInventory.getDirectDescendentsOf(getUUID(),cat_array,item_array);
|
||||
// Destination stock folder must be empty OR types of incoming and existing items must be identical
|
||||
accept = (!item_array->count() || (item_array->get(0)->getInventoryType() == inv_item->getInventoryType()));
|
||||
}
|
||||
}
|
||||
return accept;
|
||||
}
|
||||
|
||||
void LLViewerInventoryCategory::determineFolderType()
|
||||
{
|
||||
/* Do NOT uncomment this code. This is for future 2.1 support of ensembles.
|
||||
|
|
|
|||
|
|
@ -225,6 +225,9 @@ public:
|
|||
bool importFileLocal(LLFILE* fp);
|
||||
void determineFolderType();
|
||||
void changeType(LLFolderType::EType new_folder_type);
|
||||
|
||||
// returns true if the category object will accept the incoming item
|
||||
bool acceptItem(LLInventoryItem* inv_item);
|
||||
|
||||
private:
|
||||
friend class LLInventoryModel;
|
||||
|
|
|
|||
Loading…
Reference in New Issue