parent
85cda6da9b
commit
cc9f5037f4
|
@ -41,6 +41,24 @@ class IcingaNotificationForm extends DirectorObjectForm
|
|||
return $this;
|
||||
}
|
||||
|
||||
$this->addElement(
|
||||
'select',
|
||||
'apply_to',
|
||||
array(
|
||||
'label' => $this->translate('Apply to'),
|
||||
'description' => $this->translate(
|
||||
'Whether this notification should affect hosts or services'
|
||||
),
|
||||
'required' => true,
|
||||
'multiOptions' => $this->optionalEnum(
|
||||
array(
|
||||
'host' => $this->translate('Hosts'),
|
||||
'service' => $this->translate('Services'),
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$sub = new AssignListSubForm();
|
||||
$sub->setObject($this->getObject());
|
||||
$sub->setup();
|
||||
|
|
|
@ -111,6 +111,43 @@ class IcingaNotification extends IcingaObject
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not render internal property apply_to
|
||||
*
|
||||
* Avoid complaints for method names with underscore:
|
||||
* @codingStandardsIgnoreStart
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renderApply_to()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function renderObjectHeader()
|
||||
{
|
||||
if ($this->isApplyRule()) {
|
||||
if (($to = $this->get('apply_to')) === null) {
|
||||
throw new ConfigurationError(
|
||||
'Applied notification "%s" has no valid object type',
|
||||
$this->getObjectName()
|
||||
);
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
"%s %s to %s %s {\n",
|
||||
$this->getObjectTypeName(),
|
||||
$this->getType(),
|
||||
ucfirst($to),
|
||||
c::renderString($this->getObjectName())
|
||||
);
|
||||
|
||||
} else {
|
||||
return parent::renderObjectHeader();
|
||||
}
|
||||
}
|
||||
|
||||
protected function setKey($key)
|
||||
{
|
||||
if (is_int($key)) {
|
||||
|
|
|
@ -493,6 +493,7 @@ abstract class DirectorObjectForm extends QuickForm
|
|||
'groups',
|
||||
'users',
|
||||
'user_groups',
|
||||
'apply_to',
|
||||
'command_id', // Notification
|
||||
'notification_interval',
|
||||
'period_id',
|
||||
|
|
Loading…
Reference in New Issue