ApplyRulesTable: use UUIDs

refs #2411
This commit is contained in:
Thomas Gelf 2021-10-18 10:04:28 +02:00
parent ce3ec67eb6
commit 2d79281583

View File

@ -14,6 +14,7 @@ use gipfl\IcingaWeb2\Link;
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable; use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
use gipfl\IcingaWeb2\Url; use gipfl\IcingaWeb2\Url;
use gipfl\IcingaWeb2\Zf1\Db\FilterRenderer; use gipfl\IcingaWeb2\Zf1\Db\FilterRenderer;
use Ramsey\Uuid\Uuid;
use Zend_Db_Select as ZfSelect; use Zend_Db_Select as ZfSelect;
class ApplyRulesTable extends ZfQueryBasedTable class ApplyRulesTable extends ZfQueryBasedTable
@ -72,10 +73,13 @@ class ApplyRulesTable extends ZfQueryBasedTable
public function renderRow($row) public function renderRow($row)
{ {
if (isset($row->uuid) && is_resource($row->uuid)) {
$row->uuid = stream_get_contents($row->uuid);
}
if ($this->linkWithName) { if ($this->linkWithName) {
$params = ['name' => $row->object_name]; $params = ['name' => $row->object_name];
} else { } else {
$params = ['id' => $row->id]; $params = ['uuid' => Uuid::fromBytes($row->uuid)->toString()];
} }
$url = Url::fromPath("director/{$this->baseObjectUrl}/edit", $params); $url = Url::fromPath("director/{$this->baseObjectUrl}/edit", $params);
@ -138,6 +142,7 @@ class ApplyRulesTable extends ZfQueryBasedTable
public function createActionLinks($row) public function createActionLinks($row)
{ {
$params = ['uuid' => Uuid::fromBytes($row->uuid)->toString()];
$baseUrl = 'director/' . $this->baseObjectUrl; $baseUrl = 'director/' . $this->baseObjectUrl;
$links = []; $links = [];
$links[] = Link::create( $links[] = Link::create(
@ -150,21 +155,21 @@ class ApplyRulesTable extends ZfQueryBasedTable
$links[] = Link::create( $links[] = Link::create(
Icon::create('edit'), Icon::create('edit'),
"$baseUrl/edit", "$baseUrl/edit",
['id' => $row->id], $params,
['title' => $this->translate('Modify this Apply Rule')] ['title' => $this->translate('Modify this Apply Rule')]
); );
$links[] = Link::create( $links[] = Link::create(
Icon::create('doc-text'), Icon::create('doc-text'),
"$baseUrl/render", "$baseUrl/render",
['id' => $row->id], $params,
['title' => $this->translate('Apply Rule rendering preview')] ['title' => $this->translate('Apply Rule rendering preview')]
); );
$links[] = Link::create( $links[] = Link::create(
Icon::create('history'), Icon::create('history'),
"$baseUrl/history", "$baseUrl/history",
['id' => $row->id], $params,
['title' => $this->translate('Apply rule history')] ['title' => $this->translate('Apply rule history')]
); );
@ -210,6 +215,7 @@ class ApplyRulesTable extends ZfQueryBasedTable
$table = $this->getDummyObject()->getTableName(); $table = $this->getDummyObject()->getTableName();
$columns = [ $columns = [
'id' => 'o.id', 'id' => 'o.id',
'uuid' => 'o.uuid',
'object_name' => 'o.object_name', 'object_name' => 'o.object_name',
'disabled' => 'o.disabled', 'disabled' => 'o.disabled',
'assign_filter' => 'o.assign_filter', 'assign_filter' => 'o.assign_filter',