Skip to content

Commit

Permalink
Dev: Models code inspection - fix some undefined things (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonisOrmisson authored and LouisGac committed Jun 8, 2017
1 parent e783d2d commit 7a99062
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 18 deletions.
14 changes: 8 additions & 6 deletions application/models/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,20 @@ public function rules()
}


function getAllRecords($condition=FALSE)
/**
* @param mixed|bool $condition
* @return static[]
*/
public function getAllRecords($condition=FALSE)
{
$criteria = new CDbCriteria;
if ($condition != FALSE) {
foreach ($condition as $item => $value) {
//FIXME this is broken: $criteria is not initiated
$criteria->addCondition($item.'="'.$value.'"');
}
}

$data = $this->findAll($criteria);

return $data;
return $this->findAll($criteria);
}

/**
Expand All @@ -89,7 +91,7 @@ function getAllRecords($condition=FALSE)
*/
public function getLabelCodeInfo($lid)
{
return Yii::app()->db->createCommand()->select('code, title, sortorder, language, assessment_value')->order('language, sortorder, code')->where('lid=:lid')->from(tableName())->bindParam(":lid", $lid, PDO::PARAM_INT)->query()->readAll();
return Yii::app()->db->createCommand()->select('code, title, sortorder, language, assessment_value')->order('language, sortorder, code')->where('lid=:lid')->from($this->tableName())->bindParam(":lid", $lid, PDO::PARAM_INT)->query()->readAll();
}

function insertRecords($data)
Expand Down
19 changes: 10 additions & 9 deletions application/models/LabelSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,21 @@ public function rules()
);
}

function getAllRecords($condition=FALSE)

/**
* @param mixed|bool $condition
* @return static[]
*/
public function getAllRecords($condition=FALSE)
{
if ($condition != FALSE)
{
foreach ($condition as $item => $value)
{
// FIXME this is broken
$criteria = new CDbCriteria;
if ($condition != FALSE) {
foreach ($condition as $item => $value) {
$criteria->addCondition($item.'="'.$value.'"');
}
}

$data = $this->findAll($criteria);

return $data;
return $this->findAll($criteria);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions application/models/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public static function getGlobalBasePermissions()
*/
public static function getPermissions($iUserID, $iEntityID=null, $sEntityName=null)
{
$aBasePermissions = array();
if ($sEntityName=='survey') {
$aBasePermissions=Permission::model()->getSurveyBasePermissions();
} elseif ($sEntityName=='global') {
Expand Down Expand Up @@ -327,6 +328,7 @@ public static function getPermissions($iUserID, $iEntityID=null, $sEntityName=nu
public static function setPermissions($iUserID, $iEntityID, $sEntityName, $aPermissions, $bBypassCheck=false)
{
$iUserID = sanitize_int($iUserID);
$aBasePermissions = array();
// Filter global permissions on save
if ($sEntityName=='global') {
$aBasePermissions=Permission::model()->getGlobalBasePermissions();
Expand Down
1 change: 1 addition & 0 deletions application/models/QuestionGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public function insertNewGroup($aQuestionGroupData)
$aAdditionalLanguages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$aSurveyLanguages=array($sBaseLangauge)+$aAdditionalLanguages;
$bFirst = true;
$iGroupID = null;
foreach ($aSurveyLanguages as $sLanguage) {
if ($bFirst) {
$iGroupID=$this->insertRecords($aQuestionGroupData[$sLanguage]);
Expand Down
2 changes: 1 addition & 1 deletion application/models/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public function setGoogleanalyticsapikeysetting($value){
*/
public function getGoogleanalyticsapikey(){
if($this->googleanalyticsapikey === "9999useGlobal9999") {
return getGlobalSetting(googleanalyticsapikey);
return getGlobalSetting('googleanalyticsapikey');
} else {
return $this->googleanalyticsapikey;
}
Expand Down
1 change: 1 addition & 0 deletions application/models/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public function generateTokens() {
}
$newtokencount = 0;
$invalidtokencount=0;
$newtoken = null;
foreach ($tkresult as $tkrow) {
$bIsValidToken = false;
while ($bIsValidToken == false && $invalidtokencount<50) {
Expand Down
2 changes: 1 addition & 1 deletion application/models/UpdateForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ private function _createDbBackup()
}
} else {
$backupDb->result = FALSE;
$backupDb->message = htmlspecialchars(db_backup_failed);
$backupDb->message = htmlspecialchars('db_backup_failed');
}
return $backupDb;

Expand Down
2 changes: 1 addition & 1 deletion application/models/UserGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getAllRecords($condition=false)

$query = 'SELECT * FROM '.$this->tableName().' '.$where_string;

$data = createCommand($query)->query()->resultAll();
$data = $this->connection->createCommand($query)->query()->resultAll();

return $data;
}
Expand Down

0 comments on commit 7a99062

Please sign in to comment.