' . $this->escape($object) . ''; -} -?>
diff --git a/application/controllers/CommandController.php b/application/controllers/CommandController.php new file mode 100644 index 00000000..5295fea9 --- /dev/null +++ b/application/controllers/CommandController.php @@ -0,0 +1,7 @@ +setHostTabs()->activate('hosts'); - $this->view->addLink = $this->view->qlink( - $this->translate('Add Host'), - 'director/object/host' - ); - $this->view->title = $this->translate('Icinga Hosts'); - $this->view->table = $this->loadTable('icingaHost')->setConnection($this->db()); - $this->render('table'); - } - - public function hostgroupsAction() - { - $this->setHostTabs()->activate('hostgroups'); - $this->view->addLink = $this->view->qlink( - $this->translate('Add Hostgroup'), - 'director/object/hostgroup' - ); - $this->view->title = $this->translate('Icinga Hostgroups'); - $this->view->table = $this->loadTable('icingaHostGroup')->setConnection($this->db()); - $this->render('table'); - } - - public function timeperiodsAction() - { - $this->setGlobalTabs()->activate('timeperiods'); - $this->view->addLink = $this->view->qlink( - $this->translate('Add Timeperiod'), - 'director/object/timeperiod' - ); - $this->view->title = $this->translate('Icinga Timeperiods'); - $this->view->table = $this->loadTable('icingaTimePeriod')->setConnection($this->db()); - $this->render('table'); - } - - public function servicesAction() - { - $this->setServiceTabs()->activate('services'); - $this->view->addLink = $this->view->qlink( - $this->translate('Add Service'), - 'director/object/service' - ); - $this->view->title = $this->translate('Icinga Services'); - $this->view->table = $this->loadTable('icingaService')->setConnection($this->db()); - $this->render('table'); - } - - public function servicegroupsAction() - { - $this->setServiceTabs()->activate('servicegroups'); - $this->view->addLink = $this->view->qlink( - $this->translate('Add Servicegroup'), - 'director/object/servicegroup' - ); - $this->view->title = $this->translate('Icinga Servicegroups'); - $this->view->table = $this->loadTable('icingaServiceGroup')->setConnection($this->db()); - $this->render('table'); - } - - public function commandsAction() - { - $this->setGlobalTabs()->activate('commands'); - $this->view->addLink = $this->view->qlink( - $this->translate('Add Command'), - 'director/object/command' - ); - $this->view->title = $this->translate('Icinga Commands'); - $this->view->table = $this->loadTable('icingaCommand')->setConnection($this->db()); - $this->render('table'); - } - - public function commandargumentsAction() - { - $this->setGlobalTabs()->activate('commandarguments'); - $this->view->addLink = $this->view->qlink( - $this->translate('Add Command Argument'), - 'director/object/commandargument' - ); - $this->view->title = $this->translate('Icinga Command Arguments'); - $this->view->table = $this->loadTable('icingaCommandArgument')->setConnection($this->db()); - $this->render('table'); - } - - public function usersAction() - { - $this->setUserTabs()->activate('users'); - $this->view->addLink = $this->view->qlink( - $this->translate('Add User'), - 'director/object/user' - ); - $this->view->title = $this->translate('Icinga Users'); - $this->view->table = $this->loadTable('icingaUser')->setConnection($this->db()); - $this->render('table'); - } - - public function usergroupsAction() - { - $this->setUserTabs()->activate('usergroups'); - $this->view->addLink = $this->view->qlink( - $this->translate('Add Usergroup'), - 'director/object/usergroup' - ); - $this->view->title = $this->translate('Icinga Usergroups'); - $this->view->table = $this->loadTable('icingaUserGroup')->setConnection($this->db()); - $this->render('table'); - } - - public function endpointsAction() - { - $this->setGlobalTabs()->activate('endpoints'); - $this->view->addLink = $this->view->qlink( - $this->translate('Add Endpoint'), - 'director/object/endpoint' - ); - $this->view->title = $this->translate('Icinga Endpoints'); - $this->view->table = $this->loadTable('icingaEndpoint')->setConnection($this->db()); - $this->render('table'); - } - - public function zonesAction() - { - $this->setGlobalTabs()->activate('zones'); - $this->view->addLink = $this->view->qlink( - $this->translate('Add Zone'), - 'director/object/zone' - ); - $this->view->title = $this->translate('Icinga Zones'); - $this->view->table = $this->loadTable('icingaZone')->setConnection($this->db()); - $this->render('table'); - } - public function activitylogAction() { $this->setConfigTabs()->activate('activitylog'); diff --git a/application/controllers/ObjectController.php b/application/controllers/ObjectController.php deleted file mode 100644 index de81aa92..00000000 --- a/application/controllers/ObjectController.php +++ /dev/null @@ -1,182 +0,0 @@ -view->form = $this->loadForm('icingaHost') - ->setDb($this->db()) - ->setSuccessUrl('director/list/hosts'); - - if ($id = $this->params->get('id')) { - $this->view->form->loadObject($id); - $this->view->title = $this->translate('Modify Icinga Host'); - } else { - $this->view->title = $this->translate('Add new Icinga Host'); - } - $this->view->form->handleRequest(); - $this->render('form'); - } - - public function hostgroupAction() - { - $this->view->form = $this->loadForm('icingaHostGroup') - ->setDb($this->db()) - ->setSuccessUrl('director/list/hostgroups'); - - if ($id = $this->params->get('id')) { - $this->view->form->loadObject($id); - $this->view->title = $this->translate('Modify Icinga Hostgroup'); - } else { - $this->view->title = $this->translate('Add new Icinga Hostgroup'); - } - $this->view->form->handleRequest(); - $this->render('form'); - } - - public function serviceAction() - { - $this->view->form = $this->loadForm('icingaService') - ->setDb($this->db()) - ->setSuccessUrl('director/list/services'); - - if ($id = $this->params->get('id')) { - $this->view->form->loadObject($id); - $this->view->title = $this->translate('Modify Icinga Service'); - } else { - $this->view->title = $this->translate('Add new Icinga Service'); - } - $this->view->form->handleRequest(); - $this->render('form'); - } - - public function servicegroupAction() - { - $this->view->form = $this->loadForm('icingaServiceGroup') - ->setDb($this->db()) - ->setSuccessUrl('director/list/servicegroups'); - - if ($id = $this->params->get('id')) { - $this->view->form->loadObject($id); - $this->view->title = $this->translate('Modify Icinga Servicegroup'); - } else { - $this->view->title = $this->translate('Add new Icinga Servicegroup'); - } - $this->view->form->handleRequest(); - $this->render('form'); - } - - public function commandAction() - { - $this->view->form = $this->loadForm('icingaCommand') - ->setDb($this->db()) - ->setSuccessUrl('director/list/commands'); - - if ($id = $this->params->get('id')) { - $this->view->form->loadObject($id); - $this->view->title = $this->translate('Modify Icinga Command'); - } else { - $this->view->title = $this->translate('Add new Icinga Command'); - } - $this->view->form->handleRequest(); - $this->render('form'); - } - - public function commandargumentAction() - { - $this->view->form = $this->loadForm('icingaCommandArgument') - ->setDb($this->db()) - ->setSuccessUrl('director/list/commandarguments'); - - if ($id = $this->params->get('id')) { - $this->view->form->loadObject($id); - $this->view->title = $this->translate('Modify Icinga Command Argument'); - } else { - $this->view->title = $this->translate('Add new Icinga Command Argument'); - } - $this->view->form->handleRequest(); - $this->render('form'); - } - - public function userAction() - { - $this->view->form = $this->loadForm('icingaUser') - ->setDb($this->db()) - ->setSuccessUrl('director/list/users'); - - if ($id = $this->params->get('id')) { - $this->view->form->loadObject($id); - $this->view->title = $this->translate('Modify Icinga User'); - } else { - $this->view->title = $this->translate('Add new Icinga User'); - } - $this->view->form->handleRequest(); - $this->render('form'); - } - - public function usergroupAction() - { - $this->view->form = $this->loadForm('icingaUserGroup') - ->setDb($this->db()) - ->setSuccessUrl('director/list/usergroups'); - - if ($id = $this->params->get('id')) { - $this->view->form->loadObject($id); - $this->view->title = $this->translate('Modify Icinga Usergroup'); - } else { - $this->view->title = $this->translate('Add new Icinga Usergroup'); - } - $this->view->form->handleRequest(); - $this->render('form'); - } - - public function endpointAction() - { - $this->view->form = $this->loadForm('icingaEndpoint') - ->setDb($this->db()) - ->setSuccessUrl('director/list/endpoints'); - - if ($id = $this->params->get('id')) { - $this->view->form->loadObject($id); - $this->view->title = $this->translate('Modify Icinga Endpoint'); - } else { - $this->view->title = $this->translate('Add new Icinga Endpoint'); - } - $this->view->form->handleRequest(); - $this->render('form'); - } - - public function timeperiodAction() - { - $this->view->form = $this->loadForm('icingaTimePeriod') - ->setDb($this->db()) - ->setSuccessUrl('director/list/timeperiods'); - - if ($id = $this->params->get('id')) { - $this->view->form->loadObject($id); - $this->view->title = $this->translate('Modify Icinga Timeperiod'); - } else { - $this->view->title = $this->translate('Add new Icinga Timeperiod'); - } - $this->view->form->handleRequest(); - $this->render('form'); - } - - public function zoneAction() - { - $this->view->form = $this->loadForm('icingaZone') - ->setDb($this->db()) - ->setSuccessUrl('director/list/zones'); - - if ($id = $this->params->get('id')) { - $this->view->title = $this->translate('Modify Icinga Zone'); - $this->view->form->loadObject($id); - } else { - $this->view->title = $this->translate('Add new Icinga Zone'); - } - $this->view->form->handleRequest(); - $this->render('form'); - } -} diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php new file mode 100644 index 00000000..eb1aeec2 --- /dev/null +++ b/application/controllers/ServiceController.php @@ -0,0 +1,7 @@ +filters[] = array('l.object_type = ?', $type); + $this->filters[] = array('l.object_name = ?', $name); + + return $this; + } + public function fetchData() { $db = $this->connection()->getConnection(); @@ -40,6 +50,10 @@ class ActivityLogTable extends QuickTable $this->getColumns() )->order('change_time DESC'); + foreach ($this->filters as $filter) { + $query->where($filter[0], $filter[1]); + } + return $db->fetchAll($query); } } diff --git a/application/tables/IcingaCommandArgumentTable.php b/application/tables/IcingaCommandArgumentTable.php index b41953b0..228abd0f 100644 --- a/application/tables/IcingaCommandArgumentTable.php +++ b/application/tables/IcingaCommandArgumentTable.php @@ -19,7 +19,7 @@ class IcingaCommandArgumentTable extends QuickTable protected function getActionUrl($row) { - return $this->url('director/object/commandargument', array('id' => $row->id)); + return $this->url('director/commandargument', array('id' => $row->id)); } public function getTitles() diff --git a/application/tables/IcingaCommandTable.php b/application/tables/IcingaCommandTable.php index 176ef6fa..3f7dcf46 100644 --- a/application/tables/IcingaCommandTable.php +++ b/application/tables/IcingaCommandTable.php @@ -18,7 +18,7 @@ class IcingaCommandTable extends QuickTable protected function getActionUrl($row) { - return $this->url('director/object/command', array('id' => $row->id)); + return $this->url('director/command', array('id' => $row->id)); } public function getTitles() diff --git a/application/tables/IcingaEndpointTable.php b/application/tables/IcingaEndpointTable.php index 29e0b4a1..e178c57b 100644 --- a/application/tables/IcingaEndpointTable.php +++ b/application/tables/IcingaEndpointTable.php @@ -18,7 +18,7 @@ class IcingaEndpointTable extends QuickTable protected function getActionUrl($row) { - return $this->url('director/object/endpoint', array('id' => $row->id)); + return $this->url('director/endpoint', array('id' => $row->id)); } public function getTitles() diff --git a/application/tables/IcingaHostGroupTable.php b/application/tables/IcingaHostGroupTable.php index 9b3d4e36..8823c704 100644 --- a/application/tables/IcingaHostGroupTable.php +++ b/application/tables/IcingaHostGroupTable.php @@ -17,7 +17,7 @@ class IcingaHostGroupTable extends QuickTable protected function getActionUrl($row) { - return $this->url('director/object/hostgroup', array('id' => $row->id)); + return $this->url('director/hostgroup', array('id' => $row->id)); } public function getTitles() diff --git a/application/tables/IcingaHostTable.php b/application/tables/IcingaHostTable.php index 58f6fef5..d1d65e09 100644 --- a/application/tables/IcingaHostTable.php +++ b/application/tables/IcingaHostTable.php @@ -18,7 +18,7 @@ class IcingaHostTable extends QuickTable protected function getActionUrl($row) { - return $this->url('director/object/host', array('id' => $row->id)); + return $this->url('director/host', array('id' => $row->id)); } public function getTitles() diff --git a/application/tables/IcingaServiceGroupTable.php b/application/tables/IcingaServiceGroupTable.php index 1b65c88f..d1f9140c 100644 --- a/application/tables/IcingaServiceGroupTable.php +++ b/application/tables/IcingaServiceGroupTable.php @@ -17,15 +17,15 @@ class IcingaServiceGroupTable extends QuickTable protected function getActionUrl($row) { - return $this->url('director/object/servicegroup', array('id' => $row->id)); + return $this->url('director/servicegroup', array('id' => $row->id)); } public function getTitles() { $view = $this->view(); return array( - 'servicegroup' => $view->translate('Servicegroup'), - 'display_name' => $view->translate('Display Name'), + 'servicegroup' => $view->translate('Servicegroup'), + 'display_name' => $view->translate('Display Name'), ); } diff --git a/application/tables/IcingaServiceTable.php b/application/tables/IcingaServiceTable.php index 242ca9b4..2c6fef98 100644 --- a/application/tables/IcingaServiceTable.php +++ b/application/tables/IcingaServiceTable.php @@ -17,7 +17,7 @@ class IcingaServiceTable extends QuickTable protected function getActionUrl($row) { - return $this->url('director/object/service', array('id' => $row->id)); + return $this->url('director/service', array('id' => $row->id)); } public function getTitles() diff --git a/application/tables/IcingaTimePeriodTable.php b/application/tables/IcingaTimePeriodTable.php index 8abc0ec8..9ca20fb0 100644 --- a/application/tables/IcingaTimePeriodTable.php +++ b/application/tables/IcingaTimePeriodTable.php @@ -18,7 +18,7 @@ class IcingaTimePeriodTable extends QuickTable protected function getActionUrl($row) { - return $this->url('director/object/timeperiod', array('id' => $row->id)); + return $this->url('director/timeperiod', array('id' => $row->id)); } public function getTitles() diff --git a/application/tables/IcingaUserGroupTable.php b/application/tables/IcingaUserGroupTable.php index 60a287fe..1d9b6d5f 100644 --- a/application/tables/IcingaUserGroupTable.php +++ b/application/tables/IcingaUserGroupTable.php @@ -18,7 +18,7 @@ class IcingaUserGroupTable extends QuickTable protected function getActionUrl($row) { - return $this->url('director/object/usergroup', array('id' => $row->id)); + return $this->url('director/usergroup', array('id' => $row->id)); } public function getTitles() diff --git a/application/tables/IcingaUserTable.php b/application/tables/IcingaUserTable.php index 06d09467..bd3a2584 100644 --- a/application/tables/IcingaUserTable.php +++ b/application/tables/IcingaUserTable.php @@ -22,7 +22,7 @@ class IcingaUserTable extends QuickTable protected function getActionUrl($row) { - return $this->url('director/object/user', array('id' => $row->id)); + return $this->url('director/user', array('id' => $row->id)); } public function getTitles() diff --git a/application/tables/IcingaZoneTable.php b/application/tables/IcingaZoneTable.php index 886de87e..b0986548 100644 --- a/application/tables/IcingaZoneTable.php +++ b/application/tables/IcingaZoneTable.php @@ -8,22 +8,30 @@ class IcingaZoneTable extends QuickTable { public function getColumns() { + if ($this->connection()->getDbType() === 'pgsql') { + $endpoints = "ARRAY_TO_STRING(ARRAY_AGG(e.object_name), ', ')"; + } else { + $endpoints = "GROUP_CONCAT(e.object_name ORDER BY e.object_name SEPARATOR ', ')"; + } + return array( - 'id' => 'z.id', - 'zone' => 'z.object_name', + 'id' => 'z.id', + 'zone' => 'z.object_name', + 'endpoints' => $endpoints, ); } protected function getActionUrl($row) { - return $this->url('director/object/zone', array('id' => $row->id)); + return $this->url('director/zone', array('id' => $row->id)); } public function getTitles() { $view = $this->view(); return array( - 'zone' => $view->translate('Zone'), + 'zone' => $view->translate('Zone'), + 'endpoints' => $view->translate('Endpoints'), ); } @@ -33,7 +41,11 @@ class IcingaZoneTable extends QuickTable $query = $db->select()->from( array('z' => 'icinga_zone'), $this->getColumns() - ); + )->joinLeft( + array('e' => 'icinga_endpoint'), + 'z.id = e.zone_id', + array() + )->group('z.id'); return $db->fetchAll($query); } diff --git a/application/views/scripts/object/form.phtml b/application/views/scripts/object/form.phtml index 317e8f20..7adf827f 100644 --- a/application/views/scripts/object/form.phtml +++ b/application/views/scripts/object/form.phtml @@ -1,13 +1,8 @@
' . $this->escape($object) . ''; -} -?>
= $this->escape($object) ?>+