From 784c526e67e1bfbdb07703395e75217567e43fbd Mon Sep 17 00:00:00 2001 From: Eric Marguin Date: Wed, 8 Oct 2008 09:44:27 +0200 Subject: [PATCH] [svn r16450] avoid having same code in same language when editing a survey (FS#2661) --- main/survey/survey.lib.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main/survey/survey.lib.php b/main/survey/survey.lib.php index ba4bf9a6d8..166ba1badf 100644 --- a/main/survey/survey.lib.php +++ b/main/survey/survey.lib.php @@ -24,7 +24,7 @@ * @package dokeos.survey * @author Patrick Cool , Ghent University: cleanup, refactoring and rewriting large parts (if not all) of the code @author Julio Montoya Armas , Dokeos: Personality Test modification and rewriting large parts of the code -* @version $Id: survey.lib.php 16426 2008-09-30 22:04:45Z juliomontoya $ +* @version $Id: survey.lib.php 16450 2008-10-08 07:44:27Z elixir_inter $ * * @todo move this file to inc/lib * @todo use consistent naming for the functions (save vs store for instance) @@ -261,6 +261,18 @@ class survey_manager } else { + + // check if the code doesn't soon exists in this language + $sql = 'SELECT 1 FROM '.$table_survey.' WHERE code="'.Database::escape_string($values['survey_code']).'" AND lang="'.Database::escape_string($values['survey_language']).'"'; + $rs = api_sql_query($sql, __FILE__, __LINE__); + if(Database::num_rows($rs)>0) + { + $return['message'] = 'ThisSurveyCodeSoonExistsInThisLanguage'; + $return['type'] = 'error'; + $return['id'] = isset($values['survey_id']) ? $values['survey_id'] : 0; + return $return; + } + if ($values['anonymous']=='') { $values['anonymous']=0;