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 @ 7547bb19

1
<?php
2

    
3
/**
4
 * @file
5
 * Basic textfield argument to handle dynamic ldap attributes
6
 */
7
class ldap_views_handler_argument_attribute extends views_handler_argument {
8

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

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

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

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

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

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

    
46
  }
47

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