From fe4f5f13da50bf833254b1d168de3b60d56f2bcb Mon Sep 17 00:00:00 2001
From: Merov Linden <merov@lindenlab.com>
Date: Tue, 3 Feb 2015 23:43:15 -0800
Subject: [PATCH] DD-303 : do not force unlist when associating listings, let
 the 1 version folder policy apply, prompt user only if it doesn't

---
 indra/newview/llfloatermarketplacelistings.cpp | 11 ++++++++++-
 indra/newview/llmarketplacefunctions.cpp       |  1 -
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llfloatermarketplacelistings.cpp b/indra/newview/llfloatermarketplacelistings.cpp
index cd76cabfbdb..c1664631f05 100755
--- a/indra/newview/llfloatermarketplacelistings.cpp
+++ b/indra/newview/llfloatermarketplacelistings.cpp
@@ -636,6 +636,15 @@ void LLFloaterMarketplaceListings::onChanged()
 // LLFloaterAssociateListing
 //-----------------------------------------------------------------------------
 
+// Tell if a listing has one only version folder
+bool hasUniqueVersionFolder(const LLUUID& folder_id)
+{
+	LLInventoryModel::cat_array_t* categories;
+	LLInventoryModel::item_array_t* items;
+	gInventory.getDirectDescendentsOf(folder_id, categories, items);
+    return (categories->size() == 1);
+}
+
 LLFloaterAssociateListing::LLFloaterAssociateListing(const LLSD& key)
 : LLFloater(key)
 , mUUID()
@@ -703,7 +712,7 @@ void LLFloaterAssociateListing::apply(BOOL user_confirm)
             // Check if the id exists in the merchant SLM DB: note that this record might exist in the LLMarketplaceData
             // structure even if unseen in the UI, for instance, if its listing_uuid doesn't exist in the merchant inventory
             LLUUID listing_uuid = LLMarketplaceData::instance().getListingFolder(id);
-            if (listing_uuid.notNull() && user_confirm && LLMarketplaceData::instance().getActivationState(listing_uuid))
+            if (listing_uuid.notNull() && user_confirm && LLMarketplaceData::instance().getActivationState(listing_uuid) && !hasUniqueVersionFolder(mUUID))
             {
                 // Look for user confirmation before unlisting
                 LLNotificationsUtil::add("ConfirmMerchantUnlist", LLSD(), LLSD(), boost::bind(&LLFloaterAssociateListing::callback_apply, this, _1, _2));
diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp
index 03157859602..3bedb0db44a 100755
--- a/indra/newview/llmarketplacefunctions.cpp
+++ b/indra/newview/llmarketplacefunctions.cpp
@@ -1348,7 +1348,6 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing
     
     // Note : we're assuming that sending unchanged info won't break anything server side...
     root["listing"]["id"] = listing_id;
-    root["listing"]["is_listed"] = false;
     root["listing"]["inventory_info"]["listing_folder_id"] = folder_id.asString();
     root["listing"]["inventory_info"]["version_folder_id"] = version_id.asString();
     root["listing"]["inventory_info"]["count_on_hand"] = -1;
-- 
GitLab