icingadb-web/application/controllers/UsergroupController.php

48 lines
1.3 KiB
PHP
Raw Normal View History

2019-11-05 03:17:11 -05:00
<?php
2020-03-13 03:38:01 -04:00
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
2019-11-05 03:17:11 -05:00
namespace Icinga\Module\Icingadb\Controllers;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Icingadb\Model\Usergroup;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\UsergroupDetail;
2019-11-05 03:17:11 -05:00
use Icinga\Module\Icingadb\Widget\ItemList\UsergroupList;
class UsergroupController extends Controller
{
/** @var Usergroup The usergroup object */
protected $usergroup;
public function init()
{
$this->assertRouteAccess('usergroups');
$this->setTitle(t('User Group'));
2019-11-05 03:17:11 -05:00
$name = $this->params->shiftRequired('name');
$query = Usergroup::on($this->getDb());
$query->getSelectBase()
->where(['usergroup.name = ?' => $name]);
2019-11-05 03:17:11 -05:00
$this->applyRestrictions($query);
2019-11-05 03:17:11 -05:00
$usergroup = $query->first();
if ($usergroup === null) {
throw new NotFoundError(t('User group not found'));
2019-11-05 03:17:11 -05:00
}
$this->usergroup = $usergroup;
}
public function indexAction()
{
$this->addControl((new UsergroupList([$this->usergroup]))->setNoSubjectLink()->setDetailActionsDisabled());
$this->addContent(new UsergroupDetail($this->usergroup));
$this->setAutorefreshInterval(10);
2019-11-05 03:17:11 -05:00
}
}