2015-07-24 09:51:31 +02:00
|
|
|
<?php
|
|
|
|
|
2015-10-20 22:34:04 +02:00
|
|
|
namespace Icinga\Module\Director\Controllers;
|
|
|
|
|
2015-07-24 09:51:31 +02:00
|
|
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
2015-11-02 09:32:38 +01:00
|
|
|
use Icinga\Module\Director\Objects\SyncRule;
|
2015-07-24 09:51:31 +02:00
|
|
|
|
2015-10-20 22:34:04 +02:00
|
|
|
class SyncpropertyController extends ActionController
|
2015-07-24 09:51:31 +02:00
|
|
|
{
|
|
|
|
public function addAction()
|
|
|
|
{
|
2015-07-29 20:13:06 +02:00
|
|
|
$this->indexAction();
|
2015-07-24 09:51:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function editAction()
|
|
|
|
{
|
2015-07-29 20:13:06 +02:00
|
|
|
$this->indexAction();
|
2015-07-24 09:51:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function indexAction()
|
|
|
|
{
|
|
|
|
$edit = false;
|
|
|
|
|
|
|
|
if ($id = $this->params->get('id')) {
|
|
|
|
$edit = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($edit) {
|
|
|
|
$this->view->title = $this->translate('Edit sync property rule');
|
|
|
|
$this->getTabs()->add('edit', array(
|
|
|
|
'url' => 'director/syncproperty/edit' . '?id=' . $id,
|
|
|
|
'label' => $this->view->title,
|
|
|
|
))->activate('edit');
|
|
|
|
} else {
|
|
|
|
$this->view->title = $this->translate('Add sync property rule');
|
|
|
|
$this->getTabs()->add('add', array(
|
|
|
|
'url' => 'director/syncproperty/add',
|
|
|
|
'label' => $this->view->title,
|
|
|
|
))->activate('add');
|
|
|
|
}
|
|
|
|
|
2015-11-02 16:22:20 +01:00
|
|
|
$form = $this->view->form = $this->loadForm('syncProperty')->setDb($this->db());
|
2015-07-24 09:51:31 +02:00
|
|
|
|
|
|
|
if ($edit) {
|
|
|
|
$form->loadObject($id);
|
2015-11-02 16:22:20 +01:00
|
|
|
$rule_id = $form->getObject()->rule_id;
|
|
|
|
$form->setRule(SyncRule::load($rule_id, $this->db()));
|
2015-11-02 09:32:38 +01:00
|
|
|
} elseif ($rule_id = $this->params->get('rule_id')) {
|
|
|
|
$form->setRule(SyncRule::load($rule_id, $this->db()));
|
2015-07-24 09:51:31 +02:00
|
|
|
}
|
2015-11-02 16:22:20 +01:00
|
|
|
$form->setSuccessUrl('director/syncrule/property', array('rule_id' => $rule_id));
|
2015-07-24 09:51:31 +02:00
|
|
|
|
|
|
|
$form->handleRequest();
|
|
|
|
|
|
|
|
$this->render('object/form', null, true);
|
|
|
|
}
|
|
|
|
}
|