/** * Create and add elements to this form * * @param array $formData The data sent by the user */ public function createElements(array $formData) { $dbChoices = array(); if (Platform::hasMysqlSupport()) { $dbChoices['mysql'] = 'MySQL'; } if (Platform::hasPostgresqlSupport()) { $dbChoices['pgsql'] = 'PostgreSQL'; } if (Platform::hasMssqlSupport()) { $dbChoices['mssql'] = 'MSSQL'; } if (Platform::hasOracleSupport()) { $dbChoices['oracle'] = 'Oracle'; } if (Platform::hasOciSupport()) { $dbChoices['oci'] = 'Oracle (OCI8)'; } $offerSsl = false; $offerPostgres = false; $offerMysql = false; $dbChoice = isset($formData['db']) ? $formData['db'] : key($dbChoices); if ($dbChoice === 'pgsql') { $offerPostgres = true; } elseif ($dbChoice === 'mysql') { $offerMysql = true; if (version_compare(Platform::getPhpVersion(), '5.4.0', '>=')) { $offerSsl = true; } } $socketInfo = ''; if ($offerPostgres) { $socketInfo = $this->translate('For using unix domain sockets, specify the path to the unix domain socket directory'); } elseif ($offerMysql) { $socketInfo = $this->translate('For using unix domain sockets, specify localhost'); } $this->addElement('text', 'name', array('required' => true, 'label' => $this->translate('Resource Name'), 'description' => $this->translate('The unique name of this resource'))); $this->addElement('select', 'db', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('Database Type'), 'description' => $this->translate('The type of SQL database'), 'multiOptions' => $dbChoices)); $this->addElement('text', 'host', array('required' => true, 'label' => $this->translate('Host'), 'description' => $this->translate('The hostname of the database') . ($socketInfo ? '. ' . $socketInfo : ''), 'value' => 'localhost')); $this->addElement('number', 'port', array('description' => $this->translate('The port to use'), 'label' => $this->translate('Port'), 'preserveDefault' => true, 'required' => $offerPostgres, 'value' => $offerPostgres ? 5432 : null)); $this->addElement('text', 'dbname', array('required' => true, 'label' => $this->translate('Database Name'), 'description' => $this->translate('The name of the database to use'))); $this->addElement('text', 'username', array('required' => true, 'label' => $this->translate('Username'), 'description' => $this->translate('The user name to use for authentication'))); $this->addElement('password', 'password', array('renderPassword' => true, 'label' => $this->translate('Password'), 'description' => $this->translate('The password to use for authentication'))); $this->addElement('text', 'charset', array('description' => $this->translate('The character set for the database'), 'label' => $this->translate('Character Set'))); $this->addElement('checkbox', 'persistent', array('description' => $this->translate('Check this box for persistent database connections. Persistent connections are not closed at the' . ' end of a request, but are cached and re-used. This is experimental'), 'label' => $this->translate('Persistent'))); if ($offerSsl) { $this->addElement('checkbox', 'use_ssl', array('autosubmit' => true, 'label' => $this->translate('Use SSL'), 'description' => $this->translate('Whether to encrypt the connection or to authenticate using certificates'))); if (isset($formData['use_ssl']) && $formData['use_ssl']) { $this->addElement('text', 'ssl_key', array('label' => $this->translate('SSL Key'), 'description' => $this->translate('The client key file path'))); $this->addElement('text', 'ssl_cert', array('label' => $this->translate('SSL Certificate'), 'description' => $this->translate('The certificate file path'))); $this->addElement('text', 'ssl_ca', array('label' => $this->translate('SSL CA'), 'description' => $this->translate('The CA certificate file path'))); $this->addElement('text', 'ssl_capath', array('label' => $this->translate('SSL CA Path'), 'description' => $this->translate('The trusted CA certificates in PEM format directory path'))); $this->addElement('text', 'ssl_cipher', array('label' => $this->translate('SSL Cipher'), 'description' => $this->translate('The list of permissible ciphers'))); } } return $this; }
public function createElements(array $formData) { $this->addElement('text', 'name', array('required' => true, 'value' => 'icinga', 'label' => $this->translate('Backend Name'), 'description' => $this->translate('The identifier of this backend'))); $resourceTypes = array(); if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { $resourceTypes['ido'] = 'IDO'; } // $resourceTypes['livestatus'] = 'Livestatus'; $this->addElement('select', 'type', array('required' => true, 'label' => $this->translate('Backend Type'), 'description' => $this->translate('The data source used for retrieving monitoring information'), 'multiOptions' => $resourceTypes)); }
/** * @see Form::createElements() */ public function createElements(array $formData) { $storageTypes = array(); $storageTypes['ini'] = $this->translate('File System (INI Files)'); if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { $storageTypes['db'] = $this->translate('Database'); } $storageTypes['none'] = $this->translate('Don\'t Store Preferences'); $this->addElement('select', 'store', array('required' => true, 'label' => $this->translate('User Preference Storage Type'), 'multiOptions' => $storageTypes)); }
/** * Create and add elements to this form * * @param array $formData The data sent by the user */ public function createElements(array $formData) { $dbChoices = array(); if (Platform::hasMysqlSupport()) { $dbChoices['mysql'] = 'MySQL'; } if (Platform::hasPostgresqlSupport()) { $dbChoices['pgsql'] = 'PostgreSQL'; } if (Platform::hasMssqlSupport()) { $dbChoices['mssql'] = 'MSSQL'; } if (Platform::hasOracleSupport()) { $dbChoices['oracle'] = 'Oracle'; } if (Platform::hasOciSupport()) { $dbChoices['oci'] = 'Oracle (OCI8)'; } $offerPostgres = false; $offerMysql = false; if (isset($formData['db'])) { if ($formData['db'] === 'pgsql') { $offerPostgres = true; } elseif ($formData['db'] === 'mysql') { $offerMysql = true; } } else { $dbChoice = key($dbChoices); if ($dbChoice === 'pgsql') { $offerPostgres = true; } elseif ($dbChoices === 'mysql') { $offerMysql = true; } } $socketInfo = ''; if ($offerPostgres) { $socketInfo = $this->translate('For using unix domain sockets, specify the path to the unix domain socket directory'); } elseif ($offerMysql) { $socketInfo = $this->translate('For using unix domain sockets, specify localhost'); } $this->addElement('text', 'name', array('required' => true, 'label' => $this->translate('Resource Name'), 'description' => $this->translate('The unique name of this resource'))); $this->addElement('select', 'db', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('Database Type'), 'description' => $this->translate('The type of SQL database'), 'multiOptions' => $dbChoices)); $this->addElement('text', 'host', array('required' => true, 'label' => $this->translate('Host'), 'description' => $this->translate('The hostname of the database') . ($socketInfo ? '. ' . $socketInfo : ''), 'value' => 'localhost')); $this->addElement('number', 'port', array('description' => $this->translate('The port to use'), 'label' => $this->translate('Port'), 'preserveDefault' => true, 'required' => $offerPostgres, 'value' => $offerPostgres ? 5432 : null)); $this->addElement('text', 'dbname', array('required' => true, 'label' => $this->translate('Database Name'), 'description' => $this->translate('The name of the database to use'))); $this->addElement('text', 'username', array('required' => true, 'label' => $this->translate('Username'), 'description' => $this->translate('The user name to use for authentication'))); $this->addElement('password', 'password', array('required' => true, 'renderPassword' => true, 'label' => $this->translate('Password'), 'description' => $this->translate('The password to use for authentication'))); $this->addElement('text', 'charset', array('description' => $this->translate('The character set for the database'), 'label' => $this->translate('Character Set'))); $this->addElement('checkbox', 'persistent', array('description' => $this->translate('Check this box for persistent database connections. Persistent connections are not closed at the' . ' end of a request, but are cached and re-used. This is experimental'), 'label' => $this->translate('Persistent'))); return $this; }
/** * @see Form::createElements() */ public function createElements(array $formData) { if (isset($formData['type']) && $formData['type'] === 'external' && !isset($_SERVER['REMOTE_USER'])) { $this->info($this->translate('You\'re currently not authenticated using any of the web server\'s authentication ' . 'mechanisms. Make sure you\'ll configure such, otherwise you\'ll not be able to ' . 'log into Icinga Web 2.'), false); } $backendTypes = array(); if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { $backendTypes['db'] = $this->translate('Database'); } if (Platform::extensionLoaded('ldap')) { $backendTypes['ldap'] = 'LDAP'; } $backendTypes['external'] = $this->translate('External'); $this->addElement('select', 'type', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('Authentication Type'), 'description' => $this->translate('The type of authentication to use when accessing Icinga Web 2'), 'multiOptions' => $backendTypes)); }
/** * @see Form::createElements() */ public function createElements(array $formData) { $dbChoices = array(); if (Platform::hasMysqlSupport()) { $dbChoices['mysql'] = 'MySQL'; } if (Platform::hasPostgresqlSupport()) { $dbChoices['pgsql'] = 'PostgreSQL'; } $this->addElement('text', 'name', array('required' => true, 'label' => $this->translate('Resource Name'), 'description' => $this->translate('The unique name of this resource'))); $this->addElement('select', 'db', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('Database Type'), 'description' => $this->translate('The type of SQL database'), 'multiOptions' => $dbChoices)); $this->addElement('text', 'host', array('required' => true, 'label' => $this->translate('Host'), 'description' => $this->translate('The hostname of the database'), 'value' => 'localhost')); $this->addElement('number', 'port', array('required' => true, 'preserveDefault' => true, 'label' => $this->translate('Port'), 'description' => $this->translate('The port to use'), 'value' => !array_key_exists('db', $formData) || $formData['db'] === 'mysql' ? 3306 : 5432)); $this->addElement('text', 'dbname', array('required' => true, 'label' => $this->translate('Database Name'), 'description' => $this->translate('The name of the database to use'))); $this->addElement('text', 'username', array('required' => true, 'label' => $this->translate('Username'), 'description' => $this->translate('The user name to use for authentication'))); $this->addElement('password', 'password', array('required' => true, 'renderPassword' => true, 'label' => $this->translate('Password'), 'description' => $this->translate('The password to use for authentication'))); return $this; }
/** * @see Form::createElemeents() */ public function createElements(array $formData) { $resourceType = isset($formData['type']) ? $formData['type'] : 'db'; $resourceTypes = array('file' => $this->translate('File'), 'livestatus' => 'Livestatus', 'ssh' => $this->translate('SSH Identity')); if ($resourceType === 'ldap' || Platform::extensionLoaded('ldap')) { $resourceTypes['ldap'] = 'LDAP'; } if ($resourceType === 'db' || Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { $resourceTypes['db'] = $this->translate('SQL Database'); } $this->addElement('select', 'type', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('Resource Type'), 'description' => $this->translate('The type of resource'), 'multiOptions' => $resourceTypes, 'value' => $resourceType)); if (isset($formData['force_creation']) && $formData['force_creation']) { // In case another error occured and the checkbox was displayed before $this->addElement($this->getForceCreationCheckbox()); } $this->addElements($this->getResourceForm($resourceType)->createElements($formData)->getElements()); }