1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Theme functions for ldap_user module.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Turns array of variables to a form embedded in one table for each ldap server.
|
10
|
*/
|
11
|
function theme_ldap_user_conf_form($variables) {
|
12
|
|
13
|
$form = $variables['form'];
|
14
|
$tables = [];
|
15
|
|
16
|
foreach ($form as $key => $element) {
|
17
|
$parts = explode('__', $key);
|
18
|
if (count($parts) == 4 && isset($element['#row']) && isset($element['#col'])) {
|
19
|
list($direction, $discard, $column_name, $i) = $parts;
|
20
|
$row = $element['#row'];
|
21
|
$col = $element['#col'];
|
22
|
$tables[$direction]['rows'][$row][$col] = ['data' => drupal_render($form[$key]), 'class' => ['module'], 'colspan' => 1];
|
23
|
}
|
24
|
}
|
25
|
|
26
|
$output = drupal_render_children($form);
|
27
|
$ldap_user_conf_admin = ldap_user_conf('admin');
|
28
|
|
29
|
foreach ($tables as $direction => $table) {
|
30
|
if ($direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER) {
|
31
|
|
32
|
$direction_text = 'todrupal';
|
33
|
|
34
|
$header = [
|
35
|
[
|
36
|
'data' => t('Remove'),
|
37
|
'rowspan' => 1,
|
38
|
'class' => 'mixedcase',
|
39
|
],
|
40
|
[
|
41
|
'data' => t('Source LDAP Tokens. (See http://drupal.org/node/1245736) ') ,
|
42
|
'class' => 'mixedcase',
|
43
|
'rowspan' => 1,
|
44
|
'colspan' => 2,
|
45
|
],
|
46
|
[
|
47
|
'data' => t('Target Drupal Attribute'),
|
48
|
'rowspan' => 1,
|
49
|
'class' => 'mixedcase',
|
50
|
],
|
51
|
[
|
52
|
'data' => t('When Should Attribute Be Synchronized to Drupal?'),
|
53
|
'colspan' => count($ldap_user_conf_admin->provisionsDrupalEvents),
|
54
|
'rowspan' => 1,
|
55
|
'class' => 'mixedcase',
|
56
|
],
|
57
|
|
58
|
];
|
59
|
|
60
|
$second_header = [
|
61
|
[
|
62
|
'data' => t(''),
|
63
|
'header' => TRUE,
|
64
|
'class' => 'mixedcase',
|
65
|
],
|
66
|
[
|
67
|
'data' => t('e.g: "[sn]", "[mail:0]", "[ou:last]", "[sn], [givenName]" etc.
|
68
|
Constants such as "17" or "imported" should not be enclosed in [].'),
|
69
|
'header' => TRUE,
|
70
|
'class' => 'mixedcase',
|
71
|
],
|
72
|
[
|
73
|
'data' => t('Convert From Binary?'),
|
74
|
'class' => 'mixedcase',
|
75
|
'header' => TRUE,
|
76
|
],
|
77
|
[
|
78
|
'data' => "",
|
79
|
'header' => TRUE,
|
80
|
],
|
81
|
];
|
82
|
|
83
|
foreach ($ldap_user_conf_admin->provisionsDrupalEvents as $col_id => $col_name) {
|
84
|
$second_header[] = ['data' => $col_name, 'header' => TRUE, 'class' => 'mixedcase'];
|
85
|
}
|
86
|
}
|
87
|
// To ldap.
|
88
|
else {
|
89
|
|
90
|
$direction_text = 'toldap';
|
91
|
|
92
|
$header = [
|
93
|
[
|
94
|
'data' => t('Remove'),
|
95
|
'rowspan' => 1,
|
96
|
'class' => 'mixedcase',
|
97
|
],
|
98
|
[
|
99
|
'data' => t('Source Drupal User Attribute') ,
|
100
|
'class' => 'mixedcase',
|
101
|
'rowspan' => 1,
|
102
|
'colspan' => 3,
|
103
|
],
|
104
|
[
|
105
|
'data' => t('Target LDAP Token'),
|
106
|
'rowspan' => 1,
|
107
|
'class' => 'mixedcase',
|
108
|
],
|
109
|
[
|
110
|
'data' => t('When Should Attribute Be Synchronized to LDAP?'),
|
111
|
'colspan' => count($ldap_user_conf_admin->provisionsLdapEvents),
|
112
|
'rowspan' => 1,
|
113
|
'class' => 'mixedcase',
|
114
|
],
|
115
|
];
|
116
|
|
117
|
$second_header = [
|
118
|
[
|
119
|
'data' => t(''),
|
120
|
'header' => TRUE,
|
121
|
],
|
122
|
[
|
123
|
'data' => t('(Select "user tokens" to use token field)'),
|
124
|
'header' => TRUE,
|
125
|
'class' => 'mixedcase',
|
126
|
],
|
127
|
[
|
128
|
'data' => t('Source Drupal User tokens such as: "[property.name]", "[field.field_fname] [field.field_lname]". Constants such as "from_drupal" or "18" should not be enclosed in []'),
|
129
|
'header' => TRUE,
|
130
|
'class' => 'mixedcase',
|
131
|
],
|
132
|
[
|
133
|
'data' => t('Convert From Binary'),
|
134
|
'header' => TRUE,
|
135
|
'class' => 'mixedcase',
|
136
|
],
|
137
|
[
|
138
|
'data' => t('Use singular token format such as [sn], [givenName], etc.'),
|
139
|
'header' => TRUE,
|
140
|
'class' => 'mixedcase',
|
141
|
],
|
142
|
];
|
143
|
foreach ($ldap_user_conf_admin->provisionsLdapEvents as $col_id => $col_name) {
|
144
|
$second_header[] = ['data' => $col_name, 'header' => TRUE, 'class' => 'mixedcase'];
|
145
|
}
|
146
|
}
|
147
|
|
148
|
// #col is ignored, so sort table columns here.
|
149
|
foreach ($table['rows'] as $row_id => $row) {
|
150
|
$discard = ksort($row);
|
151
|
$table['rows'][$row_id] = $row;
|
152
|
}
|
153
|
|
154
|
$table['header'] = $header;
|
155
|
$table['attributes'] = ['class' => ['ldap-provision-' . $direction_text]];
|
156
|
array_unshift($table['rows'], $second_header);
|
157
|
$table_themed = theme('table', $table);
|
158
|
$rendered_table = theme('table', $table);
|
159
|
$output = str_replace('[replace_with_table__' . $direction . ']', $rendered_table, $output);
|
160
|
}
|
161
|
|
162
|
return $output;
|
163
|
|
164
|
}
|