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