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