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_argument_attribute.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * Basic textfield argument to handle dynamic ldap attributes
5
 * Basic textfield argument to handle dynamic ldap attributes.
6 6
 */
7 7

  
8
/**
9
 *
10
 */
8 11
class ldap_views_handler_argument_attribute extends views_handler_argument {
9 12

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

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

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

  
31 35
    parent::options_form($form, $form_state);
32 36

  
33
    $options         = array();
37
    $options = [];
34 38
    foreach ($ldap_data->attributes as $attribute) {
35 39
      $options[$attribute] = $attribute;
36 40
    }
37 41

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

  
47 51
  }
48 52

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

  
55 60
}

Formats disponibles : Unified diff