diff --git a/application/controllers/ListController.php b/application/controllers/ListController.php index f6dba74e..82426c71 100644 --- a/application/controllers/ListController.php +++ b/application/controllers/ListController.php @@ -147,6 +147,17 @@ class Director_ListController extends ActionController $this->render('table'); } + public function usergroupmembersAction() + { + $this->view->addLink = $this->view->qlink( + $this->translate('Add Usergroup Member'), + 'director/object/usergroupmember' + ); + $this->view->title = $this->translate('Icinga Usergroup Members'); + $this->view->table = $this->loadTable('icingaUserGroupMember')->setConnection($this->db()); + $this->render('table'); + } + public function endpointsAction() { $this->view->addLink = $this->view->qlink( diff --git a/application/controllers/ObjectController.php b/application/controllers/ObjectController.php index ac39b339..cf4a6ca3 100644 --- a/application/controllers/ObjectController.php +++ b/application/controllers/ObjectController.php @@ -218,6 +218,29 @@ class Director_ObjectController extends ActionController $this->render('form'); } + public function usergroupmemberAction() + { + $this->view->form = $this->loadForm('icingaUserGroupMember') + ->setDb($this->db()) + ->setSuccessUrl('director/list/usergroupmembers'); + + if (($user_id = $this->params->get('user_id')) + && ($usergroup_id = $this->params->get('usergroup_id')) + ) { + $this->view->form->loadObject( + array( + 'user_id' => $user_id, + 'usergroup_id' => $usergroup_id, + ) + ); + $this->view->title = $this->translate('Modify Icinga Usergroup Member'); + } else { + $this->view->title = $this->translate('Add new Icinga Usergroup Member'); + } + $this->view->form->handleRequest(); + $this->render('form'); + } + public function endpointAction() { $this->view->form = $this->loadForm('icingaEndpoint') diff --git a/library/Director/Db.php b/library/Director/Db.php index 72574e7c..6875b6f1 100644 --- a/library/Director/Db.php +++ b/library/Director/Db.php @@ -118,6 +118,24 @@ class Db extends DbConnection return $this->db()->fetchPairs($select); } + public function enumUsers() + { + $select = $this->db()->select()->from('icinga_user', array( + 'id', + 'object_name', + ))->where('object_type', 'object')->order('object_name ASC'); + return $this->db()->fetchPairs($select); + } + + public function enumUsergroups() + { + $select = $this->db()->select()->from('icinga_usergroup', array( + 'id', + 'object_name', + ))->where('object_type', 'object')->order('object_name ASC'); + return $this->db()->fetchPairs($select); + } + public function clearZoneCache() { // TODO: wipe cache on update/insert/delete diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index d5949d69..dc41d0a6 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -125,6 +125,14 @@ abstract class DirectorObjectForm extends QuickForm $this->getElement('servicegroup_id') ->setMultiOptions($this->optionalEnum($db->enumServicegroups())); } + if ($this->hasElement('user_id')) { + $this->getElement('user_id') + ->setMultiOptions($this->optionalEnum($db->enumUsers())); + } + if ($this->hasElement('usergroup_id')) { + $this->getElement('usergroup_id') + ->setMultiOptions($this->optionalEnum($db->enumUsergroups())); + } if ($this->hasElement('zone_id')) { $this->getElement('zone_id') ->setMultiOptions($this->optionalEnum($db->enumZones()));