diff --git a/application/forms/ChannelForm.php b/application/forms/ChannelForm.php index f7ccbc27..ccffdb45 100644 --- a/application/forms/ChannelForm.php +++ b/application/forms/ChannelForm.php @@ -7,6 +7,7 @@ use Icinga\Exception\Http\HttpNotFoundException; use Icinga\Module\Notifications\Model\Channel; use Icinga\Module\Notifications\Model\AvailableChannelType; +use Icinga\Module\Notifications\Model\Contact; use Icinga\Module\Notifications\Model\RuleEscalationRecipient; use Icinga\Web\Session; use ipl\Html\Contract\FormSubmitElement; @@ -113,14 +114,18 @@ protected function assemble() ); if ($this->channelId !== null) { - $isInUse = RuleEscalationRecipient::on($this->db) + $isInUse = Contact::on($this->db) ->columns('1') - ->filter(Filter::any( - Filter::equal('channel_id', $this->channelId), - Filter::equal('contact.default_channel_id', $this->channelId) - )) + ->filter(Filter::equal('default_channel_id', $this->channelId)) ->first(); + if ($isInUse === null) { + $isInUse = RuleEscalationRecipient::on($this->db) + ->columns('1') + ->filter(Filter::equal('channel_id', $this->channelId)) + ->first(); + } + /** @var FormSubmitElement $deleteButton */ $deleteButton = $this->createElement( 'submit',