Skip to content

Commit

Permalink
Scrutinizer Auto-Fixes
Browse files Browse the repository at this point in the history
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
  • Loading branch information
scrutinizer-auto-fixer committed Feb 10, 2018
1 parent be1d2d3 commit d81da1d
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 61 deletions.
5 changes: 3 additions & 2 deletions application/controllers/admin/database.php
Expand Up @@ -573,7 +573,7 @@ private function actionUpdateQuestion($iSurveyID)
$aLanguages = $oSurvey->allLanguages;
foreach ($validAttributes as $validAttribute) {
/* Readonly attribute : disable save */
if($validAttribute['readonly'] || ($validAttribute['readonly_when_active'] && Survey::model()->findByPk($iSurveyID)->getIsActive()) ) {
if ($validAttribute['readonly'] || ($validAttribute['readonly_when_active'] && Survey::model()->findByPk($iSurveyID)->getIsActive())) {
continue;
}
if ($validAttribute['i18n']) {
Expand Down Expand Up @@ -1438,7 +1438,8 @@ private function actionInsertCopyQuestion($iSurveyID)
$this->getController()->redirect($redirectLink);
}

private function _resetEM(){
private function _resetEM()
{
$oSurvey = Survey::model()->findByPk($this->iSurveyID);
LimeExpressionManager::SetDirtyFlag();
$oEM =& LimeExpressionManager::singleton();
Expand Down
4 changes: 2 additions & 2 deletions application/core/LSETwigViewRenderer.php
Expand Up @@ -79,7 +79,7 @@ public function renderTemplateFromFile($sLayout, $aDatas, $bReturn)
* @param array $aDatas the datas needed to fill the layout
* @param boolean $bReturn if true, it will return the html string without rendering the whole page. Usefull for debuging, and used for Print Answers
*/
public function renderViewFromFile($sLayoutFilePath, $aDatas, $bReturn=false)
public function renderViewFromFile($sLayoutFilePath, $aDatas, $bReturn = false)
{
$viewFile = Yii::app()->getConfig('rootdir').$sLayoutFilePath;
if (file_exists($viewFile)) {
Expand Down Expand Up @@ -249,7 +249,7 @@ public function convertTwigToHtml($sString, $aDatas, $oTemplate = null)
$this->_twig = $twig = parent::getTwig();

//Run theme related things only if a theme is provided!
if($oTemplate !== null ) {
if ($oTemplate !== null) {
// Get the additional infos for the view, such as language, direction, etc
$aDatas = $this->getAdditionalInfos($aDatas, $oTemplate);

Expand Down
8 changes: 4 additions & 4 deletions application/core/LS_Twig_Extension.php
Expand Up @@ -291,7 +291,7 @@ public static function imageSrc($sImagePath, $default = './files/pattern.png')
* @param String $sInString
* @return String
*/
public static function getExpressionManagerOutput($sInString){
public static function getExpressionManagerOutput($sInString) {
templatereplace(flattenText($sInString));
return LimeExpressionManager::GetLastPrettyPrintExpression();
}
Expand All @@ -307,10 +307,10 @@ public static function getExpressionManagerOutput($sInString){
*/
public static function checkPermission($permission, $permissionGrade, $iSurveyId = null) {

if($iSurveyId === null){
return Permission::model()->hasGlobalPermission($permission,$permissionGrade);
if ($iSurveyId === null) {
return Permission::model()->hasGlobalPermission($permission, $permissionGrade);
}
return Permission::model()->hasSurveyPermission($iSurveyId,$permission,$permissionGrade);
return Permission::model()->hasSurveyPermission($iSurveyId, $permission, $permissionGrade);

}

Expand Down
64 changes: 32 additions & 32 deletions application/core/LsDefaultDataSets.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -670,7 +670,7 @@ private function initFirstStep()
{

// First time the survey is loaded
if (!isset($_SESSION[$this->LEMsessid]['step']) || ($this->previewquestion || $this->previewgrp) ) {
if (!isset($_SESSION[$this->LEMsessid]['step']) || ($this->previewquestion || $this->previewgrp)) {
// Init session, randomization and filed array
buildsurveysession($this->iSurveyid);
$fieldmap = randomizationGroupsAndQuestions($this->iSurveyid);
Expand Down
14 changes: 7 additions & 7 deletions application/helpers/admin/activate_helper.php
Expand Up @@ -129,7 +129,7 @@ function checkQuestions($postsid, $iSurveyID, $qtypes)
// # "1" -> MULTI SCALE

$survey = Survey::model()->findByPk($iSurveyID);
$oDB = Yii::app()->db;
$oDB = Yii::app()->db;

$chkquery = $oDB->createCommand()
->select(['q.qid', 'ls.question', 'gid', 'type'])
Expand Down Expand Up @@ -183,9 +183,9 @@ function checkQuestions($postsid, $iSurveyID, $qtypes)
$chkquery = Yii::app()->db->createCommand()
->select(['q.qid', 'ls.question', 'gid'])
->from('{{questions}} q')
->join('{{question_l10ns}} ls','ls.qid=q.qid')
->join('{{question_l10ns}} ls', 'ls.qid=q.qid')
->andWhere("(SELECT count(*) from {{answers}} as a where a.qid=q.qid and scale_id=0)=0")
->andWhere("sid=:sid",[':sid'=>$iSurveyID])
->andWhere("sid=:sid", [':sid'=>$iSurveyID])
->andWhere("type IN ('".Question::QT_F_ARRAY_FLEXIBLE_ROW."', '".Question::QT_H_ARRAY_FLEXIBLE_COLUMN."', '".Question::QT_Z_LIST_RADIO_FLEXIBLE."', '".Question::QT_1_ARRAY_MULTISCALE."')")
->andWhere("q.parent_qid=0");
$chkresult = $chkquery->queryAll();
Expand All @@ -197,9 +197,9 @@ function checkQuestions($postsid, $iSurveyID, $qtypes)
$chkquery = Yii::app()->db->createCommand()
->select(['q.qid', 'ls.question', 'gid'])
->from('{{questions}} q')
->join('{{question_l10ns}} ls','ls.qid=q.qid')
->join('{{question_l10ns}} ls', 'ls.qid=q.qid')
->andWhere("(Select count(*) from {{answers}} a where a.qid=q.qid and scale_id=1)=0")
->andWhere("sid=:sid",[':sid'=>$iSurveyID])
->andWhere("sid=:sid", [':sid'=>$iSurveyID])
->andWhere("type='".Question::QT_1_ARRAY_MULTISCALE."'")
->andWhere("q.parent_qid=0");
$chkresult = $chkquery->queryAll();
Expand All @@ -224,8 +224,8 @@ function checkQuestions($postsid, $iSurveyID, $qtypes)
$conquery = Yii::app()->db->createCommand()
->select(['cndn.qid', 'cqid', 'ls.question', 'q.gid'])
->from('{{conditions}} cndn')
->join('{{questions}} q','cndn.qid=q.qid')
->join('{{question_l10ns}} ls','ls.qid=q.qid')
->join('{{questions}} q', 'cndn.qid=q.qid')
->join('{{question_l10ns}} ls', 'ls.qid=q.qid')
->andWhere('q.sid=:sid', [':sid'=>$iSurveyID])
->andWhere('ls.language=:lngn', [':lngn'=>$survey->language])
->order('cndn.qid');
Expand Down
4 changes: 2 additions & 2 deletions application/helpers/admin/export/CsvWriter.php
Expand Up @@ -48,9 +48,9 @@ protected function outputRecord($headers, $values, FormattingOptions $oOptions)
if ($oOptions->output == 'display') {
header("Content-Disposition: attachment; filename=".$this->csvFilename);
header("Content-type: text/comma-separated-values; charset=UTF-8");
echo chr(239) . chr(187) . chr(191);
echo chr(239).chr(187).chr(191);
} else {
fwrite($this->file, chr(239) . chr(187) . chr(191)); // Write UTF-8 Byte Order Mark (BOM)
fwrite($this->file, chr(239).chr(187).chr(191)); // Write UTF-8 Byte Order Mark (BOM)
}

// If we don't want headers in our csv, for example in exports like r/spss etc. we suppress the header by setting this switch in the init
Expand Down
6 changes: 3 additions & 3 deletions application/helpers/admin/import_helper.php
Expand Up @@ -86,7 +86,7 @@ function XMLImportGroup($sFullFilePath, $iNewSID)
if (!isset($aGIDReplacements[$oldgid])) {
$questionGroup = new QuestionGroup();
$questionGroup->attributes = $insertdata;
if(!$questionGroup->save()){
if(!$questionGroup->save()) {
safeDie(gT("Error").": Failed to insert data [3]<br />");
}

Expand Down Expand Up @@ -1344,7 +1344,7 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul
$questionGroup = new QuestionGroup();
$questionGroup->attributes = $insertdata;
$questionGroup->sid = $iNewSID;
if(!$questionGroup->save()){
if(!$questionGroup->save()) {
safeDie(gT("Error").": Failed to insert data [3]<br />");
}

Expand Down Expand Up @@ -1770,7 +1770,7 @@ function XMLImportSurvey($sFullFilePath, $sXMLdata = null, $sNewSurveyName = nul

// now translate any links
$defaultValue = new DefaultValue();
$defaultValue->setAttributes($insertdata,false);
$defaultValue->setAttributes($insertdata, false);
if (!$defaultValue->save()) {
safeDie(gT("Error").": Failed to insert data[9]<br />");
}
Expand Down
4 changes: 2 additions & 2 deletions application/models/AnswerL10n.php
Expand Up @@ -68,8 +68,8 @@ public function relations()
public function rules()
{
return [
['aid,language,answer','required'],
['aid','numerical','integerOnly'=>true],
['aid,language,answer', 'required'],
['aid', 'numerical', 'integerOnly'=>true],
['answer', 'LSYii_Validators'],
['language', 'length', 'min' => 2, 'max'=>20], // in array languages ?
];
Expand Down
4 changes: 3 additions & 1 deletion application/models/Assessment.php
Expand Up @@ -35,7 +35,9 @@ public function init()
parent::init();
if ($this->isNewRecord) {
// default values
if (empty($this->scope)) $this->scope = '0';
if (empty($this->scope)) {
$this->scope = '0';
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions application/models/DefaultValue.php
Expand Up @@ -83,8 +83,8 @@ public function rules()
)
),
'message'=>'{attribute} "{value}" is already in use.'),
['language,specialtype','length','min' => 2,'max'=>20],
['defaultvalue','safe'],
['language,specialtype', 'length', 'min' => 2, 'max'=>20],
['defaultvalue', 'safe'],
);
}

Expand Down
4 changes: 2 additions & 2 deletions application/models/QuestionL10n.php
Expand Up @@ -73,8 +73,8 @@ public function defaultScope()
public function rules()
{
return array(
['qid,language','required'],
['qid','numerical','integerOnly'=>true],
['qid,language', 'required'],
['qid', 'numerical', 'integerOnly'=>true],
array('question', 'LSYii_Validators'),
array('help', 'LSYii_Validators'),
array('language', 'length', 'min' => 2, 'max'=>20), // in array languages ?
Expand Down
2 changes: 1 addition & 1 deletion application/models/Survey.php
Expand Up @@ -200,7 +200,7 @@ public function attributeLabels()
/** @inheritdoc */
public function delete()
{
return $this->deleteSurvey($this->sid,true);
return $this->deleteSurvey($this->sid, true);
}


Expand Down

0 comments on commit d81da1d

Please sign in to comment.