diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d3a7427b39daaf56fadbece16472306d016945c..f7e61244cad2715cd0fb01f42e6e1c765a69c0ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/themes/bbmri/perun/disco-tpl.php b/themes/bbmri/perun/disco-tpl.php index 1b8e1c543f5b0510d366dbcd03c1f8c6279b430e..b74930a53eca6a24d2752d2262c639c01227134c 100644 --- a/themes/bbmri/perun/disco-tpl.php +++ b/themes/bbmri/perun/disco-tpl.php @@ -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>'; }