Add filtering to groups
This commit is contained in:
parent
7d02c68938
commit
849d71efff
|
@ -31,8 +31,31 @@ class GroupsController extends AppController {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
$this->Group->recursive = -1;
|
$this->Group->recursive = 0;
|
||||||
$groups = $this->Group->find('all');
|
|
||||||
|
if ( $this->request->params['named'] ) {
|
||||||
|
$this->FilterComponent = $this->Components->load('Filter');
|
||||||
|
$conditions = $this->FilterComponent->buildFilter($this->request->params['named']);
|
||||||
|
} else {
|
||||||
|
$conditions = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$find_array = array(
|
||||||
|
'conditions' => &$conditions,
|
||||||
|
'contain' => array('Monitor'),
|
||||||
|
'joins' => array(
|
||||||
|
array(
|
||||||
|
'table' => 'Groups_Monitors',
|
||||||
|
'type' => 'left',
|
||||||
|
'conditions' => array(
|
||||||
|
'Groups_Monitors.GroupId = Group.Id',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'group' => '`Group`.`Id`',
|
||||||
|
);
|
||||||
|
|
||||||
|
$groups = $this->Group->find('all', $find_array);
|
||||||
$this->set(array(
|
$this->set(array(
|
||||||
'groups' => $groups,
|
'groups' => $groups,
|
||||||
'_serialize' => array('groups')
|
'_serialize' => array('groups')
|
||||||
|
|
Loading…
Reference in New Issue