Skip to content

Commit

Permalink
Fixed issue #13392 : new token form set useleft to 1 (#1008)
Browse files Browse the repository at this point in the history
* Fixed issue #13392 : new token form set useleft to 1
Dev: All form must use Models …

* Dev: cleaner way, send only attributes even with existing token
  • Loading branch information
Shnoulle authored and olleharstedt committed Feb 21, 2018
1 parent 05e4dc8 commit ab75b41
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
9 changes: 4 additions & 5 deletions application/controllers/admin/tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -2347,13 +2347,12 @@ public function _handletokenform($iSurveyId, $subaction, $iTokenId = "", $ajax =
}
Yii::app()->loadHelper("surveytranslator");

if ($subaction == "edit") {
if ($iTokenId) {
$aData['tokenid'] = $iTokenId;
$aData['tokendata'] = Token::model($iSurveyId)->findByPk($iTokenId);
$aData['tokendata'] = Token::model($iSurveyId)->findByPk($iTokenId)->getAttributes();
} else {
$aData['completed'] = null;
$aData['sent'] = null;
$aData['remindersent'] = null;
$aData['tokenid'] = null;
$aData['tokendata'] = Token::create($iSurveyId)->getAttributes();
}

$aData['iTokenLength'] = !empty(Token::model($iSurveyId)->survey->tokenlength) ? Token::model($iSurveyId)->survey->tokenlength : 15;
Expand Down
11 changes: 11 additions & 0 deletions application/models/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@
*/
abstract class Token extends Dynamic
{

/**
* Set defaults
* @inheritdoc
*/
public function init()
{
// Set the default values
$this->usesleft = 1;
$this->completed = "N";
}
/** @inheritdoc */
public function attributeLabels()
{
Expand Down
14 changes: 4 additions & 10 deletions application/views/admin/token/tokenform.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,16 @@

if ($subaction == "edit") {
eT("Edit survey participant");
foreach ($tokendata as $Key => $Value)
{
$$Key = $Value;
}
} else {
eT("Add survey participant");
$tokenid = "";
}

?>
</h3>
<?php } else { ?>
<?php
foreach ($tokendata as $Key => $Value) {
$$Key = $Value;
}
<?php } ?>
<?php
foreach ($tokendata as $Key => $Value) {
$$Key = $Value;
}
?>

Expand Down

0 comments on commit ab75b41

Please sign in to comment.