IcingaUserForm: allow to specify TimePeriods

fixes #944
This commit is contained in:
Thomas Gelf 2018-05-29 12:20:39 +02:00
parent 4b2546b14f
commit ed8a135a66
2 changed files with 54 additions and 0 deletions

View File

@ -6,6 +6,9 @@ use Icinga\Module\Director\Web\Form\DirectorObjectForm;
class IcingaUserForm extends DirectorObjectForm class IcingaUserForm extends DirectorObjectForm
{ {
/**
* @throws \Zend_Form_Exception
*/
public function setup() public function setup()
{ {
$this->addObjectTypeElement(); $this->addObjectTypeElement();
@ -46,11 +49,16 @@ class IcingaUserForm extends DirectorObjectForm
->addEnableNotificationsElement() ->addEnableNotificationsElement()
->addDisabledElement() ->addDisabledElement()
->addZoneElements() ->addZoneElements()
->addPeriodElement()
->addEventFilterElements() ->addEventFilterElements()
->groupMainProperties() ->groupMainProperties()
->setButtons(); ->setButtons();
} }
/**
* @return $this
* @throws \Zend_Form_Exception
*/
protected function addZoneElements() protected function addZoneElements()
{ {
if (! $this->isTemplate()) { if (! $this->isTemplate()) {
@ -71,6 +79,9 @@ class IcingaUserForm extends DirectorObjectForm
return $this; return $this;
} }
/**
* @return $this
*/
protected function addEnableNotificationsElement() protected function addEnableNotificationsElement()
{ {
$this->optionalBoolean( $this->optionalBoolean(
@ -82,6 +93,10 @@ class IcingaUserForm extends DirectorObjectForm
return $this; return $this;
} }
/**
* @return $this
* @throws \Zend_Form_Exception
*/
protected function addGroupsElement() protected function addGroupsElement()
{ {
$groups = $this->enumUsergroups(); $groups = $this->enumUsergroups();
@ -104,6 +119,10 @@ class IcingaUserForm extends DirectorObjectForm
return $this; return $this;
} }
/**
* @return $this
* @throws \Zend_Form_Exception
*/
protected function addDisplayNameElement() protected function addDisplayNameElement()
{ {
if ($this->isTemplate()) { if ($this->isTemplate()) {
@ -121,6 +140,36 @@ class IcingaUserForm extends DirectorObjectForm
return $this; return $this;
} }
/**
* @return $this
* @throws \Zend_Form_Exception
*/
protected function addPeriodElement()
{
$periods = $this->db->enumTimeperiods();
if (empty($periods)) {
return $this;
}
$this->addElement(
'select',
'period_id',
array(
'label' => $this->translate('Time period'),
'description' => $this->translate(
'The name of a time period which determines when notifications'
. ' to this User should be triggered. Not set by default.'
),
'multiOptions' => $this->optionalEnum($periods),
)
);
return $this;
}
/**
* @throws \Zend_Form_Exception
*/
protected function groupObjectDefinition() protected function groupObjectDefinition()
{ {
$elements = array( $elements = array(
@ -131,6 +180,7 @@ class IcingaUserForm extends DirectorObjectForm
'groups', 'groups',
'email', 'email',
'pager', 'pager',
'period_id',
'enable_notifications', 'enable_notifications',
'disabled', 'disabled',
); );
@ -145,6 +195,9 @@ class IcingaUserForm extends DirectorObjectForm
)); ));
} }
/**
* @return array
*/
protected function enumUsergroups() protected function enumUsergroups()
{ {
$db = $this->db->getDbAdapter(); $db = $this->db->getDbAdapter();

View File

@ -29,6 +29,7 @@ before switching to a new version.
* FIX: Don't suggest Command templates where Commands are required (#1414) * FIX: Don't suggest Command templates where Commands are required (#1414)
* FIX: Do not allow to delete Commands being used by other objects (#1443) * FIX: Do not allow to delete Commands being used by other objects (#1443)
* FIX: Show 'Inspect' tab only for Endpoints with an ApiUser (#1293) * FIX: Show 'Inspect' tab only for Endpoints with an ApiUser (#1293)
* FIX: It's now possible to specify TimePeriods for single Users #944
### CLI ### CLI
* FEATURE: Director Health Check Plugin (#1278) * FEATURE: Director Health Check Plugin (#1278)