diff --git a/modules/discopower/lib/PowerIdPDisco.php b/modules/discopower/lib/PowerIdPDisco.php index 7a1d8b59271d340bea862c8b9a1975fc4005edc5..0cfba1369d89724adb53834bf9cbb104a4955d83 100644 --- a/modules/discopower/lib/PowerIdPDisco.php +++ b/modules/discopower/lib/PowerIdPDisco.php @@ -246,6 +246,12 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco $idpList = $this->getIdPList(); $idpList = $this->idplistStructured($this->filterList($idpList)); $preferredIdP = $this->getRecommendedIdP(); + $faventry = NULL; + foreach ($idpList AS $tab => $slist) { + if (!empty($preferredIdP) && array_key_exists($preferredIdP, $slist)) { + $faventry = $slist[$preferredIdP]]; + } + } $t = new SimpleSAML_XHTML_Template($this->config, 'discopower:disco.tpl.php', 'disco'); $discoPowerTabs = array( @@ -262,6 +268,7 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco 'switzerland' => $t->noop('{discopower:tabs:switzerland}'), 'ukacessfederation' => $t->noop('{discopower:tabs:ukacessfederation}'), ); + $t->data['faventry'] = $faventry; $t->data['tabNames'] = $discoPowerTabs; $t->data['idplist'] = $idpList; $t->data['preferredidp'] = $preferredIdP; diff --git a/modules/discopower/templates/disco.tpl.php b/modules/discopower/templates/disco.tpl.php index 2e9afd6819e689b4f427d35d1c9efcbb93c9217c..4e1bf6c42268637afb5b67e719ed44a3f22c5af1 100644 --- a/modules/discopower/templates/disco.tpl.php +++ b/modules/discopower/templates/disco.tpl.php @@ -1,17 +1,5 @@ <?php - -$faventry = NULL; -foreach( $this->data['idplist'] AS $tab => $slist) { - if (!empty($this->data['preferredidp']) && array_key_exists($this->data['preferredidp'], $slist)) - $faventry = $slist[$this->data['preferredidp']]; -} - - - - - - if(!array_key_exists('header', $this->data)) { $this->data['header'] = 'selectidp'; } @@ -31,7 +19,7 @@ $(document).ready(function() { $i = 0; foreach ($this->data['idplist'] AS $tab => $slist) { $this->data['head'] .= "\n" . '$("#query_' . $tab . '").liveUpdate("#list_' . $tab . '")' . - (($i++ == 0) && (empty($faventry)) ? '.focus()' : '') . + (($i++ == 0) && (empty($this->data['faventry'])) ? '.focus()' : '') . ';'; @@ -46,7 +34,7 @@ $this->data['head'] .= ' -if (!empty($faventry)) $this->data['autofocus'] = 'favouritesubmit'; +if (!empty($this->data['faventry'])) $this->data['autofocus'] = 'favouritesubmit'; $this->includeAtTemplateBase('includes/header.php'); @@ -101,20 +89,20 @@ function getTranslatedName($t, $metadata) { -if (!empty($faventry)) { +if (!empty($this->data['faventry'])) { echo('<div class="favourite">'); echo($this->t('previous_auth')); - echo(' <strong>' . htmlspecialchars(getTranslatedName($this, $faventry)) . '</strong>'); + echo(' <strong>' . htmlspecialchars(getTranslatedName($this, $this->data['faventry'])) . '</strong>'); echo(' <form id="idpselectform" method="get" action="' . $this->data['urlpattern'] . '"> <input type="hidden" name="entityID" value="' . htmlspecialchars($this->data['entityID']) . '" /> <input type="hidden" name="return" value="' . htmlspecialchars($this->data['return']) . '" /> <input type="hidden" name="returnIDParam" value="' . htmlspecialchars($this->data['returnIDParam']) . '" /> - <input type="hidden" name="idpentityid" value="' . htmlspecialchars($faventry['entityid']) . '" /> + <input type="hidden" name="idpentityid" value="' . htmlspecialchars($this->data['faventry']['entityid']) . '" /> - <input type="submit" name="formsubmit" id="favouritesubmit" value="' . $this->t('login_at') . ' ' . htmlspecialchars(getTranslatedName($this, $faventry)) . '" /> + <input type="submit" name="formsubmit" id="favouritesubmit" value="' . $this->t('login_at') . ' ' . htmlspecialchars(getTranslatedName($this, $this->data['faventry'])) . '" /> </form>'); echo('</div>');