From bda7f38cebf6142379b820fdb3eab120f18c94dc Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 16 Nov 2017 14:39:18 -0800 Subject: Add search in groups --- app/Controller/GroupListController.php | 12 +++++++++++- app/Controller/UserListController.php | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'app/Controller') diff --git a/app/Controller/GroupListController.php b/app/Controller/GroupListController.php index 11081e4a..9663638d 100644 --- a/app/Controller/GroupListController.php +++ b/app/Controller/GroupListController.php @@ -20,16 +20,26 @@ class GroupListController extends BaseController */ public function index() { + $search = $this->request->getStringParam('search'); + $query = $this->groupModel->getQuery(); + + if ($search !== '') { + $query->ilike('name', '%'.$search.'%'); + } + $paginator = $this->paginator ->setUrl('GroupListController', 'index') ->setMax(30) ->setOrder(GroupModel::TABLE.'.name') - ->setQuery($this->groupModel->getQuery()) + ->setQuery($query) ->calculate(); $this->response->html($this->helper->layout->app('group/index', array( 'title' => t('Groups').' ('.$paginator->getTotal().')', 'paginator' => $paginator, + 'values' => array( + 'search' => $search + ), ))); } diff --git a/app/Controller/UserListController.php b/app/Controller/UserListController.php index 144c4662..6c4dcea9 100644 --- a/app/Controller/UserListController.php +++ b/app/Controller/UserListController.php @@ -35,7 +35,7 @@ class UserListController extends BaseController */ public function search() { - $search = urldecode($this->request->getStringParam('search')); + $search = $this->request->getStringParam('search'); $paginator = $this->userPagination->getListingPaginator(); if ($search !== '' && ! $paginator->isEmpty()) { @@ -56,5 +56,4 @@ class UserListController extends BaseController 'paginator' => $paginator ))); } - } -- cgit v1.2.3