icingadb-web/application/controllers/ContactController.php

49 lines
1.2 KiB
PHP
Raw Permalink 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\ObjectHeader;
use Icinga\Module\Icingadb\Widget\Detail\UserDetail;
use ipl\Stdlib\Filter;
2019-10-31 12:40:31 -04:00
2025-04-04 09:42:23 -04:00
class ContactController extends Controller
2019-10-31 12:40:31 -04:00
{
/** @var User The user object */
protected $user;
public function init()
{
2025-04-04 09:09:32 -04:00
$this->assertRouteAccess('contacts');
2025-04-04 09:42:23 -04:00
$this->addTitleTab(t('Contact'));
2019-10-31 12:40:31 -04:00
$name = $this->params->getRequired('name');
2019-10-31 12:40:31 -04:00
$query = User::on($this->getDb())->with('timeperiod');
$query->filter(Filter::equal('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) {
2025-04-04 09:42:23 -04:00
throw new NotFoundError(t('Contact not found'));
2019-10-31 12:40:31 -04:00
}
$this->user = $user;
$this->setTitle($user->display_name);
2019-10-31 12:40:31 -04:00
}
public function indexAction()
{
$this->addControl(new ObjectHeader($this->user));
$this->addContent(new UserDetail($this->user));
$this->setAutorefreshInterval(10);
2019-10-31 12:40:31 -04:00
}
}