Browse Source

[svn r16450] avoid having same code in same language when editing a survey (FS#2661)

Eric Marguin 16 years ago
parent
commit
784c526e67
1 changed files with 13 additions and 1 deletions
  1. 13 1
      main/survey/survey.lib.php

+ 13 - 1
main/survey/survey.lib.php

@@ -24,7 +24,7 @@
 *	@package dokeos.survey
 * 	@author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts (if not all) of the code
 	@author Julio Montoya Armas <gugli100@gmail.com>, 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;