Projet

Général

Profil

Révision 32700c57

Ajouté par Assos Assos il y a environ 5 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort_attribute.inc
2 2

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

  
8
/**
9
 *
10
 */
8 11
class ldap_views_handler_sort_attribute extends ldap_views_handler_sort {
9
  function option_definition() {
12

  
13
  /**
14
   *
15
   */
16
  public function option_definition() {
10 17
    $options = parent::option_definition();
11
    $options['attribute_name'] = array('default' => '');
18
    $options['attribute_name'] = ['default' => ''];
12 19
    return $options;
13 20
  }
14 21

  
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
  /**
23
   *
24
   */
25
  public function options_form(&$form, &$form_state) {
26
    $ldap_data = new LdapQuery(ldap_views_get_qid($this->view));
22 27
    if (empty($ldap_data)) {
23
      $form['attribute_name'] = array(
28
      $form['attribute_name'] = [
24 29
        '#markup' => 'You must select a valid LDAP search (Advanced::Query settings)',
25
      );
30
      ];
26 31
      return;
27 32
    }
28 33

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

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

  
50 56
}

Formats disponibles : Unified diff