From 57a18ba4afd03f8703e91be1ba120d2d01175c96 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?=
 <marcosgdf@gmail.com>
Date: Sat, 4 Jan 2014 15:56:37 +0100
Subject: [PATCH] Unified duplicate code that cleaned Opensurveysondage
 parameters into Opensurveysondage::cleanParameters

---
 .../class/opensurveysondage.class.php         | 42 ++++++++-----------
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php
index 22f66a2c2a4..80bb57dddfa 100644
--- a/htdocs/opensurvey/class/opensurveysondage.class.php
+++ b/htdocs/opensurvey/class/opensurveysondage.class.php
@@ -91,19 +91,7 @@ class Opensurveysondage extends CommonObject
 		$error=0;
 
 		// Clean parameters
-
-		$this->id_sondage = trim($this->id_sondage);
-		$this->commentaires = trim($this->commentaires);
-		$this->mail_admin = trim($this->mail_admin);
-		$this->nom_admin = trim($this->nom_admin);
-		$this->titre = trim($this->titre);
-		$this->format = trim($this->format);
-		$this->mailsonde = ($this->mailsonde ? 1 : 0);
-		$this->canedit = ($this->canedit ? 1 : 0);
-		$this->allow_comments = ($this->allow_comments ? 1 : 0);
-		$this->allow_spy = ($this->allow_spy ? 1 : 0);
-		$this->origin = trim($this->origin);
-		$this->sujet = trim($this->sujet);
+		$this->cleanParameters();
 
 		// Check parameters
 		// Put here code to add control on parameters values
@@ -267,17 +255,7 @@ class Opensurveysondage extends CommonObject
 		$error=0;
 
 		// Clean parameters
-
-		if (isset($this->id_sondage)) $this->id_sondage=trim($this->id_sondage);
-		if (isset($this->commentaires)) $this->commentaires=trim($this->commentaires);
-		if (isset($this->mail_admin)) $this->mail_admin=trim($this->mail_admin);
-		if (isset($this->nom_admin)) $this->nom_admin=trim($this->nom_admin);
-		if (isset($this->titre)) $this->titre=trim($this->titre);
-		if (isset($this->format)) $this->format=trim($this->format);
-		if (isset($this->mailsonde)) $this->mailsonde=trim($this->mailsonde);
-		$this->canedit = $this->canedit ? 1 : 0;
-		$this->allow_comments = $this->allow_comments ? 1 : 0;
-		$this->allow_spy = $this->allow_spy ? 1 : 0;
+		$this->cleanParameters();
 
 		// Check parameters
 		// Put here code to add a control on parameters values
@@ -506,5 +484,21 @@ class Opensurveysondage extends CommonObject
 		
 		return true;
 	}
+	
+	private function cleanParameters() {
+		
+		$this->id_sondage = trim($this->id_sondage);
+		$this->commentaires = trim($this->commentaires);
+		$this->mail_admin = trim($this->mail_admin);
+		$this->nom_admin = trim($this->nom_admin);
+		$this->titre = trim($this->titre);
+		$this->format = trim($this->format);
+		$this->mailsonde = ($this->mailsonde ? 1 : 0);
+		$this->canedit = ($this->canedit ? 1 : 0);
+		$this->allow_comments = ($this->allow_comments ? 1 : 0);
+		$this->allow_spy = ($this->allow_spy ? 1 : 0);
+		$this->origin = trim($this->origin);
+		$this->sujet = trim($this->sujet);
+	}
 }
 ?>
-- 
GitLab