Skip to content

Commit

Permalink
Dev Scrutinizer Auto-Fixes (#922)
Browse files Browse the repository at this point in the history
  • Loading branch information
scrutinizer-auto-fixer authored and c-schmitz committed Jan 7, 2018
1 parent 03b7369 commit e90fd61
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 77 deletions.
10 changes: 5 additions & 5 deletions application/controllers/admin/questions.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public function _editansweroptions($surveyid, $gid, $qid)
$oAnserL10n = new AnswerL10n();
$oAnserL10n->answer = "";
$oAnserL10n->language = $baselang;
$oAnserL10n->aid=$oAnswer->aid;
$oAnserL10n->aid = $oAnswer->aid;
$oAnserL10n->save();
}

Expand Down Expand Up @@ -706,9 +706,9 @@ public function _editsubquestion($surveyid, $gid, $qid)
$subQuestion->attributes = $data;
$subQuestion->save();
$oQuestionL10n = new QuestionL10n();
$oQuestionL10n->qid=$subQuestion->qid;
$oQuestionL10n->question='';
$oQuestionL10n->language=$oSurvey->language;
$oQuestionL10n->qid = $subQuestion->qid;
$oQuestionL10n->question = '';
$oQuestionL10n->language = $oSurvey->language;
$oQuestionL10n->save();
$subquestiondata = Question::model()->findAllByAttributes(array(
'parent_qid' => $qid,
Expand Down Expand Up @@ -1007,7 +1007,7 @@ public function newquestion($surveyid)
$oQuestion->relevance = 1;
$oQuestion->group_name = '';
$oQuestion->modulename = '';
$oQuestion->questionL10ns=array($baselang=>new QuestionL10n);
$oQuestion->questionL10ns = array($baselang=>new QuestionL10n);
if (isset($_GET['gid'])) {
$oQuestion->gid = $_GET['gid'];
}
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/admin/surveyadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public function getAjaxQuestionGroupArray($surveyid)
if (count($aGroups)) {
foreach ($aGroups as $group) {
$curGroup = $group->attributes;
$curGroup['group_name']=$group->questionGroupL10ns[$baselang]->group_name;
$curGroup['group_name'] = $group->questionGroupL10ns[$baselang]->group_name;
$curGroup['link'] = $this->getController()->createUrl("admin/questiongroups/sa/view", ['surveyid' => $surveyid, 'gid' => $group->gid]);
$group->aQuestions = Question::model()->findAllByAttributes(array("sid"=>$iSurveyID, "gid"=>$group['gid'], 'parent_qid'=>0), array('order'=>'question_order ASC'));
$curGroup['questions'] = array();
Expand Down
71 changes: 36 additions & 35 deletions application/helpers/admin/import_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -978,16 +978,16 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
$iOldSID = $insertdata['sid'];
$insertdata['sid'] = $iNewSID;
$oldgid = $insertdata['gid']; unset($insertdata['gid']); // save the old qid
$aDataL10n=array();
if ($iDBVersion<339) {
$aDataL10n = array();
if ($iDBVersion < 339) {
// now translate any links
if ($bTranslateInsertansTags) {
$insertdata['group_name'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['group_name']);
$insertdata['description'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['description']);
}
$aDataL10n['group_name']= $insertdata['group_name'];
$aDataL10n['description']= $insertdata['description'];
$aDataL10n['language']= $insertdata['language'];
$aDataL10n['group_name'] = $insertdata['group_name'];
$aDataL10n['description'] = $insertdata['description'];
$aDataL10n['language'] = $insertdata['language'];
unset($insertdata['group_name']);
unset($insertdata['description']);
unset($insertdata['language']);
Expand All @@ -999,10 +999,10 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
}
if (!empty($aDataL10n))
{
$aDataL10n['gid']=$aGIDReplacements[$oldgid];
$oQuestionGroupL10n=new QuestionGroupL10n();
$oQuestionGroupL10n->setAttributes($aDataL10n,false);
$oQuestionGroupL10n->save();
$aDataL10n['gid']=$aGIDReplacements[$oldgid];
$oQuestionGroupL10n=new QuestionGroupL10n();
$oQuestionGroupL10n->setAttributes($aDataL10n,false);
$oQuestionGroupL10n->save();
}

}
Expand Down Expand Up @@ -1053,15 +1053,16 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul

// We have to run the question table data two times - first to find all main questions
// then for subquestions (because we need to determine the new qids for the main questions first)
if (isset($xml->questions)) { // There could be surveys without a any questions.
if (isset($xml->questions)) {
// There could be surveys without a any questions.
foreach ($xml->questions->rows->row as $row) {

$insertdata = array();
foreach ($row as $key=>$value) {
$insertdata[(string) $key] = (string) $value;
}

if ($iDBVersion<339) {
if ($iDBVersion < 339) {
if (!in_array($insertdata['language'], $aLanguagesSupported)) {
continue;
}
Expand All @@ -1082,15 +1083,15 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
XSSFilterArray($insertdata);
}
// now translate any links
if ($iDBVersion<339) {
if ($iDBVersion < 339) {
if ($bTranslateInsertansTags) {
$insertdata['question'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['question']);
$insertdata['help'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['help']);
}
$oQuestionL10n= new QuestionL10n();
$oQuestionL10n->question= $insertdata['question'];
$oQuestionL10n->help= $insertdata['help'];
$oQuestionL10n->language= $insertdata['language'];
$oQuestionL10n = new QuestionL10n();
$oQuestionL10n->question = $insertdata['question'];
$oQuestionL10n->help = $insertdata['help'];
$oQuestionL10n->language = $insertdata['language'];
unset($insertdata['question']);
unset($insertdata['help']);
unset($insertdata['language']);
Expand Down Expand Up @@ -1129,16 +1130,16 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
}
}

if (!isset($aQIDReplacements[$iOldQID])){
if (!isset($aQIDReplacements[$iOldQID])) {
if (!$oQuestion->save()) {
safeDie(gT("Error while saving: "). print_r($oQuestion->errors, true));
safeDie(gT("Error while saving: ").print_r($oQuestion->errors, true));
}
$aQIDReplacements[$iOldQID] = $oQuestion->qid;;
$aQIDReplacements[$iOldQID] = $oQuestion->qid; ;
$results['questions']++;
}

if (isset($oQuestionL10n)) {
$oQuestionL10n->qid=$aQIDReplacements[$iOldQID];
$oQuestionL10n->qid = $aQIDReplacements[$iOldQID];
$oQuestionL10n->save();
unset($oQuestionL10n);
}
Expand All @@ -1164,7 +1165,7 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
$insertdata[(string) $key] = (string) $value;
}

if ($iDBVersion<339) {
if ($iDBVersion < 339) {
if (!in_array($insertdata['language'], $aLanguagesSupported)) {
continue;
}
Expand All @@ -1184,7 +1185,7 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
XSSFilterArray($insertdata);
}
// now translate any links
if ($iDBVersion<339) {
if ($iDBVersion < 339) {
if ($bTranslateInsertansTags) {
$insertdata['question'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['question']);
if (isset($insertdata['help'])) {
Expand All @@ -1194,7 +1195,7 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
$oQuestionL10n = new QuestionL10n();
$oQuestionL10n->question = $insertdata['question'];
$oQuestionL10n->help = $insertdata['help'];
$oQuestionL10n->language= $insertdata['language'];
$oQuestionL10n->language = $insertdata['language'];
unset($insertdata['question']);
unset($insertdata['help']);
unset($insertdata['language']);
Expand Down Expand Up @@ -1238,16 +1239,16 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
}
}

if (!isset($aQIDReplacements[$iOldQID])){
if (!isset($aQIDReplacements[$iOldQID])) {
if (!$oQuestion->save()) {
safeDie(gT("Error while saving: "). print_r($oQuestion->errors, true));
safeDie(gT("Error while saving: ").print_r($oQuestion->errors, true));
}
$aQIDReplacements[$iOldQID] = $oQuestion->qid;;
$aQIDReplacements[$iOldQID] = $oQuestion->qid; ;
$results['questions']++;
}

if (isset($oQuestionL10n)) {
$oQuestionL10n->qid=$aQIDReplacements[$iOldQID];
$oQuestionL10n->qid = $aQIDReplacements[$iOldQID];
$oQuestionL10n->save();
unset($oQuestionL10n);
}
Expand All @@ -1271,8 +1272,8 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
foreach ($row as $key=>$value) {
$insertdata[(string) $key] = (string) $value;
}
if ($iDBVersion>=339) {
$iOldAID=$insertdata['aid'];
if ($iDBVersion >= 339) {
$iOldAID = $insertdata['aid'];
}
if (!in_array($insertdata['language'], $aLanguagesSupported) || !isset($aQIDReplacements[(int) $insertdata['qid']])) {
continue;
Expand All @@ -1283,26 +1284,26 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
if ($insertdata) {
XSSFilterArray($insertdata);
}
if ($iDBVersion<339) {
if ($iDBVersion < 339) {
// now translate any links
if ($bTranslateInsertansTags) {
$insertdata['answer'] = translateLinks('survey', $iOldSID, $iNewSID, $insertdata['answer']);
}
$oAnswerL10n = new AnswerL10n();
$oAnswerL10n->answer = $insertdata['answer'];
$oAnswerL10n->language= $insertdata['language'];
$oAnswerL10n->language = $insertdata['language'];
unset($insertdata['answer']);
unset($insertdata['language']);
}
$oAnswer = new Answer();
$oAnswer->setAttributes($insertdata, false);
if ($oAnswer->save() && $iDBVersion>=339){
$aAIDReplacements[$iOldAID]=$oAnswer->aid;
if ($oAnswer->save() && $iDBVersion >= 339) {
$aAIDReplacements[$iOldAID] = $oAnswer->aid;
}
$results['answers']++;
if (isset($oAnswerL10n)) {
$oAnswer=Answer::model()->findByAttributes(['qid'=>$insertdata['qid'],'code'=>$insertdata['code'],'scale_id'=>$insertdata['scale_id']]);
$oAnswerL10n->aid=$oAnswer->aid;
$oAnswer = Answer::model()->findByAttributes(['qid'=>$insertdata['qid'], 'code'=>$insertdata['code'], 'scale_id'=>$insertdata['scale_id']]);
$oAnswerL10n->aid = $oAnswer->aid;
$oAnswerL10n->save();
unset($oAnswerL10n);
}
Expand Down

0 comments on commit e90fd61

Please sign in to comment.