Révision 32700c57
Ajouté par Assos Assos il y a environ 5 ans
drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_filter_attribute.inc | ||
---|---|---|
3 | 3 |
/** |
4 | 4 |
* @file |
5 | 5 |
* Basic textfield filter to handle string filtering commands for a generic ldap attribute |
6 |
* Includes new criterias |
|
6 |
* Includes new criterias.
|
|
7 | 7 |
*/ |
8 | 8 |
|
9 |
/** |
|
10 |
* |
|
11 |
*/ |
|
9 | 12 |
class ldap_views_handler_filter_attribute extends ldap_views_handler_filter { |
10 | 13 |
|
11 | 14 |
/** |
12 | 15 |
* Determine if a filter can be exposed. |
13 | 16 |
*/ |
14 |
function can_expose() { |
|
17 |
public function can_expose() {
|
|
15 | 18 |
return TRUE; |
16 | 19 |
} |
17 | 20 |
|
18 |
function option_definition() { |
|
21 |
/** |
|
22 |
* |
|
23 |
*/ |
|
24 |
public function option_definition() { |
|
19 | 25 |
$options = parent::option_definition(); |
20 |
$options['attribute_name'] = array('default' => '');
|
|
26 |
$options['attribute_name'] = ['default' => ''];
|
|
21 | 27 |
return $options; |
22 | 28 |
} |
23 | 29 |
|
... | ... | |
26 | 32 |
* to add or remove functionality by overriding this function and |
27 | 33 |
* adding/removing items from this array. |
28 | 34 |
*/ |
29 |
function operators() { |
|
30 |
$operators = array(
|
|
31 |
'exists' => array(
|
|
35 |
public function operators() {
|
|
36 |
$operators = [
|
|
37 |
'exists' => [
|
|
32 | 38 |
'title' => t('Exists'), |
33 | 39 |
'method' => 'op_exists', |
34 | 40 |
'short' => t('exists'), |
35 | 41 |
'values' => 0, |
36 |
),
|
|
37 |
'not exists' => array(
|
|
42 |
],
|
|
43 |
'not exists' => [
|
|
38 | 44 |
'title' => t('Not exists'), |
39 | 45 |
'method' => 'op_exists', |
40 | 46 |
'short' => t('not exists'), |
41 | 47 |
'values' => 0, |
42 |
),
|
|
43 |
);
|
|
48 |
],
|
|
49 |
];
|
|
44 | 50 |
|
45 | 51 |
return parent::operators() + $operators; |
46 | 52 |
} |
53 |
|
|
47 | 54 |
/** |
48 |
* Provide a simple textfield for equality |
|
55 |
* Provide a simple textfield for equality.
|
|
49 | 56 |
*/ |
50 |
function value_form(&$form, &$form_state) { |
|
51 |
/* |
|
52 |
$current_display = $this->view->display[$this->view->current_display]; |
|
53 |
$qid = isset($current_display->display_options['query']['options']['qid']) ? $current_display->display_options['query']['options']['qid'] |
|
54 |
: $current_display->handler->default_display->display->display_options['query']['options']['qid']; |
|
55 |
*/ |
|
56 |
$ldap_data = new LdapQuery(ldap_views_get_qid($this->view)); //ldap_data_load($qid); |
|
57 |
public function value_form(&$form, &$form_state) { |
|
58 |
$ldap_data = new LdapQuery(ldap_views_get_qid($this->view)); |
|
57 | 59 |
|
58 | 60 |
if (empty($ldap_data)) { |
59 |
$form['attribute_name'] = array(
|
|
61 |
$form['attribute_name'] = [
|
|
60 | 62 |
'#markup' => 'You must select a valid LDAP search (Advanced::Query settings)', |
61 |
);
|
|
63 |
];
|
|
62 | 64 |
return; |
63 | 65 |
} |
64 | 66 |
|
65 |
$options = array();
|
|
67 |
$options = [];
|
|
66 | 68 |
foreach ($ldap_data->attributes as $attribute) { |
67 | 69 |
$options[$attribute] = $attribute; |
68 | 70 |
} |
69 | 71 |
|
70 | 72 |
if (empty($form_state['exposed'])) { |
71 |
$form['attribute_name'] = array(
|
|
73 |
$form['attribute_name'] = [
|
|
72 | 74 |
'#type' => 'select', |
73 | 75 |
'#title' => t('Attribute name'), |
74 | 76 |
'#description' => t('The attribute name from LDAP response'), |
75 | 77 |
'#options' => $options, |
76 | 78 |
'#default_value' => $this->options['attribute_name'], |
77 | 79 |
'#required' => TRUE, |
78 |
);
|
|
80 |
];
|
|
79 | 81 |
} |
80 | 82 |
|
81 | 83 |
parent::value_form($form, $form_state); |
82 | 84 |
} |
83 |
function op_equal($field) { |
|
85 |
|
|
86 |
/** |
|
87 |
* |
|
88 |
*/ |
|
89 |
public function op_equal($field) { |
|
84 | 90 |
parent::op_equal($this->options['attribute_name']); |
85 | 91 |
} |
86 | 92 |
|
87 |
function op_contains($field) { |
|
93 |
/** |
|
94 |
* |
|
95 |
*/ |
|
96 |
public function op_contains($field) { |
|
88 | 97 |
parent::op_contains($this->options['attribute_name']); |
89 | 98 |
} |
90 | 99 |
|
91 |
function op_starts($field) { |
|
100 |
/** |
|
101 |
* |
|
102 |
*/ |
|
103 |
public function op_starts($field) { |
|
92 | 104 |
parent::op_starts($this->options['attribute_name']); |
93 | 105 |
} |
94 | 106 |
|
95 |
function op_not_starts($field) { |
|
107 |
/** |
|
108 |
* |
|
109 |
*/ |
|
110 |
public function op_not_starts($field) { |
|
96 | 111 |
parent::op_not_starts($this->options['attribute_name']); |
97 | 112 |
} |
98 | 113 |
|
99 |
function op_ends($field) { |
|
114 |
/** |
|
115 |
* |
|
116 |
*/ |
|
117 |
public function op_ends($field) { |
|
100 | 118 |
parent::op_ends($this->options['attribute_name']); |
101 | 119 |
} |
102 | 120 |
|
103 |
function op_not_ends($field) { |
|
121 |
/** |
|
122 |
* |
|
123 |
*/ |
|
124 |
public function op_not_ends($field) { |
|
104 | 125 |
parent::op_not_ends($this->options['attribute_name']); |
105 | 126 |
} |
106 | 127 |
|
107 |
function op_not($field) { |
|
128 |
/** |
|
129 |
* |
|
130 |
*/ |
|
131 |
public function op_not($field) { |
|
108 | 132 |
parent::op_not($this->options['attribute_name']); |
109 | 133 |
} |
110 | 134 |
|
111 |
function op_greater_eq($field) { |
|
135 |
/** |
|
136 |
* |
|
137 |
*/ |
|
138 |
public function op_greater_eq($field) { |
|
112 | 139 |
parent::op_greater_eq($this->options['attribute_name']); |
113 | 140 |
} |
114 | 141 |
|
115 |
function op_less_eq($field) { |
|
142 |
/** |
|
143 |
* |
|
144 |
*/ |
|
145 |
public function op_less_eq($field) { |
|
116 | 146 |
parent::op_less_eq($this->options['attribute_name']); |
117 | 147 |
} |
118 | 148 |
|
119 |
function op_exists($field) { |
|
149 |
/** |
|
150 |
* |
|
151 |
*/ |
|
152 |
public function op_exists($field) { |
|
120 | 153 |
parent::op_exists($this->options['attribute_name']); |
121 | 154 |
} |
122 | 155 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules