Projet

Général

Profil

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

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

1
<?php
2

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

    
8
class ldap_views_handler_argument_attribute extends views_handler_argument {
9

    
10
  function option_definition() {
11
    $options = parent::option_definition();
12
    $options['attribute_name'] = array('default' => '');
13
    return $options;
14
  }
15

    
16
  function options_form(&$form, &$form_state) {
17
/**
18
    $current_display = $this->view->display[$this->view->current_display];
19
    $qid             = isset($current_display->display_options['query']['options']['qid']) ? $current_display->display_options['query']['options']['qid']
20
                                                                                           : $current_display->handler->default_display->display->display_options['query']['options']['qid'];
21
 */
22
    $ldap_data       = new LdapQuery(ldap_views_get_qid($this->view)); //ldap_data_load($qid);
23

    
24
    if (empty($ldap_data)) {
25
      $form['attribute_name'] = array(
26
        '#markup' => 'You must select a valid LDAP search (Advanced::Query settings)',
27
      );
28
      return;
29
    }
30

    
31
    parent::options_form($form, $form_state);
32

    
33
    $options         = array();
34
    foreach ($ldap_data->attributes as $attribute) {
35
      $options[$attribute] = $attribute;
36
    }
37

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

    
47
  }
48

    
49
  /**
50
   * Build the query
51
   */
52
  function query($group_by = FALSE) {
53
    $this->query->add_where(0, $this->options['attribute_name'], $this->argument, '=');
54
  }
55
}