2013-08-16 10:24:12 -04:00
|
|
|
<?php
|
2016-02-08 09:41:00 -05:00
|
|
|
/* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */
|
2013-08-16 10:24:12 -04:00
|
|
|
|
2015-06-02 03:58:57 -04:00
|
|
|
namespace Icinga\Forms\Config\UserBackend;
|
2013-08-16 10:24:12 -04:00
|
|
|
|
2014-08-29 09:16:13 -04:00
|
|
|
use Icinga\Web\Form;
|
2013-08-16 10:24:12 -04:00
|
|
|
|
|
|
|
|
/**
|
2015-06-02 03:58:57 -04:00
|
|
|
* Form class for adding/modifying database user backends
|
2013-08-16 10:24:12 -04:00
|
|
|
*/
|
2014-08-29 09:16:13 -04:00
|
|
|
class DbBackendForm extends Form
|
2013-08-16 10:24:12 -04:00
|
|
|
{
|
|
|
|
|
/**
|
2014-08-29 09:16:13 -04:00
|
|
|
* The database resource names the user can choose from
|
2014-08-11 04:43:54 -04:00
|
|
|
*
|
2014-07-29 06:22:43 -04:00
|
|
|
* @var array
|
2013-08-16 10:24:12 -04:00
|
|
|
*/
|
2014-07-29 06:22:43 -04:00
|
|
|
protected $resources;
|
2014-04-16 05:50:58 -04:00
|
|
|
|
2014-08-11 04:39:13 -04:00
|
|
|
/**
|
|
|
|
|
* Initialize this form
|
|
|
|
|
*/
|
|
|
|
|
public function init()
|
2013-08-16 10:24:12 -04:00
|
|
|
{
|
2014-08-29 09:16:13 -04:00
|
|
|
$this->setName('form_config_authbackend_db');
|
|
|
|
|
}
|
2013-08-16 10:24:12 -04:00
|
|
|
|
2014-08-29 09:16:13 -04:00
|
|
|
/**
|
|
|
|
|
* Set the resource names the user can choose from
|
|
|
|
|
*
|
|
|
|
|
* @param array $resources The resources to choose from
|
|
|
|
|
*
|
2015-04-07 08:23:26 -04:00
|
|
|
* @return $this
|
2014-08-29 09:16:13 -04:00
|
|
|
*/
|
|
|
|
|
public function setResources(array $resources)
|
|
|
|
|
{
|
|
|
|
|
$this->resources = $resources;
|
|
|
|
|
return $this;
|
2014-07-29 06:22:43 -04:00
|
|
|
}
|
2013-08-16 10:24:12 -04:00
|
|
|
|
2014-08-11 04:43:54 -04:00
|
|
|
/**
|
2015-07-23 10:18:09 -04:00
|
|
|
* Create and add elements to this form
|
|
|
|
|
*
|
|
|
|
|
* @param array $formData
|
2014-08-11 04:43:54 -04:00
|
|
|
*/
|
2014-07-29 06:22:43 -04:00
|
|
|
public function createElements(array $formData)
|
|
|
|
|
{
|
2014-09-03 06:21:31 -04:00
|
|
|
$this->addElement(
|
|
|
|
|
'text',
|
|
|
|
|
'name',
|
|
|
|
|
array(
|
|
|
|
|
'required' => true,
|
2015-01-19 05:26:23 -05:00
|
|
|
'label' => $this->translate('Backend Name'),
|
|
|
|
|
'description' => $this->translate(
|
2014-10-21 10:15:04 -04:00
|
|
|
'The name of this authentication provider that is used to differentiate it from others'
|
2015-07-23 10:18:09 -04:00
|
|
|
)
|
2013-10-23 06:25:51 -04:00
|
|
|
)
|
|
|
|
|
);
|
2014-09-03 06:21:31 -04:00
|
|
|
$this->addElement(
|
|
|
|
|
'select',
|
|
|
|
|
'resource',
|
|
|
|
|
array(
|
|
|
|
|
'required' => true,
|
2015-01-19 05:26:23 -05:00
|
|
|
'label' => $this->translate('Database Connection'),
|
|
|
|
|
'description' => $this->translate(
|
|
|
|
|
'The database connection to use for authenticating with this provider'
|
|
|
|
|
),
|
2015-07-23 10:18:09 -04:00
|
|
|
'multiOptions' => !empty($this->resources)
|
2014-09-03 06:21:31 -04:00
|
|
|
? array_combine($this->resources, $this->resources)
|
|
|
|
|
: array()
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
$this->addElement(
|
|
|
|
|
'hidden',
|
|
|
|
|
'backend',
|
|
|
|
|
array(
|
2014-11-18 09:06:36 -05:00
|
|
|
'disabled' => true,
|
2014-09-03 06:21:31 -04:00
|
|
|
'value' => 'db'
|
|
|
|
|
)
|
|
|
|
|
);
|
2014-09-29 05:06:16 -04:00
|
|
|
}
|
2013-08-16 10:24:12 -04:00
|
|
|
}
|