1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* LDAP field handler
|
6
|
*
|
7
|
* Defines a new class field handler for a default ldap field
|
8
|
*/
|
9
|
class ldap_views_handler_field_attribute extends ldap_views_handler_field {
|
10
|
|
11
|
|
12
|
function option_definition() {
|
13
|
$options = parent::option_definition();
|
14
|
$options['attribute_name'] = array('default' => '');
|
15
|
return $options;
|
16
|
}
|
17
|
|
18
|
/*
|
19
|
* Add the field for the LDAP Attribute
|
20
|
*/
|
21
|
function options_form(&$form, &$form_state) {
|
22
|
/**
|
23
|
$current_display = $this->view->display[$this->view->current_display];
|
24
|
$qid = isset($current_display->display_options['query']['options']['qid']) ? $current_display->display_options['query']['options']['qid']
|
25
|
: $current_display->handler->default_display->display->display_options['query']['options']['qid'];
|
26
|
*/
|
27
|
$ldap_data = new LdapQuery(ldap_views_get_qid($this->view)); //ldap_data_load($qid);
|
28
|
|
29
|
if (empty($ldap_data)) {
|
30
|
$form['attribute_name'] = array(
|
31
|
'#markup' => 'You must select a valid LDAP search (Advanced::Query settings)',
|
32
|
);
|
33
|
return;
|
34
|
}
|
35
|
|
36
|
parent::options_form($form, $form_state);
|
37
|
|
38
|
$options = array();
|
39
|
foreach ($ldap_data->attributes as $attribute) {
|
40
|
$options[$attribute] = $attribute;
|
41
|
}
|
42
|
|
43
|
$form['attribute_name'] = array(
|
44
|
'#type' => 'select',
|
45
|
'#title' => t('Attribute name'),
|
46
|
'#description' => t('The attribute name from LDAP response'),
|
47
|
'#options' => $options,
|
48
|
'#default_value' => $this->options['attribute_name'],
|
49
|
'#required' => TRUE,
|
50
|
);
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* Called to add the field to a query.
|
55
|
*/
|
56
|
function query() {
|
57
|
$this->real_field = $this->options['attribute_name'];
|
58
|
parent::query();
|
59
|
}
|
60
|
}
|