Skip to content

Commit

Permalink
Fixed issues with inline functions
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@12068 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Daniel Klischies authored and Daniel Klischies committed Jan 15, 2012
1 parent 3b2f713 commit 7d1a1b6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions application/controllers/Statistics_userController.php
Expand Up @@ -222,13 +222,13 @@ function actionAction($surveyid)
$totalrecords = 0;

//count number of answers
$query = "SELECT count(*) FROM {{survey_{intval($surveyid)}}}";
$query = "SELECT count(*) FROM {{survey_".intval($surveyid)."}}";

//if incompleted answers should be filtert submitdate has to be not null
//this setting is taken from config-defaults.php
if (Yii::app()->getConfig("filterout_incomplete_answers") == true)
{
$query .= " WHERE {{survey_{intval($surveyid)}}}.submitdate is not null";
$query .= " WHERE {{survey_".intval($surveyid)."}}.submitdate is not null";
}
$result = Yii::app()->db->createCommand($query)->queryAll();

Expand Down
4 changes: 2 additions & 2 deletions application/controllers/admin/export.php
Expand Up @@ -218,7 +218,7 @@ public function exportresults()
$data['excesscols'] = $excesscols;

//get max number of datasets
$max_datasets_query = Yii::app()->db->createCommand("SELECT COUNT(id) AS count FROM {{survey_{intval($surveyid)}}}")->query()->read();
$max_datasets_query = Yii::app()->db->createCommand("SELECT COUNT(id) AS count FROM {{survey_".intval($surveyid)."}}")->query()->read();
$max_datasets = $max_datasets_query['count'];

$data['max_datasets'] = $max_datasets;
Expand Down Expand Up @@ -955,7 +955,7 @@ public function vvexport()

$vvoutput = $firstline . "\n";
$vvoutput .= $secondline . "\n";
$query = "SELECT * FROM {{Yii::app()->db->quoteTableName($surveytable)}}";
$query = "SELECT * FROM ".Yii::app()->db->quoteTableName($surveytable);

if (incompleteAnsFilterstate() == "inc")
{
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/saved.php
Expand Up @@ -55,7 +55,7 @@ public function delete($iSurveyId, $iSurveyResponseId, $iSavedControlId)
$clang = $this->getController()->lang;

Saved_control::model()->deleteAllByAttributes(array('scid' => $iSavedControlId, 'sid' => $iSurveyId)) or die($clang->gT("Couldn't delete"));
Yii::app()->db->createCommand()->delete("{{survey_{intval($iSurveyId)}}}", 'id=:id', array('id' => $iSurveyResponseId)) or die($clang->gT("Couldn't delete"));
Yii::app()->db->createCommand()->delete("{{survey_".intval($iSurveyId)."}}", 'id=:id', array('id' => $iSurveyResponseId)) or die($clang->gT("Couldn't delete"));

$this->getController()->redirect($this->getController()->createUrl("admin/saved/view/surveyid/{$iSurveyId}"));
}
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/surveyaction.php
Expand Up @@ -280,7 +280,7 @@ public function deactivate($surveyid = null)
if (Yii::app()->db->getDriverName() == 'postgre')
{
$deactivateresult = Yii::app()->db->createCommand()->renameTable($toldtable . '_tid_seq', $tnewtable . '_tid_seq');
$setsequence = "ALTER TABLE {{{Yii::app->db->quoteTableName($tnewtable)}}} ALTER COLUMN tid SET DEFAULT nextval('{{{$tnewtable}}}_tid_seq'::regclass);";
$setsequence = "ALTER TABLE ".Yii::app()->db->quoteTableName($tnewtable)." ALTER COLUMN tid SET DEFAULT nextval('{{{$tnewtable}}}_tid_seq'::regclass);";
$deactivateresult = Yii::app()->db->createCommand($setsequence)->query();
$setidx = "ALTER INDEX {{{$toldtable}}}_idx RENAME TO {{{$tnewtable}}}_idx;";
$deactivateresult = Yii::app()->db->createCommand($setidx)->query();
Expand Down
14 changes: 7 additions & 7 deletions application/controllers/admin/tokens.php
Expand Up @@ -859,7 +859,7 @@ function updatetokenattributes($iSurveyId)
$i++;
}
$tokenattributefieldnames[] = 'attribute_' . $i;
Yii::app()->db->createCommand(Yii::app()->db->getSchema()->addColumn("{{tokens_{intval($iSurveyId)}}}", 'attribute_' . $i, 'VARCHAR(255)'))->execute();
Yii::app()->db->createCommand(Yii::app()->db->getSchema()->addColumn("{{tokens_".intval($iSurveyId)."}}", 'attribute_' . $i, 'VARCHAR(255)'))->execute();
$fields['attribute_' . $i] = array('type' => 'VARCHAR', 'constraint' => '255');
}

