Projet

Général

Profil

Paste
Télécharger (1,28 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ldap / ldap_views / handlers / ldap_views_handler_argument_attribute.inc @ 32700c57

1
<?php
2

    
3
/**
4
 * @file
5
 * Basic textfield argument to handle dynamic ldap attributes.
6
 */
7

    
8
/**
9
 *
10
 */
11
class ldap_views_handler_argument_attribute extends views_handler_argument {
12

    
13
  /**
14
   *
15
   */
16
  public function option_definition() {
17
    $options = parent::option_definition();
18
    $options['attribute_name'] = ['default' => ''];
19
    return $options;
20
  }
21

    
22
  /**
23
   *
24
   */
25
  public function options_form(&$form, &$form_state) {
26
    $ldap_data = new LdapQuery(ldap_views_get_qid($this->view));
27

    
28
    if (empty($ldap_data)) {
29
      $form['attribute_name'] = [
30
        '#markup' => 'You must select a valid LDAP search (Advanced::Query settings)',
31
      ];
32
      return;
33
    }
34

    
35
    parent::options_form($form, $form_state);
36

    
37
    $options = [];
38
    foreach ($ldap_data->attributes as $attribute) {
39
      $options[$attribute] = $attribute;
40
    }
41

    
42
    $form['attribute_name'] = [
43
      '#type' => 'select',
44
      '#title' => t('Attribute name'),
45
      '#description' => t('The attribute name from LDAP response'),
46
      '#options' => $options,
47
      '#default_value' => $this->options['attribute_name'],
48
      '#required' => TRUE,
49
    ];
50

    
51
  }
52

    
53
  /**
54
   * Build the query.
55
   */
56
  public function query($group_by = FALSE) {
57
    $this->query->add_where(0, $this->options['attribute_name'], $this->argument, '=');
58
  }
59

    
60
}