2015-07-03 07:17:05 -04:00
|
|
|
<?php
|
|
|
|
|
|
2015-10-20 16:34:04 -04:00
|
|
|
namespace Icinga\Module\Director\Controllers;
|
|
|
|
|
|
2017-07-11 09:28:04 -04:00
|
|
|
use Icinga\Module\Director\Forms\DirectorDatafieldForm;
|
2015-07-03 07:17:05 -04:00
|
|
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
|
|
|
|
|
2015-10-20 16:34:04 -04:00
|
|
|
class DatafieldController extends ActionController
|
2015-07-03 07:17:05 -04:00
|
|
|
{
|
2015-07-03 08:20:47 -04:00
|
|
|
public function addAction()
|
|
|
|
|
{
|
2015-07-29 14:13:06 -04:00
|
|
|
$this->indexAction();
|
2015-07-03 08:20:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function editAction()
|
|
|
|
|
{
|
2015-07-29 14:13:06 -04:00
|
|
|
$this->indexAction();
|
2015-07-03 08:20:47 -04:00
|
|
|
}
|
|
|
|
|
|
2015-07-03 07:17:05 -04:00
|
|
|
public function indexAction()
|
|
|
|
|
{
|
2015-07-03 08:35:56 -04:00
|
|
|
$edit = false;
|
|
|
|
|
|
2016-02-27 15:04:13 -05:00
|
|
|
if ($id = $this->params->get('id')) {
|
2015-07-03 08:35:56 -04:00
|
|
|
$edit = true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-11 09:28:04 -04:00
|
|
|
$form = DirectorDatafieldForm::load()
|
2016-03-01 14:56:53 -05:00
|
|
|
->setSuccessUrl('director/data/fields')
|
2015-07-03 07:17:05 -04:00
|
|
|
->setDb($this->db());
|
|
|
|
|
|
2015-07-03 08:35:56 -04:00
|
|
|
if ($edit) {
|
2015-07-03 07:17:05 -04:00
|
|
|
$form->loadObject($id);
|
2017-07-11 09:28:04 -04:00
|
|
|
$this->addTitle(
|
2016-10-17 13:48:04 -04:00
|
|
|
$this->translate('Modify %s'),
|
|
|
|
|
$form->getObject()->varname
|
|
|
|
|
);
|
2017-07-20 09:10:12 -04:00
|
|
|
$this->addSingleTab($this->translate('Edit a Field'));
|
2016-10-17 13:48:04 -04:00
|
|
|
} else {
|
2017-07-11 09:28:04 -04:00
|
|
|
$this->addTitle($this->translate('Add a new Data Field'));
|
2017-07-20 09:10:12 -04:00
|
|
|
$this->addSingleTab($this->translate('New Field'));
|
2015-07-03 07:17:05 -04:00
|
|
|
}
|
2015-07-03 08:20:47 -04:00
|
|
|
|
2015-07-03 07:17:05 -04:00
|
|
|
$form->handleRequest();
|
2017-07-11 09:28:04 -04:00
|
|
|
$this->content()->add($form);
|
2015-07-03 07:17:05 -04:00
|
|
|
}
|
|
|
|
|
}
|