Skip to content

Commit

Permalink
Dev: Clean-up scrutinizer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Mar 2, 2016
1 parent 67f5f93 commit d2866a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
3 changes: 2 additions & 1 deletion application/controllers/admin/participantsaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public function getAttributeInfo_json()
$aData = new stdClass();
$aData->page = $page;
$aData->records = count($records);
$aData->total = ceil(ParticipantAttributeName::model()->getCPDBAttributes(true) / $limit);
$aData->total = ceil(count(ParticipantAttributeName::model()->getCPDBAttributes()) / $limit);
$i = 0;
foreach($records as $row) { //Iterate through each attribute
$sAttributeCaption=htmlspecialchars($row->defaultname); //Choose the first item by default
Expand Down Expand Up @@ -1790,6 +1790,7 @@ public function blacklistParticipant()
$this->load->model('participants_model');
$iParticipantId = $this->uri->segment(4);
$iSurveyId = $this->uri->segment(5);
$aData = array();
if (!is_numeric($iSurveyId))
{
$blacklist = $this->uri->segment(5);
Expand Down
32 changes: 12 additions & 20 deletions application/models/ParticipantAttributeName.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,14 @@ function getAttributeValue($participantid,$attributeid)
return $data;
}

function getCPDBAttributes($count = false, $limit = -1, $offset = -1)
/**
* @return array
*/
function getCPDBAttributes()
{
$findCriteria=new CDbCriteria();
$findCriteria->offset=$offset;
$findCriteria->limit=$limit;
$findCriteria->offset = -1;
$findCriteria->limit = -1;
$output=array();
$records = ParticipantAttributeName::model()->with('participant_attribute_names_lang')->findAll($findCriteria);
foreach($records as $row) { //Iterate through each attribute
Expand All @@ -247,25 +250,14 @@ function getCPDBAttributes($count = false, $limit = -1, $offset = -1)
if($names->lang == Yii::app()->session['adminlang']) {$thisname=$names->attribute_name; $thislang=$names->lang;} //Override the default with the admin language version if found
}
$output[]=array('attribute_id'=>$row->attribute_id,
'attribute_type'=>$row->attribute_type,
'attribute_display'=>$row->visible,
'attribute_name'=>$thisname,
'lang'=>$thislang);
'attribute_type'=>$row->attribute_type,
'attribute_display'=>$row->visible,
'attribute_name'=>$thisname,
'lang'=>$thislang
);
}

/* $command = Yii::app()->db->createCommand()
->from('{{participant_attribute_names}}')
->leftjoin('{{participant_attribute_names_lang}}', '{{participant_attribute_names}}.attribute_id = {{participant_attribute_names_lang}}.attribute_id')
->where('lang = "'.Yii::app()->session['adminlang'].'"')
->limit(intval($limit), intval($offset)); */
if (empty($count))
{
return $output;
}
else
{
return count($output);
}
return $output;
}

function getAttributesValues($attribute_id)
Expand Down

0 comments on commit d2866a2

Please sign in to comment.