summaryrefslogtreecommitdiffstats
path: root/application/forms/IcingaCloneObjectForm.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:17:48 +0000
commite6d4dfc040bbe3cb80a2ce65b82493b557f751fc (patch)
tree40bd6366b01b06f4d96fc8638f23a772263cb5e9 /application/forms/IcingaCloneObjectForm.php
parentReleasing progress-linux version 1.10.2-2~progress7.99u1. (diff)
downloadicingaweb2-module-director-e6d4dfc040bbe3cb80a2ce65b82493b557f751fc.tar.xz
icingaweb2-module-director-e6d4dfc040bbe3cb80a2ce65b82493b557f751fc.zip
Merging upstream version 1.11.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/forms/IcingaCloneObjectForm.php')
-rw-r--r--application/forms/IcingaCloneObjectForm.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/application/forms/IcingaCloneObjectForm.php b/application/forms/IcingaCloneObjectForm.php
index 6ee99ba..8381eee 100644
--- a/application/forms/IcingaCloneObjectForm.php
+++ b/application/forms/IcingaCloneObjectForm.php
@@ -5,8 +5,10 @@ namespace Icinga\Module\Director\Forms;
use gipfl\Web\Widget\Hint;
use Icinga\Exception\IcingaException;
use Icinga\Module\Director\Acl;
+use Icinga\Module\Director\Auth\Permission;
use Icinga\Module\Director\Data\Db\DbObjectStore;
use Icinga\Module\Director\Db\Branch\Branch;
+use Icinga\Module\Director\Objects\IcingaCommand;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Objects\IcingaObject;
use Icinga\Module\Director\Objects\IcingaService;
@@ -41,7 +43,7 @@ class IcingaCloneObjectForm extends DirectorForm
'value' => $name,
));
- if (!$branchOnly && Acl::instance()->hasPermission('director/admin')) {
+ if (!$branchOnly && Acl::instance()->hasPermission(Permission::ADMIN)) {
$this->addElement('select', 'clone_type', array(
'label' => 'Clone type',
'required' => true,
@@ -95,7 +97,9 @@ class IcingaCloneObjectForm extends DirectorForm
}
}
- if ($this->object->isTemplate() && $this->object->supportsFields()) {
+ if (($this->object->isTemplate() || $this->object instanceof IcingaCommand)
+ && $this->object->supportsFields()
+ ) {
$this->addBoolean('clone_fields', [
'label' => $this->translate('Clone Template Fields'),
'description' => $this->translate(
@@ -132,7 +136,7 @@ class IcingaCloneObjectForm extends DirectorForm
$connection = $object->getConnection();
$db = $connection->getDbAdapter();
$newName = $this->getValue('new_object_name');
- $resolve = Acl::instance()->hasPermission('director/admin')
+ $resolve = Acl::instance()->hasPermission(Permission::ADMIN)
&& $this->getValue('clone_type') === 'flat';
$msg = sprintf(
@@ -189,7 +193,7 @@ class IcingaCloneObjectForm extends DirectorForm
$fields = $db->fetchAll(
$db->select()
->from($table . '_field')
- ->where("${type}_id = ?", $object->get('id'))
+ ->where("{$type}_id = ?", $object->get('id'))
);
} else {
$fields = [];
@@ -221,7 +225,7 @@ class IcingaCloneObjectForm extends DirectorForm
}
foreach ($fields as $row) {
- $row->{"${type}_id"} = $newId;
+ $row->{"{$type}_id"} = $newId;
$db->insert($table . '_field', (array) $row);
}
@@ -247,6 +251,7 @@ class IcingaCloneObjectForm extends DirectorForm
return $db->fetchPairs(
$db->select()
->from('icinga_service_set', ['id', 'object_name'])
+ ->where('object_type = ?', 'template')
->order('object_name')
);
}