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

1
<?php
2

    
3
/**
4
 * @file
5
 * Base sort handler for a ldap attributes
6
 */
7
class ldap_views_handler_sort_attribute extends ldap_views_handler_sort {
8
  function option_definition() {
9
    $options = parent::option_definition();
10
    $options['attribute_name'] = array('default' => '');
11
    return $options;
12
  }
13

    
14
  function options_form(&$form, &$form_state) {
15
/*
16
    $current_display = $this->view->display[$this->view->current_display];
17
    $did             = isset($current_display->display_options['query']['options']['did']) ? $current_display->display_options['query']['options']['did']
18
                                                                                           : $current_display->handler->default_display->display->display_options['query']['options']['did'];
19
 */
20
    $ldap_data       = new LdapQuery(ldap_views_get_qid($this->view)); //ldap_data_load($did);
21
    if (empty($ldap_data)) {
22
      $form['attribute_name'] = array(
23
        '#markup' => 'You must select a valid LDAP search (Advanced::Query settings)',
24
      );
25
      return;
26
    }
27

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

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