dirty fix filtering Monitors by GroupId. Change occurrences of GroupId to ' ' as that is what the key is in conditions. Please note that other operators like != won't work.

This commit is contained in:
Isaac Connor 2019-12-04 22:23:55 -05:00
parent df9f6103e4
commit eee3729b85
1 changed files with 6 additions and 5 deletions

View File

@ -36,7 +36,7 @@ class MonitorsController extends AppController {
* @return void
*/
public function index() {
$this->Monitor->recursive = 0;
$this->Monitor->recursive = 1;
if ( $this->request->params['named'] ) {
$this->FilterComponent = $this->Components->load('Filter');
@ -44,21 +44,21 @@ class MonitorsController extends AppController {
} else {
$conditions = array();
}
global $user;
$allowedMonitors = $user ? preg_split('@,@', $user['MonitorIds'], NULL, PREG_SPLIT_NO_EMPTY) : null;
if ( $allowedMonitors ) {
$conditions['Monitor.Id' ] = $allowedMonitors;
}
$find_array = array('conditions'=>$conditions,'contain'=>array('Group'));
if ( isset($conditions['GroupId']) ) {
$find_array = array('conditions'=>&$conditions,'contain'=>array('Group'));
if ( isset($conditions['`GroupId` ']) ) {
$find_array['joins'] = array(
array(
'table' => 'Groups_Monitors',
'type' => 'inner',
'conditions' => array(
'Groups_Monitors.MonitorId = Monitor.Id'
'Groups_Monitors.MonitorId = Monitor.Id',
'Groups_Monitors.GroupId' => $conditions['`GroupId` ']
),
),
//array(
@ -70,6 +70,7 @@ class MonitorsController extends AppController {
//),
//)
);
unset($conditions['`GroupId` ']);
}
$monitors = $this->Monitor->find('all',$find_array);
$this->set(array(