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