Skip to content

Commit

Permalink
Merge branch 'Yii' of github.com:LimeSurvey/LimeSurvey into Yii
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Jul 22, 2012
2 parents 15f0f60 + 383e06f commit d6cdd8e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions application/controllers/admin/tokens.php
Expand Up @@ -57,6 +57,9 @@ function index($iSurveyId)
}
else
{
//Check that the tokens table has the required fields
Tokens_dynamic::model($iSurveyId)->checkColumns();

$aData['thissurvey'] = $thissurvey;
$aData['surveyid'] = $iSurveyId;
$aData['queries'] = Tokens_dynamic::model($iSurveyId)->summary();
Expand Down
14 changes: 14 additions & 0 deletions application/models/Tokens_dynamic.php
Expand Up @@ -97,6 +97,20 @@ public function summary()
return $data;
}

/**
* Checks to make sure that all required columns exist in this tokens table
* (some older tokens tables dont' get udated properly)
*
*/
public function checkColumns() {
$sid = self::$sid;
$surveytable='{{tokens_'.$sid.'}}';
$columns = Yii::app()->db->schema->getTable($surveytable)->getColumnNames();
if(!in_array('participant_id', $columns)) Yii::app()->db->createCommand()->addColumn($surveytable, "participant_id", "text null");
if(!in_array('validuntil', $columns)) Yii::app()->db->createCommand()->addColumn($surveytable, 'validuntil', 'date null');
if(!in_array('validfrom', $columns)) Yii::app()->db->createCommand()->addColumn($surveytable, 'validfrom', 'date null');
}

public function findUninvited($aTokenIds = false, $iMaxEmails = 0, $bEmail = true, $SQLemailstatuscondition = '', $SQLremindercountcondition = '', $SQLreminderdelaycondition = '')
{
$emquery = "SELECT * FROM {{tokens_" . self::$sid . "}} WHERE ((completed ='N') or (completed='')) AND token <> '' AND email <> ''";
Expand Down
2 changes: 1 addition & 1 deletion scripts/admin/tokens.js
Expand Up @@ -110,13 +110,13 @@ $(document).ready(function() {
var lastSel,lastSel2;
jQuery("#displaytokens").jqGrid({
align:"center",
headertitles: true,
url: jsonUrl,
editurl: editUrl,
datatype: "json",
mtype: "post",
colNames : colNames,
colModel: colModels,
toppager: true,
height: "100%",
rowNum: 25,
editable:true,
Expand Down

0 comments on commit d6cdd8e

Please sign in to comment.