Skip to content

Commit

Permalink
New feature: Ability to use comma or dot as decimal separator for num…
Browse files Browse the repository at this point in the history
…eric and multiple numeric question types - - work done by Google Code-In participant Kshitij Parajuli. Thank you!

Dev: Please re-install DB because there is a new field

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@9571 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Dec 2, 2010
1 parent bf13652 commit 76d9e10
Show file tree
Hide file tree
Showing 18 changed files with 152 additions and 25 deletions.
11 changes: 9 additions & 2 deletions admin/database.php
Expand Up @@ -1256,7 +1256,8 @@ function get_max_question_order($gid)
. "surveyls_endtext='".db_quote($_POST['endtext_'.$langname])."',\n"
. "surveyls_url='".db_quote($_POST['url_'.$langname])."',\n"
. "surveyls_urldescription='".db_quote($_POST['urldescrip_'.$langname])."',\n"
. "surveyls_dateformat='".db_quote($_POST['dateformat_'.$langname])."'\n"
. "surveyls_dateformat='".db_quote($_POST['dateformat_'.$langname])."',\n"
. "surveyls_numberformat='".db_quote($_POST['numberformat_'.$langname])."'\n"
. "WHERE surveyls_survey_id=".$postsid." and surveyls_language='".$langname."'";
$usresult = $connect->Execute($usquery) or safe_die("Error updating<br />".$usquery."<br /><br /><strong>".$connect->ErrorMsg()); // Checked
}
Expand All @@ -1272,6 +1273,11 @@ function get_max_question_order($gid)
elseif ($action == "insertsurvey" && $_SESSION['USER_RIGHT_CREATE_SURVEY'])
{
$dateformatdetails=getDateFormatData($_SESSION['dateformat']);
// $_POST['language']

$supportedLanguages = getLanguageData();
$numberformatid = $supportedLanguages[$_POST['language']]['radixpoint'];

if ($_POST['url'] == 'http://') {$_POST['url']="";}
if (!$_POST['surveyls_title'])
{
Expand Down Expand Up @@ -1422,7 +1428,8 @@ function get_max_question_order($gid)
'email_admin_notification'=>conditional_nl2br($aDefaultTexts['admin_notification'],$is_html_email,'unescaped'),
'email_admin_responses_subj'=>$aDefaultTexts['admin_detailed_notification_subject'],
'email_admin_responses'=>$aDefaultTexts['admin_detailed_notification'],
'surveyls_dateformat'=>$_POST['dateformat']
'surveyls_dateformat'=>$_POST['dateformat'],
'surveyls_numberformat'=>$numberformatid
);
$dbtablename=db_table_name_nq('surveys_languagesettings');
$isquery = $connect->GetInsertSQL($dbtablename, $insertarray);
Expand Down
1 change: 0 additions & 1 deletion admin/editsurveysettings.php
Expand Up @@ -25,7 +25,6 @@
else
{
$js_admin_includes[]='scripts/surveysettings.js';

if ($action == "newsurvey") {
//New survey, set the defaults
$esrow = array();
Expand Down
12 changes: 11 additions & 1 deletion admin/editsurveytextelements.php
Expand Up @@ -74,8 +74,18 @@
}
$tab_content[$i].= ">".$dateformatdata['dateformat'].'</option>';
}
$tab_content[$i].= "</select></li>"
. "<li><label for=''>".$clang->gT("Decimal Point Format:")."</label>\n";
$tab_content[$i].="<select size='1' name='numberformat_".$esrow['surveyls_language']."'>\n";
foreach (getRadixPointData() as $index=>$radixptdata)
{
$tab_content[$i].= "<option value='{$index}'";
if ($esrow['surveyls_numberformat']==$index) {
$tab_content[$i].=" selected='selected'";
}
$tab_content[$i].= ">".$radixptdata['desc'].'</option>';
}
$tab_content[$i].= "</select></li></ul>";

$i++;
}

Expand Down
2 changes: 1 addition & 1 deletion admin/import_functions.php
Expand Up @@ -464,7 +464,7 @@ function CSVImportSurvey($sFullFilepath,$iDesiredSurveyId=NULL)
$surveylsrowdata['surveyls_email_register']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_email_register']);
$surveylsrowdata['surveyls_email_confirm']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_email_confirm']);
unset($surveylsrowdata['lastpage']);

