icingadb-web/application/controllers/UsergroupsController.php

55 lines
1.5 KiB
PHP
Raw Normal View History

2019-10-24 08:04:20 -04:00
<?php
2020-03-13 03:38:01 -04:00
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
2019-11-04 19:07:30 -05:00
namespace Icinga\Module\Icingadb\Controllers;
2019-10-24 08:04:20 -04:00
2019-11-04 19:07:30 -05:00
use Icinga\Module\Icingadb\Model\Usergroup;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\ItemList\UsergroupList;
use Icinga\Security\SecurityException;
2019-10-24 08:04:20 -04:00
class UsergroupsController extends Controller
{
public function init()
{
parent::init();
if (! $this->hasPermission('*') && $this->hasPermission('no-monitoring/contacts')) {
throw new SecurityException($this->translate('No permission for %s'), 'monitoring/contacts');
}
}
2019-10-24 08:04:20 -04:00
public function indexAction()
{
$this->setTitle($this->translate('User Groups'));
$db = $this->getDb();
$usergroups = Usergroup::on($db)->with('user');
$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($usergroups);
2019-12-11 08:00:26 -05:00
$sortControl = $this->createSortControl(
$usergroups,
[
'usergroup.display_name' => $this->translate('Name')
]
);
2019-10-24 08:04:20 -04:00
$filterControl = $this->createFilterControl($usergroups);
$this->filter($usergroups);
yield $this->export($usergroups);
$this->addControl($paginationControl);
2019-12-11 08:00:26 -05:00
$this->addControl($sortControl);
2019-10-24 08:04:20 -04:00
$this->addControl($limitControl);
$this->addControl($filterControl);
$this->addContent(new UsergroupList($usergroups));
$this->setAutorefreshInterval(10);
2019-10-24 08:04:20 -04:00
}
}