diff --git a/application/controllers/GroupController.php b/application/controllers/GroupController.php index ffaadd76a..7e30f7ccd 100644 --- a/application/controllers/GroupController.php +++ b/application/controllers/GroupController.php @@ -7,6 +7,7 @@ use Icinga\Application\Config; use Icinga\Application\Logger; use Icinga\Authentication\UserGroup\UserGroupBackend; use Icinga\Authentication\UserGroup\UserGroupBackendInterface; +use Icinga\Forms\Config\UserGroupForm; use Icinga\Web\Controller; use Icinga\Web\Form; use Icinga\Web\Notification; @@ -100,6 +101,62 @@ class GroupController extends Controller ); } + /** + * Add a group + */ + public function addAction() + { + $form = new UserGroupForm(); + $form->setRepository( + $this->getUserGroupBackend($this->params->getRequired('backend'), 'Icinga\Data\Extensible') + ); + $form->add()->handleRequest(); + + $this->view->form = $form; + $this->render('form'); + } + + /** + * Edit a group + */ + public function editAction() + { + $groupName = $this->params->getRequired('group'); + $backend = $this->getUserGroupBackend($this->params->getRequired('backend'), 'Icinga\Data\Updatable'); + + $row = $backend->select(array('group_name'))->where('group_name', $groupName)->fetchRow(); + if ($row === false) { + $this->httpNotFound(sprintf($this->translate('Group "%s" not found'), $groupName)); + } + + $form = new UserGroupForm(); + $form->setRepository($backend); + $form->edit($groupName, get_object_vars($row))->handleRequest(); + + $this->view->form = $form; + $this->render('form'); + } + + /** + * Remove a group + */ + public function removeAction() + { + $groupName = $this->params->getRequired('group'); + $backend = $this->getUserGroupBackend($this->params->getRequired('backend'), 'Icinga\Data\Reducible'); + + if ($backend->select()->where('group_name', $groupName)->count() === 0) { + $this->httpNotFound(sprintf($this->translate('Group "%s" not found'), $groupName)); + } + + $form = new UserGroupForm(); + $form->setRepository($backend); + $form->remove($groupName)->handleRequest(); + + $this->view->form = $form; + $this->render('form'); + } + /** * Return all user group backends implementing the given interface * diff --git a/application/views/scripts/group/form.phtml b/application/views/scripts/group/form.phtml new file mode 100644 index 000000000..cbf06590d --- /dev/null +++ b/application/views/scripts/group/form.phtml @@ -0,0 +1,6 @@ +<div class="controls"> + <?= $tabs->showOnlyCloseButton(); ?> +</div> +<div class="content"> + <?= $form; ?> +</div> \ No newline at end of file