$surveylsrowdata['surveyls_numberformat']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_numberformat']);;
$surveylsrowdata['surveyls_survey_id']=$newsid;
$newvalues=array_values($surveylsrowdata);
$newvalues=array_map(array(&$connect, "qstr"),$newvalues); // quote everything accordingly
Expand Down
3 changes: 2 additions & 1 deletion admin/install/create-mssql.sql
Expand Up @@ -322,7 +322,8 @@ CREATE TABLE [prefix_surveys_languagesettings] (
[email_admin_notification] TEXT NULL,
[email_admin_responses_subj] VARCHAR(255) NULL,
[email_admin_responses] TEXT NULL,
[surveyls_dateformat] INT NOT NULL DEFAULT 1,
[surveyls_dateformat] INT NOT NULL DEFAULT 1,
[surveyls_numberformat] INT NOT NULL DEFAULT 0,
PRIMARY KEY ([surveyls_survey_id],[surveyls_language])
)
;
Expand Down
3 changes: 2 additions & 1 deletion admin/install/create-mssqlnative.sql
Expand Up @@ -331,7 +331,8 @@ CREATE TABLE [prefix_surveys_languagesettings] (
[email_admin_notification] varchar(max) NULL,
[email_admin_responses_subj] VARCHAR(255) NULL,
[email_admin_responses] varchar(max) NULL,
[surveyls_dateformat] INT NOT NULL DEFAULT 1,
[surveyls_dateformat] INT NOT NULL DEFAULT 1,
[surveyls_numberformat] INT NOT NULL DEFAULT 0,
PRIMARY KEY ([surveyls_survey_id],[surveyls_language])
)
;
Expand Down
3 changes: 2 additions & 1 deletion admin/install/create-mysql.sql
Expand Up @@ -305,7 +305,8 @@ CREATE TABLE `prefix_surveys_languagesettings` (
`surveyls_email_register` TEXT NULL,
`surveyls_email_confirm_subj` VARCHAR(255) NULL,
`surveyls_email_confirm` TEXT NULL,
`surveyls_dateformat` INT UNSIGNED NOT NULL DEFAULT 1,
`surveyls_dateformat` INT UNSIGNED NOT NULL DEFAULT 1,
`surveyls_numberformat` INT NOT NULL DEFAULT 0,
`email_admin_notification_subj` VARCHAR(255) NULL,
`email_admin_notification` TEXT NULL,
`email_admin_responses_subj` VARCHAR(255) NULL,
Expand Down
3 changes: 2 additions & 1 deletion admin/install/create-postgres.sql
Expand Up @@ -335,7 +335,8 @@ CREATE TABLE prefix_surveys_languagesettings (
email_admin_notification text,
email_admin_responses_subj character varying(255),
email_admin_responses text,
surveyls_dateformat integer DEFAULT 1 NOT NULL
surveyls_dateformat integer DEFAULT 1 NOT NULL,
surveyls_numberformat integer NOT NULL DEFAULT 1
);

ALTER TABLE ONLY prefix_surveys_languagesettings ADD CONSTRAINT prefix_surveys_languagesettings_pkey PRIMARY KEY (surveyls_survey_id, surveyls_language);
Expand Down
2 changes: 2 additions & 0 deletions admin/update/upgrade-mssql.php
Expand Up @@ -477,6 +477,8 @@ function db_upgrade($oldversion) {

}

modify_database("", "ALTER TABLE [prefix_surveys_languagesettings] ADD [surveyls_numberformat] int(11) default 0 NOT NULL AFTER [surveyls_dateformat]"); echo $modifyoutput; flush();

echo '<br /><br />Database update finished ('.date('Y-m-d H:i:s').')<br />';
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions admin/update/upgrade-mssqlnative.php
Expand Up @@ -474,6 +474,8 @@ function db_upgrade($oldversion) {
);"); echo $modifyoutput; flush();

}
modify_database("", "ALTER TABLE [prefix_surveys_languagesettings] ADD [surveyls_numberformat] int(11) default 0 NOT NULL AFTER [surveyls_dateformat]"); echo $modifyoutput; flush();

echo '<br /><br />Database update finished ('.date('Y-m-d H:i:s').')<br />';
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions admin/update/upgrade-mysql.php
Expand Up @@ -578,6 +578,8 @@ function db_upgrade($oldversion) {

}

modify_database("", "ALTER TABLE `prefix_surveys_languagesettings` ADD `surveyls_numberformat` int(11) NOT NULL DEFAULT 0 AFTER `surveyls_dateformat`"); echo $modifyoutput; flush();

echo '<br /><br />Database update finished ('.date('Y-m-d H:i:s').')<br />';
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions admin/update/upgrade-postgres.php
Expand Up @@ -297,6 +297,8 @@ function db_upgrade($oldversion) {


}
modify_database("", "ALTER TABLE prefix_surveys_languagesettings ADD surveyls_numberformat integer default 0 NOT NULL AFTER surveyls_dateformat"); echo $modifyoutput; flush();


echo '<br /><br />Database update finished ('.date('Y-m-d H:i:s').')<br />';
return true;
Expand Down
1 change: 1 addition & 0 deletions classes/core/sanitize.php
Expand Up @@ -283,6 +283,7 @@ function sanitize_labelname($string)
// make float float!
function sanitize_float($float, $min='', $max='')
{
$float = str_replace(',','.',$float);
$float = floatval($float);
if((($min != '') && ($float < $min)) || (($max != '') && ($float > $max)))
return FALSE;
Expand Down

0 comments on commit 76d9e10

Please sign in to comment.