1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Basic textfield filter to handle string filtering commands for a generic ldap attribute
|
6
|
* Includes new criterias
|
7
|
*/
|
8
|
class ldap_views_handler_filter_attribute extends ldap_views_handler_filter {
|
9
|
|
10
|
/**
|
11
|
* Determine if a filter can be exposed.
|
12
|
*/
|
13
|
function can_expose() {
|
14
|
return TRUE;
|
15
|
}
|
16
|
|
17
|
function option_definition() {
|
18
|
$options = parent::option_definition();
|
19
|
$options['attribute_name'] = array('default' => '');
|
20
|
return $options;
|
21
|
}
|
22
|
|
23
|
/**
|
24
|
* This kind of construct makes it relatively easy for a child class
|
25
|
* to add or remove functionality by overriding this function and
|
26
|
* adding/removing items from this array.
|
27
|
*/
|
28
|
function operators() {
|
29
|
$operators = array(
|
30
|
'exists' => array(
|
31
|
'title' => t('Exists'),
|
32
|
'method' => 'op_exists',
|
33
|
'short' => t('exists'),
|
34
|
'values' => 0,
|
35
|
),
|
36
|
'not exists' => array(
|
37
|
'title' => t('Not exists'),
|
38
|
'method' => 'op_exists',
|
39
|
'short' => t('not exists'),
|
40
|
'values' => 0,
|
41
|
),
|
42
|
);
|
43
|
|
44
|
return parent::operators() + $operators;
|
45
|
}
|
46
|
/**
|
47
|
* Provide a simple textfield for equality
|
48
|
*/
|
49
|
function value_form(&$form, &$form_state) {
|
50
|
/*
|
51
|
$current_display = $this->view->display[$this->view->current_display];
|
52
|
$qid = isset($current_display->display_options['query']['options']['qid']) ? $current_display->display_options['query']['options']['qid']
|
53
|
: $current_display->handler->default_display->display->display_options['query']['options']['qid'];
|
54
|
*/
|
55
|
$ldap_data = new LdapQuery(ldap_views_get_qid($this->view)); //ldap_data_load($qid);
|
56
|
|
57
|
if (empty($ldap_data)) {
|
58
|
$form['attribute_name'] = array(
|
59
|
'#markup' => 'You must select a valid LDAP search (Advanced::Query settings)',
|
60
|
);
|
61
|
return;
|
62
|
}
|
63
|
|
64
|
$options = array();
|
65
|
foreach ($ldap_data->attributes as $attribute) {
|
66
|
$options[$attribute] = $attribute;
|
67
|
}
|
68
|
|
69
|
if (empty($form_state['exposed'])) {
|
70
|
$form['attribute_name'] = array(
|
71
|
'#type' => 'select',
|
72
|
'#title' => t('Attribute name'),
|
73
|
'#description' => t('The attribute name from LDAP response'),
|
74
|
'#options' => $options,
|
75
|
'#default_value' => $this->options['attribute_name'],
|
76
|
'#required' => TRUE,
|
77
|
);
|
78
|
}
|
79
|
|
80
|
parent::value_form($form, $form_state);
|
81
|
}
|
82
|
function op_equal($field) {
|
83
|
parent::op_equal($this->options['attribute_name']);
|
84
|
}
|
85
|
|
86
|
function op_contains($field) {
|
87
|
parent::op_contains($this->options['attribute_name']);
|
88
|
}
|
89
|
|
90
|
function op_starts($field) {
|
91
|
parent::op_starts($this->options['attribute_name']);
|
92
|
}
|
93
|
|
94
|
function op_not_starts($field) {
|
95
|
parent::op_not_starts($this->options['attribute_name']);
|
96
|
}
|
97
|
|
98
|
function op_ends($field) {
|
99
|
parent::op_ends($this->options['attribute_name']);
|
100
|
}
|
101
|
|
102
|
function op_not_ends($field) {
|
103
|
parent::op_not_ends($this->options['attribute_name']);
|
104
|
}
|
105
|
|
106
|
function op_not($field) {
|
107
|
parent::op_not($this->options['attribute_name']);
|
108
|
}
|
109
|
|
110
|
function op_greater_eq($field) {
|
111
|
parent::op_greater_eq($this->options['attribute_name']);
|
112
|
}
|
113
|
|
114
|
function op_less_eq($field) {
|
115
|
parent::op_less_eq($this->options['attribute_name']);
|
116
|
}
|
117
|
|
118
|
function op_exists($field) {
|
119
|
parent::op_exists($this->options['attribute_name']);
|
120
|
}
|
121
|
|
122
|
}
|