From 2f79920a18ec01cda765f5524839e19482a6de34 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 27 Jun 2017 00:20:40 +0200 Subject: [PATCH] TemplateChoice: small fixes, forms --- ...teChoiceForm.php => IcingaTemplateChoiceHostForm.php} | 0 library/Director/Objects/IcingaTemplateChoice.php | 9 +++------ library/Director/Objects/IcingaTemplateChoiceService.php | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) rename application/forms/{IcingaHostTemplateChoiceForm.php => IcingaTemplateChoiceHostForm.php} (100%) diff --git a/application/forms/IcingaHostTemplateChoiceForm.php b/application/forms/IcingaTemplateChoiceHostForm.php similarity index 100% rename from application/forms/IcingaHostTemplateChoiceForm.php rename to application/forms/IcingaTemplateChoiceHostForm.php diff --git a/library/Director/Objects/IcingaTemplateChoice.php b/library/Director/Objects/IcingaTemplateChoice.php index 08c1501a..25d03cb4 100644 --- a/library/Director/Objects/IcingaTemplateChoice.php +++ b/library/Director/Objects/IcingaTemplateChoice.php @@ -3,12 +3,10 @@ namespace Icinga\Module\Director\Objects; use Icinga\Module\Director\Web\Form\QuickForm; -use ipl\Translation\TranslationHelper; -use Zend_Form_Element as ZfElement; class IcingaTemplateChoice extends IcingaObject { - private $objectTable; + protected $objectTable; protected $defaultProperties = [ 'id' => null, @@ -90,11 +88,10 @@ class IcingaTemplateChoice extends IcingaObject if ($this->hasBeenLoadedFromDb()) { $db = $this->getDb(); $query = $db->select()->from( - ['o' => $this->objectTable], + ['o' => $this->getObjectTableName()], ['o.id', 'o.object_name'] )->where("o.object_type = 'template'") - ->where('o.template_choice_id = ?', $this->get('id')); - + ->where('o.template_choice_id IS NULL OR o.template_choice_id = ?', $this->get('id')); return $db->fetchPairs($query); } else { return []; diff --git a/library/Director/Objects/IcingaTemplateChoiceService.php b/library/Director/Objects/IcingaTemplateChoiceService.php index ada52344..ff74d426 100644 --- a/library/Director/Objects/IcingaTemplateChoiceService.php +++ b/library/Director/Objects/IcingaTemplateChoiceService.php @@ -2,7 +2,7 @@ namespace Icinga\Module\Director\Objects; -class IcingaTemplateChoiceHost extends IcingaTemplateChoice +class IcingaTemplateChoiceService extends IcingaTemplateChoice { protected $table = 'icinga_service_template_choice';