Commit 17fe4478 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1579285: Allow the discovery page to show idp logo



If the logo is part of the metadata

To test - see bug report

Also fixing up metadata textarea overlapping the label

behatnotneeded

Change-Id: Ifd1741089724a08d6fa8b31457269b44040ee980
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 1ad5fb90
......@@ -307,15 +307,36 @@ function auth_saml_find_authinstance($saml_attributes) {
* @param string $preferred
*/
function auth_saml_disco_screen($list, $preferred) {
$idps = array();
$lang = current_language();
$lang = strtolower(array_shift(explode('.', $lang)));
$haslogos = false;
foreach ($list as $entityid => $value) {
$desc = $entityid;
$desc = $name = $entityid;
if (isset($value['description'][$lang])) {
$desc = $value['description'][$lang];
}
$idps[]= array('idpentityid' => $entityid, 'description' => $desc);
if (isset($value['name'][$lang])) {
$name = $value['name'][$lang];
}
$idplogo = array();
if (isset($value['UIInfo']) && isset($value['UIInfo']['Logo'])) {
$haslogos = true;
// Fetch logo from provider if given
$logos = $value['UIInfo']['Logo'];
foreach ($logos as $logo) {
if ($logo['lang'] == $lang) {
$idplogo = $logo;
break;
}
}
// None matching the lang wanted so use the first one
if (empty($idplogo)) {
$idplogo = $logos[0];
}
}
$idps[]= array('idpentityid' => $entityid, 'name' => $name, 'description' => $desc, 'logo' => $idplogo);
}
$idps = array(
......@@ -326,20 +347,29 @@ function auth_saml_disco_screen($list, $preferred) {
);
$cols = array(
'logo' => array('name' => get_string('logo', 'auth.saml'),
'template' => 'auth:saml:idplogo.tpl',
'class' => 'short',
'sort' => 'false'),
'idpentityid' => array('name' => get_string('idpentityid', 'auth.saml'),
'template' => 'auth:saml:idpentityid.tpl',
'class' => 'col-sm-3',
'sort' => false),
'description' => array('name' => get_string('institution'),
'description' => array('name' => get_string('idpprovider','auth.saml'),
'sort' => false),
);
if ($haslogos === false) {
unset($cols['logo']);
}
$smarty = smarty_core();
$smarty->assign_by_ref('results', $idps);
$smarty->assign('cols', $cols);
$smarty->assign('pagedescriptionhtml', get_string('selectidp', 'auth.saml'));
$idps = $smarty->fetch('auth:saml:idptable.tpl');
$smarty = smarty(array(), array(), array(), array('pagehelp' => false, 'sidebars' => false));
$smarty->assign('columns', $cols);
$smarty->assign('idps', $idps);
$smarty->assign('preferred', $preferred);
$smarty->assign('PAGEHEADING', get_string('disco', 'auth.saml'));
......
......@@ -38,6 +38,8 @@ $string['errorregistrationenabledwithautocreate'] = 'An institution has registra
$string['errorremoteuser'] = 'Matching on remoteuser is mandatory if usersuniquebyusername is turned off.';
$string['IdPSelection'] = 'IdP Selection';
$string['noidpsfound'] = 'No IdPs found';
$string['idpentityid'] = 'IdP Entity';
$string['idpprovider'] = 'Provider';
$string['institutionattribute'] = 'Institution attribute (contains "%s")';
$string['institutionidp'] = 'Institution IdP SAML Metadata';
$string['institutionvalue'] = 'Institution value to check against attribute';
......@@ -47,6 +49,7 @@ $string['linkaccounts'] = 'Do you want to link remote account %s with local acco
$string['loginlink'] = 'Allow users to link own account';
$string['logintolink'] = 'Local login to %s to link to remote account';
$string['logintolinkdesc'] = '<p><b>You are currently connected with remote user %s. Please log in with your local account to link them together or register if you do not currently have an account on %s.</b></p>';
$string['logo'] = '';
$string['institutionregex'] = 'Do partial string match with institution shortname';
$string['login'] = 'SSO';
$string['notusable'] = 'Please install the SimpleSAMLPHP SP libraries';
......
......@@ -580,6 +580,7 @@ class PluginAuthSaml extends PluginAuth {
'cols' => 80,
'defaultvalue' => self::$default_config['institutionidp'],
'help' => true,
'class' => 'under-label',
),
'institutionattribute' => array(
'type' => 'text',
......
......@@ -2,8 +2,8 @@
{if $idps}
<p class="lead">{str tag=selectidp section=auth.saml}</p>
{/if}
<div id="idps" class="section panel panel-default">
<h2 class="panel-heading" id="idpsheading">{str tag="IdPSelection" section=auth.saml}</h2>
<div id="idps" class="table-responsive">
<h3 id="idpsheading">{str tag="IdPSelection" section=auth.saml}</h3>
{if $idps}
<div class="table-responsive">
<table id="searchidps" class="table table-striped listing">
......@@ -15,7 +15,7 @@
{if $c.help}
{$c.helplink|safe}
{/if}
{if $c.headhtml}<div style="font-weight: normal;">{$c.headhtml|safe}</div>{/if}
{if $c.headhtml}<div>{$c.headhtml|safe}</div>{/if}
</th>
{/foreach}
</tr>
......
<a href="{$WWWROOT}auth/saml/index.php?idpentityid={$r.idpentityid}" title="{$r.description}">{$r.description}</a>
\ No newline at end of file
<a href="{$WWWROOT}auth/saml/index.php?idpentityid={$r.idpentityid}" title="{$r.description}">{$r.name}</a>
\ No newline at end of file
{if $r.logo.url}
<a href="{$WWWROOT}auth/saml/index.php?idpentityid={$r.idpentityid}" title="{$r.description}">
<img src="{$r.logo.url}" width="{$r.logo.width}" height="{$r.logo.height}" alt="{$r.description}">
</a>
{/if}
\ No newline at end of file
......@@ -428,3 +428,7 @@
}
}
}
#auth_config_institutionidp {
width: 90%;
}
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