2015-07-03 07:17:05 -04:00
|
|
|
<?php
|
|
|
|
|
|
2015-10-20 16:34:04 -04:00
|
|
|
namespace Icinga\Module\Director\Controllers;
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($edit) {
|
|
|
|
|
$this->view->title = $this->translate('Edit field');
|
|
|
|
|
$this->getTabs()->add('editfield', array(
|
|
|
|
|
'url' => 'director/datafield/edit' . '?id=' . $id,
|
|
|
|
|
'label' => $this->view->title,
|
|
|
|
|
))->activate('editfield');
|
|
|
|
|
} else {
|
|
|
|
|
$this->view->title = $this->translate('Add field');
|
|
|
|
|
$this->getTabs()->add('addfield', array(
|
|
|
|
|
'url' => 'director/datafield/add',
|
|
|
|
|
'label' => $this->view->title,
|
|
|
|
|
))->activate('addfield');
|
|
|
|
|
}
|
2015-07-03 07:17:05 -04:00
|
|
|
|
|
|
|
|
$form = $this->view->form = $this->loadForm('directorDatafield')
|
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);
|
|
|
|
|
}
|
2015-07-03 08:20:47 -04:00
|
|
|
|
2015-07-03 07:17:05 -04:00
|
|
|
$form->handleRequest();
|
|
|
|
|
|
|
|
|
|
$this->render('object/form', null, true);
|
|
|
|
|
}
|
|
|
|
|
}
|