Skip to content

Commit

Permalink
Dev Fixed usage of deprecated 't' alias for tables. http://static.yii…
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Jun 25, 2013
1 parent dd647df commit 0127071
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 20 deletions.
8 changes: 7 additions & 1 deletion application/controllers/PluginsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ public function __set($property, $value)
$this->properties[$property] = $value;
}




public function actionTest()
{
$response = Response::model(66957)->findByPk(11);
$this->renderText('test');
}
}
?>
2 changes: 1 addition & 1 deletion application/helpers/SurveyRuntimeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function createQuestionIndex($LEMsessid, $surveyMode)
if ($_SESSION[$LEMsessid]['maxstep'] == $_SESSION[$LEMsessid]['totalsteps'])
{
echo "<input class='submit' type='submit' accesskey='l' onclick=\"javascript:document.limesurvey.move.value = 'movesubmit';\" value=' "
. $clang->gT("Submit") . " ' name='move2' />\n";
. gT("Submit") . " ' name='move2' />\n";
}

echo '</div></div>';
Expand Down
3 changes: 2 additions & 1 deletion application/models/Answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ public function primaryKey()
*/
public function relations()
{
$alias = $this->getTableAlias();
return array(
'questions' => array(self::HAS_ONE, 'Question', '',
'on' => 't.qid = questions.qid',
'on' => "$alias.qid = questions.qid",
),
'groups' => array(self::HAS_ONE, 'QuestionGroup', '', 'through' => 'questions',
'on' => 'questions.gid = groups.gid'
Expand Down
3 changes: 2 additions & 1 deletion application/models/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ public function primaryKey()
*/
public function relations()
{
$alias = $this->getTableAlias();
return array(
'questions' => array(self::HAS_ONE, 'Question', '',
'on' => 't.cqid = questions.qid',
'on' => "$alias.cqid = questions.qid",
),
);
}
Expand Down
3 changes: 2 additions & 1 deletion application/models/DefaultValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ public function primaryKey()
*/
public function relations()
{
$alias = $this->getTableAlias();
return array(
'question' => array(self::HAS_ONE, 'Question', '',
'on' => 't.qid = question.qid',
'on' => "$alias.qid = question.qid",
),
);
}
Expand Down
3 changes: 2 additions & 1 deletion application/models/ParticipantAttributeName.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ function getnotaddedAttributes($attributeid)
}

$criteria = new CDbCriteria();
$criteria->addNotInCondition('t.attribute_id', $attributeid);
$alias = $this->getTableAlias();
$criteria->addNotInCondition("$alias.attribute_id", $attributeid);
$records = ParticipantAttributeName::model()->with('participant_attribute_names_lang')->findAll($criteria);
foreach($records as $row) { //Iterate through each attribute
$thisname="";
Expand Down
5 changes: 3 additions & 2 deletions application/models/Question.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ public function primaryKey()
*/
public function relations()
{
$alias = $this->getTableAlias();
return array(
'groups' => array(self::HAS_ONE, 'QuestionGroup', '',
'on' => 't.gid = groups.gid AND t.language = groups.language'
'on' => "$alias.gid = groups.gid AND $alias.language = groups.language"
),
'parents' => array(self::HAS_ONE, 'Question', '',
'on' => 't.parent_qid = parents.qid',
'on' => "$alias.parent_qid = parents.qid",
),
);
}
Expand Down
3 changes: 2 additions & 1 deletion application/models/QuestionAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ public function primaryKey()
*/
public function relations()
{
$alias = $this->getTableAlias();
return array(
'qid' => array(self::HAS_ONE, 'Questions', '',
'on' => 't.qid = questions.qid',
'on' => "$alias.qid = questions.qid",
),
);
}
Expand Down
3 changes: 2 additions & 1 deletion application/models/Quota.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ public function primaryKey()
*/
public function relations()
{
$alias = $this->getTableAlias();
return array(
'languagesettings' => array(self::HAS_MANY, 'QuotaLanguageSetting', '',
'on' => 't.id = languagesettings.quotals_quota_id'),
'on' => "$alias.id = languagesettings.quotals_quota_id"),
);
}

Expand Down
3 changes: 2 additions & 1 deletion application/models/QuotaLanguageSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ public function primaryKey()
*/
public function relations()
{
$alias = $this->getTableAlias();
return array(
'quota' => array(self::BELONGS_TO, 'Quota', '',
'on' => 'quota.id = t.quotals_quota_id'),
'on' => "quota.id = $alias.quotals_quota_id"),
);
}

Expand Down
5 changes: 3 additions & 2 deletions application/models/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ public static function model($class = __CLASS__)
*/
public function relations()
{
$alias = $this->getTableAlias();
return array(
'languagesettings' => array(self::HAS_MANY, 'SurveyLanguageSetting', 'surveyls_survey_id'),
'owner' => array(self::BELONGS_TO, 'User', '', 'on' => 't.owner_id = owner.uid'),
'languagesettings' => array(self::HAS_MANY, 'SurveyLanguageSetting', 'surveyls_survey_id'),
'owner' => array(self::BELONGS_TO, 'User', '', 'on' => "$alias.owner_id = owner.uid"),
);
}

Expand Down
12 changes: 7 additions & 5 deletions application/models/SurveyDynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ public function addTimingCriteria($condition)
{
$criteria->select = 't.*';
}
$alias = $this->getTableAlias();

$newCriteria->join = "LEFT JOIN {{survey_" . self::$sid . "_timings}} survey_timings ON t.id = survey_timings.id";
$newCriteria->join = "LEFT JOIN {{survey_" . self::$sid . "_timings}} survey_timings ON $alias.id = survey_timings.id";
$newCriteria->select = 'survey_timings.*'; // Otherwise we don't get records from the token table
$newCriteria->mergeWith($criteria);

Expand All @@ -167,17 +168,18 @@ public function addTokenCriteria($condition)
$aSelectFields=Yii::app()->db->schema->getTable('{{survey_' . self::$sid . '}}')->getColumnNames();
$aSelectFields=array_diff($aSelectFields, array('token'));
$aSelect=array();
$alias = $this->getTableAlias();
foreach($aSelectFields as $sField)
$aSelect[]='t.'.Yii::app()->db->schema->quoteColumnName($sField);
$aSelectFields=$aSelect;
$aSelectFields[]='t.token';
$aSelect[]="$alias.".Yii::app()->db->schema->quoteColumnName($sField);
$aSelectFields=$aSelect;
$aSelectFields[]='$alias.token';

if ($criteria->select == '*')
{
$criteria->select = $aSelectFields;
}

$newCriteria->join = "LEFT JOIN {{tokens_" . self::$sid . "}} tokens ON t.token = tokens.token";
$newCriteria->join = "LEFT JOIN {{tokens_" . self::$sid . "}} tokens ON $alias.token = tokens.token";

$aTokenFields=Yii::app()->db->schema->getTable('{{tokens_' . self::$sid . '}}')->getColumnNames();
$aTokenFields=array_diff($aTokenFields, array('token'));
Expand Down
3 changes: 2 additions & 1 deletion application/models/SurveyLanguageSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public static function model($class = __CLASS__)
*/
public function relations()
{
$alias = $this->getTableAlias();
return array(
'survey' => array(self::BELONGS_TO, 'Survey', '', 'on' => 't.surveyls_survey_id = survey.sid'),
'survey' => array(self::BELONGS_TO, 'Survey', '', 'on' => "$alias.surveyls_survey_id = survey.sid"),
'owner' => array(self::BELONGS_TO, 'User', '', 'on' => 'survey.owner_id = owner.uid'),
);
}
Expand Down
2 changes: 1 addition & 1 deletion application/models/SurveyTimingDynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function tableName()
public function statistics()
{
$sid = self::$sid;
if(Yii::app()->db->schema->getTable($this->tableName())){
if(Yii::app()->db->schema->getTable($this->tableName())){
$queryAvg=Yii::app()->db->createCommand()
->select("AVG(interviewtime) AS avg, COUNT(*) as count")
->from($this->tableName()." t")
Expand Down

0 comments on commit 0127071

Please sign in to comment.