Expand Down Expand Up @@ -1358,7 +1358,7 @@ public function importldap($iSurveyId)
$invalidemail = false;
if ($filterduplicatetoken)
{
$dupquery = "SELECT firstname, lastname from {{tokens_{intval($iSurveyId)}}} where email=:email and firstname=:firstname and lastname=:lastname";
$dupquery = "SELECT firstname, lastname from {{tokens_".intval($iSurveyId)."}} where email=:email and firstname=:firstname and lastname=:lastname";
$dupresult = Yii::app()->db->createCommand($dupquery)->bindParam(":email", $myemail, PDO::PARAM_STR)->bindParam(":firstname", $myfirstname, PDO::PARAM_STR)->bindParam(":lastname", $mylastname, PDO::PARAM_STR)->query();
if ($dupresult->getRowCount() > 0)
{
Expand Down Expand Up @@ -1389,7 +1389,7 @@ public function importldap($iSurveyId)
elseif ($meetminirequirements === true)
{
// No issue, let's import
$iq = "INSERT INTO {{tokens_{intval($iSurveyId)}}} \n"
$iq = "INSERT INTO {{tokens_".intval($iSurveyId)."}} \n"
. "(firstname, lastname, email, emailstatus, token, language";

foreach ($aTokenAttr as $thisattrfieldname)
Expand Down Expand Up @@ -1627,12 +1627,12 @@ function import($iSurveyId)

if ($filterduplicatetoken != false)
{
$dupquery = "SELECT tid from {{tokens_{intval($iSurveyId)}}} where 1=1";
$dupquery = "SELECT tid from {{tokens_".intval($iSurveyId)."}} where 1=1";
foreach ($filterduplicatefields as $field)
{
if (isset($writearray[$field]))
{
$dupquery.= " and {Yii:app()->db->quoteColumnName($field)} = '{Yii:app()->db->quoteValue($writearray[$field])}'";
$dupquery.= " and ".Yii::app()->db->quoteColumnName($field)." = " . Yii::app()->db->quoteValue($writearray[$field])."'";
}
}
$dupresult = Yii::app()->db->createCommand($dupquery)->query();
Expand Down Expand Up @@ -1933,7 +1933,7 @@ function _newtokentable($iSurveyId)
'mpid' => 'INT(11)'
);
$comm = Yii::app()->db->createCommand();
$comm->createTable('{{tokens_{intval($iSurveyId)}}}', $fields);
$comm->createTable("{{tokens_".intval($iSurveyId)."}}", $fields);

//$tabname = "{{tokens_{$iSurveyId}}}"; # not using db_table_name as it quotes the table name (as does CreateTableSQL)
/* $taboptarray = array('mysql' => 'ENGINE='.$aDatabasetabletype.' CHARACTER SET utf8 COLLATE utf8_unicode_ci',
Expand Down Expand Up @@ -1971,7 +1971,7 @@ function _newtokentable($iSurveyId)
else
{
$this->getController()->loadHelper('database');
$result = Yii::app()->db->createCommand(db_select_tables_like('{{old_tokens_{intval($iSurveyId)}_%}}'))->queryAll();
$result = Yii::app()->db->createCommand(db_select_tables_like('{{old_tokens_".intval($iSurveyId)."_%}}'))->queryAll();
$tcount = count($result);
if ($tcount > 0)
{
Expand Down
12 changes: 6 additions & 6 deletions application/models/Survey.php
Expand Up @@ -218,19 +218,19 @@ public function deleteSurvey($iSurveyID, $recursive=true)

if ($recursive == true)
{
if (tableExists("{{survey_{intval($iSurveyID)}}}")) //delete the survey_$iSurveyID table
if (tableExists("{{survey_".intval($iSurveyID)."}}")) //delete the survey_$iSurveyID table
{
Yii::app()->db->createCommand()->dropTable("{{survey_{intval($iSurveyID)}}}");
Yii::app()->db->createCommand()->dropTable("{{survey_".intval($iSurveyID)."}}");
}

if (tableExists("{{survey_{intval($iSurveyID)}_timings}}")) //delete the survey_$iSurveyID_timings table
if (tableExists("{{survey_".intval($iSurveyID)."_timings}}")) //delete the survey_$iSurveyID_timings table
{
Yii::app()->db->createCommand()->dropTable("{{survey_{intval($iSurveyID)}_timings}}");
Yii::app()->db->createCommand()->dropTable("{{survey_".intval($iSurveyID)."_timings}}");
}

if (tableExists("{{tokens_{intval($iSurveyID)}}}")) //delete the tokens_$iSurveyID table
if (tableExists("{{tokens_".intval($iSurveyID)."}}")) //delete the tokens_$iSurveyID table
{
Yii::app()->db->createCommand()->dropTable("{{tokens_{intval($iSurveyID)}}}");
Yii::app()->db->createCommand()->dropTable("{{tokens_".intval($iSurveyID)."}}");
}

$oResult = Questions::model()->findAllByAttributes(array('sid' => $iSurveyID));
Expand Down

0 comments on commit 7d1a1b6

Please sign in to comment.