yii-auth icon indicating copy to clipboard operation
yii-auth copied to clipboard

Assignments needs a filter

Open cstdenis opened this issue 11 years ago • 2 comments

My database has a huge number of users -- couple hundred thousand (most do not have special permissions). The current pagination based system doesn't cut it, I need filters to find the users I want.

So I made them. Please review these small diffs and add them if you like.

--- widgets/AuthAssignmentNameColumn.php.orig   2013-01-20 03:04:31.000000000 -0800
+++ widgets/AuthAssignmentNameColumn.php        2013-06-10 00:32:59.000000000 -0700
@@ -32,4 +32,12 @@
        {
                echo CHtml::link(CHtml::value($data, $this->nameColumn), array('view', 'id'=>$data->{$this->idColumn}));
        }
+
+       /**
+        * Renders the filter cell content.
+        */
+       protected function renderFilterCellContent()
+       {
+               echo CHtml::activeTextField($this->grid->filter, $this->getNameColumn(), array('id'=>false));
+       }
 }
--- views/assignment/index.php.orig     2013-01-01 12:05:32.000000000 -0800
+++ views/assignment/index.php  2013-06-10 01:05:37.000000000 -0700
@@ -11,7 +11,8 @@

 <?php $this->widget('bootstrap.widgets.TbGridView', array(
     'type' => 'striped hover',
-    'dataProvider' => $dataProvider,
+    'filter' => $model,
+    'dataProvider' => $model->search(),
        'emptyText' => Yii::t('AuthModule.main', 'No assignments found.'),
        'template'=>"{items}\n{pager}",
     'columns' => array(
--- controllers/AssignmentController.php.orig   2013-01-11 18:54:10.000000000 -0800
+++ controllers/AssignmentController.php        2013-06-10 00:56:04.000000000 -0700
@@ -17,10 +17,13 @@
         */
        public function actionIndex()
        {
-               $dataProvider = new CActiveDataProvider($this->module->userClass);
+               $model = new $this->module->userClass('search');
+               $model->unsetAttributes();  // clear any default values
+               if(isset($_GET[$this->module->userClass]))
+                       $model->attributes=$_GET[$this->module->userClass];

                $this->render('index', array(
-                       'dataProvider' => $dataProvider
+                       'model' => $model
                ));
        }

cstdenis avatar Jun 10 '13 08:06 cstdenis

You better make a pull request for this changes. It seems that they will be useful.

kachar avatar Jun 19 '13 09:06 kachar

Created pull request #81

cstdenis avatar Jun 19 '13 19:06 cstdenis