summaryrefslogtreecommitdiffstats
path: root/application/controllers/SettingsController.php
blob: c4709e6b817cd40a0be8e8045a8be927a4218c6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

namespace Icinga\Module\Director\Controllers;

use Icinga\Module\Director\Forms\KickstartForm;
use Icinga\Module\Director\Forms\SelfServiceSettingsForm;
use Icinga\Module\Director\Settings;
use Icinga\Module\Director\Web\Controller\ActionController;
use ipl\Html\Html;

class SettingsController extends ActionController
{
    /**
     * @throws \Icinga\Exception\Http\HttpNotFoundException
     */
    public function indexAction()
    {
        // Hint: this is for the module configuration tab, legacy code
        $this->view->tabs = $this->Module()
            ->getConfigTabs()
            ->activate('config');

        $this->view->form = KickstartForm::load()
            ->setModuleConfig($this->Config())
            ->handleRequest();
    }

    /**
     * @throws \Icinga\Exception\ConfigurationError
     * @throws \Icinga\Exception\IcingaException
     */
    public function selfServiceAction()
    {
        $form = SelfServiceSettingsForm::create($this->db(), new Settings($this->db()));
        $form->handleRequest();

        $hint = $this->translate(
            'The Icinga Director Self Service API allows your Hosts to register'
            . ' themselves. This allows them to get their Icinga Agent configured,'
            . ' installed and upgraded in an automated way.'
        );

        $this->addSingleTab($this->translate('Self Service'))
            ->addTitle($this->translate('Self Service API - Global Settings'))
            ->content()->add(Html::tag('p', null, $hint))
            ->add($form);
    }
}