1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Provides settings pages for the CAS LDAP module.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Lists available CAS Attributes.
|
10
|
*/
|
11
|
function cas_ldap_list() {
|
12
|
$cas_attr_ldap_server = variable_get('cas_attributes_ldap_server', NULL);
|
13
|
|
14
|
if (empty($cas_attr_ldap_server)) {
|
15
|
// No CAS server configured.
|
16
|
return t('An <a href="@url">LDAP server</a> must be selected.', array('@url' => url('admin/config/people/cas/attributes')));
|
17
|
}
|
18
|
$ldap_server = ldap_servers_get_servers($cas_attr_ldap_server, 'enabled', TRUE);
|
19
|
|
20
|
if (empty($ldap_server->testingDrupalUsername)) {
|
21
|
return t('Please configure the LDAP server\'s <a href="@url">testing Drupal username</a>.', array('@url' => url('admin/config/people/ldap/servers/edit/' . $ldap_server->sid)));
|
22
|
}
|
23
|
|
24
|
$header = array('Token', 'Value');
|
25
|
$rows = array();
|
26
|
|
27
|
$attributes = cas_ldap_attributes($ldap_server->testingDrupalUsername);
|
28
|
foreach ($attributes as $attribute => $value) {
|
29
|
if (is_numeric($attribute)) {
|
30
|
continue;
|
31
|
}
|
32
|
if (is_array($value)) {
|
33
|
$value = $value[0];
|
34
|
}
|
35
|
$rows[] = array(
|
36
|
t('[cas:ldap:@attribute]', array('@attribute' => drupal_strtolower($attribute))),
|
37
|
check_plain($value),
|
38
|
);
|
39
|
}
|
40
|
|
41
|
if (empty($rows)) {
|
42
|
$rows[] = array(
|
43
|
'data' => array(
|
44
|
array(
|
45
|
'data' => t('No LDAP attributes were returned by the LDAP server. Please ensure the <a href="@url">LDAP server</a> is configured correctly.', array('@url' => url('admin/config/people/ldap/servers/edit/' . $ldap_server->sid))),
|
46
|
'colspan' => 2,
|
47
|
),
|
48
|
),
|
49
|
);
|
50
|
}
|
51
|
|
52
|
return theme('table', array('header' => $header, 'rows' => $rows));
|
53
|
}
|
54
|
|