Commit ed0d01ed authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Gerrit Code Review

Merge "Bug 1855358: Update the login box"

parents 631ac26e 1c22867c
......@@ -1709,7 +1709,8 @@ function auth_get_login_form() {
'pluginname' => 'internal',
'elements' => $elements,
'dieaftersubmit' => false,
'iscancellable' => false
'iscancellable' => false,
'hiderequiredheader' => (!empty($elements['login_extra']) ? true : false),
);
return $form;
......@@ -1762,10 +1763,12 @@ function auth_get_login_form_elements() {
);
$elements = array(
'login' => array(
'type' => 'container',
'class' => 'login form-condensed',
'isformgroup' => false,
'elements' => $elements
'type' => 'fieldset',
'class' => 'login_internal',
'legend' => get_string('alternativelogins', 'auth'),
'collapsible' => true,
'collapsed' => true,
'elements' => $elements
)
);
......@@ -1784,34 +1787,34 @@ function auth_get_login_form_elements() {
$showbasicform = true;
}
}
if (!empty($extraelements) && $showbasicform) {
$loginlabel = array(
'type' => 'markup',
'value' => '<p><a name="sso" />' . get_string('orloginvia') . '</p>'
);
$extraelements = array_merge(array('label' => $loginlabel), $extraelements);
$keys = array_keys($extraelements);
if (!empty($keys)) {
$key = $keys[count($keys) - 1];
}
}
if (count($extraelements)) {
$extraelements = array(
'login_extra' => array(
'type' => 'container',
'class' => 'login_extra panel-footer text-small',
'class' => 'login_extra',
'isformgroup' => false,
'elements' => $extraelements
)
);
}
else {
$elements['login']['type'] = 'container';
$elements['login']['class'] = 'login form-condensed';
$elements['login']['isformgroup'] = false;
}
// Replace or supplement the standard login form elements
if ($showbasicform) {
$elements = array_merge($elements, $extraelements);
if ($showbasicform && !empty($extraelements)) {
$elements = array_merge($extraelements, $elements);
}
else {
else if (!$showbasicform && !empty($extraelements)) {
$elements = $extraelements;
}
else if (!$showbasicform) {
// Should we allow having no login options?
$elements = array();
}
return $elements;
}
/**
......@@ -2491,6 +2494,7 @@ function auth_generate_login_form() {
'pluginname' => 'internal',
'autofocus' => false,
'elements' => $elements,
'hiderequiredheader' => (!empty($elements['login_extra']) ? true : false),
)));
return $loginform;
......
......@@ -109,3 +109,11 @@ $string['newkeycreated'] = 'New key / certificate created';
$string['deleteoldkeytext'] = 'Delete old certificate';
$string['oldkeydeleted'] = 'Old key / certificate deleted';
$string['keyrollfailed'] = 'Failed to remove old key / certificate';
// SSO labels
// The SSO buttons will be labelled with the display name of your institution
$string['ssolabelfor'] = '%s login';
// If you want to have a custom label you can either add them here
// or create a htdocs/local/lang/en.utf8/auth.saml.php file and add them there.
// They need to have the key 'login' + shortname of institution, eg:
// For 'testinstitution' it would be: $string['logintestinstitution'] = 'Special label';
......@@ -1484,14 +1484,54 @@ EOF;
* Add "SSO Login" link below the normal login form.
*/
public static function login_form_elements() {
// Check how many active IdPs we can connect to and if it less than four we
// can display sso buttons for them on login block - otherwise have them
// redirect to IdP discovery page
$idps = array();
if ($rawidps = get_records_sql_array("
SELECT aic.value, ai.institution
FROM {auth_instance} ai
JOIN {auth_instance_config} aic ON aic.instance = ai.id
WHERE ai.authname = ?
AND ai.active = ?
AND aic.field = ?
ORDER BY ai.id ASC", array('saml', 1, 'institutionidpentityid'))) {
foreach ($rawidps as $rawidp) {
if (!isset($idps[$rawidp->value])) {
$idps[$rawidp->value] = $rawidp;
}
}
}
$url = get_config('wwwroot') . 'auth/saml/index.php';
if (param_exists('login')) {
// We're on the transient login page. Redirect back to original page once we're done.
$url .= '?wantsurl=' . urlencode(get_full_script_path());
}
$value = '<div class="login-externallink">';
if (count($idps) < 4) {
foreach ($idps as $idp) {
$idpurl = $url;
$idpurl .= param_exists('login') ? '&' : '?';
$idpurl .= 'idpentityid=' . $idp->value;
if (string_exists('login' . $idp->institution, 'auth.saml')) {
// we use custom string defined in auth.saml
$ssolabel = get_string('login' . $idp->institution, 'auth.saml');
}
else {
$ssolabel = get_string('ssolabelfor', 'auth.saml', get_field('institution', 'displayname', 'name', $idp->institution));
}
$value .= '<a class="btn btn-primary saml-' . $idp->institution . '" href="' . $idpurl . '">' . $ssolabel . '</a>';
}
}
else {
$value .= '<a class="btn btn-primary" href="' . $url . '">' . get_string('login', 'auth.saml') . '</a>';
}
$value .= '</div>';
$elements = array(
'loginsaml' => array(
'value' => '<div class="login-externallink"><a class="btn btn-primary btn-sm" href="' . $url . '">' . get_string('login', 'auth.saml') . '</a></div>'
'value' => $value
)
);
return $elements;
......
......@@ -82,3 +82,4 @@ $string['warninstitutionregistrationinstitutions'] = array(
1 => "The following institutions have registration enabled:\n %2\$s",
);
$string['warnmultiinstitutionsoff'] = '$cfg->usersuniquebyusername is turned on but the site option \'Users allowed multiple institutions\' is off. This makes no sense, as users will then change institution every time they log in from somewhere else. Please turn this setting on in Administration -> Configure site -> Institution settings.';
$string['alternativelogins'] = 'Administration login';
......@@ -785,7 +785,7 @@ class Pieform {/*{{{*/
if ($this->has_required_fields) {
$result .= '<div class="form-group requiredmarkerdesc';
if ($this->all_required_field_labels_hidden) {
if ($this->all_required_field_labels_hidden || $this->get_property('hiderequiredheader')) {
$result .= ' d-none';
}
$result .= '">' . get_string('requiredfields', 'pieforms', $this->get_property('requiredmarker')) . '</div>';
......
......@@ -237,6 +237,9 @@
// Login card
.login-externallink {
display: inline-block;
a.btn {
margin: 0 5px 5px 0;
}
}
.login-related-links {
......@@ -929,3 +932,11 @@ a.online-users {
margin-top: 10px;
}
}
#login_login_container fieldset {
border-bottom: 1px solid $card-border-color;
h4 a {
font-size: 80%;
font-weight: normal;
}
}
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