mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 14:54:24 +02:00
parent
86146b8048
commit
899a00e983
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
use \Exception;
|
use \Exception;
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
|
use Icinga\Data\DataArray\ArrayDatasource;
|
||||||
use Icinga\Data\Reducible;
|
use Icinga\Data\Reducible;
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
|
use Icinga\Forms\Config\UserGroup\AddMemberForm;
|
||||||
use Icinga\Forms\Config\UserGroup\UserGroupForm;
|
use Icinga\Forms\Config\UserGroup\UserGroupForm;
|
||||||
use Icinga\Web\Controller\AuthBackendController;
|
use Icinga\Web\Controller\AuthBackendController;
|
||||||
use Icinga\Web\Form;
|
use Icinga\Web\Form;
|
||||||
@ -222,6 +224,32 @@ class GroupController extends AuthBackendController
|
|||||||
$this->render('form');
|
$this->render('form');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a group member
|
||||||
|
*/
|
||||||
|
public function addmemberAction()
|
||||||
|
{
|
||||||
|
$groupName = $this->params->getRequired('group');
|
||||||
|
$backend = $this->getUserGroupBackend($this->params->getRequired('backend'), 'Icinga\Data\Extensible');
|
||||||
|
|
||||||
|
if ($backend->select()->where('group_name', $groupName)->count() === 0) {
|
||||||
|
$this->httpNotFound(sprintf($this->translate('Group "%s" not found'), $groupName));
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = new AddMemberForm();
|
||||||
|
$form->setDataSource($this->fetchUsers())
|
||||||
|
->setBackend($backend)
|
||||||
|
->setGroupName($groupName)
|
||||||
|
->setRedirectUrl(
|
||||||
|
Url::fromPath('group/show', array('backend' => $backend->getName(), 'group' => $groupName))
|
||||||
|
)
|
||||||
|
->setUidDisabled()
|
||||||
|
->handleRequest();
|
||||||
|
|
||||||
|
$this->view->form = $form;
|
||||||
|
$this->render('form');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a group member
|
* Remove a group member
|
||||||
*/
|
*/
|
||||||
@ -271,6 +299,23 @@ class GroupController extends AuthBackendController
|
|||||||
$form->handleRequest();
|
$form->handleRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch and return all users from all user backends
|
||||||
|
*
|
||||||
|
* @return ArrayDatasource
|
||||||
|
*/
|
||||||
|
protected function fetchUsers()
|
||||||
|
{
|
||||||
|
$users = array();
|
||||||
|
foreach ($this->loadUserBackends('Icinga\Data\Selectable') as $backend) {
|
||||||
|
foreach ($backend->select(array('user_name')) as $row) {
|
||||||
|
$users[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ArrayDatasource($users);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the tabs to display when showing a group
|
* Create the tabs to display when showing a group
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user