Add missing platform checks to DbResourceForm

This commit is contained in:
Johannes Meyer 2014-09-29 14:46:27 +02:00
parent 288ae6885b
commit ab93969944
2 changed files with 11 additions and 6 deletions

View File

@ -10,6 +10,7 @@ use Icinga\Web\Form;
use Icinga\Web\Request; use Icinga\Web\Request;
use Icinga\Web\Form\Element\Number; use Icinga\Web\Form\Element\Number;
use Icinga\Data\ResourceFactory; use Icinga\Data\ResourceFactory;
use Icinga\Application\Platform;
/** /**
* Form class for adding/modifying database resources * Form class for adding/modifying database resources
@ -29,6 +30,14 @@ class DbResourceForm extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
$dbChoices = array();
if (Platform::zendClassExists('Zend_Db_Adapter_Pdo_Mysql')) {
$dbChoices['mysql'] = 'MySQL';
}
if (Platform::zendClassExists('Zend_Db_Adapter_Pdo_Pgsql')) {
$dbChoices['pgsql'] = 'PostgreSQL';
}
$this->addElement( $this->addElement(
'text', 'text',
'name', 'name',
@ -45,11 +54,7 @@ class DbResourceForm extends Form
'required' => true, 'required' => true,
'label' => t('Database Type'), 'label' => t('Database Type'),
'description' => t('The type of SQL database'), 'description' => t('The type of SQL database'),
'multiOptions' => array( 'multiOptions' => $dbChoices
'mysql' => 'MySQL',
'pgsql' => 'PostgreSQL'
//'oracle' => 'Oracle'
)
) )
); );
$this->addElement( $this->addElement(

View File

@ -220,7 +220,7 @@ class ResourceConfigForm extends ConfigForm
if ($resourceType === 'ldap' || Platform::extensionLoaded('ldap')) { if ($resourceType === 'ldap' || Platform::extensionLoaded('ldap')) {
$resourceTypes['ldap'] = 'LDAP'; $resourceTypes['ldap'] = 'LDAP';
} }
if ($resourceType === 'db' || Platform::extensionLoaded('mysql') || Platform::extensionLoaded('pgsql')) { if ($resourceType === 'db' || Platform::extensionLoaded('pdo')) {
$resourceTypes['db'] = t('SQL Database'); $resourceTypes['db'] = t('SQL Database');
} }