Commit 01d11e6c authored by Carsten  Rose's avatar Carsten Rose
Browse files

Bug #5890 config.qfq.ini: migrate LDAP credentials too. Extend T3 internal qfq...

Bug #5890 config.qfq.ini: migrate LDAP credentials too. Extend T3 internal qfq config with 30 'custom'-vars. This replaces the old custom vars in config.qfq.ini
parent 12fe62b5
......@@ -474,9 +474,6 @@ Example: *typo3conf/config.qfq.php*
; DB_2_PASSWORD = <DBPW>
; DB_2_NAME = <DB>
; Access via {{TECHNICAL_CONTACT:Y}}
; TECHNICAL_CONTACT = john@doe.com
; LDAP_1_RDN =
; LDAP_1_PASSWORD =
......@@ -494,15 +491,13 @@ After parsing the configuration, the following variables will be set automatical
Custom variables
^^^^^^^^^^^^^^^^
It's also possible to setup custom variables in `config.qfq.php`.
E.g. to setup a contact address and reuse the information inside your installation do:
Up to 30 custom variables can be defined in `configuration`_.
* `config.qfq.php`::
E.g. to setup a contact address and reuse the information inside your installation do: ::
ADMINISTRATIVE_CONTACT = john@doe.com
ADMINISTRATIVE_ADDRESS = John Doe, Hollywood Blvd. 1, L.A.
ADMINISTRATIVE_NAME = John Doe
custom1: ADMINISTRATIVE_CONTACT = john@doe.com
custom2: ADMINISTRATIVE_ADDRESS = John Doe, Hollywood Blvd. 1, L.A.
custom3: ADMINISTRATIVE_NAME = John Doe
* Somewhere in a `Form` or in `Report`::
......
......@@ -245,5 +245,96 @@ newButtonClass = btn btn-default navbar-btn
newButtonGlyphIcon = glyphicon-plus
# cat=custom/layout; type=string; label=Custom variable 01:Default empty. Can be used the centrally define variables. E.g. "CONTACT_EMAIL = 'john@doe.com'". Retrieve them via '{{CONTACT_EMAIL:Y}}'.
custom1 =
# cat=custom/layout; type=string; label=Custom variable 02
custom2 =
# cat=custom/layout; type=string; label=Custom variable 03
custom3 =
# cat=custom/layout; type=string; label=Custom variable 04
custom4 =
# cat=custom/layout; type=string; label=Custom variable 05
custom5 =
# cat=custom/layout; type=string; label=Custom variable 06
custom6 =
# cat=custom/layout; type=string; label=Custom variable 07
custom7 =
# cat=custom/layout; type=string; label=Custom variable 08
custom8 =
# cat=custom/layout; type=string; label=Custom variable 09
custom9 =
# cat=custom/layout; type=string; label=Custom variable 10
custom10 =
# cat=custom/layout; type=string; label=Custom variable 11
custom11 =
# cat=custom/layout; type=string; label=Custom variable 12
custom12 =
# cat=custom/layout; type=string; label=Custom variable 13
custom13 =
# cat=custom/layout; type=string; label=Custom variable 14
custom14 =
# cat=custom/layout; type=string; label=Custom variable 15
custom15 =
# cat=custom/layout; type=string; label=Custom variable 16
custom16 =
# cat=custom/layout; type=string; label=Custom variable 17
custom17 =
# cat=custom/layout; type=string; label=Custom variable 18
custom18 =
# cat=custom/layout; type=string; label=Custom variable 19
custom19 =
# cat=custom/layout; type=string; label=Custom variable 20
custom20 =
# cat=custom/layout; type=string; label=Custom variable 21
custom21 =
# cat=custom/layout; type=string; label=Custom variable 22
custom22 =
# cat=custom/layout; type=string; label=Custom variable 23
custom23 =
# cat=custom/layout; type=string; label=Custom variable 24
custom24 =
# cat=custom/layout; type=string; label=Custom variable 25
custom25 =
# cat=custom/layout; type=string; label=Custom variable 26
custom26 =
# cat=custom/layout; type=string; label=Custom variable 27
custom27 =
# cat=custom/layout; type=string; label=Custom variable 28
custom28 =
# cat=custom/layout; type=string; label=Custom variable 29
custom29 =
# cat=custom/layout; type=string; label=Custom variable 30
custom30 =
......@@ -20,6 +20,7 @@ require_once(__DIR__ . '/../helper/Support.php');
class Config {
/**
* Migrate config.qfq.ini to config.qfq.php
* @param $configIni
* @param $configPhp
*/
......@@ -30,10 +31,11 @@ class Config {
$pre = isset($config[SYSTEM_DB_NAME]) ? 'DB' : 'DB_1';
$content = '<?php' . PHP_EOL . 'return [' . PHP_EOL;
$content .= " '" . $pre . "_NAME' => '" . $config[$pre . '_NAME'] . "'," . PHP_EOL;
$content .= " '" . $pre . "_PASSWORD' => '" . $config[$pre . '_PASSWORD'] . "'," . PHP_EOL;
$content .= " '" . $pre . "_SERVER' => '" . $config[$pre . '_SERVER'] . "'," . PHP_EOL;
$content .= " '" . $pre . "_USER' => '" . $config[$pre . '_USER'] . "'," . PHP_EOL;
foreach([$pre . '_NAME', $pre . '_PASSWORD', $pre . '_SERVER', $pre . '_USER', SYSTEM_LDAP_1_RDN, SYSTEM_LDAP_1_PASSWORD] as $key){
$content .= " '$key' => '" . $config[$key] . "'," . PHP_EOL;
}
$content .= "];" . PHP_EOL;
// Write new config file
......@@ -43,12 +45,42 @@ class Config {
chmod($configIni, 000);
}
/**
* Iterates over all 30 custom vars, explode them to split between key and value, append to $config.
*
* @param array $config
* @return array
* @throws UserReportException
*/
private function getCustomVariable(array $config) {
for ($i = 1; $i <= 30; $i++) {
if (isset($config['custom' . $i])) {
$arr = explode('=', $config['custom' . $i], 2);
if (!empty($arr[0]) && !empty($arr[1])) {
$arr[0]=trim($arr[0]);
$arr[1]=trim($arr[1]);
if (isset($config[$arr[0]])) {
throw new UserReportException("Variable '$arr[0]' already defined", ERROR_INVALID_OR_MISSING_PARAMETER);
}
$config[$arr[0]] = $arr[1];
}
}
}
return $config;
}
/**
* Read config.qfq.ini.
*
* @param string $configIni
* @return array
* @throws UserFormException
* @throws UserReportException
*/
public function readConfig($configIni = '') {
$configT3qfq = array();
......@@ -89,6 +121,8 @@ class Config {
} catch (\Exception $e) {
throw new qfq\UserFormException ("Error read file " . $pathTypo3Conf . ": " . $e->getMessage(), ERROR_IO_READ_FILE);
}
$configT3qfq = $this->getCustomVariable($configT3qfq);
// Settings in config.qfq.ini overwrite T3 settings
$config = array_merge($configT3qfq, $config);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment