-
Notifications
You must be signed in to change notification settings - Fork 1
/
surfconext.theme.inc
96 lines (82 loc) · 2.12 KB
/
surfconext.theme.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
87
88
89
90
91
92
93
94
95
96
<?php
/**
* @file
* Contains all theme related functions.
*/
/**
* Generates the text for the log in block.
*/
function theme_surfconext_login_link() {
global $user;
if (!SurfConext::isEnabled()) {
// Exit without executing.
return;
}
// Check if valid local session exists..
if (SurfConext::isAuthenticated()) {
return '<p>' . t('Logged in as: %name', array('%name', $user->name)) . '<br />' . l(t('Log Out'), 'user/logout') . '</p>';
}
return '<p>' . l(t('SURFconext Log In'), 'user/login/surfconext') . '</p>';
}
/**
* Show any authentication information on current user.
*
* Mainly intended for showing debug information.
*/
function theme_surfconext_info() {
global $user;
// Get the instance.
$surfconext = SurfConext::get();
if (!$surfconext) {
return;
}
// Get the saml attributes.
$attributes = $surfconext->getAttributes();
// Init header.
$header = array(t('Name'), t('Value'));
$rows = array();
foreach ($attributes as $key => $value) {
$rows[] = array($key, implode(',', $value));
}
$form = array();
$form['surfconext'] = array(
'#title' => 'SURFConext authentication attributes',
'#type' => 'fieldset',
'#collapsed' => TRUE,
'#collapsible' => TRUE,
'#attributes' => array('class' => array('collapsible collapsed')),
'#attached' => array('library' => array(array('system', 'drupal.collapse'))),
);
$form['surfconext']['contents'] = array(
'#markup' => theme(
'table',
array(
'header' => $header,
'rows' => $rows,
'empty' => t('No SURFconext attributes found.'),
)
),
);
// Add info about Drupal user.
// Init header.
$header = array(t('Name'), t('Value'));
$rows = array();
if (user_is_logged_in()) {
$rows = array(
array('UID', $user->uid),
array('User', $user->name),
array('Mail', $user->mail),
);
}
$form['surfconext']['drupal'] = array(
'#markup' => theme(
'table',
array(
'header' => $header,
'rows' => $rows,
'empty' => t('Drupal user is not logged in.'),
)
),
);
return drupal_render($form);
}