Skip to content

Commit

Permalink
Merge pull request #378 from odalecne/patch-2
Browse files Browse the repository at this point in the history
Fixed issue: 'token' column collation is not set in survey tables
  • Loading branch information
c-schmitz committed Oct 30, 2015
2 parents 814468e + 6e60957 commit 3405470
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions application/helpers/admin/activate_helper.php
Expand Up @@ -259,6 +259,15 @@ function activateSurvey($iSurveyID, $simulate = false)
$createsurveytimings='';
$fieldstiming = array();
$createsurveydirectory=false;
// Specify case sensitive collations for the token
$sCollation='';
if (Yii::app()->db->driverName=='mysqli' | Yii::app()->db->driverName=='mysqli'){
$sCollation=" COLLATE 'utf8_bin'";
}
if (Yii::app()->db->driverName=='sqlsrv' | Yii::app()->db->driverName=='dblib' | Yii::app()->db->driverName=='mssql'){
$sCollation=" COLLATE SQL_Latin1_General_CP1_CS_AS";
}

//Check for any additional fields for this survey and create necessary fields (token and datestamp)
$prow = Survey::model()->findByAttributes(array('sid' => $iSurveyID));

Expand Down Expand Up @@ -343,25 +352,17 @@ function activateSurvey($iSurveyID, $simulate = false)
$createsurvey[$arow['fieldname']] = "string";
break;
case "token":
// Specify case sensitive collations for the token
$sCollation='';
if (Yii::app()->db->driverName=='mysqli' | Yii::app()->db->driverName=='mysqli'){
$sCollation=" COLLATE 'utf8_bin'";
}
if (Yii::app()->db->driverName=='sqlsrv' | Yii::app()->db->driverName=='dblib' | Yii::app()->db->driverName=='mssql'){
$sCollation=" COLLATE SQL_Latin1_General_CP1_CS_AS";
}
$createsurvey[$arow['fieldname']] = 'string(35)'.$sCollation;
$createsurvey[$arow['fieldname']] = 'string(35)'.$sCollation;
break;
case '*': // Equation
$createsurvey[$arow['fieldname']] = "text";
break;
default:
$createsurvey[$arow['fieldname']] = "string(5)";
}
if ($prow->anonymized == 'N' && !array_key_exists('token',$createsurvey)) {
$createsurvey['token'] = "string(36)";
}
if ($prow->anonymized == 'N' && !array_key_exists('token',$createsurvey)){
$createsurvey['token'] = 'string(35)'.$sCollation;
}
if ($simulate){
$tempTrim = trim($createsurvey);
$brackets = strpos($tempTrim,"(");
Expand Down

0 comments on commit 3405470

Please sign in to comment.