2019-11-05 03:17:11 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
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\ItemList\UsergroupList;
|
|
|
|
|
use Icinga\Module\Icingadb\Widget\ItemList\UserList;
|
2019-12-10 04:46:10 -05:00
|
|
|
use Icinga\Security\SecurityException;
|
2019-11-05 03:17:11 -05:00
|
|
|
|
|
|
|
|
class UsergroupController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/** @var Usergroup The usergroup object */
|
|
|
|
|
protected $usergroup;
|
|
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
|
{
|
2019-12-10 04:46:10 -05:00
|
|
|
if (! $this->hasPermission('*') && $this->hasPermission('no-monitoring/contacts')) {
|
|
|
|
|
throw new SecurityException('No permission for %s', 'monitoring/contacts');
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-05 03:17:11 -05:00
|
|
|
$this->setTitle($this->translate('User Group'));
|
|
|
|
|
|
|
|
|
|
$name = $this->params->shiftRequired('name');
|
|
|
|
|
|
|
|
|
|
$query = Usergroup::on($this->getDb());
|
|
|
|
|
$query->getSelectBase()
|
2019-11-25 09:35:48 -05:00
|
|
|
->where(['usergroup.name = ?' => $name]);
|
2019-11-05 03:17:11 -05:00
|
|
|
|
2019-11-22 10:01:27 -05:00
|
|
|
$this->applyMonitoringRestriction($query);
|
|
|
|
|
|
2019-11-05 03:17:11 -05:00
|
|
|
$usergroup = $query->first();
|
|
|
|
|
if ($usergroup === null) {
|
|
|
|
|
throw new NotFoundError($this->translate('User group not found'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->usergroup = $usergroup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function indexAction()
|
|
|
|
|
{
|
|
|
|
|
$this->addControl(new UsergroupList([$this->usergroup]));
|
|
|
|
|
|
|
|
|
|
$this->addContent(new UserList($this->usergroup->user));
|
2019-12-11 02:59:30 -05:00
|
|
|
|
|
|
|
|
$this->setAutorefreshInterval(10);
|
2019-11-05 03:17:11 -05:00
|
|
|
}
|
|
|
|
|
}
|