GroupController: Introduce addAction, editAction and removeAction
refs #8826
This commit is contained in:
parent
9c6a8898fd
commit
539b824470
|
@ -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
|
||||
*
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<div class="controls">
|
||||
<?= $tabs->showOnlyCloseButton(); ?>
|
||||
</div>
|
||||
<div class="content">
|
||||
<?= $form; ?>
|
||||
</div>
|
Loading…
Reference in New Issue