1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* theming functions for ldap_servers module
|
6
|
*
|
7
|
*/
|
8
|
|
9
|
/**
|
10
|
* Returns HTML for ldap servers list.
|
11
|
*
|
12
|
* @param $variables
|
13
|
* An associative array containing:
|
14
|
* - ldap_servers: an array of one or more ldap server configurations.
|
15
|
* - actions: true or false indicating include update, delete, etc. links
|
16
|
* - type: 'table', 'list', etc for style to render
|
17
|
*
|
18
|
* @ingroup themeable
|
19
|
*/
|
20
|
function theme_ldap_servers_list($variables) {
|
21
|
extract($variables);
|
22
|
|
23
|
$table = array(
|
24
|
'header' => array(t('Name'), t('Type'), t('Enabled'), t('Server Address')),
|
25
|
'attributes' => array('id' => 'ldap_servers_servers', 'class' => 'data'),
|
26
|
'colgroups' => array(),
|
27
|
'sticky' => FALSE,
|
28
|
'empty' => '',
|
29
|
'caption' => 'LDAP Server Configurations',
|
30
|
);
|
31
|
|
32
|
if ($actions) {
|
33
|
$table['header'][] = "Operations";
|
34
|
}
|
35
|
if (count($ldap_servers)) {
|
36
|
foreach ($ldap_servers as $sid => $ldap_server ) {
|
37
|
$row = array(
|
38
|
$ldap_server->name,
|
39
|
$ldap_server->ldap_type,
|
40
|
($ldap_server->status == 1) ? "Yes" : "No",
|
41
|
$ldap_server->address
|
42
|
);
|
43
|
if ($actions) {
|
44
|
$admin = new LdapServerAdmin($ldap_server->sid);
|
45
|
$row[] = join(' | ', $admin->getLdapServerActions());
|
46
|
}
|
47
|
$table['rows'][] = $row;
|
48
|
}
|
49
|
}
|
50
|
else {
|
51
|
$table['rows'] = array();
|
52
|
}
|
53
|
$output = theme('table', $table);
|
54
|
|
55
|
return $output;
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
* Returns HTML for ldap server.
|
60
|
*
|
61
|
* @param $variables
|
62
|
* An associative array containing:
|
63
|
* - ldap_servers_config: an array of one or more ldap server configurations.
|
64
|
* - actions: true or false indicating include update, delete, etc. links
|
65
|
* - type: 'table', 'list', etc for style to render
|
66
|
*
|
67
|
* @ingroup themeable
|
68
|
*/
|
69
|
|
70
|
function theme_ldap_servers_server($variables) {
|
71
|
extract($variables); // $ldap_server, $actions, $type (see above)
|
72
|
|
73
|
ldap_servers_module_load_include('php', 'ldap_servers', 'LdapServer.class');
|
74
|
$properties = array();
|
75
|
foreach (LdapServer::field_to_properties_map() as $field_name => $property_name) {
|
76
|
$properties[] = "$field_name = " . print_r($ldap_server->$property_name, TRUE);
|
77
|
}
|
78
|
|
79
|
if ($actions) {
|
80
|
$admin = new LdapServerAdmin($ldap_server->sid);
|
81
|
$properties = join(' | ', $admin->getLdapServerActions());
|
82
|
}
|
83
|
|
84
|
$output = theme_item_list(
|
85
|
array(
|
86
|
'items' => $properties,
|
87
|
'type' => 'ul',
|
88
|
'title' => 'Server Properties',
|
89
|
'attributes' => array()
|
90
|
)
|
91
|
);
|
92
|
|
93
|
return $output;
|
94
|
}
|
95
|
|
96
|
function theme_ldap_server_token_table($variables) {
|
97
|
$header = array(
|
98
|
array('data' => 'Token', 'sort' => 'asc'),
|
99
|
array('data' => 'Value'),
|
100
|
);
|
101
|
foreach ($variables['tokens'] as $token => $value) {
|
102
|
$rows[] = array('data' => array($token, $value));
|
103
|
}
|
104
|
$token_table = '<div class="content"><h2>' . t('Available Tokens') . '</h2>' .
|
105
|
theme_table(array('colgroups' => NULL, 'caption' => 'tokens', 'header' => $header, 'rows' => $rows, 'sticky' => TRUE, 'attributes' => array(), 'empty' => 'No data')) .
|
106
|
'</div>';
|
107
|
|
108
|
return $token_table;
|
109
|
}
|
110
|
|
111
|
function theme_ldap_server_ldap_entry_table($variables) {
|
112
|
if (!isset($variables['entry']) || !is_array($variables['entry'])) {
|
113
|
return '<p>' . t('No Entry Returned.') . t('</p>');
|
114
|
}
|
115
|
|
116
|
$header = array('Attribute Name', 'Instance', 'Value', 'token');
|
117
|
$rows = array();
|
118
|
foreach ($variables['entry'] as $key => $value) {
|
119
|
if (is_numeric($key) || $key == 'count') {
|
120
|
}
|
121
|
elseif (count($value) > 1) {
|
122
|
$count = (int)$value['count'];
|
123
|
foreach ($value as $i => $value2) {
|
124
|
|
125
|
if ((string)$i == 'count') {
|
126
|
continue;
|
127
|
}
|
128
|
elseif ($i == 0 && $count == 1) {
|
129
|
$token = LDAP_SERVERS_TOKEN_PRE . $key . LDAP_SERVERS_TOKEN_POST;
|
130
|
}
|
131
|
elseif ($i == 0 && $count > 1) {
|
132
|
$token = LDAP_SERVERS_TOKEN_PRE . $key . LDAP_SERVERS_TOKEN_DEL . '0' . LDAP_SERVERS_TOKEN_POST;
|
133
|
}
|
134
|
elseif (($i == $count - 1) && $count > 1) {
|
135
|
$token = LDAP_SERVERS_TOKEN_PRE . $key . LDAP_SERVERS_TOKEN_DEL . 'last' . LDAP_SERVERS_TOKEN_POST;
|
136
|
}
|
137
|
elseif ($count > 1) {
|
138
|
$token = LDAP_SERVERS_TOKEN_PRE . $key . LDAP_SERVERS_TOKEN_DEL . $i . LDAP_SERVERS_TOKEN_POST;
|
139
|
}
|
140
|
else {
|
141
|
$token = "";
|
142
|
}
|
143
|
$rows[] = array('data' => array($key, $i, ldap_servers_string_binary_check($value2), $token));
|
144
|
}
|
145
|
}
|
146
|
}
|
147
|
$entry_table = '<div class="content"><h2>' . t('LDAP Entry for %username (dn: %dn)', array('%dn' => $variables['dn'], '%username' => $variables['username'])) . '</h2>' . theme('table', array('colgroups' => NULL, 'caption' => 'ldap entry array', 'header' => $header, 'rows' => $rows, 'sticky' => TRUE, 'attributes' => array(), 'empty' => 'No data')) . '</div>';
|
148
|
return $entry_table;
|
149
|
}
|