Skip to content

Commit

Permalink
Fixed issue #8537: Survey admin allows token length to be set at a va…
Browse files Browse the repository at this point in the history
…lue that exceeds schema column width (36)
  • Loading branch information
c-schmitz committed Jan 17, 2014
1 parent 528a218 commit 521095a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
4 changes: 4 additions & 0 deletions application/controllers/admin/database.php
Expand Up @@ -1016,6 +1016,10 @@ function index($sa = null)
{
$tokenlength = 15;
}
if($tokenlength > 36)
{
$tokenlength = 36;
}

cleanLanguagesFromSurvey($iSurveyID,Yii::app()->request->getPost('languageids'));

Expand Down
15 changes: 13 additions & 2 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -1492,7 +1492,18 @@ function insert($iSurveyID=null)
$converter = new Date_Time_Converter($sExpiryDate, $aDateFormatData['phpdate'] . ' H:i:s');
$sExpiryDate = $converter->convert("Y-m-d H:i:s");
}


$iTokenLength=$_POST['tokenlength'];
//token length has to be at least 5, otherwise set it to default (15)
if($iTokenLength < 5)
{
$iTokenLength = 15;
}
if($iTokenLength > 36)
{
$iTokenLength = 36;
}

// Insert base settings into surveys table
$aInsertData = array(
'expires' => $sExpiryDate,
Expand Down Expand Up @@ -1535,7 +1546,7 @@ function insert($iSurveyID=null)
'publicgraphs' => $_POST['publicgraphs'],
'assessments' => $_POST['assessments'],
'emailresponseto' => $_POST['emailresponseto'],
'tokenlength' => $_POST['tokenlength']
'tokenlength' => $iTokenLength
);

$warning = '';
Expand Down
2 changes: 1 addition & 1 deletion application/models/Survey.php
Expand Up @@ -182,7 +182,7 @@ public function rules()
array('format', 'in','range'=>array('G','S','A'), 'allowEmpty'=>true),
array('googleanalyticsstyle', 'numerical', 'integerOnly'=>true, 'min'=>'0', 'max'=>'2', 'allowEmpty'=>true),
array('autonumber_start','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
array('tokenlength','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
array('tokenlength','numerical', 'integerOnly'=>true,'allowEmpty'=>true, 'min'=>'5', 'max'=>'36'),
array('bouncetime','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
array('navigationdelay','numerical', 'integerOnly'=>true,'allowEmpty'=>true),
// array('expires','date', 'format'=>array('yyyy-MM-dd', 'yyyy-MM-dd HH:mm', 'yyyy-MM-dd HH:mm:ss',), 'allowEmpty'=>true),
Expand Down
9 changes: 2 additions & 7 deletions application/views/admin/survey/subview/tabTokens_view.php
@@ -1,5 +1,4 @@
<div id='tokens'><ul>

<li><label for='anonymized'><?php $clang->eT("Anonymized responses?"); ?>

<script type="text/javascript"><!--
Expand All @@ -16,7 +15,6 @@ function alertPrivacy()
}
}
//--></script></label>

<?php if ($esrow['active'] == "Y") {
if ($esrow['anonymized'] == "N") { ?>
<?php $clang->eT("Responses to this survey are NOT anonymized."); ?>
Expand Down Expand Up @@ -114,11 +112,8 @@ function alertPrivacy()
><?php $clang->eT("No"); ?></option>
</select>
</li>


<li><label for='tokenlength'><?php $clang->eT("Set token length to:"); ?></label>
<input type='text' value="<?php echo $esrow['tokenlength']; ?>" name='tokenlength' id='tokenlength' size='12' maxlength='2' onkeypress="return goodchars(event,'0123456789')" />
<input type='text' value="<?php echo $esrow['tokenlength']; ?>" name='tokenlength' id='tokenlength' size='4' maxlength='2' onkeypress="return goodchars(event,'0123456789')" />
</li>


</ul></div>

0 comments on commit 521095a

Please sign in to comment.