2015-06-01 14:33:07 +02:00
|
|
|
<?php
|
|
|
|
|
2015-10-20 22:34:04 +02:00
|
|
|
namespace Icinga\Module\Director\Controllers;
|
|
|
|
|
2015-06-11 22:49:33 +02:00
|
|
|
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
2015-08-28 23:45:16 +02:00
|
|
|
use Icinga\Module\Director\Objects\IcingaObject;
|
2015-09-14 16:26:51 +02:00
|
|
|
use Icinga\Module\Director\ConfigDiff;
|
2015-06-23 14:37:23 +02:00
|
|
|
use Icinga\Module\Director\Util;
|
2015-06-30 11:27:32 +02:00
|
|
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
2015-06-11 22:49:33 +02:00
|
|
|
|
2015-10-20 22:34:04 +02:00
|
|
|
class ShowController extends ActionController
|
2015-06-01 14:33:07 +02:00
|
|
|
{
|
|
|
|
public function activitylogAction()
|
|
|
|
{
|
|
|
|
if ($id = $this->params->get('id')) {
|
2015-06-18 11:01:45 +02:00
|
|
|
$this->view->entry = $this->db()->fetchActivityLogEntryById($id);
|
|
|
|
} elseif ($checksum = $this->params->get('checksum')) {
|
2015-06-23 14:37:23 +02:00
|
|
|
$this->view->entry = $this->db()->fetchActivityLogEntry(Util::hex2binary($checksum));
|
2015-06-01 14:33:07 +02:00
|
|
|
}
|
2015-06-18 11:01:45 +02:00
|
|
|
|
2015-08-28 23:45:16 +02:00
|
|
|
$entry = $this->view->entry;
|
|
|
|
|
|
|
|
if ($entry->old_properties) {
|
|
|
|
$old = $this->createObject($entry->object_type, $entry->old_properties);
|
|
|
|
if ($entry->new_properties) {
|
|
|
|
$new = $this->createObject($entry->object_type, $entry->old_properties);
|
|
|
|
$new->setProperties((array) json_decode($entry->new_properties));
|
|
|
|
} else {
|
|
|
|
$new = null;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$old = null;
|
|
|
|
$new = $this->createObject($entry->object_type, $entry->new_properties);
|
|
|
|
}
|
|
|
|
|
2015-09-14 16:26:51 +02:00
|
|
|
if ($old && $new) {
|
|
|
|
$d = ConfigDiff::create($old, $new);
|
|
|
|
$this->view->diff = strtr(
|
|
|
|
$d->renderHtml(),
|
|
|
|
array('\\n' => "\\n\n")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-08-28 23:45:16 +02:00
|
|
|
$this->view->entry = $entry;
|
|
|
|
$this->view->newObject = $new;
|
|
|
|
$this->view->oldObject = $old;
|
2015-06-18 11:01:45 +02:00
|
|
|
$this->view->title = $this->translate('Activity');
|
2015-06-01 14:33:07 +02:00
|
|
|
}
|
2015-08-28 23:45:16 +02:00
|
|
|
|
|
|
|
protected function createObject($type, $props)
|
|
|
|
{
|
|
|
|
$props = json_decode($props);
|
|
|
|
return IcingaObject::createByType($type, (array) $props, $this->db());
|
|
|
|
}
|
2015-06-01 14:33:07 +02:00
|
|
|
}
|