Projet

Général

Profil

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

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

1
<?php
2

    
3
/**
4
 * @file
5
 * Base sort handler for a ldap attributes
6
 */
7

    
8
class ldap_views_handler_sort_attribute extends ldap_views_handler_sort {
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
    $did             = isset($current_display->display_options['query']['options']['did']) ? $current_display->display_options['query']['options']['did']
19
                                                                                           : $current_display->handler->default_display->display->display_options['query']['options']['did'];
20
 */
21
    $ldap_data       = new LdapQuery(ldap_views_get_qid($this->view)); //ldap_data_load($did);
22
    if (empty($ldap_data)) {
23
      $form['attribute_name'] = array(
24
        '#markup' => 'You must select a valid LDAP search (Advanced::Query settings)',
25
      );
26
      return;
27
    }
28

    
29
    parent::options_form($form, $form_state);
30
    $options         = array();
31
    foreach ($ldap_data->attributes as $attribute) {
32
      $options[$attribute] = $attribute;
33
    }
34
    $form['attribute_name'] = array(
35
      '#type' => 'select',
36
      '#title' => t('Attribute name'),
37
      '#description' => t('The attribute name from LDAP response'),
38
      '#options' => $options,
39
      '#default_value' => $this->options['attribute_name'],
40
      '#required' => TRUE,
41
    );
42
  }
43

    
44
  /**
45
   * Called to add the sort to a query.
46
   */
47
  function query() {
48
    $this->query->add_orderby($this->table, $this->options['attribute_name'], $this->options['order']);
49
  }
50
}