From c353e640fa80a335be741dd0edfdc9952ea3cdea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=B4=D0=BC=D0=B8=D0=BD=D0=B8=D1=81=D1=82=D1=80?=
 =?UTF-8?q?=D0=B0=D1=82=D0=BE=D1=80?= <>
Date: Mon, 21 Dec 2009 16:13:09 +0200
Subject: Fixed low bug EXT-3353 - There's an ability to create classified w/o
 title and description.

--HG--
branch : product-engine
---
 indra/newview/llpanelclassified.cpp | 39 +++++++++++++++++++++++++++++++++++++
 indra/newview/llpanelclassified.h   |  6 ++++++
 indra/newview/llpanelpicks.cpp      |  5 +++++
 3 files changed, 50 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 0dae667e7f..e29320ffc2 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -1557,6 +1557,11 @@ void LLPanelClassifiedEdit::resetControls()
 	childSetValue("price_for_listing", MINIMUM_PRICE_FOR_LISTING);
 }
 
+bool LLPanelClassifiedEdit::canClose()
+{
+	return isValidName();
+}
+
 void LLPanelClassifiedEdit::sendUpdate()
 {
 	LLAvatarClassifiedInfo c_data;
@@ -1671,6 +1676,12 @@ void LLPanelClassifiedEdit::onChange()
 
 void LLPanelClassifiedEdit::onSaveClick()
 {
+	if(!isValidName())
+	{
+		notifyInvalidName();
+		return;
+	}
+
 	sendUpdate();
 	resetDirty();
 }
@@ -1681,6 +1692,34 @@ std::string LLPanelClassifiedEdit::getLocationNotice()
 	return location_notice;
 }
 
+bool LLPanelClassifiedEdit::isValidName()
+{
+	std::string name = getClassifiedName();
+	if (name.empty())
+	{
+		return false;
+	}
+	if (!isalnum(name[0]))
+	{
+		return false;
+	}
+
+	return true;
+}
+
+void LLPanelClassifiedEdit::notifyInvalidName()
+{
+	std::string name = getClassifiedName();
+	if (name.empty())
+	{
+		LLNotificationsUtil::add("BlankClassifiedName");
+	}
+	else if (!isalnum(name[0]))
+	{
+		LLNotificationsUtil::add("ClassifiedMustBeAlphanumeric");
+	}
+}
+
 void LLPanelClassifiedEdit::onTexturePickerMouseEnter(LLUICtrl* ctrl)
 {
 	ctrl->setVisible(TRUE);
diff --git a/indra/newview/llpanelclassified.h b/indra/newview/llpanelclassified.h
index 8b32495854..10fdf60bbe 100644
--- a/indra/newview/llpanelclassified.h
+++ b/indra/newview/llpanelclassified.h
@@ -305,6 +305,8 @@ public:
 
 	bool isNew() { return mIsNew; }
 
+	bool canClose();
+
 protected:
 
 	LLPanelClassifiedEdit();
@@ -325,6 +327,10 @@ protected:
 
 	std::string getLocationNotice();
 
+	bool isValidName();
+
+	void notifyInvalidName();
+
 	void onSetLocationClick();
 	void onChange();
 	void onSaveClick();
diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp
index 4d22d96072..a52aa6d30f 100644
--- a/indra/newview/llpanelpicks.cpp
+++ b/indra/newview/llpanelpicks.cpp
@@ -769,6 +769,11 @@ void LLPanelPicks::onPanelPickSave(LLPanel* panel)
 
 void LLPanelPicks::onPanelClassifiedSave(LLPanelClassifiedEdit* panel)
 {
+	if(!panel->canClose())
+	{
+		return;
+	}
+
 	if(panel->isNew())
 	{
 		LLClassifiedItem* c_item = new LLClassifiedItem(getAvatarId(), panel->getClassifiedId());
-- 
cgit v1.2.3