Projet

Général

Profil

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

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

1
<?php
2

    
3
/**
4
 * @file
5
 * LDAP field handler
6
 *
7
 * Defines a new class field handler for a default ldap field
8
 */
9

    
10
class ldap_views_handler_field_attribute extends ldap_views_handler_field {
11

    
12

    
13
  function option_definition() {
14
    $options = parent::option_definition();
15
    $options['attribute_name'] = array('default' => '');
16
    return $options;
17
  }
18

    
19
  /*
20
   * Add the field for the LDAP Attribute
21
   */
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);
29

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

    
37
    parent::options_form($form, $form_state);
38

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

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

    
54
  /**
55
   * Called to add the field to a query.
56
   */
57
  function query() {
58
    $this->real_field = $this->options['attribute_name'];
59
    parent::query();
60
  }
61
}