function generate_login_text in Shibboleth Authentication 6.3
Same name and namespace in other branches
- 5.3 shib_auth.module \generate_login_text()
- 5.2 shib_auth.module \generate_login_text()
- 6 shib_auth.module \generate_login_text()
- 6.2 shib_auth.module \generate_login_text()
Generate the login text in HTML format using the 't' function @returns HTML text of the login form
2 calls to generate_login_text()
- shib_auth_block in ./
shib_auth.module - Generate the HTML text for the shib_auth login block
- shib_auth_form_alter in ./
shib_auth.module - Alters user_login form for the shibboleth authentication module.
File
- ./
shib_auth.module, line 278 - This is a Shibboleth authentication module.
Code
function generate_login_text() {
global $user;
if (!$user->uid) {
$handlerurl = variable_get('shib_auth_handler_url', '/Shibboleth.sso');
$handlerprotocol = variable_get('shib_auth_handler_protocol', 'https');
$wayfuri = variable_get('shib_auth_wayf_uri', '/DS');
// If the WAYF's URI doesn't start with slash then extend it
if (!ereg("^/", $wayfuri)) {
$wayfuri = "/" . $wayfuri;
}
$handler = '';
$block_content = '';
if (ereg("^http[s]{0,1}://", $handlerurl)) {
// If handlerurl is an absolute path
$handler = $handlerurl . $wayfuri;
}
else {
// Else, if the handlerurl is a relative path
// If the WAYF's URI doesn't start with slash then extend it
if (!ereg("^/", $handlerurl)) {
$handlerurl = "/" . $handlerurl;
}
$handler = $handlerprotocol . "://" . $_SERVER['HTTP_HOST'] . $handlerurl . $wayfuri;
}
//Check whether clean url and i18 is enabled, and insert ?q=/ in the return url if not
$url_prefix = '';
if (!module_exists("i18n") && !variable_get('clean_url', FALSE)) {
$url_prefix = '?q=';
}
//$actuallocation: the path where the Shibboleth should return
$actuallocation = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . url('<front>') . $url_prefix . '/shib_login/' . $_GET['q'];
// If there is no session yet then we should put the login text into the block
$block_content .= "<p><b><a href=\"{$handler}?target=" . urlencode($actuallocation) . "\">" . variable_get('auth_link_text', t('Shibboleth Login')) . "</a></b></p>";
return $block_content;
}
}