Add UserGroupMember management

This commit is contained in:
Alexander Fuhr 2015-06-12 13:16:41 +02:00
parent 49f7afc2ff
commit 8ae4ed6bfa
4 changed files with 60 additions and 0 deletions

View File

@ -147,6 +147,17 @@ class Director_ListController extends ActionController
$this->render('table'); $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() public function endpointsAction()
{ {
$this->view->addLink = $this->view->qlink( $this->view->addLink = $this->view->qlink(

View File

@ -218,6 +218,29 @@ class Director_ObjectController extends ActionController
$this->render('form'); $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() public function endpointAction()
{ {
$this->view->form = $this->loadForm('icingaEndpoint') $this->view->form = $this->loadForm('icingaEndpoint')

View File

@ -118,6 +118,24 @@ class Db extends DbConnection
return $this->db()->fetchPairs($select); 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() public function clearZoneCache()
{ {
// TODO: wipe cache on update/insert/delete // TODO: wipe cache on update/insert/delete

View File

@ -125,6 +125,14 @@ abstract class DirectorObjectForm extends QuickForm
$this->getElement('servicegroup_id') $this->getElement('servicegroup_id')
->setMultiOptions($this->optionalEnum($db->enumServicegroups())); ->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')) { if ($this->hasElement('zone_id')) {
$this->getElement('zone_id') $this->getElement('zone_id')
->setMultiOptions($this->optionalEnum($db->enumZones())); ->setMultiOptions($this->optionalEnum($db->enumZones()));