Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed issue #15954: Filtering users in admin panel not working
  • Loading branch information
Trischi80 committed Apr 16, 2020
1 parent 0c542bc commit 66ff71b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 5 deletions.
37 changes: 32 additions & 5 deletions application/models/User.php
Expand Up @@ -43,7 +43,6 @@ class User extends LSActiveRecord
public $lang = 'auto';
public $searched_value;


/**
* @inheritdoc
* @return User
Expand Down Expand Up @@ -848,10 +847,38 @@ public function search()
// @todo Please modify the following code to remove attributes that should not be searched.
$pageSize = Yii::app()->user->getState('pageSize', Yii::app()->params['defaultPageSize']);
$criteria = new CDbCriteria;

$criteria->compare('full_name',$this->searched_value,true);
$criteria->compare('users_name',$this->searched_value,true, 'OR');
$criteria->compare('email',$this->searched_value,true, 'OR');

$criteria->compare('t.uid',$this->uid);
$criteria->compare('t.full_name',$this->full_name,true);
$criteria->compare('t.users_name',$this->users_name,true, 'OR');
$criteria->compare('t.email',$this->email,true, 'OR');

//filter for 'created' date comparison
$dateformatdetails = getDateFormatData(Yii::app()->session['dateformat']);
if ($this->created) {
try {
$dateTimeInput = $this->created .' 00:00'; //append time
$s = DateTime::createFromFormat($dateformatdetails['phpdate'].' H:i', $dateTimeInput);
if($s) {
$s2 = $s->format('Y-m-d H:i');
$criteria->addCondition('t.created >= \'' . $s2 . '\'');
}else{
throw new Exception('wrong date format.');
}
}catch (Exception $e){
//could only mean wrong input from user ...reset filter value
$this->created='';
}
}

//filter for parentUserName
$getParentName = Yii::app()->request->getParam('User');
$getParentName = $getParentName['parentUserName'];
if(isset($getParentName) && $getParentName!==null && $getParentName!==''){
$criteria->join = "LEFT JOIN lime_users luparent ON t.parent_id = luparent.uid";
$criteria->compare('luparent.users_name', $getParentName, true, 'OR');
}

return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination' => array(
Expand Down
28 changes: 28 additions & 0 deletions application/views/admin/usermanagement/view.php
Expand Up @@ -28,6 +28,34 @@
</div>
<?php App()->getController()->renderPartial('/admin/usermanagement/partial/_menubar'); ?>
<div class="pagetitle h3"><?php eT("User control");?></div>

<div class="row">
<?php
/* Example Datepicker ...
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'name'=>'publishDate',
// additional javascript options for the date picker plugin
'options'=>array(
'showAnim'=>'fold',
),
'htmlOptions'=>array(
'style'=>'height:20px;'
),
));
*/
?>

<?php
/* Example used in survey participants gridview
Yii::app()->getController()->widget('yiiwheels.widgets.datetimepicker.WhDateTimePicker', array(
'name' => "no",
'id' => "no",
'value' => '',
));
*/
?>
</div>
<div class="row" style="margin-bottom: 100px">
<div class="container-fluid">
<?php
Expand Down

0 comments on commit 66ff71b

Please sign in to comment.