Skip to content

Commit

Permalink
Fixed issue #11539: Filtering answers is not working
Browse files Browse the repository at this point in the history
  • Loading branch information
markusfluer committed Aug 12, 2016
1 parent ef22ae5 commit 047efc9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
16 changes: 8 additions & 8 deletions application/controllers/admin/responses.php
Expand Up @@ -424,19 +424,19 @@ public function browse($iSurveyId)
$model = SurveyDynamic::model($iSurveyId);

// Page size
if (isset($_GET['pageSize']))
if (!empty(Yii::app()->request->getParam('pageSize')))
{
Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
Yii::app()->user->setState('pageSize',(int)Yii::app()->request->getParam('pageSize'));
}

// Model filters
// Using safe search on dynamic column names would be far too much complex.
// So we pass over the safe validation and directly set attributes (second parameter of setAttributes to false).
// see: http://www.yiiframework.com/wiki/161/understanding-safe-validation-rules/
// see: http://www.yiiframework.com/doc/api/1.1/CModel#setAttributes-detail
if(isset($_GET['SurveyDynamic']))
if(!empty(Yii::app()->request->getParam('SurveyDynamic')))
{
$model->setAttributes($_GET['SurveyDynamic'],false);
$model->setAttributes(Yii::app()->request->getParam('SurveyDynamic'),false);
}

// Virtual attributes filters
Expand All @@ -445,9 +445,9 @@ public function browse($iSurveyId)
// @see: http://www.yiiframework.com/wiki/281/searching-and-sorting-by-related-model-in-cgridview/
$aVirtualFilters = array('completed_filter', 'firstname_filter', 'lastname_filter', 'email_filter');
foreach($aVirtualFilters as $sFilterName)
if(isset($_GET['SurveyDynamic'][$sFilterName]))
if(!empty(Yii::app()->request->getParam('SurveyDynamic')[$sFilterName]))
{
$model->$sFilterName = $_GET['SurveyDynamic'][$sFilterName];
$model->$sFilterName = Yii::app()->request->getParam('SurveyDynamic')[$sFilterName];
}

// rendering
Expand Down Expand Up @@ -1056,9 +1056,9 @@ public function time($iSurveyID)
*/

// Set number of page
if (isset($_GET['pageSize']))
if (!empty(Yii::app()->request->getParam('pageSize')))
{
Yii::app()->user->setState('pageSize',(int)$_GET['pageSize']);
Yii::app()->user->setState('pageSize',(int)Yii::app()->request->getParam('pageSize'));
}


Expand Down
5 changes: 5 additions & 0 deletions application/models/Response.php
Expand Up @@ -91,7 +91,12 @@ public function getSurveyId() {
return $this->dynamicId;
}

public function browse(){

}
public function search(){

}
}

?>
4 changes: 2 additions & 2 deletions application/models/SurveyDynamic.php
Expand Up @@ -18,6 +18,7 @@ class SurveyDynamic extends LSActiveRecord
public $firstname_filter;
public $lastname_filter;
public $email_filter;
public $lastpage;

protected static $sid = 0;
protected $bHaveToken;
Expand Down Expand Up @@ -605,9 +606,8 @@ public function search()
}

// Basic filters

$criteria->compare('t.lastpage',empty($this->lastpage)?null:(int)$this->lastpage, false);
$criteria->compare('t.id',empty($this->id)?null:(int)$this->id, false);
$criteria->compare('t.lastpage',empty($this->lastpage)?null:(int)$this->lastpage, true);
$criteria->compare('t.submitdate',$this->submitdate, true);
$criteria->compare('t.startlanguage',$this->startlanguage, true);

Expand Down
5 changes: 5 additions & 0 deletions application/views/admin/responses/listResponses_view.php
Expand Up @@ -71,6 +71,10 @@
$aColumns[] = array(
'header'=>'lastpage',
'name'=>'lastpage',
'type'=>'number',
'filter'=>TbHtml::textField(
'SurveyDynamic[lastpage]',
$model->lastpage)
);

$aColumns[] = array(
Expand Down Expand Up @@ -162,6 +166,7 @@
'itemsCssClass' =>'table-striped',
'id' => 'responses-grid',
'ajaxUpdate' => true,
'ajaxType' => 'POST',
'template' => "{items}\n<div id='ListPager'><div class=\"col-sm-4\" id=\"massive-action-container\">$massiveAction</div><div class=\"col-sm-4 pager-container \">{pager}</div><div class=\"col-sm-4 summary-container\">{summary}</div></div>",
'summaryText' => gT('Displaying {start}-{end} of {count} result(s).').' '. sprintf(gT('%s rows per page'),
CHtml::dropDownList(
Expand Down

0 comments on commit 047efc9

Please sign in to comment.