icingadb-web/application/controllers/UserController.php

48 lines
1.2 KiB
PHP
Raw Normal View History

2019-10-31 12:40:31 -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-31 12:40:31 -04:00
use Icinga\Exception\NotFoundError;
2019-11-04 19:07:30 -05:00
use Icinga\Module\Icingadb\Model\User;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\UserDetail;
2019-11-04 19:07:30 -05:00
use Icinga\Module\Icingadb\Widget\ItemList\UserList;
2019-10-31 12:40:31 -04:00
class UserController extends Controller
{
/** @var User The user object */
protected $user;
public function init()
{
$this->assertRouteAccess('users');
$this->setTitle(t('User'));
2019-10-31 12:40:31 -04:00
$name = $this->params->shiftRequired('name');
$query = User::on($this->getDb());
$query->getSelectBase()
->where(['user.name = ?' => $name]);
2019-10-31 12:40:31 -04:00
$this->applyRestrictions($query);
2019-10-31 12:40:31 -04:00
$user = $query->first();
if ($user === null) {
throw new NotFoundError(t('User not found'));
2019-10-31 12:40:31 -04:00
}
$this->user = $user;
}
public function indexAction()
{
$this->addControl((new UserList([$this->user]))->setNoSubjectLink()->setDetailActionsDisabled());
$this->addContent(new UserDetail($this->user));
$this->setAutorefreshInterval(10);
2019-10-31 12:40:31 -04:00
}
}