From a46fc2e1c2177ab3966950e5eab3b05bb586b51a Mon Sep 17 00:00:00 2001
From: darode <drd.sqki@gmail.com>
Date: Fri, 29 Jul 2011 11:30:46 +0000
Subject: [PATCH] 2011-07-29 Dario Rodriguez <dario.rodriguez@artica.es>

        * godmode/modules/manage_network_templates_form.php: Fixed
        a bug with allows to create a module template without a
        name.

        Fixes: 3371381



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4653 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/ChangeLog                     | 10 +++++
 .../modules/manage_network_templates_form.php | 45 ++++++++++---------
 2 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index 33bc64ba08..5071164cba 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,8 +1,18 @@
+2011-07-29 Dario Rodriguez <dario.rodriguez@artica.es>
+
+	* godmode/modules/manage_network_templates_form.php: Fixed
+	a bug with allows to create a module template without a
+	name.
+
+	Fixes: 3371381
+
 2011-07-29 Dario Rodriguez <dario.rodriguez@artica.es>
 
 	* include/functions_agents.php: Fixed a bug related to
 	wrong value for a foreach function.
 
+	Fixes: 3371341
+
 2011-07-28  Sergio Martin <sergio.martin@artica.es>
 
 	* include/functions_networkmap.php: Added new mode to 
diff --git a/pandora_console/godmode/modules/manage_network_templates_form.php b/pandora_console/godmode/modules/manage_network_templates_form.php
index 856a33d447..433bcc833e 100644
--- a/pandora_console/godmode/modules/manage_network_templates_form.php
+++ b/pandora_console/godmode/modules/manage_network_templates_form.php
@@ -74,28 +74,31 @@ if (isset ($_GET["create"]) || isset ($_GET["update"])) {
 	//Submitted form
 	$name = get_parameter_post ("name");
 	$description = get_parameter_post ("description");
-	
-	if ($id_np > 0) {
-		//Profile exists
-		$values = array(
-			'name' => $name,
-			'description' => $description);
-		$result = db_process_sql_update('tnetwork_profile', $values, array('id_np' => $id_np));
+	if ($name != "") {		
+		if ($id_np > 0) {
+			//Profile exists
+			$values = array(
+				'name' => $name,
+				'description' => $description);
+			$result = db_process_sql_update('tnetwork_profile', $values, array('id_np' => $id_np));
 		
-		ui_print_result_message ($result !== false,
-			__('Successfully updated network profile'),
-			__('Error updating network profile'));
-	}
-	else {
-		//Profile doesn't exist
-		$values = array('name' => $name, 'description' => $description);
-		$result = db_process_sql_insert('tnetwork_profile', $values);
-		
-		ui_print_result_message ($result,
-			__('Successfully added network profile'),
-			__('Error adding network profile'));
-		$id_np = (int) $result; //Will return either 0 (in case of error) or an int
-	}
+			ui_print_result_message ($result !== false,
+				__('Successfully updated network profile'),
+				__('Error updating network profile'));
+		}
+		else {
+			//Profile doesn't exist
+			$values = array('name' => $name, 'description' => $description);
+			$result = db_process_sql_insert('tnetwork_profile', $values);
+			
+			ui_print_result_message ($result,
+				__('Successfully added network profile'),
+				__('Error adding network profile'));
+			$id_np = (int) $result; //Will return either 0 (in case of error) or an int
+		}
+	} else {
+		ui_print_result_message(false, "", _("Cannot create a template without name"));
+	}	
 
 }
 elseif ($id_np > 0) {