Skip to content
Snippets Groups Projects
Unverified Commit d3369b2b authored by Pavel Vyskočil's avatar Pavel Vyskočil Committed by GitHub
Browse files

Merge pull request #9 from BaranekD/discoToConfig

addInstitution URL and email in disco-tpl.php are loaded from a config file
parents 71550428 a79c551f
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
[Changed]
- Changed code style to PSR-2
- addInstitution URL and email in disco-tpl.php are loaded from a config file
## [v2.2.0]
[Added]
......
......@@ -36,6 +36,10 @@ const WARNING_USER_CAN_CONTINUE = 'userCanContinue';
const WARNING_TITLE = 'title';
const WARNING_TEXT = 'text';
const PERUN_CONFIG_FILE_NAME = 'module_perun.php';
const ADD_INSTITUTION_URL = 'disco.addInstitution.URL';
const ADD_INSTITUTION_EMAIL = 'disco.addInstitution.email';
const URN_CESNET_PROXYIDP_IDPENTITYID = "urn:cesnet:proxyidp:idpentityid:";
$authContextClassRef = null;
......@@ -45,17 +49,43 @@ $warningIsOn = false;
$warningUserCanContinue = null;
$warningTitle = null;
$warningText = null;
$config = null;
$configWarning = null;
$configPerun = null;
$addInstitutionUrl = '';
$addInstitutionEmail = '';
try {
$config = Configuration::getConfig(WARNING_CONFIG_FILE_NAME);
$configWarning = Configuration::getConfig(WARNING_CONFIG_FILE_NAME);
} catch (\Exception $ex) {
Logger::warning("bbmri:disco-tpl: missing or invalid config-warning file");
}
if ($config != null) {
try {
$configPerun = Configuration::getConfig(PERUN_CONFIG_FILE_NAME);
} catch (\Exception $ex) {
Logger::warning("bbmri:disco-tpl: invalid module_perun.php file");
}
if (!is_null($configPerun)) {
try {
$warningIsOn = $config->getBoolean(WARNING_IS_ON);
$addInstitutionUrl = $configPerun->getString(ADD_INSTITUTION_URL);
} catch (\Exception $ex) {
Logger::warning("bbmri:disco-tpl: missing or invalid addInstitution.URL parameter in module_perun.php file");
}
}
if (!is_null($configPerun)) {
try {
$addInstitutionEmail = $configPerun->getString(ADD_INSTITUTION_EMAIL);
} catch (\Exception $ex) {
Logger::warning("bbmri:disco-tpl: missing or invalid addInstitution.email parameter in module_perun.php file");
}
}
if ($configWarning != null) {
try {
$warningIsOn = $configWarning->getBoolean(WARNING_IS_ON);
} catch (\Exception $ex) {
Logger::warning("bbmri:disco-tpl: missing or invalid isOn parameter in config-warning file");
$warningIsOn = false;
......@@ -64,7 +94,7 @@ if ($config != null) {
if ($warningIsOn) {
try {
$warningUserCanContinue = $config->getBoolean(WARNING_USER_CAN_CONTINUE);
$warningUserCanContinue = $configWarning->getBoolean(WARNING_USER_CAN_CONTINUE);
} catch (\Exception $ex) {
Logger::warning(
"bbmri:disco-tpl: missing or invalid userCanContinue parameter in config-warning file"
......@@ -72,8 +102,8 @@ if ($warningIsOn) {
$warningUserCanContinue = true;
}
try {
$warningTitle = $config->getString(WARNING_TITLE);
$warningText = $config->getString(WARNING_TEXT);
$warningTitle = $configWarning->getString(WARNING_TITLE);
$warningText = $configWarning->getString(WARNING_TEXT);
if (empty($warningTitle) || empty($warningText)) {
throw new Exception();
}
......@@ -174,9 +204,9 @@ if (!$warningIsOn || $warningUserCanContinue) {
echo '<div class="no-idp-found alert alert-info">';
if ($this->isAddInstitutionApp()) {
echo $this->t('{bbmri:bbmri:cannot_find_institution}') .
'<a href="mailto:aai-infrastructure@lists.bbmri-eric.eu?subject=Request%20for%20adding%20new%20IdP">
aai-infrastructure@lists.bbmri-eric.eu
</a>';
'<a href="mailto:' . $addInstitutionEmail . '?subject=Request%20for%20adding%20new%20IdP">' .
$addInstitutionEmail .
'</a>';
echo '<div class="metalist list-group">';
echo '<a class="btn btn-block social"' .
'href="https://adm.hostel.eduid.cz/registrace/k1" style="background: #43554a">';
......@@ -186,7 +216,7 @@ if (!$warningIsOn || $warningUserCanContinue) {
echo '</div>';
} else {
echo $this->t('{bbmri:bbmri:cannot_find_institution_extended}') .
'<a class="btn btn-primary" href="https://login.bbmri-eric.eu/add-institution/">' .
'<a class="btn btn-primary" href="' . $addInstitutionUrl . '">' .
$this->t('{bbmri:bbmri:add_institution}') .
'</a>';
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment