From b15e81415133805491dead1a5a6511ff1ed6336c Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 17 Jun 2015 11:11:25 +0200 Subject: [PATCH] Forms: centralize groups property loading --- application/forms/IcingaHostForm.php | 7 ------- application/forms/IcingaServiceForm.php | 5 +++++ application/forms/IcingaUserForm.php | 5 +++++ library/Director/Web/Form/DirectorObjectForm.php | 5 +++++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/application/forms/IcingaHostForm.php b/application/forms/IcingaHostForm.php index 2d1afb11..54ae8b50 100644 --- a/application/forms/IcingaHostForm.php +++ b/application/forms/IcingaHostForm.php @@ -97,11 +97,4 @@ class IcingaHostForm extends DirectorObjectForm $this->addElement('submit', $this->translate('Store')); } - - public function loadObject($id) - { - parent::loadObject($id); - $this->getElement('groups')->setValue(implode(', ', $this->object->groups()->listGroupNames())); - return $this; - } } diff --git a/application/forms/IcingaServiceForm.php b/application/forms/IcingaServiceForm.php index 6c2af94e..7c945996 100644 --- a/application/forms/IcingaServiceForm.php +++ b/application/forms/IcingaServiceForm.php @@ -80,6 +80,11 @@ class IcingaServiceForm extends DirectorObjectForm 'description' => $this->translate('Check this host in this specific Icinga cluster zone') )); + $this->addElement('text', 'groups', array( + 'label' => $this->translate('Servicegroups'), + 'description' => $this->translate('One or more comma separated servicegroup names') + )); + $this->addElement('submit', $this->translate('Store')); } } diff --git a/application/forms/IcingaUserForm.php b/application/forms/IcingaUserForm.php index cb9a5180..d928007b 100644 --- a/application/forms/IcingaUserForm.php +++ b/application/forms/IcingaUserForm.php @@ -55,6 +55,11 @@ class IcingaUserForm extends DirectorObjectForm 'description' => $this->translate('Check this user in this specific Icinga cluster zone') )); + $this->addElement('text', 'groups', array( + 'label' => $this->translate('Usergroups'), + 'description' => $this->translate('One or more comma separated usergroup names') + )); + $this->addElement('submit', $this->translate('Store')); } } diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index 7f4a16dd..0f92bff7 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -116,6 +116,11 @@ abstract class DirectorObjectForm extends QuickForm $this->addHidden('id'); } $this->setDefaults($this->object->getProperties()); + if ($this->object->supportsGroups()) { + $this->getElement('groups')->setValue( + implode(', ', $this->object->groups()->listGroupNames()) + ); + ] if ($this->object->supportsCustomVars()) { foreach ($this->object->vars() as $key => $value) {