mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
IcingaUserForm: re-organize elements, structure
This commit is contained in:
parent
920b8440c7
commit
3e0fbf5dac
@ -8,18 +8,13 @@ class IcingaUserForm extends DirectorObjectForm
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
$isTemplate = isset($_POST['object_type']) && $_POST['object_type'] === 'template';
|
||||
$this->addElement('select', 'object_type', array(
|
||||
'label' => $this->translate('Object type'),
|
||||
'description' => $this->translate('Whether this should be a template'),
|
||||
'multiOptions' => array(
|
||||
null => '- please choose -',
|
||||
'object' => 'User object',
|
||||
'template' => 'User template',
|
||||
)
|
||||
));
|
||||
$this->addObjectTypeElement();
|
||||
if (! $this->hasObjectType()) {
|
||||
$this->groupObjectDefinition();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($isTemplate) {
|
||||
if ($this->isTemplate()) {
|
||||
$this->addElement('text', 'object_name', array(
|
||||
'label' => $this->translate('User template name'),
|
||||
'required' => true,
|
||||
@ -43,9 +38,33 @@ class IcingaUserForm extends DirectorObjectForm
|
||||
'description' => $this->translate('The pager address of the user.')
|
||||
));
|
||||
|
||||
$this->addGroupsElement();
|
||||
$this->addImportsElement();
|
||||
$this->optionalBoolean(
|
||||
'enable_notifications',
|
||||
$this->translate('Send notifications'),
|
||||
$this->translate('Whether to send notifications for this user')
|
||||
);
|
||||
$this->addDisabledElement();
|
||||
$this->groupObjectDefinition();
|
||||
|
||||
|
||||
$this->addEventFilterElements();
|
||||
|
||||
$this->setButtons();
|
||||
}
|
||||
|
||||
protected function addGroupsElement()
|
||||
{
|
||||
$groups = $this->enumUsergroups();
|
||||
|
||||
if (empty($groups)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->addElement('extensibleSet', 'groups', array(
|
||||
'label' => $this->translate('Groups'),
|
||||
'multiOptions' => $this->optionallyAddFromEnum($this->enumUsergroups()),
|
||||
'multiOptions' => $this->optionallyAddFromEnum($groups),
|
||||
'positional' => false,
|
||||
'description' => $this->translate(
|
||||
'User groups that should be directly assigned to this user. Groups can be useful'
|
||||
@ -54,27 +73,40 @@ class IcingaUserForm extends DirectorObjectForm
|
||||
)
|
||||
));
|
||||
|
||||
$this->optionalBoolean(
|
||||
'enable_notifications',
|
||||
$this->translate('Send notifications'),
|
||||
$this->translate('Whether to send notifications for this user')
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function addEventFilterElements()
|
||||
{
|
||||
$this->addElement('extensibleSet', 'states', array(
|
||||
'label' => $this->translate('States'),
|
||||
'multiOptions' => $this->optionallyAddFromEnum($this->enumStates()),
|
||||
'description' => $this->translate('The host/service states you want to get notifications for'),
|
||||
'description' => $this->translate(
|
||||
'The host/service states you want to get notifications for'
|
||||
),
|
||||
));
|
||||
|
||||
$this->addElement('extensibleSet', 'types', array(
|
||||
'label' => $this->translate('Event types'),
|
||||
'label' => $this->translate('Transition types'),
|
||||
'multiOptions' => $this->optionallyAddFromEnum($this->enumTypes()),
|
||||
'description' => $this->translate('The event types you want to get notifications for'),
|
||||
'description' => $this->translate(
|
||||
'The state transition types you want to get notifications for'
|
||||
),
|
||||
));
|
||||
|
||||
$this->addImportsElement();
|
||||
$this->addDisabledElement();
|
||||
$this->setButtons();
|
||||
$elements = array(
|
||||
'states',
|
||||
'types',
|
||||
);
|
||||
$this->addDisplayGroup($elements, 'event_filters', array(
|
||||
'decorators' => array(
|
||||
'FormElements',
|
||||
array('HtmlTag', array('tag' => 'dl')),
|
||||
'Fieldset',
|
||||
),
|
||||
'order' =>70,
|
||||
'legend' => $this->translate('State and transition type filters')
|
||||
));
|
||||
}
|
||||
|
||||
protected function enumStates()
|
||||
@ -89,6 +121,30 @@ class IcingaUserForm extends DirectorObjectForm
|
||||
return $set->enumAllowedValues();
|
||||
}
|
||||
|
||||
protected function groupObjectDefinition()
|
||||
{
|
||||
$elements = array(
|
||||
'object_type',
|
||||
'object_name',
|
||||
'display_name',
|
||||
'imports',
|
||||
'groups',
|
||||
'email',
|
||||
'pager',
|
||||
'enable_notifications',
|
||||
'disabled',
|
||||
);
|
||||
$this->addDisplayGroup($elements, 'object_definition', array(
|
||||
'decorators' => array(
|
||||
'FormElements',
|
||||
array('HtmlTag', array('tag' => 'dl')),
|
||||
'Fieldset',
|
||||
),
|
||||
'order' => 20,
|
||||
'legend' => $this->translate('User properties')
|
||||
));
|
||||
}
|
||||
|
||||
protected function enumUsergroups()
|
||||
{
|
||||
$db = $this->db->getDbAdapter();
|
||||
|
Loading…
x
Reference in New Issue
Block a user