Skip to content

Commit

Permalink
Fixed issue: token length setting is not read from inherited survey s…
Browse files Browse the repository at this point in the history
…ettings
  • Loading branch information
dominikvitt committed Dec 27, 2018
1 parent 47c3525 commit 9862036
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions application/controllers/admin/tokens.php
Expand Up @@ -702,7 +702,8 @@ public function addnew($iSurveyId)

$aData['thissurvey'] = getSurveyInfo($iSurveyId);
$aData['surveyid'] = $iSurveyId;
$aData['iTokenLength'] = !empty(Token::model($iSurveyId)->survey->tokenlength) ? Token::model($iSurveyId)->survey->tokenlength : 15;
$aData['iTokenLength'] = !empty(Token::model($iSurveyId)->survey->oOptions->tokenlength) ? Token::model($iSurveyId)->survey->oOptions->tokenlength : 15;


$aData['sidemenu']['state'] = false;

Expand Down Expand Up @@ -1031,7 +1032,8 @@ public function addDummies($iSurveyId, $subaction = '')
$aData['validfrom'] = null;
$aData['validuntil'] = null;
$aData['amount'] = 100;
$aData['tokenlength'] = !empty(Token::model($iSurveyId)->survey->tokenlength) ? Token::model($iSurveyId)->survey->tokenlength : 15;
$aData['tokenlength'] = !empty(Token::model($iSurveyId)->survey->oOptions->tokenlength) ? Token::model($iSurveyId)->survey->oOptions->tokenlength : 15;



$thissurvey = getSurveyInfo($iSurveyId);
Expand Down Expand Up @@ -2417,7 +2419,8 @@ public function _handletokenform($iSurveyId, $subaction, $iTokenId = "", $ajax =
$aData['tokendata'] = Token::create($iSurveyId)->getAttributes();
}

$aData['iTokenLength'] = !empty(Token::model($iSurveyId)->survey->tokenlength) ? Token::model($iSurveyId)->survey->tokenlength : 15;
$aData['iTokenLength'] = !empty(Token::model($iSurveyId)->survey->oOptions->tokenlength) ? Token::model($iSurveyId)->survey->oOptions->tokenlength : 15;


$thissurvey = $oSurvey->attributes;
$aAdditionalAttributeFields = $oSurvey->decodedAttributedescriptions;
Expand Down
2 changes: 1 addition & 1 deletion application/models/Token.php
Expand Up @@ -264,7 +264,7 @@ public function generateTokens()
throw new \Exception("This function should only be called like: Token::model(12345)->generateTokens");
}
$surveyId = $this->dynamicId;
$iTokenLength = isset($this->survey) && is_numeric($this->survey->tokenlength) ? $this->survey->tokenlength : 15;
$iTokenLength = isset($this->survey) && is_numeric($this->survey->oOptions->tokenlength) ? $this->survey->oOptions->tokenlength : 15;

$tkresult = Yii::app()->db->createCommand("SELECT tid FROM {{tokens_{$surveyId}}} WHERE token IS NULL OR token=''")->queryAll();
//Exit early if there are not empty tokens
Expand Down

0 comments on commit 9862036

Please sign in to comment.