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:
parent
df9f6103e4
commit
eee3729b85
|
@ -36,7 +36,7 @@ class MonitorsController extends AppController {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
$this->Monitor->recursive = 0;
|
$this->Monitor->recursive = 1;
|
||||||
|
|
||||||
if ( $this->request->params['named'] ) {
|
if ( $this->request->params['named'] ) {
|
||||||
$this->FilterComponent = $this->Components->load('Filter');
|
$this->FilterComponent = $this->Components->load('Filter');
|
||||||
|
@ -44,21 +44,21 @@ class MonitorsController extends AppController {
|
||||||
} else {
|
} else {
|
||||||
$conditions = array();
|
$conditions = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
global $user;
|
global $user;
|
||||||
$allowedMonitors = $user ? preg_split('@,@', $user['MonitorIds'], NULL, PREG_SPLIT_NO_EMPTY) : null;
|
$allowedMonitors = $user ? preg_split('@,@', $user['MonitorIds'], NULL, PREG_SPLIT_NO_EMPTY) : null;
|
||||||
if ( $allowedMonitors ) {
|
if ( $allowedMonitors ) {
|
||||||
$conditions['Monitor.Id' ] = $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(
|
$find_array['joins'] = array(
|
||||||
array(
|
array(
|
||||||
'table' => 'Groups_Monitors',
|
'table' => 'Groups_Monitors',
|
||||||
'type' => 'inner',
|
'type' => 'inner',
|
||||||
'conditions' => array(
|
'conditions' => array(
|
||||||
'Groups_Monitors.MonitorId = Monitor.Id'
|
'Groups_Monitors.MonitorId = Monitor.Id',
|
||||||
|
'Groups_Monitors.GroupId' => $conditions['`GroupId` ']
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
//array(
|
//array(
|
||||||
|
@ -70,6 +70,7 @@ class MonitorsController extends AppController {
|
||||||
//),
|
//),
|
||||||
//)
|
//)
|
||||||
);
|
);
|
||||||
|
unset($conditions['`GroupId` ']);
|
||||||
}
|
}
|
||||||
$monitors = $this->Monitor->find('all',$find_array);
|
$monitors = $this->Monitor->find('all',$find_array);
|
||||||
$this->set(array(
|
$this->set(array(
|
||||||
|
|
Loading…
Reference in New Issue