From 84a7394ae03608556b5974ca1bdfc280cf5874b7 Mon Sep 17 00:00:00 2001
From: Merov Linden <merov@lindenlab.com>
Date: Tue, 9 Jun 2015 19:44:03 -0700
Subject: [PATCH] DD-412 : WIP : Validate a listing before creating a listing
 on SLM

---
 indra/newview/llinventorybridge.cpp           | 24 ++++++++++++++++++-
 indra/newview/llinventoryfunctions.cpp        |  3 ++-
 .../skins/default/xui/en/notifications.xml    | 12 ++++++++++
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 521eefe583..8b37480830 100755
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -3234,7 +3234,29 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
 	}
 	else if ("marketplace_create_listing" == action)
 	{
-        LLMarketplaceData::instance().createListing(mUUID);
+        LLViewerInventoryCategory* cat = gInventory.getCategory(mUUID);
+        mMessage = "";
+        bool validates = true;
+        if (!validate_marketplacelistings(cat,boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3)))
+        {
+            mMessage = "";
+            validates = validate_marketplacelistings(cat,boost::bind(&LLFolderBridge::gatherMessage, this, _1, _2, _3),true);
+            if (validates)
+            {
+                LLNotificationsUtil::add("MerchantForceValidateListing");
+            }
+        }
+        
+        if (!validates)
+        {
+            LLSD subs;
+            subs["[ERROR_CODE]"] = mMessage;
+            LLNotificationsUtil::add("MerchantListingFailed", subs);
+        }
+        else
+        {
+            LLMarketplaceData::instance().createListing(mUUID);
+        }
 		return;
 	}
     else if ("marketplace_disassociate_listing" == action)
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index e245fd2d59..d9002a631d 100755
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -1916,8 +1916,9 @@ bool validate_marketplacelistings(LLInventoryCategory* cat, validation_callback_
                 else if (depth == 1)
                 {
                     // Report items not wrapped in version folder
+                    result = false;
                     std::string message = indent + "    " + viewer_inv_item->getName() + LLTrans::getString("Marketplace Validation Warning Unwrapped Item");
-                    cb(message,depth,LLError::LEVEL_WARN);
+                    cb(message,depth,LLError::LEVEL_ERROR);
                 }
             }
         }
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 398a06726c..5fc23b6d4b 100755
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -386,6 +386,18 @@ Initialization with the Marketplace failed because of a system or network error.
         yestext="OK"/>
     </notification>
 
+    <notification
+        icon="alertmodal.tga"
+        name="MerchantForceValidateListing"
+        type="alertmodal">
+        In order to create your listing, we fixed the hierarchy of your listing contents.
+        <tag>confirm</tag>
+        <usetemplate
+            ignoretext="Confirm when creating a listing validates the content"
+            name="okignore" 
+            yestext="OK"/>
+    </notification>
+
     <notification
         icon="alertmodal.tga"
         name="ConfirmMerchantActiveChange"
-- 
GitLab