/
osso_provider.block.inc
86 lines (77 loc) · 2.7 KB
/
osso_provider.block.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* Generate hub bar.
*/
function osso_provider_block_site_network() {
global $user;
// Generate links to relying parties.
$links = array();
$links['provider'] = array(
'title' => variable_get('site_name', 'Drupal'),
'href' => '<front>',
);
$i = 0;
foreach (openid_provider_sso_relying_parties() as $rp) {
$links["relying {$i}"] = array(
'title' => $rp['name'],
'href' => $rp['realm'],
);
$i++;
}
$output = theme('links', $links, array('class' => 'links site-links'));
// Generate user links.
$links = array();
if ($user->uid) {
$links['username'] = array(
'title' => t('Hello @user', array('@user' => $user->name)),
'href' => 'user/'. $user->uid,
);
$links['logout'] = array(
'title' => t('Log out'),
'href' => 'logout',
);
}
else {
$links['login'] = array(
'title' => t('Log in / Sign up'),
'href' => 'user/login',
);
}
$output .= theme('links', $links, array('class' => 'links user-links'));
return array('content' => $output);
}
/**
* Login page message.
*/
function osso_provider_block_login_message() {
$output = '<div class="sso-message">';
if (isset($_SESSION['openid_provider']['request']['openid.realm']) && $relying_party = openid_provider_sso_relying_party($_SESSION['openid_provider']['request']['openid.realm'])) {
drupal_set_title(t('Login to @relying_party', array('@relying_party' => $relying_party['name'])));
$output .= '<p>'. t('<strong>@relying_party</strong> is part of <strong>@site_name</strong>. ', array('@site_name' => variable_get('site_name', 'Drupal'), '@relying_party' => $relying_party['name'])) .'</p>';
}
$output .= '<p>'. t('An account on @site_name gives you easy access to a series of sites with a single username and password.', array('@site_name' => variable_get('site_name', 'Drupal'))) .'</p>';
$output .= '</div>';
return array(
'subject' => t('User login'),
'content' => $output,
);
}
/**
* Welcome page message.
*/
function osso_provider_block_welcome_message() {
$relying_parties = array();
foreach (variable_get('openid_provider_sso_rps', array()) as $rp) {
$relying_parties[] = $rp['name'];
}
$examples = array_pop($relying_parties);
if ($relying_parties = implode(', ', $relying_parties)) {
$examples = $relying_parties .' or '. $examples;
}
$content = t('<p>@site_name is your key to a host of sites.</p>', array('@site_name' => variable_get('site_name', 'Drupal')));
$content .= t('<p>Create an account once, and gain easy access with one username and password to sites like !examples.</p>', array('!examples' => $examples));
return array(
'title' => t('Welcome'),
'content' => $content,
);
}