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;
|
2021-08-06 07:16:31 -04:00
|
|
|
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()
|
|
|
|
|
{
|
2021-04-07 06:32:14 -04:00
|
|
|
$this->assertRouteAccess('users');
|
2019-12-10 04:46:10 -05:00
|
|
|
|
2020-04-24 08:36:37 -04:00
|
|
|
$this->setTitle(t('User'));
|
2019-10-31 12:40:31 -04:00
|
|
|
|
|
|
|
|
$name = $this->params->shiftRequired('name');
|
|
|
|
|
|
|
|
|
|
$query = User::on($this->getDb());
|
|
|
|
|
$query->getSelectBase()
|
2019-11-25 09:35:48 -05:00
|
|
|
->where(['user.name = ?' => $name]);
|
2019-10-31 12:40:31 -04:00
|
|
|
|
2021-01-28 06:38:03 -05:00
|
|
|
$this->applyRestrictions($query);
|
2019-11-22 10:01:27 -05:00
|
|
|
|
2019-10-31 12:40:31 -04:00
|
|
|
$user = $query->first();
|
|
|
|
|
if ($user === null) {
|
2020-04-24 08:36:37 -04:00
|
|
|
throw new NotFoundError(t('User not found'));
|
2019-10-31 12:40:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->user = $user;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function indexAction()
|
|
|
|
|
{
|
2021-04-29 10:32:29 -04:00
|
|
|
$this->addControl((new UserList([$this->user]))->setNoSubjectLink()->setDetailActionsDisabled());
|
2021-08-06 07:16:31 -04:00
|
|
|
$this->addContent(new UserDetail($this->user));
|
2019-12-11 02:59:30 -05:00
|
|
|
|
|
|
|
|
$this->setAutorefreshInterval(10);
|
2019-10-31 12:40:31 -04:00
|
|
|
}
|
|
|
|
|
}
|